diff --git a/Dockerfile b/Dockerfile
index 1cedae5..f02820c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -32,6 +32,6 @@ RUN echo "pushstate: enabled" > /etc/nginx/html/Staticfile
# then starts/reloads nginx.
ENTRYPOINT ["./entrypoint.sh", \
"/etc/nginx/html/index.html,/etc/nginx/conf.d/default.conf", \
- "PRODUCTION,API_URL,IRB_URL,HOME_ROUTE,BASE_HREF,DEPLOY_URL,PORT0", \
+ "PRODUCTION,API_URL,IRB_URL,HOME_ROUTE,BASE_HREF,DEPLOY_URL,PORT0,GOOGLE_ANALYTICS_KEY", \
"/etc/nginx/html", \
"true"]
diff --git a/package-lock.json b/package-lock.json
index a0eadf2..6327b5e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -12299,9 +12299,9 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sartography-workflow-lib": {
- "version": "0.0.230",
- "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.230.tgz",
- "integrity": "sha512-2ZcYGyeesW6KBdnxHjp3GUYzDL5z7E+UUMMtugQ6JVDRK2WoLgzBU/1H3yFT+dZ/iTyGXUf3ZtL4O1DvfkIlpQ=="
+ "version": "0.0.235",
+ "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.235.tgz",
+ "integrity": "sha512-1M646LRHpyyLoH+QKvtP40Tp+KMwYtlwIpyr5vllin20+zRAAzEj4FMuI/aBGnwpBVcNuLfhql4NMqvgfxIggQ=="
},
"sass": {
"version": "1.23.3",
diff --git a/package.json b/package.json
index 86bf485..9f07cde 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,7 @@
"e2e-wf:db-setup": "docker exec -it backend pipenv run flask load-example-data",
"e2e-wf:pb-setup": "docker exec -it pb pipenv run flask db upgrade",
"e2e-wf": "npm run e2e-wf:stop && npm run e2e-wf:clean && npm run e2e-wf:build && npm run e2e-wf:start && npm run e2e-wf:db-upgrade && npm run e2e-wf:db-setup && npm run e2e-wf:pb-setup",
- "env": "chmod +x ./docker/substitute-env-variables.sh && ./docker/substitute-env-variables.sh src/index.html PRODUCTION,API_URL,IRB_URL,HOME_ROUTE,BASE_HREF,PORT0",
+ "env": "chmod +x ./docker/substitute-env-variables.sh && ./docker/substitute-env-variables.sh src/index.html PRODUCTION,API_URL,IRB_URL,HOME_ROUTE,BASE_HREF,PORT0,GOOGLE_ANALYTICS_KEY",
"ci": "npm run lint && npm run test:coverage && sonar-scanner"
},
"private": true,
@@ -54,7 +54,7 @@
"ngx-file-drop": "^8.0.8",
"ngx-markdown": "^9.0.0",
"rxjs": "~6.5.4",
- "sartography-workflow-lib": "0.0.230",
+ "sartography-workflow-lib": "0.0.235",
"tslib": "^1.11.1",
"uuid": "^7.0.2",
"zone.js": "^0.10.3"
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 2f759e1..0e19b29 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -15,6 +15,7 @@ export class ThisEnvironment implements AppEnvironment {
api = environment.api;
irbUrl = environment.irbUrl;
title = environment.title;
+ googleAnalyticsKey = environment.googleAnalyticsKey;
}
const routes: Routes = [
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index a1d377a..0d1947f 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,5 +1,5 @@
import {Component} from '@angular/core';
-import {ApiService} from 'sartography-workflow-lib';
+import {ApiService, GoogleAnalyticsService} from 'sartography-workflow-lib';
@Component({
selector: 'app-root',
@@ -9,7 +9,11 @@ import {ApiService} from 'sartography-workflow-lib';
export class AppComponent {
title = 'CR Connect Configuration';
- constructor(private apiService: ApiService) {
+ constructor(
+ private apiService: ApiService,
+ private googleAnalyticsService: GoogleAnalyticsService
+ ) {
+ this.googleAnalyticsService.init();
}
get isSignedIn() {
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 7521467..dd3b0d5 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -59,6 +59,7 @@ export class ThisEnvironment implements AppEnvironment {
api = environment.api;
irbUrl = environment.irbUrl;
title = environment.title;
+ googleAnalyticsKey = environment.googleAnalyticsKey;
}
/**
diff --git a/src/app/navbar/navbar.component.ts b/src/app/navbar/navbar.component.ts
index 7e1af1c..288ba4c 100644
--- a/src/app/navbar/navbar.component.ts
+++ b/src/app/navbar/navbar.component.ts
@@ -1,6 +1,6 @@
-import {Component, Inject, OnInit} from '@angular/core';
+import {Component, Inject} from '@angular/core';
import {Router} from '@angular/router';
-import {ApiService, AppEnvironment, isSignedIn, User, UserParams} from 'sartography-workflow-lib';
+import {ApiService, AppEnvironment, GoogleAnalyticsService, isSignedIn, User} from 'sartography-workflow-lib';
interface NavItem {
path?: string;
@@ -25,6 +25,7 @@ export class NavbarComponent {
private router: Router,
private api: ApiService,
@Inject('APP_ENVIRONMENT') private environment: AppEnvironment,
+ private googleAnalyticsService: GoogleAnalyticsService
) {
this._loadUser();
this.title = environment.title;
@@ -38,6 +39,11 @@ export class NavbarComponent {
if (isSignedIn()) {
this.api.getUser().subscribe(u => {
this.user = u;
+
+ if (this.user && this.user.uid) {
+ this.googleAnalyticsService.setUser(this.user.uid);
+ }
+
this._loadNavLinks();
}, error => {
localStorage.removeItem('token');
diff --git a/src/environments/environment.runtime.ts b/src/environments/environment.runtime.ts
index c40401d..21c6088 100644
--- a/src/environments/environment.runtime.ts
+++ b/src/environments/environment.runtime.ts
@@ -10,4 +10,5 @@ export const environment: AppEnvironment = {
api: _has(ENV, 'api', '$API_URL') ? ENV.api : 'http://localhost:5000/v1.0',
irbUrl: _has(ENV, 'irbUrl', '$IRB_URL') ? ENV.irbUrl : 'http://localhost:5001',
title: _has(ENV, 'title', '$TITLE') ? ENV.title : 'Research Ramp-Up Toolkit Configurator',
+ googleAnalyticsKey: _has(ENV, 'googleAnalyticsKey', '$GOOGLE_ANALYTICS_KEY') ? ENV.title : 'UA-168203235-5',
};
diff --git a/src/index.html b/src/index.html
index 124a135..e33289a 100644
--- a/src/index.html
+++ b/src/index.html
@@ -11,9 +11,11 @@
api: '$API_URL',
irbUrl: '$IRB_URL',
baseHref: '$BASE_HREF',
+ googleAnalyticsKey: '$GOOGLE_ANALYTICS_KEY',
};
+