1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-22 11:13:46 +00:00

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
19 changed files with 23 additions and 197 deletions

View File

@@ -4,10 +4,8 @@ import {
BodyOutputType,
Toast,
ToasterConfig,
ToasterContainerComponent,
ToasterService,
} from 'angular2-toaster';
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
import Swal, { SweetAlertIcon } from 'sweetalert2/src/sweetalert2.js';
import {
@@ -24,8 +22,6 @@ import {
RouterOutlet,
} from '@angular/router';
import { Angulartics2 } from 'angulartics2';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { AuthService } from 'jslib/abstractions/auth.service';
@@ -61,8 +57,7 @@ export class AppComponent implements OnInit {
private lastActivity: number = null;
constructor(private angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics, private analytics: Angulartics2,
private toasterService: ToasterService, private storageService: StorageService,
constructor(private toasterService: ToasterService, private storageService: StorageService,
private broadcasterService: BroadcasterService, private authService: AuthService,
private i18nService: I18nService, private router: Router,
private stateService: StateService, private messagingService: MessagingService,
@@ -87,7 +82,6 @@ export class AppComponent implements OnInit {
if (msg.command === 'doneLoggingOut') {
this.ngZone.run(async () => {
this.authService.logOut(() => {
this.analytics.eventTrack.next({ action: 'Logged Out' });
if (msg.expired) {
this.showToast({
type: 'warning',
@@ -115,11 +109,6 @@ export class AppComponent implements OnInit {
this.ngZone.run(() => {
this.showToast(msg);
});
} else if (msg.command === 'analyticsEventTrack') {
this.analytics.eventTrack.next({
action: msg.action,
properties: { label: msg.label },
});
} else if (msg.command === 'reloadProcess') {
const windowReload = this.platformUtilsService.isSafari() ||
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 { ToasterModule } from 'angular2-toaster';
import { Angulartics2Module } from 'angulartics2';
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
import { AppRoutingModule } from './app-routing.module';
@@ -166,11 +164,6 @@ registerLocaleData(localeZhTw, 'zh-TW');
FormsModule,
AppRoutingModule,
ServicesModule,
Angulartics2Module.forRoot({
pageTracking: {
clearQueryParams: true,
},
}),
ToasterModule.forRoot(),
InfiniteScrollModule,
DragDropModule,

View File

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

View File

@@ -4,8 +4,6 @@ import {
OnInit,
} from '@angular/core';
import { Angulartics2 } from 'angulartics2';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { PopupUtilsService } from '../services/popup-utils.service';
@@ -17,7 +15,7 @@ import { PopupUtilsService } from '../services/popup-utils.service';
export class PopOutComponent implements OnInit {
@Input() show = true;
constructor(private analytics: Angulartics2, private platformUtilsService: PlatformUtilsService,
constructor(private platformUtilsService: PlatformUtilsService,
private popupUtilsService: PopupUtilsService) { }
ngOnInit() {
@@ -29,7 +27,6 @@ export class PopOutComponent implements OnInit {
}
expand() {
this.analytics.eventTrack.next({ action: 'Pop Out 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 { StateService } from 'jslib/services/state.service';
import { Analytics } from 'jslib/misc/analytics';
import { PopupSearchService } from './popup-search.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('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,
} from '@angular/core';
import { Angulartics2 } from 'angulartics2';
import { UriMatchType } from 'jslib/enums/uriMatchType';
import { I18nService } from 'jslib/abstractions/i18n.service';
@@ -38,10 +36,8 @@ export class OptionsComponent implements OnInit {
clearClipboard: number;
clearClipboardOptions: any[];
constructor(private analytics: Angulartics2, private messagingService: MessagingService,
private platformUtilsService: PlatformUtilsService, private storageService: StorageService,
private stateService: StateService, private totpService: TotpService,
i18nService: I18nService) {
constructor(private messagingService: MessagingService, private storageService: StorageService,
private stateService: StateService, private totpService: TotpService, i18nService: I18nService) {
this.themeOptions = [
{ name: i18nService.t('default'), value: null },
{ name: i18nService.t('light'), value: 'light' },
@@ -100,36 +96,30 @@ export class OptionsComponent implements OnInit {
async updateAddLoginNotification() {
await this.storageService.save(ConstantsService.disableAddLoginNotificationKey,
this.disableAddLoginNotification);
this.callAnalytics('Add Login Notification', !this.disableAddLoginNotification);
}
async updateChangedPasswordNotification() {
await this.storageService.save(ConstantsService.disableChangedPasswordNotificationKey,
this.disableChangedPasswordNotification);
this.callAnalytics('Changed Password Notification', !this.disableChangedPasswordNotification);
}
async updateDisableContextMenuItem() {
await this.storageService.save(ConstantsService.disableContextMenuItemKey,
this.disableContextMenuItem);
this.messagingService.send('bgUpdateContextMenu');
this.callAnalytics('Context Menu Item', !this.disableContextMenuItem);
}
async updateAutoTotpCopy() {
await this.storageService.save(ConstantsService.disableAutoTotpCopyKey, this.disableAutoTotpCopy);
this.callAnalytics('Auto Copy TOTP', !this.disableAutoTotpCopy);
}
async updateAutoFillOnPageLoad() {
await this.storageService.save(ConstantsService.enableAutoFillOnPageLoadKey, this.enableAutoFillOnPageLoad);
this.callAnalytics('Auto-fill Page Load', this.enableAutoFillOnPageLoad);
}
async updateDisableFavicon() {
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
this.callAnalytics('Favicon', !this.disableFavicon);
}
async updateDisableBadgeCounter() {
@@ -141,35 +131,23 @@ export class OptionsComponent implements OnInit {
async updateShowCards() {
await this.storageService.save(ConstantsService.dontShowCardsCurrentTab, this.dontShowCards);
await this.stateService.save(ConstantsService.dontShowCardsCurrentTab, this.dontShowCards);
this.callAnalytics('Show Cards on Current Tab', !this.dontShowCards);
}
async updateShowIdentities() {
await this.storageService.save(ConstantsService.dontShowIdentitiesCurrentTab, this.dontShowIdentities);
await this.stateService.save(ConstantsService.dontShowIdentitiesCurrentTab, this.dontShowIdentities);
this.callAnalytics('Show Identities on Current Tab', !this.dontShowIdentities);
}
async saveTheme() {
await this.storageService.save(ConstantsService.themeKey, this.theme);
this.analytics.eventTrack.next({ action: 'Set Theme ' + this.theme });
window.setTimeout(() => window.location.reload(), 200);
}
async saveDefaultUriMatch() {
await this.storageService.save(ConstantsService.defaultUriMatch, this.defaultUriMatch);
this.analytics.eventTrack.next({ action: 'Set Default URI Match ' + this.defaultUriMatch });
}
async saveClearClipboard() {
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 {
@@ -57,11 +56,10 @@ export class SettingsComponent implements OnInit {
previousVaultTimeout: number = null;
constructor(private platformUtilsService: PlatformUtilsService, private i18nService: I18nService,
private analytics: Angulartics2, private vaultTimeoutService: VaultTimeoutService,
private storageService: StorageService, public messagingService: MessagingService,
private router: Router, private environmentService: EnvironmentService,
private cryptoService: CryptoService, private userService: UserService,
private popupUtilsService: PopupUtilsService) {
private vaultTimeoutService: VaultTimeoutService, private storageService: StorageService,
public messagingService: MessagingService, private router: Router,
private environmentService: EnvironmentService, private cryptoService: CryptoService,
private userService: UserService, private popupUtilsService: PopupUtilsService) {
}
async ngOnInit() {
@@ -280,7 +278,6 @@ export class SettingsComponent implements OnInit {
}
async lock() {
this.analytics.eventTrack.next({ action: 'Lock Now' });
await this.vaultTimeoutService.lock(true);
}
@@ -294,7 +291,6 @@ export class SettingsComponent implements OnInit {
}
async changePassword() {
this.analytics.eventTrack.next({ action: 'Clicked Change Password' });
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('changeMasterPasswordConfirmation'), this.i18nService.t('changeMasterPassword'),
this.i18nService.t('yes'), this.i18nService.t('cancel'));
@@ -304,7 +300,6 @@ export class SettingsComponent implements OnInit {
}
async twoStep() {
this.analytics.eventTrack.next({ action: 'Clicked Two-step Login' });
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('twoStepLoginConfirmation'), this.i18nService.t('twoStepLogin'),
this.i18nService.t('yes'), this.i18nService.t('cancel'));
@@ -314,7 +309,6 @@ export class SettingsComponent implements OnInit {
}
async share() {
this.analytics.eventTrack.next({ action: 'Clicked Share Vault' });
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('shareVaultConfirmation'), this.i18nService.t('shareVault'),
this.i18nService.t('yes'), this.i18nService.t('cancel'));
@@ -324,7 +318,6 @@ export class SettingsComponent implements OnInit {
}
async webVault() {
this.analytics.eventTrack.next({ action: 'Clicked Web Vault' });
let url = this.environmentService.getWebVaultUrl();
if (url == null) {
url = 'https://vault.bitwarden.com';
@@ -333,7 +326,6 @@ export class SettingsComponent implements OnInit {
}
import() {
this.analytics.eventTrack.next({ action: 'Clicked Import Items' });
BrowserApi.createNewTab('https://help.bitwarden.com/article/import-data/');
}
@@ -342,13 +334,10 @@ export class SettingsComponent implements OnInit {
}
help() {
this.analytics.eventTrack.next({ action: 'Clicked Help and Feedback' });
BrowserApi.createNewTab('https://help.bitwarden.com/');
}
about() {
this.analytics.eventTrack.next({ action: 'Clicked About' });
const year = (new Date()).getFullYear();
const versionText = document.createTextNode(
this.i18nService.t('version') + ': ' + BrowserApi.getApplicationVersion());
@@ -368,8 +357,6 @@ export class SettingsComponent implements OnInit {
}
async fingerprint() {
this.analytics.eventTrack.next({ action: 'Clicked Fingerprint' });
const fingerprint = await this.cryptoService.getFingerprint(await this.userService.getUserId());
const p = document.createElement('p');
p.innerText = this.i18nService.t('yourAccountsFingerprint') + ':';
@@ -395,7 +382,6 @@ export class SettingsComponent implements OnInit {
}
rate() {
this.analytics.eventTrack.next({ action: 'Rate Extension' });
const deviceType = this.platformUtilsService.getDevice();
BrowserApi.createNewTab((RateUrls as any)[deviceType]);
}

View File

@@ -1,11 +1,9 @@
import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
import {
Component,
OnInit,
} from '@angular/core';
import { Router } from '@angular/router';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { SyncService } from 'jslib/abstractions/sync.service';
@@ -18,8 +16,7 @@ export class SyncComponent implements OnInit {
lastSync = '--';
syncPromise: Promise<any>;
constructor(private syncService: SyncService, private router: Router,
private toasterService: ToasterService, private analytics: Angulartics2,
constructor(private syncService: SyncService, private toasterService: ToasterService,
private i18nService: I18nService) {
}
@@ -32,7 +29,6 @@ export class SyncComponent implements OnInit {
const success = await this.syncPromise;
if (success) {
await this.setLastSync();
this.analytics.eventTrack.next({ action: 'Synced Full' });
this.toasterService.popAsync('success', null, this.i18nService.t('syncingComplete'));
} else {
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 {
ChangeDetectorRef,
@@ -63,8 +61,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
private changeDetectorRef: ChangeDetectorRef, private stateService: StateService,
private popupUtils: PopupUtilsService, private i18nService: I18nService,
private folderService: FolderService, private collectionService: CollectionService,
private analytics: Angulartics2, private platformUtilsService: PlatformUtilsService,
private cipherService: CipherService) {
private platformUtilsService: PlatformUtilsService, private cipherService: CipherService) {
super(searchService);
this.pageSize = 100;
this.applySavedState = (window as any).previousPopupUrl != null &&
@@ -196,7 +193,6 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
window.clearTimeout(this.selectedTimeout);
}
this.preventSelected = true;
this.analytics.eventTrack.next({ action: 'Launched URI From Listing' });
await this.cipherService.updateLastLaunchedDate(cipher.id);
BrowserApi.createNewTab(cipher.login.launchUri);
if (this.popupUtils.inPopup(window)) {

View File

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

View File

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