diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0f257e7..7844b44 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,3 +1,5 @@ +import { environment } from '../environments/environment'; + import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { LocationStrategy, HashLocationStrategy } from '@angular/common'; @@ -38,6 +40,8 @@ import { P500Component } from './pages/500.component'; import { AuthModule } from './auth/auth.module'; import { DashboardModule } from './dashboard/dashboard.module'; + + @NgModule({ imports: [ BrowserModule, @@ -78,4 +82,10 @@ import { DashboardModule } from './dashboard/dashboard.module'; ], bootstrap: [ AppComponent ] }) -export class AppModule { } +export class AppModule { + constructor () { + if (environment.enableAnalytics) { + (window).ga('create', environment.analyticsKey, 'auto'); + } + } +} diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index 444a17c..4a15b1e 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -1,9 +1,10 @@ import { Component } from '@angular/core'; -import { Router } from '@angular/router'; +import {Router, NavigationEnd} from "@angular/router"; import { GraphWidget } from '../widgets/graph-widget.component'; import { OrgBarSnippetComponent } from '../snippets/org-snippet-bar.component'; import { GraphPanel } from '../panels/graph-panel.component'; import { DataType } from '../shared/data-types.enum'; +import { environment } from '../../environments/environment'; @Component({ templateUrl: 'dashboard.component.html' @@ -50,6 +51,14 @@ export class DashboardComponent { dataType: DataType.currency, }, ]; - - constructor() { } + constructor(private router: Router) { + if (environment.enableAnalytics) { + this.router.events.subscribe(event => { + if (event instanceof NavigationEnd) { + (window).ga('set', 'page', event.urlAfterRedirects); + (window).ga('send', 'pageview'); + } + }); + } + } } diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 725706a..4dd4515 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -7,4 +7,6 @@ export const environment = { production: false, apiUrl: 'https://dev.peartrade.org/api', mapApiKey: 'CHANGEME', + enableAnalytics: false, + analyticsKey: 'CHANGEME', }; diff --git a/src/environments/environments.tar.enc b/src/environments/environments.tar.enc index d5414b3..ebe8734 100644 Binary files a/src/environments/environments.tar.enc and b/src/environments/environments.tar.enc differ diff --git a/src/index.html b/src/index.html index 3ea6f13..e650904 100644 --- a/src/index.html +++ b/src/index.html @@ -18,7 +18,6 @@ - @@ -123,6 +122,13 @@
+ +