GoogleAnalytics service added

This commit is contained in:
Piotr Pekala 2020-01-03 03:53:33 -08:00
parent 85f3172111
commit 11baa33169
2 changed files with 23 additions and 1 deletions

View File

@ -258,6 +258,7 @@ import { Gns3vmService } from './services/gns3vm.service';
import { ThemeService } from './services/theme.service';
import { ConfigureGns3VMDialogComponent } from './components/servers/configure-gns3vm-dialog/configure-gns3vm-dialog.component';
import { ImportApplianceComponent } from './components/project-map/import-appliance/import-appliance.component';
import { GoogleAnalyticsService } from './services/google-analytics.service';
if (environment.production) {
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
@ -522,7 +523,8 @@ if (environment.production) {
PacketCaptureService,
NotificationService,
Gns3vmService,
ThemeService
ThemeService,
GoogleAnalyticsService
],
entryComponents: [
AddServerDialogComponent,

View File

@ -0,0 +1,20 @@
import { Injectable } from '@angular/core';
import {Router, NavigationEnd} from '@angular/router';
import { environment } from '../../environments/environment';
declare var ga:Function;
@Injectable()
export class GoogleAnalyticsService {
constructor(router: Router) {
if (!environment.production) return;
router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
ga('set', 'page', event.url);
ga('send', 'pageview');
}
})
}
}