From 70c7f1133cec48b47b37e5455d8ceb06253d2225 Mon Sep 17 00:00:00 2001 From: Zak Timson Date: Fri, 13 Jul 2018 12:05:09 -0400 Subject: [PATCH] Added page recording for analytics --- src/app/app.component.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 9bb67c2..de194a3 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,7 +1,8 @@ import {Component, OnInit} from '@angular/core'; -import {Router} from '@angular/router'; +import {Router, NavigationEnd} from '@angular/router'; import {ElectronService} from 'ngx-electron'; import {AngularFirestore} from 'angularfire2/firestore'; +import {filter} from 'rxjs/operators'; @Component({ selector: 'app-root', @@ -15,6 +16,13 @@ export class AppComponent implements OnInit { } ngOnInit() { + // Record routing for analytics + this.router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe((event: NavigationEnd) => { + (window).ga('set', 'page', event.urlAfterRedirects); + (window).ga('send', 'pageview'); + }); + + // Send electron users right to formula manager if (this.electron.isElectronApp) { this.router.navigate(['/formulaManager']); }