Skip to content

Commit 6e618f3

Browse files
committed
Include new GTM package
1 parent f5b0169 commit 6e618f3

File tree

14 files changed

+151
-83
lines changed

14 files changed

+151
-83
lines changed

src/SIL.XForge.Scripture/ClientApp/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SIL.XForge.Scripture/ClientApp/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"@sillsdev/machine": "^2.4.2",
5454
"@sillsdev/scripture": "1.4.1",
5555
"angular-file": "^4.0.2",
56+
"angular-google-tag-manager": "^1.9.0",
5657
"angular-split": "^16.2.1",
5758
"arraydiff": "^0.1.3",
5859
"bowser": "^2.11.0",

src/SIL.XForge.Scripture/ClientApp/src/app/app-routing.module.ts

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,47 @@ import { SettingsComponent } from './settings/settings.component';
1616
import { PageNotFoundComponent } from './shared/page-not-found/page-not-found.component';
1717
import { SettingsAuthGuard, SyncAuthGuard } from './shared/project-router.guard';
1818
import { SyncComponent } from './sync/sync.component';
19+
import { environment } from '../environments/environment';
1920

2021
const routes: Routes = [
2122
{ path: 'callback/auth0', component: MyProjectsComponent, canActivate: [AuthGuard] },
22-
{ path: 'connect-project', component: ConnectProjectComponent, canActivate: [AuthGuard] },
23+
{
24+
path: 'connect-project',
25+
component: ConnectProjectComponent,
26+
canActivate: [AuthGuard],
27+
title: `Connect Project - ${environment.siteName}`
28+
},
2329
{ path: 'login', redirectTo: 'projects', pathMatch: 'full' },
24-
{ path: 'join/:shareKey', component: JoinComponent },
25-
{ path: 'join/:shareKey/:locale', component: JoinComponent },
26-
{ path: 'projects/:projectId/event-log', component: EventMetricsComponent, canActivate: [EventMetricsAuthGuard] },
27-
{ path: 'projects/:projectId/settings', component: SettingsComponent, canActivate: [SettingsAuthGuard] },
28-
{ path: 'projects/:projectId/sync', component: SyncComponent, canActivate: [SyncAuthGuard] },
30+
{ path: 'join/:shareKey', component: JoinComponent, title: `Join Project - ${environment.siteName}` },
31+
{ path: 'join/:shareKey/:locale', component: JoinComponent, title: `Join Project - ${environment.siteName}` },
32+
{
33+
path: 'projects/:projectId/event-log', component: EventMetricsComponent, canActivate: [EventMetricsAuthGuard] },
34+
{ path: 'projects/:projectId/settings',
35+
component: SettingsComponent,
36+
canActivate: [SettingsAuthGuard],
37+
title: `Project Settings - ${environment.siteName}`
38+
},
39+
{
40+
path: 'projects/:projectId/sync',
41+
component: SyncComponent,
42+
canActivate: [SyncAuthGuard],
43+
title: `Synchronize Project - ${environment.siteName}`
44+
},
2945
{ path: 'projects/:projectId', component: ProjectComponent, canActivate: [AuthGuard] },
3046
{ path: 'projects', component: MyProjectsComponent, canActivate: [AuthGuard] },
3147
{ path: 'serval-administration/:projectId', component: ServalProjectComponent, canActivate: [ServalAdminAuthGuard] },
32-
{ path: 'serval-administration', component: ServalAdministrationComponent, canActivate: [ServalAdminAuthGuard] },
33-
{ path: 'system-administration', component: SystemAdministrationComponent, canActivate: [SystemAdminAuthGuard] },
48+
{
49+
path: 'serval-administration',
50+
component: ServalAdministrationComponent,
51+
canActivate: [ServalAdminAuthGuard],
52+
title: `Serval Administration - ${environment.siteName}`
53+
},
54+
{
55+
path: 'system-administration',
56+
component: SystemAdministrationComponent,
57+
canActivate: [SystemAdminAuthGuard],
58+
title: `System Administration - ${environment.siteName}`
59+
},
3460
{ path: '**', component: PageNotFoundComponent }
3561
];
3662

src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout';
22
import { Component, DestroyRef, OnDestroy, OnInit } from '@angular/core';
3-
import { NavigationEnd, Router } from '@angular/router';
3+
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
44
import Bugsnag from '@bugsnag/js';
55
import { translate } from '@ngneat/transloco';
66
import { cloneDeep } from 'lodash-es';
77
import { CookieService } from 'ngx-cookie-service';
88
import { SystemRole } from 'realtime-server/lib/esm/common/models/system-role';
99
import { AuthType, getAuthType, User } from 'realtime-server/lib/esm/common/models/user';
1010
import { SFProjectRole } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-role';
11-
import { Observable, Subscription } from 'rxjs';
12-
import { filter, map } from 'rxjs/operators';
11+
import { Observable, pipe, Subscription } from 'rxjs';
12+
import { debounceTime, distinctUntilChanged, filter, map } from 'rxjs/operators';
1313
import { ActivatedProjectService } from 'xforge-common/activated-project.service';
1414
import { AuthService } from 'xforge-common/auth.service';
1515
import { DataLoadingComponent } from 'xforge-common/data-loading-component';
@@ -36,9 +36,9 @@ import { quietTakeUntilDestroyed } from 'xforge-common/util/rxjs-util';
3636
import { issuesEmailTemplate, supportedBrowser } from 'xforge-common/utils';
3737
import { ThemeService } from 'xforge-common/theme.service';
3838
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
39+
import { AnalyticsService, PageViewEvent, TagEventType } from 'xforge-common/analytics.service';
3940
import versionData from '../../../version.json';
4041
import { environment } from '../environments/environment';
41-
import { AnalyticsService } from "xforge-common/analytics.service";
4242
import { SFProjectProfileDoc } from './core/models/sf-project-profile-doc';
4343
import { roleCanAccessTranslate } from './core/models/sf-project-role-info';
4444
import { SFProjectUserConfigDoc } from './core/models/sf-project-user-config-doc';
@@ -93,7 +93,8 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
9393
private readonly themeService: ThemeService,
9494
onlineStatusService: OnlineStatusService,
9595
private destroyRef: DestroyRef,
96-
private readonly analytics: AnalyticsService
96+
private readonly analytics: AnalyticsService,
97+
private readonly activatedRoute: ActivatedRoute
9798
) {
9899
super(noticeService);
99100
this.breakpointObserver
@@ -127,17 +128,25 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
127128
pwaService.hasUpdate$.pipe(quietTakeUntilDestroyed(this.destroyRef)).subscribe(() => (this.hasUpdate = true));
128129

129130
// Google Analytics - send data at end of navigation so we get data inside the SPA client-side routing
130-
if (environment.releaseStage === 'live') {
131-
const navEndEvent$ = router.events.pipe(
132-
filter(e => e instanceof NavigationEnd),
133-
map(e => e as NavigationEnd)
134-
);
135-
navEndEvent$.pipe(quietTakeUntilDestroyed(this.destroyRef)).subscribe(e => {
136-
if (this.isAppOnline) {
137-
this.analytics.logNavigation(e.urlAfterRedirects);
138-
}
139-
});
140-
}
131+
const navEndEvent$ = router.events.pipe(
132+
filter(e => e instanceof NavigationEnd),
133+
distinctUntilChanged((previous, current) => {
134+
const previousUrl = new URL((previous as NavigationEnd).urlAfterRedirects, location.origin);
135+
const currentUrl = new URL((current as NavigationEnd).urlAfterRedirects, location.origin);
136+
console.log(previousUrl, currentUrl);
137+
return previousUrl.pathname === currentUrl.pathname;
138+
}),
139+
map(e => {
140+
const navEndEvent = e as NavigationEnd;
141+
let route = this.activatedRoute.root;
142+
while (route.firstChild) route = route.firstChild;
143+
return {
144+
pageName: this.locationService.host + navEndEvent.urlAfterRedirects,
145+
title: route.snapshot.routeConfig?.title?.toString()
146+
} as PageViewEvent;
147+
})
148+
);
149+
this.subscribe(navEndEvent$, pageViewEvent => this.analytics.logNavigation(pageViewEvent));
141150
}
142151

143152
get canInstallOnDevice$(): Observable<boolean> {

src/SIL.XForge.Scripture/ClientApp/src/app/app.module.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { InAppRootOverlayContainer } from 'xforge-common/overlay-container';
2424
import { SupportedBrowsersDialogComponent } from 'xforge-common/supported-browsers-dialog/supported-browsers-dialog.component';
2525
import { UICommonModule } from 'xforge-common/ui-common.module';
2626
import { XForgeCommonModule } from 'xforge-common/xforge-common.module';
27+
import { en } from 'xforge-common/i18n.service';
28+
import { GoogleTagManagerModule } from 'angular-google-tag-manager';
2729
import { environment } from '../environments/environment';
2830
import { AppRoutingModule } from './app-routing.module';
2931
import { AppComponent } from './app.component';
@@ -82,7 +84,12 @@ import { UsersModule } from './users/users.module';
8284
AvatarComponent,
8385
MatRipple,
8486
GlobalNoticesComponent,
85-
QuillModule.forRoot()
87+
QuillModule.forRoot(),
88+
GoogleTagManagerModule.forRoot({
89+
id: environment.googleTagManagerId,
90+
gtm_auth: environment.googleTagManagerAuth,
91+
gtm_preview: environment.googleTagManagerPreview
92+
})
8693
],
8794
providers: [
8895
{ provide: APP_ID, useValue: 'ng-cli-universal' },

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking-routing.module.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,27 @@ import { RouterModule, Routes } from '@angular/router';
44
import { CheckingAuthGuard } from '../shared/project-router.guard';
55
import { CheckingOverviewComponent } from './checking-overview/checking-overview.component';
66
import { CheckingComponent } from './checking/checking.component';
7+
import { environment } from '../../environments/environment';
78

89
const routes: Routes = [
910
{
1011
path: 'projects/:projectId/checking/:bookId/:chapter',
1112
component: CheckingComponent,
12-
canActivate: [CheckingAuthGuard]
13+
canActivate: [CheckingAuthGuard],
14+
title: `Community Checking Questions & Answers - ${environment.siteName}`
1315
},
14-
{ path: 'projects/:projectId/checking/:bookId', component: CheckingComponent, canActivate: [CheckingAuthGuard] },
15-
{ path: 'projects/:projectId/checking', component: CheckingOverviewComponent, canActivate: [CheckingAuthGuard] }
16+
{
17+
path: 'projects/:projectId/checking/:bookId',
18+
component: CheckingComponent,
19+
canActivate: [CheckingAuthGuard],
20+
title: `Community Checking Questions & Answers - ${environment.siteName}`
21+
},
22+
{
23+
path: 'projects/:projectId/checking',
24+
component: CheckingOverviewComponent,
25+
canActivate: [CheckingAuthGuard],
26+
title: `Community Checking Management - ${environment.siteName}`
27+
}
1628
];
1729

1830
@NgModule({

src/SIL.XForge.Scripture/ClientApp/src/app/translate/translate-routing.module.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,38 @@ import { DraftGenerationComponent } from './draft-generation/draft-generation.co
55
import { DraftSourcesComponent } from './draft-generation/draft-sources/draft-sources.component';
66
import { EditorComponent } from './editor/editor.component';
77
import { TranslateOverviewComponent } from './translate-overview/translate-overview.component';
8+
import { environment } from '../../environments/environment';
89

910
const routes: Routes = [
1011
{
1112
path: 'projects/:projectId/translate/:bookId/:chapter',
1213
component: EditorComponent,
13-
canActivate: [TranslateAuthGuard]
14+
canActivate: [TranslateAuthGuard],
15+
title: `Editor & Review - ${environment.siteName}`
16+
},
17+
{
18+
path: 'projects/:projectId/translate/:bookId',
19+
component: EditorComponent,
20+
canActivate: [TranslateAuthGuard],
21+
title: `Editor & Review - ${environment.siteName}`
22+
},
23+
{
24+
path: 'projects/:projectId/translate',
25+
component: TranslateOverviewComponent,
26+
canActivate: [TranslateAuthGuard],
27+
title: `Translation Overview - ${environment.siteName}`
1428
},
15-
{ path: 'projects/:projectId/translate/:bookId', component: EditorComponent, canActivate: [TranslateAuthGuard] },
16-
{ path: 'projects/:projectId/translate', component: TranslateOverviewComponent, canActivate: [TranslateAuthGuard] },
1729
{
1830
path: 'projects/:projectId/draft-generation',
1931
component: DraftGenerationComponent,
20-
canActivate: [NmtDraftAuthGuard]
32+
canActivate: [NmtDraftAuthGuard],
33+
title: `Draft Generation - ${environment.siteName}`
2134
},
2235
{
2336
path: 'projects/:projectId/draft-generation/sources',
2437
component: DraftSourcesComponent,
25-
canActivate: [NmtDraftAuthGuard]
38+
canActivate: [NmtDraftAuthGuard],
39+
title: `Configure Draft Sources - ${environment.siteName}`
2640
}
2741
];
2842

src/SIL.XForge.Scripture/ClientApp/src/app/users/users-routing.module.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ import { NgModule } from '@angular/core';
22
import { RouterModule, Routes } from '@angular/router';
33
import { UsersAuthGuard } from '../shared/project-router.guard';
44
import { UsersComponent } from './users.component';
5+
import { environment } from '../../environments/environment';
56

67
const routes: Routes = [
7-
{ path: 'projects/:projectId/users', component: UsersComponent, canActivate: [UsersAuthGuard] }
8+
{
9+
path: 'projects/:projectId/users',
10+
component: UsersComponent,
11+
canActivate: [UsersAuthGuard],
12+
title: `User Management - ${environment.siteName}`
13+
}
814
];
915

1016
@NgModule({

src/SIL.XForge.Scripture/ClientApp/src/environments/environment.prod.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ export const environment = {
1717
authDomain: 'login.languagetechnology.org',
1818
authClientId: 'tY2wXn40fsL5VsPM4uIHNtU6ZUEXGeFn',
1919
offlineDBVersion: 8,
20-
googleTagId: 'G-SVKBDV7K3Q'
20+
googleTagManagerId: 'GTM-P2DF8SLM',
21+
googleTagManagerAuth: 'OCXvABYNFBKJ0TJkAGsvAw',
22+
googleTagManagerPreview: 'env-1'
2123
};

src/SIL.XForge.Scripture/ClientApp/src/environments/environment.pwa-test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ export const environment = {
1717
authDomain: 'sil-appbuilder.auth0.com',
1818
authClientId: 'aoAGb9Yx1H5WIsvCW6JJCteJhSa37ftH',
1919
offlineDBVersion: 8,
20-
googleTagId: null
20+
googleTagManagerId: 'GTM-P2DF8SLM',
21+
googleTagManagerAuth: 'AC1M72Jw4UydK-bnFoT0Cw',
22+
googleTagManagerPreview: 'env-8'
2123
};

src/SIL.XForge.Scripture/ClientApp/src/environments/environment.staging.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ export const environment = {
1717
authDomain: 'dev-sillsdev.auth0.com',
1818
authClientId: '4eHLjo40mAEGFU6zUxdYjnpnC1K1Ydnj',
1919
offlineDBVersion: 8,
20-
googleTagId: null
20+
googleTagManagerId: 'GTM-P2DF8SLM',
21+
googleTagManagerAuth: 'pcbHrZyROB6E6AS0PZsD1Q',
22+
googleTagManagerPreview: 'env-7'
2123
};

src/SIL.XForge.Scripture/ClientApp/src/environments/environment.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ export const environment = {
2424
authDomain: 'sil-appbuilder.auth0.com',
2525
authClientId: 'aoAGb9Yx1H5WIsvCW6JJCteJhSa37ftH',
2626
offlineDBVersion: 8,
27-
googleTagId: null
27+
googleTagManagerId: 'GTM-P2DF8SLM',
28+
googleTagManagerAuth: 'AC1M72Jw4UydK-bnFoT0Cw',
29+
googleTagManagerPreview: 'env-8'
2830
};

src/SIL.XForge.Scripture/ClientApp/src/index.html

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4-
<script async src="https://www.googletagmanager.com/gtag/js"></script>
5-
<script>
6-
window.dataLayer = window.dataLayer || [];
7-
function gtag() {
8-
dataLayer.push(arguments);
9-
}
10-
</script>
11-
124
<link href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined" rel="stylesheet" />
135
<link rel="preconnect" href="https://fonts.googleapis.com" />
146
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />

0 commit comments

Comments
 (0)