From b2971b88ee846022c01db6cdd6295ed83b09d19a Mon Sep 17 00:00:00 2001 From: Michael Chinn Date: Thu, 26 Jul 2018 16:55:23 -0700 Subject: [PATCH 1/2] ga tracking --- app/src/app/app.component.ts | 105 +++++++++++-------- app/src/environments/environment.prod.ts | 3 +- app/src/environments/environment.ts | 3 +- app/src/index.html | 124 +++++++++++------------ 4 files changed, 125 insertions(+), 110 deletions(-) diff --git a/app/src/app/app.component.ts b/app/src/app/app.component.ts index 2ca1c2f2ce..274f9c655f 100644 --- a/app/src/app/app.component.ts +++ b/app/src/app/app.component.ts @@ -1,75 +1,90 @@ - -import { Component } from '@angular/core'; +import {AfterViewInit, Component, ElementRef, OnInit} from '@angular/core'; import {ToasterContainerComponent, ToasterService, ToasterConfig} from 'angular2-toaster'; import {Idle, DEFAULT_INTERRUPTSOURCES} from '@ng-idle/core'; import {Keepalive} from '@ng-idle/keepalive'; -import { AuthenticationService, MessageService } from './core/services/index'; -import { Router } from '@angular/router'; -import { Location } from '@angular/common'; +import {AuthenticationService, MessageService} from './core/services/index'; +import {NavigationEnd, Router} from '@angular/router'; +import {Location} from '@angular/common'; import {BodyOutputType} from 'angular2-toaster'; - +import {environment} from "../environments/environment"; +declare let ga; @Component({ selector: 'app-root', templateUrl: './app.component.html', - // directives: [ToasterContainerComponent], + // directives: [ToasterContainerComponent], providers: [ToasterService, MessageService], styleUrls: ['./app.component.scss'] }) -export class AppComponent { - idleState = 'Not started.'; +export class AppComponent implements OnInit{ + idleState = 'Not started.'; timedOut = false; lastPing?: Date = null; - public wrapperClass = ''; - tst:any; + public wrapperClass = ''; + tst: any; + + constructor( + private toasterService: ToasterService, + private idle: Idle, + private location: Location, + private keepalive: Keepalive, + private messageservice: MessageService, + private authenticationservice: AuthenticationService, + private router: Router + ) { - constructor( - private toasterService: ToasterService, - private idle: Idle, - private location: Location, - private keepalive: Keepalive,private router: Router, - private messageservice:MessageService, - private authenticationservice:AuthenticationService - ) { - - // sets an idle timeout of 15 mins, for testing purposes. - idle.setIdle(60*15); + // sets an idle timeout of 15 mins, for testing purposes. + idle.setIdle(60 * 15); // sets a timeout period of 15 mins. after 30 mins of inactivity, the user will be considered timed out. - idle.setTimeout(60*15); + idle.setTimeout(60 * 15); // sets the default interrupts, in this case, things like clicks, scrolls, touches to the document idle.setInterrupts(DEFAULT_INTERRUPTSOURCES); idle.onTimeout.subscribe(() => { - if(this.authenticationservice.isLoggedIn()){ - this.authenticationservice.logout(); - this.router.navigate(['']);//location.path routed to landing page - let msg = this.messageservice.sessionEnd("true"); - this.toasterService.pop('error','Oops!',msg); - } - + if (this.authenticationservice.isLoggedIn()) { + this.authenticationservice.logout(); + this.router.navigate(['']);//location.path routed to landing page + let msg = this.messageservice.sessionEnd("true"); + this.toasterService.pop('error', 'Oops!', msg); + } + this.idleState = 'Timed out!'; - this.timedOut = true; - this.reset(); + this.timedOut = true; + this.reset(); }); - this.reset(); - //location.path routed to landing page + this.reset(); + //location.path routed to landing page if (location.path() == '') { this.wrapperClass = 'landing'; } - this.toasterService = toasterService; - } - reset() { + this.toasterService = toasterService; + } + + ngOnInit() { + if(environment.gaTrackingId) { + ga('create', environment.gaTrackingId, 'auto'); + this.router.events.subscribe(event => { + if(event instanceof NavigationEnd){ + ga('set', 'page', event.urlAfterRedirects); + ga('send', 'pageview'); + } + }) + } + + } + + reset() { this.idle.watch(); this.idleState = 'Started.'; this.timedOut = false; } - public toasterconfig : ToasterConfig = - new ToasterConfig({ - showCloseButton: true, - tapToDismiss: false, - timeout: 4000, - limit:1 - - }); + public toasterconfig: ToasterConfig = + new ToasterConfig({ + showCloseButton: true, + tapToDismiss: false, + timeout: 4000, + limit: 1 + + }); } diff --git a/app/src/environments/environment.prod.ts b/app/src/environments/environment.prod.ts index 3716d282a5..95d457da17 100644 --- a/app/src/environments/environment.prod.ts +++ b/app/src/environments/environment.prod.ts @@ -14,5 +14,6 @@ export const environment = { }, userJourney: { registrationMessage: '' - } + }, + gaTrackingId: 'UA-121896506-1' }; diff --git a/app/src/environments/environment.ts b/app/src/environments/environment.ts index e850f86dbe..5609cf613c 100644 --- a/app/src/environments/environment.ts +++ b/app/src/environments/environment.ts @@ -14,5 +14,6 @@ export const environment = { }, userJourney: { registrationMessage: '' - } + }, + gaTrackingId: 'UA-121896506-1' }; diff --git a/app/src/index.html b/app/src/index.html index 80f0eef4b3..19909c74af 100644 --- a/app/src/index.html +++ b/app/src/index.html @@ -2,99 +2,97 @@ - - Jazz Serverless Platform - - - - - - - + - -
-
-
-
-
-
+ +
+
+
+
+
+
- - + From 2da4cf9cb98b5ce1388ed1eb0e5983867a118041 Mon Sep 17 00:00:00 2001 From: Michael Chinn Date: Tue, 31 Jul 2018 16:39:53 -0700 Subject: [PATCH 2/2] remove dev ga tracking --- app/src/environments/environment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/environments/environment.ts b/app/src/environments/environment.ts index 5609cf613c..2756b5d6df 100644 --- a/app/src/environments/environment.ts +++ b/app/src/environments/environment.ts @@ -15,5 +15,5 @@ export const environment = { userJourney: { registrationMessage: '' }, - gaTrackingId: 'UA-121896506-1' + gaTrackingId: '' };