Remove dead code (#1787)

* Remove dead analytics code
This commit is contained in:
Oscar Hinton 2021-04-14 23:43:09 +02:00 committed by GitHub
parent dd6b08bb2c
commit 44463e7bc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 23 additions and 197 deletions

2
jslib

@ -1 +1 @@
Subproject commit 0a0cdaa7fdfb7322c73258b270105c8fb6552b99 Subproject commit 92df63304029049891a46d575612222fb9b6c325

5
package-lock.json generated
View File

@ -1335,11 +1335,6 @@
"resolved": "https://registry.npmjs.org/angular2-toaster/-/angular2-toaster-8.0.0.tgz", "resolved": "https://registry.npmjs.org/angular2-toaster/-/angular2-toaster-8.0.0.tgz",
"integrity": "sha512-MRDswCmhqFLBiot7C7SIq96NyU5aT9pwIVdYgmYJtXHp7N6fXk6QzuMSMhVvK12edUJntgmUft+SZfh45Oq0Wg==" "integrity": "sha512-MRDswCmhqFLBiot7C7SIq96NyU5aT9pwIVdYgmYJtXHp7N6fXk6QzuMSMhVvK12edUJntgmUft+SZfh45Oq0Wg=="
}, },
"angulartics2": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/angulartics2/-/angulartics2-9.1.0.tgz",
"integrity": "sha512-RAfHJSHyeRe834e5qCYLtp7fdFuKnz/myFTSVEUZV6nLp4cUotvX8XQhewUEpFv6gkrzJwcuY32JZxstDlNiXQ=="
},
"ansi-colors": { "ansi-colors": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz",

View File

@ -92,7 +92,6 @@
"@microsoft/signalr": "3.1.13", "@microsoft/signalr": "3.1.13",
"@microsoft/signalr-protocol-msgpack": "3.1.13", "@microsoft/signalr-protocol-msgpack": "3.1.13",
"angular2-toaster": "8.0.0", "angular2-toaster": "8.0.0",
"angulartics2": "9.1.0",
"big-integer": "1.6.48", "big-integer": "1.6.48",
"browser-hrtime": "^1.1.8", "browser-hrtime": "^1.1.8",
"core-js": "2.6.2", "core-js": "2.6.2",

View File

@ -2,8 +2,6 @@ import { BrowserApi } from '../browser/browserApi';
import MainBackground from './main.background'; import MainBackground from './main.background';
import { Analytics } from 'jslib/misc';
import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service'; import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { VaultTimeoutService } from 'jslib/abstractions/vaultTimeout.service'; import { VaultTimeoutService } from 'jslib/abstractions/vaultTimeout.service';
@ -13,8 +11,7 @@ export default class CommandsBackground {
private isVivaldi: boolean; private isVivaldi: boolean;
constructor(private main: MainBackground, private passwordGenerationService: PasswordGenerationService, constructor(private main: MainBackground, private passwordGenerationService: PasswordGenerationService,
private platformUtilsService: PlatformUtilsService, private analytics: Analytics, private platformUtilsService: PlatformUtilsService, private vaultTimeoutService: VaultTimeoutService) {
private vaultTimeoutService: VaultTimeoutService) {
this.isSafari = this.platformUtilsService.isSafari(); this.isSafari = this.platformUtilsService.isSafari();
this.isVivaldi = this.platformUtilsService.isVivaldi(); this.isVivaldi = this.platformUtilsService.isVivaldi();
} }
@ -57,11 +54,6 @@ export default class CommandsBackground {
const password = await this.passwordGenerationService.generatePassword(options); const password = await this.passwordGenerationService.generatePassword(options);
this.platformUtilsService.copyToClipboard(password, { window: window }); this.platformUtilsService.copyToClipboard(password, { window: window });
this.passwordGenerationService.addHistory(password); this.passwordGenerationService.addHistory(password);
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Generated Password From Command',
});
} }
private async autoFillLogin(tab?: any) { private async autoFillLogin(tab?: any) {
@ -78,11 +70,6 @@ export default class CommandsBackground {
} }
await this.main.collectPageDetailsForContentScript(tab, 'autofill_cmd'); await this.main.collectPageDetailsForContentScript(tab, 'autofill_cmd');
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Autofilled From Command',
});
} }
private async openPopup() { private async openPopup() {
@ -92,9 +79,5 @@ export default class CommandsBackground {
} }
this.main.openPopup(); this.main.openPopup();
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Opened Popup From Command',
});
} }
} }

View File

@ -2,8 +2,6 @@ import { BrowserApi } from '../browser/browserApi';
import MainBackground from './main.background'; import MainBackground from './main.background';
import { Analytics } from 'jslib/misc';
import { CipherService } from 'jslib/abstractions/cipher.service'; import { CipherService } from 'jslib/abstractions/cipher.service';
import { EventService } from 'jslib/abstractions/event.service'; import { EventService } from 'jslib/abstractions/event.service';
import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service'; import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service';
@ -17,7 +15,7 @@ export default class ContextMenusBackground {
private contextMenus: any; private contextMenus: any;
constructor(private main: MainBackground, private cipherService: CipherService, constructor(private main: MainBackground, private cipherService: CipherService,
private passwordGenerationService: PasswordGenerationService, private analytics: Analytics, private passwordGenerationService: PasswordGenerationService,
private platformUtilsService: PlatformUtilsService, private vaultTimeoutService: VaultTimeoutService, private platformUtilsService: PlatformUtilsService, private vaultTimeoutService: VaultTimeoutService,
private eventService: EventService, private totpService: TotpService) { private eventService: EventService, private totpService: TotpService) {
this.contextMenus = chrome.contextMenus; this.contextMenus = chrome.contextMenus;
@ -45,11 +43,6 @@ export default class ContextMenusBackground {
const password = await this.passwordGenerationService.generatePassword(options); const password = await this.passwordGenerationService.generatePassword(options);
this.platformUtilsService.copyToClipboard(password, { window: window }); this.platformUtilsService.copyToClipboard(password, { window: window });
this.passwordGenerationService.addHistory(password); this.passwordGenerationService.addHistory(password);
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Generated Password From Context Menu',
});
} }
private async cipherAction(info: any) { private async cipherAction(info: any) {
@ -72,29 +65,13 @@ export default class ContextMenusBackground {
} }
if (info.parentMenuItemId === 'autofill') { if (info.parentMenuItemId === 'autofill') {
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Autofilled From Context Menu',
});
await this.startAutofillPage(cipher); await this.startAutofillPage(cipher);
} else if (info.parentMenuItemId === 'copy-username') { } else if (info.parentMenuItemId === 'copy-username') {
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Copied Username From Context Menu',
});
this.platformUtilsService.copyToClipboard(cipher.login.username, { window: window }); this.platformUtilsService.copyToClipboard(cipher.login.username, { window: window });
} else if (info.parentMenuItemId === 'copy-password') { } else if (info.parentMenuItemId === 'copy-password') {
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Copied Password From Context Menu',
});
this.platformUtilsService.copyToClipboard(cipher.login.password, { window: window }); this.platformUtilsService.copyToClipboard(cipher.login.password, { window: window });
this.eventService.collect(EventType.Cipher_ClientCopiedPassword, cipher.id); this.eventService.collect(EventType.Cipher_ClientCopiedPassword, cipher.id);
} else if (info.parentMenuItemId === 'copy-totp') { } else if (info.parentMenuItemId === 'copy-totp') {
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Copied Totp From Context Menu',
});
const totpValue = await this.totpService.getCode(cipher.login.totp); const totpValue = await this.totpService.getCode(cipher.login.totp);
this.platformUtilsService.copyToClipboard(totpValue, { window: window }); this.platformUtilsService.copyToClipboard(totpValue, { window: window });
} }

View File

@ -64,7 +64,6 @@ import { SearchService as SearchServiceAbstraction } from 'jslib/abstractions/se
import { SendService as SendServiceAbstraction } from 'jslib/abstractions/send.service'; import { SendService as SendServiceAbstraction } from 'jslib/abstractions/send.service';
import { SystemService as SystemServiceAbstraction } from 'jslib/abstractions/system.service'; import { SystemService as SystemServiceAbstraction } from 'jslib/abstractions/system.service';
import { Analytics } from 'jslib/misc';
import { Utils } from 'jslib/misc/utils'; import { Utils } from 'jslib/misc/utils';
import { BrowserApi } from '../browser/browserApi'; import { BrowserApi } from '../browser/browserApi';
@ -123,7 +122,6 @@ export default class MainBackground {
systemService: SystemServiceAbstraction; systemService: SystemServiceAbstraction;
eventService: EventServiceAbstraction; eventService: EventServiceAbstraction;
policyService: PolicyServiceAbstraction; policyService: PolicyServiceAbstraction;
analytics: Analytics;
popupUtilsService: PopupUtilsService; popupUtilsService: PopupUtilsService;
sendService: SendServiceAbstraction; sendService: SendServiceAbstraction;
fileUploadService: FileUploadServiceAbstraction; fileUploadService: FileUploadServiceAbstraction;
@ -227,8 +225,6 @@ export default class MainBackground {
this.apiService, this.vaultTimeoutService, () => this.logout(true), this.consoleLogService); this.apiService, this.vaultTimeoutService, () => this.logout(true), this.consoleLogService);
this.environmentService = new EnvironmentService(this.apiService, this.storageService, this.environmentService = new EnvironmentService(this.apiService, this.storageService,
this.notificationsService); this.notificationsService);
this.analytics = new Analytics(window, () => BrowserApi.gaFilter(), this.platformUtilsService,
this.storageService, this.appIdService);
this.popupUtilsService = new PopupUtilsService(this.platformUtilsService); this.popupUtilsService = new PopupUtilsService(this.platformUtilsService);
this.systemService = new SystemService(this.storageService, this.vaultTimeoutService, this.systemService = new SystemService(this.storageService, this.vaultTimeoutService,
this.messagingService, this.platformUtilsService, () => { this.messagingService, this.platformUtilsService, () => {
@ -246,18 +242,17 @@ export default class MainBackground {
// Background // Background
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService, this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
this.platformUtilsService as BrowserPlatformUtilsService, this.storageService, this.i18nService, this.platformUtilsService as BrowserPlatformUtilsService, this.storageService, this.i18nService,
this.analytics, this.notificationsService, this.systemService, this.vaultTimeoutService, this.notificationsService, this.systemService, this.vaultTimeoutService,
this.environmentService, this.policyService, this.userService, this.messagingService); this.environmentService, this.policyService, this.userService, this.messagingService);
this.nativeMessagingBackground = new NativeMessagingBackground(this.storageService, this.cryptoService, this.cryptoFunctionService, this.nativeMessagingBackground = new NativeMessagingBackground(this.storageService, this.cryptoService, this.cryptoFunctionService,
this.vaultTimeoutService, this.runtimeBackground, this.i18nService, this.userService, this.messagingService, this.appIdService, this.vaultTimeoutService, this.runtimeBackground, this.i18nService, this.userService, this.messagingService, this.appIdService,
this.platformUtilsService); this.platformUtilsService);
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService, this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService,
this.platformUtilsService, this.analytics, this.vaultTimeoutService); this.platformUtilsService, this.vaultTimeoutService);
this.tabsBackground = new TabsBackground(this); this.tabsBackground = new TabsBackground(this);
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService, this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService, this.passwordGenerationService,
this.passwordGenerationService, this.analytics, this.platformUtilsService, this.vaultTimeoutService, this.platformUtilsService, this.vaultTimeoutService, this.eventService, this.totpService);
this.eventService, this.totpService);
this.idleBackground = new IdleBackground(this.vaultTimeoutService, this.storageService, this.idleBackground = new IdleBackground(this.vaultTimeoutService, this.storageService,
this.notificationsService); this.notificationsService);
this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService, this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService,
@ -277,7 +272,6 @@ export default class MainBackground {
} }
async bootstrap() { async bootstrap() {
this.analytics.ga('send', 'pageview', '/background.html');
this.containerService.attachToWindow(window); this.containerService.attachToWindow(window);
(this.authService as AuthService).init(); (this.authService as AuthService).init();

View File

@ -22,7 +22,6 @@ import { BrowserApi } from '../browser/browserApi';
import MainBackground from './main.background'; import MainBackground from './main.background';
import { Analytics } from 'jslib/misc';
import { Utils } from 'jslib/misc/utils'; import { Utils } from 'jslib/misc/utils';
import { OrganizationUserStatusType } from 'jslib/enums/organizationUserStatusType'; import { OrganizationUserStatusType } from 'jslib/enums/organizationUserStatusType';
@ -37,7 +36,7 @@ export default class RuntimeBackground {
constructor(private main: MainBackground, private autofillService: AutofillService, constructor(private main: MainBackground, private autofillService: AutofillService,
private cipherService: CipherService, private platformUtilsService: BrowserPlatformUtilsService, private cipherService: CipherService, private platformUtilsService: BrowserPlatformUtilsService,
private storageService: StorageService, private i18nService: I18nService, private storageService: StorageService, private i18nService: I18nService,
private analytics: Analytics, private notificationsService: NotificationsService, private notificationsService: NotificationsService,
private systemService: SystemService, private vaultTimeoutService: VaultTimeoutService, private systemService: SystemService, private vaultTimeoutService: VaultTimeoutService,
private environmentService: EnvironmentService, private policyService: PolicyService, private environmentService: EnvironmentService, private policyService: PolicyService,
private userService: UserService, private messagingService: MessagingService) { private userService: UserService, private messagingService: MessagingService) {
@ -247,10 +246,6 @@ export default class RuntimeBackground {
const cipher = await this.cipherService.encrypt(model); const cipher = await this.cipherService.encrypt(model);
await this.cipherService.saveWithServer(cipher); await this.cipherService.saveWithServer(cipher);
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Added Login from Notification Bar',
});
} }
} }
@ -279,10 +274,6 @@ export default class RuntimeBackground {
model.login.password = queueMessage.newPassword; model.login.password = queueMessage.newPassword;
const newCipher = await this.cipherService.encrypt(model); const newCipher = await this.cipherService.encrypt(model);
await this.cipherService.saveWithServer(newCipher); await this.cipherService.saveWithServer(newCipher);
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Changed Password from Notification Bar',
});
} }
} }
} }
@ -413,10 +404,6 @@ export default class RuntimeBackground {
await this.setDefaultSettings(); await this.setDefaultSettings();
} }
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'onInstalled ' + this.onInstalledReason,
});
this.onInstalledReason = null; this.onInstalledReason = null;
} }
}, 100); }, 100);

View File

@ -4,10 +4,8 @@ import {
BodyOutputType, BodyOutputType,
Toast, Toast,
ToasterConfig, ToasterConfig,
ToasterContainerComponent,
ToasterService, ToasterService,
} from 'angular2-toaster'; } from 'angular2-toaster';
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
import Swal, { SweetAlertIcon } from 'sweetalert2/src/sweetalert2.js'; import Swal, { SweetAlertIcon } from 'sweetalert2/src/sweetalert2.js';
import { import {
@ -24,8 +22,6 @@ import {
RouterOutlet, RouterOutlet,
} from '@angular/router'; } from '@angular/router';
import { Angulartics2 } from 'angulartics2';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service'; import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { AuthService } from 'jslib/abstractions/auth.service'; import { AuthService } from 'jslib/abstractions/auth.service';
@ -61,8 +57,7 @@ export class AppComponent implements OnInit {
private lastActivity: number = null; private lastActivity: number = null;
constructor(private angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics, private analytics: Angulartics2, constructor(private toasterService: ToasterService, private storageService: StorageService,
private toasterService: ToasterService, private storageService: StorageService,
private broadcasterService: BroadcasterService, private authService: AuthService, private broadcasterService: BroadcasterService, private authService: AuthService,
private i18nService: I18nService, private router: Router, private i18nService: I18nService, private router: Router,
private stateService: StateService, private messagingService: MessagingService, private stateService: StateService, private messagingService: MessagingService,
@ -87,7 +82,6 @@ export class AppComponent implements OnInit {
if (msg.command === 'doneLoggingOut') { if (msg.command === 'doneLoggingOut') {
this.ngZone.run(async () => { this.ngZone.run(async () => {
this.authService.logOut(() => { this.authService.logOut(() => {
this.analytics.eventTrack.next({ action: 'Logged Out' });
if (msg.expired) { if (msg.expired) {
this.showToast({ this.showToast({
type: 'warning', type: 'warning',
@ -115,11 +109,6 @@ export class AppComponent implements OnInit {
this.ngZone.run(() => { this.ngZone.run(() => {
this.showToast(msg); this.showToast(msg);
}); });
} else if (msg.command === 'analyticsEventTrack') {
this.analytics.eventTrack.next({
action: msg.action,
properties: { label: msg.label },
});
} else if (msg.command === 'reloadProcess') { } else if (msg.command === 'reloadProcess') {
const windowReload = this.platformUtilsService.isSafari() || const windowReload = this.platformUtilsService.isSafari() ||
this.platformUtilsService.isFirefox() || this.platformUtilsService.isOpera(); this.platformUtilsService.isFirefox() || this.platformUtilsService.isOpera();

View File

@ -3,8 +3,6 @@ import 'zone.js/dist/zone';
import { DragDropModule } from '@angular/cdk/drag-drop'; import { DragDropModule } from '@angular/cdk/drag-drop';
import { ToasterModule } from 'angular2-toaster'; import { ToasterModule } from 'angular2-toaster';
import { Angulartics2Module } from 'angulartics2';
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
import { InfiniteScrollModule } from 'ngx-infinite-scroll'; import { InfiniteScrollModule } from 'ngx-infinite-scroll';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
@ -166,11 +164,6 @@ registerLocaleData(localeZhTw, 'zh-TW');
FormsModule, FormsModule,
AppRoutingModule, AppRoutingModule,
ServicesModule, ServicesModule,
Angulartics2Module.forRoot({
pageTracking: {
clearQueryParams: true,
},
}),
ToasterModule.forRoot(), ToasterModule.forRoot(),
InfiniteScrollModule, InfiniteScrollModule,
DragDropModule, DragDropModule,

View File

@ -6,9 +6,6 @@ import {
} from '@angular/core'; } from '@angular/core';
import { ToasterService } from 'angular2-toaster'; import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
import { BrowserApi } from '../../browser/browserApi';
import { CipherType } from 'jslib/enums/cipherType'; import { CipherType } from 'jslib/enums/cipherType';
import { EventType } from 'jslib/enums/eventType'; import { EventType } from 'jslib/enums/eventType';
@ -36,9 +33,8 @@ export class ActionButtonsComponent {
cipherType = CipherType; cipherType = CipherType;
userHasPremiumAccess = false; userHasPremiumAccess = false;
constructor(private analytics: Angulartics2, private toasterService: ToasterService, constructor(private toasterService: ToasterService, private i18nService: I18nService,
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService, private platformUtilsService: PlatformUtilsService, private eventService: EventService,
private popupUtilsService: PopupUtilsService, private eventService: EventService,
private totpService: TotpService, private userService: UserService) { } private totpService: TotpService, private userService: UserService) { }
async ngOnInit() { async ngOnInit() {
@ -60,7 +56,6 @@ export class ActionButtonsComponent {
return; return;
} }
this.analytics.eventTrack.next({ action: 'Copied ' + aType });
this.platformUtilsService.copyToClipboard(value, { window: window }); this.platformUtilsService.copyToClipboard(value, { window: window });
this.toasterService.popAsync('info', null, this.toasterService.popAsync('info', null,
this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey))); this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey)));

View File

@ -4,8 +4,6 @@ import {
OnInit, OnInit,
} from '@angular/core'; } from '@angular/core';
import { Angulartics2 } from 'angulartics2';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { PopupUtilsService } from '../services/popup-utils.service'; import { PopupUtilsService } from '../services/popup-utils.service';
@ -17,7 +15,7 @@ import { PopupUtilsService } from '../services/popup-utils.service';
export class PopOutComponent implements OnInit { export class PopOutComponent implements OnInit {
@Input() show = true; @Input() show = true;
constructor(private analytics: Angulartics2, private platformUtilsService: PlatformUtilsService, constructor(private platformUtilsService: PlatformUtilsService,
private popupUtilsService: PopupUtilsService) { } private popupUtilsService: PopupUtilsService) { }
ngOnInit() { ngOnInit() {
@ -29,7 +27,6 @@ export class PopOutComponent implements OnInit {
} }
expand() { expand() {
this.analytics.eventTrack.next({ action: 'Pop Out Window' });
this.popupUtilsService.popOut(window); this.popupUtilsService.popOut(window);
} }
} }

View File

@ -53,8 +53,6 @@ import { ConstantsService } from 'jslib/services/constants.service';
import { SearchService } from 'jslib/services/search.service'; import { SearchService } from 'jslib/services/search.service';
import { StateService } from 'jslib/services/state.service'; import { StateService } from 'jslib/services/state.service';
import { Analytics } from 'jslib/misc/analytics';
import { PopupSearchService } from './popup-search.service'; import { PopupSearchService } from './popup-search.service';
import { PopupUtilsService } from './popup-utils.service'; import { PopupUtilsService } from './popup-utils.service';
@ -100,14 +98,6 @@ export function initFactory(platformUtilsService: PlatformUtilsService, i18nServ
} }
window.document.documentElement.classList.add('locale_' + i18nService.translationLocale); window.document.documentElement.classList.add('locale_' + i18nService.translationLocale);
window.document.documentElement.classList.add('theme_' + theme); window.document.documentElement.classList.add('theme_' + theme);
const analytics = new Analytics(window, () => BrowserApi.gaFilter(), null, null, null, () => {
const bgPage = BrowserApi.getBackgroundPage();
if (bgPage == null || bgPage.bitwardenMain == null) {
throw new Error('Cannot resolve background page main.');
}
return bgPage.bitwardenMain;
});
} }
}; };
} }

View File

@ -3,8 +3,6 @@ import {
OnInit, OnInit,
} from '@angular/core'; } from '@angular/core';
import { Angulartics2 } from 'angulartics2';
import { UriMatchType } from 'jslib/enums/uriMatchType'; import { UriMatchType } from 'jslib/enums/uriMatchType';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
@ -38,10 +36,8 @@ export class OptionsComponent implements OnInit {
clearClipboard: number; clearClipboard: number;
clearClipboardOptions: any[]; clearClipboardOptions: any[];
constructor(private analytics: Angulartics2, private messagingService: MessagingService, constructor(private messagingService: MessagingService, private storageService: StorageService,
private platformUtilsService: PlatformUtilsService, private storageService: StorageService, private stateService: StateService, private totpService: TotpService, i18nService: I18nService) {
private stateService: StateService, private totpService: TotpService,
i18nService: I18nService) {
this.themeOptions = [ this.themeOptions = [
{ name: i18nService.t('default'), value: null }, { name: i18nService.t('default'), value: null },
{ name: i18nService.t('light'), value: 'light' }, { name: i18nService.t('light'), value: 'light' },
@ -100,36 +96,30 @@ export class OptionsComponent implements OnInit {
async updateAddLoginNotification() { async updateAddLoginNotification() {
await this.storageService.save(ConstantsService.disableAddLoginNotificationKey, await this.storageService.save(ConstantsService.disableAddLoginNotificationKey,
this.disableAddLoginNotification); this.disableAddLoginNotification);
this.callAnalytics('Add Login Notification', !this.disableAddLoginNotification);
} }
async updateChangedPasswordNotification() { async updateChangedPasswordNotification() {
await this.storageService.save(ConstantsService.disableChangedPasswordNotificationKey, await this.storageService.save(ConstantsService.disableChangedPasswordNotificationKey,
this.disableChangedPasswordNotification); this.disableChangedPasswordNotification);
this.callAnalytics('Changed Password Notification', !this.disableChangedPasswordNotification);
} }
async updateDisableContextMenuItem() { async updateDisableContextMenuItem() {
await this.storageService.save(ConstantsService.disableContextMenuItemKey, await this.storageService.save(ConstantsService.disableContextMenuItemKey,
this.disableContextMenuItem); this.disableContextMenuItem);
this.messagingService.send('bgUpdateContextMenu'); this.messagingService.send('bgUpdateContextMenu');
this.callAnalytics('Context Menu Item', !this.disableContextMenuItem);
} }
async updateAutoTotpCopy() { async updateAutoTotpCopy() {
await this.storageService.save(ConstantsService.disableAutoTotpCopyKey, this.disableAutoTotpCopy); await this.storageService.save(ConstantsService.disableAutoTotpCopyKey, this.disableAutoTotpCopy);
this.callAnalytics('Auto Copy TOTP', !this.disableAutoTotpCopy);
} }
async updateAutoFillOnPageLoad() { async updateAutoFillOnPageLoad() {
await this.storageService.save(ConstantsService.enableAutoFillOnPageLoadKey, this.enableAutoFillOnPageLoad); await this.storageService.save(ConstantsService.enableAutoFillOnPageLoadKey, this.enableAutoFillOnPageLoad);
this.callAnalytics('Auto-fill Page Load', this.enableAutoFillOnPageLoad);
} }
async updateDisableFavicon() { async updateDisableFavicon() {
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicon); await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicon); await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
this.callAnalytics('Favicon', !this.disableFavicon);
} }
async updateDisableBadgeCounter() { async updateDisableBadgeCounter() {
@ -141,35 +131,23 @@ export class OptionsComponent implements OnInit {
async updateShowCards() { async updateShowCards() {
await this.storageService.save(ConstantsService.dontShowCardsCurrentTab, this.dontShowCards); await this.storageService.save(ConstantsService.dontShowCardsCurrentTab, this.dontShowCards);
await this.stateService.save(ConstantsService.dontShowCardsCurrentTab, this.dontShowCards); await this.stateService.save(ConstantsService.dontShowCardsCurrentTab, this.dontShowCards);
this.callAnalytics('Show Cards on Current Tab', !this.dontShowCards);
} }
async updateShowIdentities() { async updateShowIdentities() {
await this.storageService.save(ConstantsService.dontShowIdentitiesCurrentTab, this.dontShowIdentities); await this.storageService.save(ConstantsService.dontShowIdentitiesCurrentTab, this.dontShowIdentities);
await this.stateService.save(ConstantsService.dontShowIdentitiesCurrentTab, this.dontShowIdentities); await this.stateService.save(ConstantsService.dontShowIdentitiesCurrentTab, this.dontShowIdentities);
this.callAnalytics('Show Identities on Current Tab', !this.dontShowIdentities);
} }
async saveTheme() { async saveTheme() {
await this.storageService.save(ConstantsService.themeKey, this.theme); await this.storageService.save(ConstantsService.themeKey, this.theme);
this.analytics.eventTrack.next({ action: 'Set Theme ' + this.theme });
window.setTimeout(() => window.location.reload(), 200); window.setTimeout(() => window.location.reload(), 200);
} }
async saveDefaultUriMatch() { async saveDefaultUriMatch() {
await this.storageService.save(ConstantsService.defaultUriMatch, this.defaultUriMatch); await this.storageService.save(ConstantsService.defaultUriMatch, this.defaultUriMatch);
this.analytics.eventTrack.next({ action: 'Set Default URI Match ' + this.defaultUriMatch });
} }
async saveClearClipboard() { async saveClearClipboard() {
await this.storageService.save(ConstantsService.clearClipboardKey, this.clearClipboard); await this.storageService.save(ConstantsService.clearClipboardKey, this.clearClipboard);
this.analytics.eventTrack.next({
action: 'Set Clear Clipboard ' + (this.clearClipboard == null ? 'Disabled' : this.clearClipboard),
});
}
private callAnalytics(name: string, enabled: boolean) {
const status = enabled ? 'Enabled' : 'Disabled';
this.analytics.eventTrack.next({ action: `${status} ${name}` });
} }
} }

View File

@ -1,4 +1,3 @@
import { Angulartics2 } from 'angulartics2';
import Swal from 'sweetalert2/src/sweetalert2.js'; import Swal from 'sweetalert2/src/sweetalert2.js';
import { import {
@ -57,11 +56,10 @@ export class SettingsComponent implements OnInit {
previousVaultTimeout: number = null; previousVaultTimeout: number = null;
constructor(private platformUtilsService: PlatformUtilsService, private i18nService: I18nService, constructor(private platformUtilsService: PlatformUtilsService, private i18nService: I18nService,
private analytics: Angulartics2, private vaultTimeoutService: VaultTimeoutService, private vaultTimeoutService: VaultTimeoutService, private storageService: StorageService,
private storageService: StorageService, public messagingService: MessagingService, public messagingService: MessagingService, private router: Router,
private router: Router, private environmentService: EnvironmentService, private environmentService: EnvironmentService, private cryptoService: CryptoService,
private cryptoService: CryptoService, private userService: UserService, private userService: UserService, private popupUtilsService: PopupUtilsService) {
private popupUtilsService: PopupUtilsService) {
} }
async ngOnInit() { async ngOnInit() {
@ -280,7 +278,6 @@ export class SettingsComponent implements OnInit {
} }
async lock() { async lock() {
this.analytics.eventTrack.next({ action: 'Lock Now' });
await this.vaultTimeoutService.lock(true); await this.vaultTimeoutService.lock(true);
} }
@ -294,7 +291,6 @@ export class SettingsComponent implements OnInit {
} }
async changePassword() { async changePassword() {
this.analytics.eventTrack.next({ action: 'Clicked Change Password' });
const confirmed = await this.platformUtilsService.showDialog( const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('changeMasterPasswordConfirmation'), this.i18nService.t('changeMasterPassword'), this.i18nService.t('changeMasterPasswordConfirmation'), this.i18nService.t('changeMasterPassword'),
this.i18nService.t('yes'), this.i18nService.t('cancel')); this.i18nService.t('yes'), this.i18nService.t('cancel'));
@ -304,7 +300,6 @@ export class SettingsComponent implements OnInit {
} }
async twoStep() { async twoStep() {
this.analytics.eventTrack.next({ action: 'Clicked Two-step Login' });
const confirmed = await this.platformUtilsService.showDialog( const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('twoStepLoginConfirmation'), this.i18nService.t('twoStepLogin'), this.i18nService.t('twoStepLoginConfirmation'), this.i18nService.t('twoStepLogin'),
this.i18nService.t('yes'), this.i18nService.t('cancel')); this.i18nService.t('yes'), this.i18nService.t('cancel'));
@ -314,7 +309,6 @@ export class SettingsComponent implements OnInit {
} }
async share() { async share() {
this.analytics.eventTrack.next({ action: 'Clicked Share Vault' });
const confirmed = await this.platformUtilsService.showDialog( const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('shareVaultConfirmation'), this.i18nService.t('shareVault'), this.i18nService.t('shareVaultConfirmation'), this.i18nService.t('shareVault'),
this.i18nService.t('yes'), this.i18nService.t('cancel')); this.i18nService.t('yes'), this.i18nService.t('cancel'));
@ -324,7 +318,6 @@ export class SettingsComponent implements OnInit {
} }
async webVault() { async webVault() {
this.analytics.eventTrack.next({ action: 'Clicked Web Vault' });
let url = this.environmentService.getWebVaultUrl(); let url = this.environmentService.getWebVaultUrl();
if (url == null) { if (url == null) {
url = 'https://vault.bitwarden.com'; url = 'https://vault.bitwarden.com';
@ -333,7 +326,6 @@ export class SettingsComponent implements OnInit {
} }
import() { import() {
this.analytics.eventTrack.next({ action: 'Clicked Import Items' });
BrowserApi.createNewTab('https://help.bitwarden.com/article/import-data/'); BrowserApi.createNewTab('https://help.bitwarden.com/article/import-data/');
} }
@ -342,13 +334,10 @@ export class SettingsComponent implements OnInit {
} }
help() { help() {
this.analytics.eventTrack.next({ action: 'Clicked Help and Feedback' });
BrowserApi.createNewTab('https://help.bitwarden.com/'); BrowserApi.createNewTab('https://help.bitwarden.com/');
} }
about() { about() {
this.analytics.eventTrack.next({ action: 'Clicked About' });
const year = (new Date()).getFullYear(); const year = (new Date()).getFullYear();
const versionText = document.createTextNode( const versionText = document.createTextNode(
this.i18nService.t('version') + ': ' + BrowserApi.getApplicationVersion()); this.i18nService.t('version') + ': ' + BrowserApi.getApplicationVersion());
@ -368,8 +357,6 @@ export class SettingsComponent implements OnInit {
} }
async fingerprint() { async fingerprint() {
this.analytics.eventTrack.next({ action: 'Clicked Fingerprint' });
const fingerprint = await this.cryptoService.getFingerprint(await this.userService.getUserId()); const fingerprint = await this.cryptoService.getFingerprint(await this.userService.getUserId());
const p = document.createElement('p'); const p = document.createElement('p');
p.innerText = this.i18nService.t('yourAccountsFingerprint') + ':'; p.innerText = this.i18nService.t('yourAccountsFingerprint') + ':';
@ -395,7 +382,6 @@ export class SettingsComponent implements OnInit {
} }
rate() { rate() {
this.analytics.eventTrack.next({ action: 'Rate Extension' });
const deviceType = this.platformUtilsService.getDevice(); const deviceType = this.platformUtilsService.getDevice();
BrowserApi.createNewTab((RateUrls as any)[deviceType]); BrowserApi.createNewTab((RateUrls as any)[deviceType]);
} }

View File

@ -1,11 +1,9 @@
import { ToasterService } from 'angular2-toaster'; import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
import { import {
Component, Component,
OnInit, OnInit,
} from '@angular/core'; } from '@angular/core';
import { Router } from '@angular/router';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
import { SyncService } from 'jslib/abstractions/sync.service'; import { SyncService } from 'jslib/abstractions/sync.service';
@ -18,8 +16,7 @@ export class SyncComponent implements OnInit {
lastSync = '--'; lastSync = '--';
syncPromise: Promise<any>; syncPromise: Promise<any>;
constructor(private syncService: SyncService, private router: Router, constructor(private syncService: SyncService, private toasterService: ToasterService,
private toasterService: ToasterService, private analytics: Angulartics2,
private i18nService: I18nService) { private i18nService: I18nService) {
} }
@ -32,7 +29,6 @@ export class SyncComponent implements OnInit {
const success = await this.syncPromise; const success = await this.syncPromise;
if (success) { if (success) {
await this.setLastSync(); await this.setLastSync();
this.analytics.eventTrack.next({ action: 'Synced Full' });
this.toasterService.popAsync('success', null, this.i18nService.t('syncingComplete')); this.toasterService.popAsync('success', null, this.i18nService.t('syncingComplete'));
} else { } else {
this.toasterService.popAsync('error', null, this.i18nService.t('syncingFailed')); this.toasterService.popAsync('error', null, this.i18nService.t('syncingFailed'));

View File

@ -1,5 +1,3 @@
import { Angulartics2 } from 'angulartics2';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { import {
ChangeDetectorRef, ChangeDetectorRef,
@ -63,8 +61,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
private changeDetectorRef: ChangeDetectorRef, private stateService: StateService, private changeDetectorRef: ChangeDetectorRef, private stateService: StateService,
private popupUtils: PopupUtilsService, private i18nService: I18nService, private popupUtils: PopupUtilsService, private i18nService: I18nService,
private folderService: FolderService, private collectionService: CollectionService, private folderService: FolderService, private collectionService: CollectionService,
private analytics: Angulartics2, private platformUtilsService: PlatformUtilsService, private platformUtilsService: PlatformUtilsService, private cipherService: CipherService) {
private cipherService: CipherService) {
super(searchService); super(searchService);
this.pageSize = 100; this.pageSize = 100;
this.applySavedState = (window as any).previousPopupUrl != null && this.applySavedState = (window as any).previousPopupUrl != null &&
@ -196,7 +193,6 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
window.clearTimeout(this.selectedTimeout); window.clearTimeout(this.selectedTimeout);
} }
this.preventSelected = true; this.preventSelected = true;
this.analytics.eventTrack.next({ action: 'Launched URI From Listing' });
await this.cipherService.updateLastLaunchedDate(cipher.id); await this.cipherService.updateLastLaunchedDate(cipher.id);
BrowserApi.createNewTab(cipher.login.launchUri); BrowserApi.createNewTab(cipher.login.launchUri);
if (this.popupUtils.inPopup(window)) { if (this.popupUtils.inPopup(window)) {

View File

@ -9,7 +9,6 @@ import {
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { ToasterService } from 'angular2-toaster'; import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
import { BrowserApi } from '../../browser/browserApi'; import { BrowserApi } from '../../browser/browserApi';
@ -59,8 +58,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
constructor(private platformUtilsService: PlatformUtilsService, private cipherService: CipherService, constructor(private platformUtilsService: PlatformUtilsService, private cipherService: CipherService,
private popupUtilsService: PopupUtilsService, private autofillService: AutofillService, private popupUtilsService: PopupUtilsService, private autofillService: AutofillService,
private analytics: Angulartics2, private toasterService: ToasterService, private toasterService: ToasterService, private i18nService: I18nService, private router: Router,
private i18nService: I18nService, private router: Router,
private ngZone: NgZone, private broadcasterService: BroadcasterService, private ngZone: NgZone, private broadcasterService: BroadcasterService,
private changeDetectorRef: ChangeDetectorRef, private syncService: SyncService, private changeDetectorRef: ChangeDetectorRef, private syncService: SyncService,
private searchService: SearchService, private storageService: StorageService) { private searchService: SearchService, private storageService: StorageService) {
@ -136,7 +134,6 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
} }
if (this.pageDetails == null || this.pageDetails.length === 0) { if (this.pageDetails == null || this.pageDetails.length === 0) {
this.analytics.eventTrack.next({ action: 'Autofilled Error' });
this.toasterService.popAsync('error', null, this.i18nService.t('autofillError')); this.toasterService.popAsync('error', null, this.i18nService.t('autofillError'));
return; return;
} }
@ -148,7 +145,6 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
doc: window.document, doc: window.document,
fillNewPassword: true, fillNewPassword: true,
}); });
this.analytics.eventTrack.next({ action: 'Autofilled' });
if (this.totpCode != null) { if (this.totpCode != null) {
this.platformUtilsService.copyToClipboard(this.totpCode, { window: window }); this.platformUtilsService.copyToClipboard(this.totpCode, { window: window });
} }
@ -157,7 +153,6 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
} }
} catch { } catch {
this.ngZone.run(() => { this.ngZone.run(() => {
this.analytics.eventTrack.next({ action: 'Autofilled Error' });
this.toasterService.popAsync('error', null, this.i18nService.t('autofillError')); this.toasterService.popAsync('error', null, this.i18nService.t('autofillError'));
this.changeDetectorRef.detectChanges(); this.changeDetectorRef.detectChanges();
}); });

View File

@ -1,5 +1,3 @@
import { Angulartics2 } from 'angulartics2';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { import {
ChangeDetectorRef, ChangeDetectorRef,
@ -74,9 +72,8 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
private ngZone: NgZone, private broadcasterService: BroadcasterService, private ngZone: NgZone, private broadcasterService: BroadcasterService,
private changeDetectorRef: ChangeDetectorRef, private route: ActivatedRoute, private changeDetectorRef: ChangeDetectorRef, private route: ActivatedRoute,
private stateService: StateService, private popupUtils: PopupUtilsService, private stateService: StateService, private popupUtils: PopupUtilsService,
private syncService: SyncService, private analytics: Angulartics2, private syncService: SyncService, private platformUtilsService: PlatformUtilsService,
private platformUtilsService: PlatformUtilsService, private searchService: SearchService, private searchService: SearchService, private location: Location) {
private location: Location) {
super(collectionService, folderService, storageService, userService); super(collectionService, folderService, storageService, userService);
this.noFolderListSize = 100; this.noFolderListSize = 100;
} }
@ -284,7 +281,6 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
window.clearTimeout(this.selectedTimeout); window.clearTimeout(this.selectedTimeout);
} }
this.preventSelected = true; this.preventSelected = true;
this.analytics.eventTrack.next({ action: 'Launched URI From Listing' });
await this.cipherService.updateLastLaunchedDate(cipher.id); await this.cipherService.updateLastLaunchedDate(cipher.id);
BrowserApi.createNewTab(cipher.login.launchUri); BrowserApi.createNewTab(cipher.login.launchUri);
if (this.popupUtils.inPopup(window)) { if (this.popupUtils.inPopup(window)) {

View File

@ -6,8 +6,6 @@ import { DeviceType } from 'jslib/enums/deviceType';
import { MessagingService } from 'jslib/abstractions/messaging.service'; import { MessagingService } from 'jslib/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { AnalyticsIds } from 'jslib/misc/analytics';
const DialogPromiseExpiration = 600000; // 10 minutes const DialogPromiseExpiration = 600000; // 10 minutes
export default class BrowserPlatformUtilsService implements PlatformUtilsService { export default class BrowserPlatformUtilsService implements PlatformUtilsService {
@ -15,7 +13,6 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
private showDialogResolves = new Map<number, { resolve: (value: boolean) => void, date: Date }>(); private showDialogResolves = new Map<number, { resolve: (value: boolean) => void, date: Date }>();
private deviceCache: DeviceType = null; private deviceCache: DeviceType = null;
private analyticsIdCache: string = null;
private prefersColorSchemeDark = window.matchMedia('(prefers-color-scheme: dark)'); private prefersColorSchemeDark = window.matchMedia('(prefers-color-scheme: dark)');
constructor(private messagingService: MessagingService, constructor(private messagingService: MessagingService,
@ -82,15 +79,6 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
return false; return false;
} }
analyticsId(): string {
if (this.analyticsIdCache) {
return this.analyticsIdCache;
}
this.analyticsIdCache = (AnalyticsIds as any)[this.getDevice()];
return this.analyticsIdCache;
}
async isViewOpen(): Promise<boolean> { async isViewOpen(): Promise<boolean> {
if (await BrowserApi.isPopupOpen()) { if (await BrowserApi.isPopupOpen()) {
return true; return true;
@ -161,14 +149,6 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
}); });
} }
eventTrack(action: string, label?: string, options?: any) {
this.messagingService.send('analyticsEventTrack', {
action: action,
label: label,
options: options,
});
}
isDev(): boolean { isDev(): boolean {
return process.env.ENV === 'development'; return process.env.ENV === 'development';
} }