From 0f5af81bd9c0cf48c050143ec1e97ba748a10000 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 26 Jan 2018 10:50:06 -0500 Subject: [PATCH] add analytics support --- package.json | 4 +++- src/app/app.component.ts | 4 ++++ src/app/app.module.ts | 7 +++++++ src/app/services/services.module.ts | 3 +++ src/services/desktopPlatformUtils.service.ts | 4 ++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c96445eb..17c24fcc 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,8 @@ "@angular/upgrade": "5.2.0", "core-js": "^2.4.1", "rxjs": "^5.5.6", - "zone.js": "^0.8.19" + "zone.js": "^0.8.19", + "angular2-toaster": "4.0.2", + "angulartics2": "5.0.1" } } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4fbdb488..74687f85 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,3 +1,5 @@ +import { Angulartics2GoogleAnalytics } from 'angulartics2/ga'; + import { Component } from '@angular/core'; @Component({ @@ -6,4 +8,6 @@ import { Component } from '@angular/core'; template: '', }) export class AppComponent { + constructor(angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics) { + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3dab8590..c1048bb9 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,6 +1,8 @@ import 'core-js'; import 'zone.js/dist/zone'; +import { Angulartics2Module } from 'angulartics2'; +import { Angulartics2GoogleAnalytics } from 'angulartics2/ga'; import { AppRoutingModule } from './app-routing.module'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; @@ -27,6 +29,11 @@ import { ViewComponent } from './vault/view.component'; FormsModule, AppRoutingModule, ServicesModule, + Angulartics2Module.forRoot([Angulartics2GoogleAnalytics], { + pageTracking: { + clearQueryParams: true, + }, + }), ], declarations: [ AddComponent, diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index 02312c44..f9547273 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -11,6 +11,8 @@ import { DesktopStorageService } from '../../services/desktopStorage.service'; import { DesktopSecureStorageService } from '../../services/desktopSecureStorage.service'; import { I18nService } from '../../services/i18n.service'; +import { Analytics } from 'jslib/misc/analytics'; + import { ApiService, AppIdService, @@ -90,6 +92,7 @@ const authService: AuthServiceAbstraction = new AuthService(cryptoService, apiSe userService, tokenService, appIdService, platformUtilsService, constantsService, messagingService); +const analytics = new Analytics(window, null, platformUtilsService, storageService, appIdService); containerService.attachToWindow(window); environmentService.setUrlsFromStorage().then(() => { return syncService.fullSync(true); diff --git a/src/services/desktopPlatformUtils.service.ts b/src/services/desktopPlatformUtils.service.ts index 8447e9cf..63fa9c90 100644 --- a/src/services/desktopPlatformUtils.service.ts +++ b/src/services/desktopPlatformUtils.service.ts @@ -120,4 +120,8 @@ export class DesktopPlatformUtilsService implements PlatformUtilsService { message: message, }); } + + getApplicationVersion(): string { + return (window as any).require('electron').remote.app.getVersion(); + } }