From 930c4d219a8500216ea6edbfa3f9170f5e215089 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Mon, 1 Jun 2020 16:40:44 -0400 Subject: [PATCH 1/6] Updates sartography-workflow-lib --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index a0eadf2..aae9ad2 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.231", + "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.231.tgz", + "integrity": "sha512-89kkRnTy3Ix9bawDXt0uddMtjGDj7VacARa78PEHR3CSYt/dWTsqAC7x4SJr3IdElzgvPDh9yZqxAUuciMHtLg==" }, "sass": { "version": "1.23.3", diff --git a/package.json b/package.json index 86bf485..9a3c489 100644 --- a/package.json +++ b/package.json @@ -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.231", "tslib": "^1.11.1", "uuid": "^7.0.2", "zone.js": "^0.10.3" From cb5b76c92f1c600ef5a1b0fbb8c5a9e52568af36 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Mon, 1 Jun 2020 23:15:11 -0400 Subject: [PATCH 2/6] Adds Google Analytics --- package-lock.json | 6 +++--- package.json | 2 +- src/app/app.component.ts | 7 ++++++- src/app/navbar/navbar.component.ts | 3 +++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index aae9ad2..92ce583 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12299,9 +12299,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sartography-workflow-lib": { - "version": "0.0.231", - "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.231.tgz", - "integrity": "sha512-89kkRnTy3Ix9bawDXt0uddMtjGDj7VacARa78PEHR3CSYt/dWTsqAC7x4SJr3IdElzgvPDh9yZqxAUuciMHtLg==" + "version": "0.0.234", + "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.234.tgz", + "integrity": "sha512-v0IznXGlVaznpIE5jLVNqNWeIr4I22oU2E1yyayAc4eCYC5P8+KnvJYKdW/sUBfH9jKRKUlseMK3jSX7Tt/IPw==" }, "sass": { "version": "1.23.3", diff --git a/package.json b/package.json index 9a3c489..23c450c 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "ngx-file-drop": "^8.0.8", "ngx-markdown": "^9.0.0", "rxjs": "~6.5.4", - "sartography-workflow-lib": "0.0.231", + "sartography-workflow-lib": "0.0.234", "tslib": "^1.11.1", "uuid": "^7.0.2", "zone.js": "^0.10.3" diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a1d377a..8503dc1 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,6 @@ import {Component} from '@angular/core'; import {ApiService} from 'sartography-workflow-lib'; +import {GoogleAnalyticsService} from 'sartography-workflow-lib/lib/services/google-analytics.service'; @Component({ selector: 'app-root', @@ -9,7 +10,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/navbar/navbar.component.ts b/src/app/navbar/navbar.component.ts index 7e1af1c..03219a6 100644 --- a/src/app/navbar/navbar.component.ts +++ b/src/app/navbar/navbar.component.ts @@ -1,6 +1,7 @@ import {Component, Inject, OnInit} from '@angular/core'; import {Router} from '@angular/router'; import {ApiService, AppEnvironment, isSignedIn, User, UserParams} from 'sartography-workflow-lib'; +import {GoogleAnalyticsService} from 'sartography-workflow-lib/lib/services/google-analytics.service'; interface NavItem { path?: string; @@ -25,6 +26,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; @@ -37,6 +39,7 @@ export class NavbarComponent { private _loadUser() { if (isSignedIn()) { this.api.getUser().subscribe(u => { + this.googleAnalyticsService.setUser(u.uid); this.user = u; this._loadNavLinks(); }, error => { From cb09d4d460b27744d532f8e9fc07f923612c0cce Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Mon, 1 Jun 2020 23:49:21 -0400 Subject: [PATCH 3/6] Injects GA key via environment variable. Fixes GA service imports. --- package-lock.json | 6 +++--- package.json | 2 +- src/app/app-routing.module.ts | 1 + src/app/app.component.ts | 3 +-- src/app/app.module.ts | 1 + src/app/navbar/navbar.component.ts | 7 +++---- src/environments/environment.runtime.ts | 1 + src/index.html | 2 ++ 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 92ce583..6327b5e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12299,9 +12299,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sartography-workflow-lib": { - "version": "0.0.234", - "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.234.tgz", - "integrity": "sha512-v0IznXGlVaznpIE5jLVNqNWeIr4I22oU2E1yyayAc4eCYC5P8+KnvJYKdW/sUBfH9jKRKUlseMK3jSX7Tt/IPw==" + "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 23c450c..2e0f458 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "ngx-file-drop": "^8.0.8", "ngx-markdown": "^9.0.0", "rxjs": "~6.5.4", - "sartography-workflow-lib": "0.0.234", + "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 8503dc1..0d1947f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,6 +1,5 @@ import {Component} from '@angular/core'; -import {ApiService} from 'sartography-workflow-lib'; -import {GoogleAnalyticsService} from 'sartography-workflow-lib/lib/services/google-analytics.service'; +import {ApiService, GoogleAnalyticsService} from 'sartography-workflow-lib'; @Component({ selector: 'app-root', 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 03219a6..4ad7cff 100644 --- a/src/app/navbar/navbar.component.ts +++ b/src/app/navbar/navbar.component.ts @@ -1,7 +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 {GoogleAnalyticsService} from 'sartography-workflow-lib/lib/services/google-analytics.service'; +import {ApiService, AppEnvironment, GoogleAnalyticsService, isSignedIn, User} from 'sartography-workflow-lib'; interface NavItem { path?: string; @@ -39,8 +38,8 @@ export class NavbarComponent { private _loadUser() { if (isSignedIn()) { this.api.getUser().subscribe(u => { - this.googleAnalyticsService.setUser(u.uid); this.user = u; + 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..e38110c 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 : 'AIzaSyD-m_e_Ilm7CHA9gY9nqp56vp2drz4VTy4', }; 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', }; + From 8097e161730f3d5e09940544657784f0cfa22e94 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Mon, 1 Jun 2020 23:52:53 -0400 Subject: [PATCH 4/6] Injects GA key in Docker image build --- Dockerfile | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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.json b/package.json index 2e0f458..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, From 34ffe430a600eab10474d178109cbde6758ef06d Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Tue, 2 Jun 2020 00:13:12 -0400 Subject: [PATCH 5/6] Wrong key --- src/environments/environment.runtime.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/environments/environment.runtime.ts b/src/environments/environment.runtime.ts index e38110c..21c6088 100644 --- a/src/environments/environment.runtime.ts +++ b/src/environments/environment.runtime.ts @@ -10,5 +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 : 'AIzaSyD-m_e_Ilm7CHA9gY9nqp56vp2drz4VTy4', + googleAnalyticsKey: _has(ENV, 'googleAnalyticsKey', '$GOOGLE_ANALYTICS_KEY') ? ENV.title : 'UA-168203235-5', }; From 6784b6ca1e654f7fb8e5f3dfadc461f36ce6bc2c Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Tue, 2 Jun 2020 00:23:50 -0400 Subject: [PATCH 6/6] Checks for user --- src/app/navbar/navbar.component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/navbar/navbar.component.ts b/src/app/navbar/navbar.component.ts index 4ad7cff..288ba4c 100644 --- a/src/app/navbar/navbar.component.ts +++ b/src/app/navbar/navbar.component.ts @@ -39,7 +39,11 @@ export class NavbarComponent { if (isSignedIn()) { this.api.getUser().subscribe(u => { this.user = u; - this.googleAnalyticsService.setUser(this.user.uid); + + if (this.user && this.user.uid) { + this.googleAnalyticsService.setUser(this.user.uid); + } + this._loadNavLinks(); }, error => { localStorage.removeItem('token');