Merge pull request #649 from GNS3/Integrate-Google-Analytics-in-Web-UI

Integrate Google Analytics in Web UI
This commit is contained in:
ziajka 2020-01-07 10:28:25 +01:00 committed by GitHub
commit 2d2738024e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 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');
}
})
}
}

View File

@ -37,5 +37,16 @@
<!-- <body class="mat-app-background" oncontextmenu="return false;"> -->
<body class="mat-app-background" oncontextmenu="return false;">
<app-root></app-root>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-5D6FZL9923"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag()
{dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-5D6FZL9923');
</script>
</body>
</html>