From 76eeb4e41dd19fe8c2423f81182aead6cd5a54af Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 13 Apr 2018 14:36:25 -0400 Subject: [PATCH] fix analytics --- src/popup/services/services.module.ts | 20 +++++++++++++++----- src/popup/vault/current-tab.component.html | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/popup/services/services.module.ts b/src/popup/services/services.module.ts index 613fee51e6..131f48cac3 100644 --- a/src/popup/services/services.module.ts +++ b/src/popup/services/services.module.ts @@ -43,6 +43,8 @@ import { AuthService } from 'jslib/services/auth.service'; import { ConstantsService } from 'jslib/services/constants.service'; import { StateService } from 'jslib/services/state.service'; +import { Analytics } from 'jslib/misc/analytics'; + import { PopupUtilsService } from './popup-utils.service'; function getBgService(service: string) { @@ -71,13 +73,21 @@ export function initFactory(i18nService: I18nService, storageService: StorageSer window.document.body.classList.add('body-sm'); } - if (i18nService != null) { - window.document.documentElement.classList.add('locale_' + i18nService.translationLocale); - authService.init(); - } - stateService.save(ConstantsService.disableFaviconKey, await storageService.get(ConstantsService.disableFaviconKey)); + + if (BrowserApi.getBackgroundPage() != null) { + window.document.documentElement.classList.add('locale_' + i18nService.translationLocale); + authService.init(); + + new Analytics(window, () => BrowserApi.gaFilter(), null, null, null, () => { + const bgPage = BrowserApi.getBackgroundPage(); + if (bgPage == null || bgPage.bitwardenMain == null) { + throw 'Cannot resolve background page main.'; + } + return bgPage.bitwardenMain; + }); + } }; } diff --git a/src/popup/vault/current-tab.component.html b/src/popup/vault/current-tab.component.html index 94c967f307..955c0113af 100644 --- a/src/popup/vault/current-tab.component.html +++ b/src/popup/vault/current-tab.component.html @@ -2,7 +2,7 @@