mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-15 05:18:08 +00:00
Merge pull request #649 from GNS3/Integrate-Google-Analytics-in-Web-UI
Integrate Google Analytics in Web UI
This commit is contained in:
@ -258,6 +258,7 @@ import { Gns3vmService } from './services/gns3vm.service';
|
|||||||
import { ThemeService } from './services/theme.service';
|
import { ThemeService } from './services/theme.service';
|
||||||
import { ConfigureGns3VMDialogComponent } from './components/servers/configure-gns3vm-dialog/configure-gns3vm-dialog.component';
|
import { ConfigureGns3VMDialogComponent } from './components/servers/configure-gns3vm-dialog/configure-gns3vm-dialog.component';
|
||||||
import { ImportApplianceComponent } from './components/project-map/import-appliance/import-appliance.component';
|
import { ImportApplianceComponent } from './components/project-map/import-appliance/import-appliance.component';
|
||||||
|
import { GoogleAnalyticsService } from './services/google-analytics.service';
|
||||||
|
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
||||||
@ -522,7 +523,8 @@ if (environment.production) {
|
|||||||
PacketCaptureService,
|
PacketCaptureService,
|
||||||
NotificationService,
|
NotificationService,
|
||||||
Gns3vmService,
|
Gns3vmService,
|
||||||
ThemeService
|
ThemeService,
|
||||||
|
GoogleAnalyticsService
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
AddServerDialogComponent,
|
AddServerDialogComponent,
|
||||||
|
20
src/app/services/google-analytics.service.ts
Normal file
20
src/app/services/google-analytics.service.ts
Normal 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');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -37,5 +37,16 @@
|
|||||||
<!-- <body class="mat-app-background" oncontextmenu="return false;"> -->
|
<!-- <body class="mat-app-background" oncontextmenu="return false;"> -->
|
||||||
<body class="mat-app-background" oncontextmenu="return false;">
|
<body class="mat-app-background" oncontextmenu="return false;">
|
||||||
<app-root></app-root>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Reference in New Issue
Block a user