1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

Remove last remnants of old analytics code (#345)

This commit is contained in:
Oscar Hinton 2021-04-14 21:34:30 +02:00 committed by GitHub
parent 0a0cdaa7fd
commit 92df633040
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 1 additions and 202 deletions

View File

@ -12,7 +12,6 @@ export abstract class PlatformUtilsService {
isSafari: () => boolean;
isIE: () => boolean;
isMacAppStore: () => boolean;
analyticsId: () => string;
isViewOpen: () => Promise<boolean>;
/**
* @deprecated This only ever returns null. Pull from your platform's storage using ConstantsService.vaultTimeoutKey
@ -27,7 +26,6 @@ export abstract class PlatformUtilsService {
options?: any) => void;
showDialog: (body: string, title?: string, confirmText?: string, cancelText?: string,
type?: string, bodyIsHtml?: boolean) => Promise<boolean>;
eventTrack: (action: string, label?: string, options?: any) => void;
isDev: () => boolean;
isSelfHost: () => boolean;
copyToClipboard: (text: string, options?: any) => void;

View File

@ -286,7 +286,6 @@ export class AddEditComponent implements OnInit {
this.formPromise = this.saveCipher(cipher);
await this.formPromise;
this.cipher.id = cipher.id;
this.platformUtilsService.eventTrack(this.editMode && !this.cloneMode ? 'Edited Cipher' : 'Added Cipher');
this.platformUtilsService.showToast('success', null,
this.i18nService.t(this.editMode && !this.cloneMode ? 'editedItem' : 'addedItem'));
this.onSavedCipher.emit(this.cipher);
@ -369,7 +368,6 @@ export class AddEditComponent implements OnInit {
try {
this.deletePromise = this.deleteCipher();
await this.deletePromise;
this.platformUtilsService.eventTrack((this.cipher.isDeleted ? 'Permanently ' : '') + 'Deleted Cipher');
this.platformUtilsService.showToast('success', null,
this.i18nService.t(this.cipher.isDeleted ? 'permanentlyDeletedItem' : 'deletedItem'));
this.onDeletedCipher.emit(this.cipher);
@ -394,7 +392,6 @@ export class AddEditComponent implements OnInit {
try {
this.restorePromise = this.restoreCipher();
await this.restorePromise;
this.platformUtilsService.eventTrack('Restored Cipher');
this.platformUtilsService.showToast('success', null, this.i18nService.t('restoredItem'));
this.onRestoredCipher.emit(this.cipher);
this.messagingService.send('restoredCipher');
@ -418,7 +415,6 @@ export class AddEditComponent implements OnInit {
}
togglePassword() {
this.platformUtilsService.eventTrack('Toggled Password on Edit');
this.showPassword = !this.showPassword;
document.getElementById('loginPassword').focus();
if (this.editMode && this.showPassword) {
@ -427,7 +423,6 @@ export class AddEditComponent implements OnInit {
}
toggleCardCode() {
this.platformUtilsService.eventTrack('Toggled CardCode on Edit');
this.showCardCode = !this.showCardCode;
document.getElementById('cardCode').focus();
if (this.editMode && this.showCardCode) {
@ -481,7 +476,6 @@ export class AddEditComponent implements OnInit {
return;
}
this.platformUtilsService.eventTrack('Check Password');
this.checkPasswordPromise = this.auditService.passwordLeaked(this.cipher.login.password);
const matches = await this.checkPasswordPromise;
this.checkPasswordPromise = null;

View File

@ -69,7 +69,6 @@ export class AttachmentsComponent implements OnInit {
this.formPromise = this.saveCipherAttachment(files[0]);
this.cipherDomain = await this.formPromise;
this.cipher = await this.cipherDomain.decrypt();
this.platformUtilsService.eventTrack('Added Attachment');
this.platformUtilsService.showToast('success', null, this.i18nService.t('attachmentSaved'));
this.onUploadedAttachment.emit();
} catch { }
@ -96,7 +95,6 @@ export class AttachmentsComponent implements OnInit {
try {
this.deletePromises[attachment.id] = this.deleteCipherAttachment(attachment.id);
await this.deletePromises[attachment.id];
this.platformUtilsService.eventTrack('Deleted Attachment');
this.platformUtilsService.showToast('success', null, this.i18nService.t('deletedAttachment'));
const i = this.cipher.attachments.indexOf(attachment);
if (i > -1) {
@ -219,7 +217,6 @@ export class AttachmentsComponent implements OnInit {
}
}
this.platformUtilsService.eventTrack('Reuploaded Attachment');
this.platformUtilsService.showToast('success', null, this.i18nService.t('attachmentSaved'));
this.onReuploadedAttachment.emit();
} catch (e) {

View File

@ -64,7 +64,6 @@ export class CollectionsComponent implements OnInit {
this.formPromise = this.saveCollections();
await this.formPromise;
this.onSavedCollections.emit();
this.platformUtilsService.eventTrack('Edited Cipher Collections');
this.platformUtilsService.showToast('success', null, this.i18nService.t('editedItem'));
} catch { }
}

View File

@ -52,7 +52,6 @@ export class EnvironmentComponent {
this.notificationsUrl = resUrls.notifications;
this.enterpriseUrl = resUrls.enterprise;
this.platformUtilsService.eventTrack('Set Environment URLs');
this.platformUtilsService.showToast('success', null, this.i18nService.t('environmentSaved'));
this.saved();
}

View File

@ -46,7 +46,6 @@ export class ExportComponent {
try {
this.formPromise = this.getExportData();
const data = await this.formPromise;
this.platformUtilsService.eventTrack('Exported Data');
this.downloadFile(data);
this.saved();
await this.collectEvent();
@ -74,7 +73,6 @@ export class ExportComponent {
}
togglePassword() {
this.platformUtilsService.eventTrack('Toggled Master Password on Export');
this.showPassword = !this.showPassword;
document.getElementById('masterPassword').focus();
}

View File

@ -42,7 +42,6 @@ export class FolderAddEditComponent implements OnInit {
const folder = await this.folderService.encrypt(this.folder);
this.formPromise = this.folderService.saveWithServer(folder);
await this.formPromise;
this.platformUtilsService.eventTrack(this.editMode ? 'Edited Folder' : 'Added Folder');
this.platformUtilsService.showToast('success', null,
this.i18nService.t(this.editMode ? 'editedFolder' : 'addedFolder'));
this.onSavedFolder.emit(this.folder);
@ -63,7 +62,6 @@ export class FolderAddEditComponent implements OnInit {
try {
this.deletePromise = this.folderService.deleteWithServer(this.folder.id);
await this.deletePromise;
this.platformUtilsService.eventTrack('Deleted Folder');
this.platformUtilsService.showToast('success', null, this.i18nService.t('deletedFolder'));
this.onDeletedFolder.emit(this.folder);
} catch { }

View File

@ -31,7 +31,6 @@ export class HintComponent {
try {
this.formPromise = this.apiService.postPasswordHint(new PasswordHintRequest(this.email));
await this.formPromise;
this.platformUtilsService.eventTrack('Requested Hint');
this.platformUtilsService.showToast('success', null, this.i18nService.t('masterPassSent'));
if (this.onSuccessfulSubmit != null) {
this.onSuccessfulSubmit();

View File

@ -164,7 +164,6 @@ export class LockComponent implements OnInit {
}
togglePassword() {
this.platformUtilsService.eventTrack('Toggled Master Password on Unlock');
this.showPassword = !this.showPassword;
document.getElementById(this.pinLock ? 'pin' : 'masterPassword').focus();
}

View File

@ -90,7 +90,6 @@ export class LoginComponent implements OnInit {
await this.storageService.remove(Keys.rememberedEmail);
}
if (response.twoFactor) {
this.platformUtilsService.eventTrack('Logged In To Two-step');
if (this.onSuccessfulLoginTwoFactorNavigate != null) {
this.onSuccessfulLoginTwoFactorNavigate();
} else {
@ -102,7 +101,6 @@ export class LoginComponent implements OnInit {
if (this.onSuccessfulLogin != null) {
this.onSuccessfulLogin();
}
this.platformUtilsService.eventTrack('Logged In');
if (this.onSuccessfulLoginNavigate != null) {
this.onSuccessfulLoginNavigate();
} else {
@ -113,7 +111,6 @@ export class LoginComponent implements OnInit {
}
togglePassword() {
this.platformUtilsService.eventTrack('Toggled Master Password on Login');
this.showPassword = !this.showPassword;
document.getElementById('masterPassword').focus();
}

View File

@ -23,7 +23,6 @@ export class PasswordGeneratorHistoryComponent implements OnInit {
}
copy(password: string) {
this.platformUtilsService.eventTrack('Copied Historical Password');
const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(password, copyOptions);
this.platformUtilsService.showToast('info', null,

View File

@ -34,14 +34,12 @@ export class PasswordGeneratorComponent implements OnInit {
this.avoidAmbiguous = !this.options.ambiguous;
this.options.type = this.options.type === 'passphrase' ? 'passphrase' : 'password';
this.password = await this.passwordGenerationService.generatePassword(this.options);
this.platformUtilsService.eventTrack('Generated Password');
await this.passwordGenerationService.addHistory(this.password);
}
async sliderChanged() {
this.saveOptions(false);
await this.passwordGenerationService.addHistory(this.password);
this.platformUtilsService.eventTrack('Regenerated Password');
}
async sliderInput() {
@ -61,11 +59,9 @@ export class PasswordGeneratorComponent implements OnInit {
async regenerate() {
this.password = await this.passwordGenerationService.generatePassword(this.options);
await this.passwordGenerationService.addHistory(this.password);
this.platformUtilsService.eventTrack('Regenerated Password');
}
copy() {
this.platformUtilsService.eventTrack('Copied Generated Password');
const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(this.password, copyOptions);
this.platformUtilsService.showToast('info', null,
@ -73,7 +69,6 @@ export class PasswordGeneratorComponent implements OnInit {
}
select() {
this.platformUtilsService.eventTrack('Selected Generated Password');
this.onSelected.emit(this.password);
}

View File

@ -18,7 +18,6 @@ export class PasswordHistoryComponent implements OnInit {
}
copy(password: string) {
this.platformUtilsService.eventTrack('Copied Password History');
const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(password, copyOptions);
this.platformUtilsService.showToast('info', null,

View File

@ -31,7 +31,6 @@ export class PremiumComponent implements OnInit {
const confirmed = await this.platformUtilsService.showDialog(this.i18nService.t('premiumPurchaseAlert'),
this.i18nService.t('premiumPurchase'), this.i18nService.t('yes'), this.i18nService.t('cancel'));
if (confirmed) {
this.platformUtilsService.eventTrack('Clicked Purchase Premium');
this.platformUtilsService.launchUri('https://vault.bitwarden.com/#/?premium=purchase');
}
}
@ -40,7 +39,6 @@ export class PremiumComponent implements OnInit {
const confirmed = await this.platformUtilsService.showDialog(this.i18nService.t('premiumManageAlert'),
this.i18nService.t('premiumManage'), this.i18nService.t('yes'), this.i18nService.t('cancel'));
if (confirmed) {
this.platformUtilsService.eventTrack('Clicked Manage Membership');
this.platformUtilsService.launchUri('https://vault.bitwarden.com/#/?premium=manage');
}
}

View File

@ -138,14 +138,12 @@ export class RegisterComponent {
try {
this.formPromise = this.apiService.postRegister(request);
await this.formPromise;
this.platformUtilsService.eventTrack('Registered');
this.platformUtilsService.showToast('success', null, this.i18nService.t('newAccountCreated'));
this.router.navigate([this.successRoute], { queryParams: { email: this.email } });
} catch { }
}
togglePassword(confirmField: boolean) {
this.platformUtilsService.eventTrack('Toggled Master Password on Register');
this.showPassword = !this.showPassword;
document.getElementById(confirmField ? 'masterPasswordRetype' : 'masterPassword').focus();
}

View File

@ -99,7 +99,6 @@ export class SetPasswordComponent extends BaseChangePasswordComponent {
}
togglePassword(confirmField: boolean) {
this.platformUtilsService.eventTrack('Toggled Master Password on Set Password');
this.showPassword = !this.showPassword;
document.getElementById(confirmField ? 'masterPasswordRetype' : 'masterPassword').focus();
}

View File

@ -82,7 +82,6 @@ export class ShareComponent implements OnInit {
this.formPromise = this.cipherService.shareWithServer(cipherView, this.organizationId,
selectedCollectionIds).then(async () => {
this.onSharedCipher.emit();
this.platformUtilsService.eventTrack('Shared Cipher');
this.platformUtilsService.showToast('success', null, this.i18nService.t('sharedItem'));
});
await this.formPromise;

View File

@ -138,7 +138,6 @@ export class SsoComponent {
this.formPromise = this.authService.logInSso(code, codeVerifier, this.redirectUri);
const response = await this.formPromise;
if (response.twoFactor) {
this.platformUtilsService.eventTrack('SSO Logged In To Two-step');
if (this.onSuccessfulLoginTwoFactorNavigate != null) {
this.onSuccessfulLoginTwoFactorNavigate();
} else {
@ -150,7 +149,6 @@ export class SsoComponent {
});
}
} else if (response.resetMasterPassword) {
this.platformUtilsService.eventTrack('SSO - routing to complete registration');
if (this.onSuccessfulLoginChangePasswordNavigate != null) {
this.onSuccessfulLoginChangePasswordNavigate();
} else {
@ -166,7 +164,6 @@ export class SsoComponent {
if (this.onSuccessfulLogin != null) {
this.onSuccessfulLogin();
}
this.platformUtilsService.eventTrack('SSO Logged In');
if (this.onSuccessfulLoginNavigate != null) {
this.onSuccessfulLoginNavigate();
} else {

View File

@ -32,7 +32,6 @@ export class TwoFactorOptionsComponent implements OnInit {
}
recover() {
this.platformUtilsService.eventTrack('Selected Recover');
this.platformUtilsService.launchUri('https://help.bitwarden.com/article/lost-two-step-device/');
this.onRecoverSelected.emit();
}

View File

@ -187,7 +187,6 @@ export class TwoFactorComponent implements OnInit, OnDestroy {
if (this.onSuccessfulLogin != null) {
this.onSuccessfulLogin();
}
this.platformUtilsService.eventTrack('Logged In From Two-step');
if (response.resetMasterPassword) {
this.successRoute = 'set-password';
}

View File

@ -129,7 +129,6 @@ export class ViewComponent implements OnDestroy, OnInit {
try {
await this.deleteCipher();
this.platformUtilsService.eventTrack((this.cipher.isDeleted ? 'Permanently ' : '') + 'Deleted Cipher');
this.platformUtilsService.showToast('success', null,
this.i18nService.t(this.cipher.isDeleted ? 'permanentlyDeletedItem' : 'deletedItem'));
this.onDeletedCipher.emit(this.cipher);
@ -152,7 +151,6 @@ export class ViewComponent implements OnDestroy, OnInit {
try {
await this.restoreCipher();
this.platformUtilsService.eventTrack('Restored Cipher');
this.platformUtilsService.showToast('success', null, this.i18nService.t('restoredItem'));
this.onRestoredCipher.emit(this.cipher);
} catch { }
@ -161,7 +159,6 @@ export class ViewComponent implements OnDestroy, OnInit {
}
togglePassword() {
this.platformUtilsService.eventTrack('Toggled Password');
this.showPassword = !this.showPassword;
if (this.showPassword) {
this.eventService.collect(EventType.Cipher_ClientToggledPasswordVisible, this.cipherId);
@ -169,7 +166,6 @@ export class ViewComponent implements OnDestroy, OnInit {
}
toggleCardCode() {
this.platformUtilsService.eventTrack('Toggled Card Code');
this.showCardCode = !this.showCardCode;
if (this.showCardCode) {
this.eventService.collect(EventType.Cipher_ClientToggledCardCodeVisible, this.cipherId);
@ -181,7 +177,6 @@ export class ViewComponent implements OnDestroy, OnInit {
return;
}
this.platformUtilsService.eventTrack('Check Password');
this.checkPasswordPromise = this.auditService.passwordLeaked(this.cipher.login.password);
const matches = await this.checkPasswordPromise;
@ -210,7 +205,6 @@ export class ViewComponent implements OnDestroy, OnInit {
this.cipherService.updateLastLaunchedDate(cipherId);
}
this.platformUtilsService.eventTrack('Launched Login URI');
this.platformUtilsService.launchUri(uri.launchUri);
}
@ -219,7 +213,6 @@ export class ViewComponent implements OnDestroy, OnInit {
return;
}
this.platformUtilsService.eventTrack('Copied ' + aType);
const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(value, copyOptions);
this.platformUtilsService.showToast('info', null,

View File

@ -72,10 +72,6 @@ export class CliPlatformUtilsService implements PlatformUtilsService {
return false;
}
analyticsId() {
return null as string;
}
isViewOpen() {
return Promise.resolve(false);
}
@ -118,10 +114,6 @@ export class CliPlatformUtilsService implements PlatformUtilsService {
throw new Error('Not implemented.');
}
eventTrack(action: string, label?: string, options?: any) {
throw new Error('Not implemented.');
}
isDev(): boolean {
return process.env.BWCLI_ENV === 'development';
}

View File

@ -16,14 +16,12 @@ import { MessagingService } from '../../abstractions/messaging.service';
import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
import { StorageService } from '../../abstractions/storage.service';
import { AnalyticsIds } from '../../misc/analytics';
import { ElectronConstants } from '../electronConstants';
export class ElectronPlatformUtilsService implements PlatformUtilsService {
identityClientId: string;
private deviceCache: DeviceType = null;
private analyticsIdCache: string = null;
constructor(private i18nService: I18nService, private messagingService: MessagingService,
private isDesktopApp: boolean, private storageService: StorageService) {
@ -86,19 +84,6 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
return isMacAppStore();
}
analyticsId(): string {
if (!this.isDesktopApp) {
return null;
}
if (this.analyticsIdCache) {
return this.analyticsIdCache;
}
this.analyticsIdCache = (AnalyticsIds as any)[this.getDevice()];
return this.analyticsIdCache;
}
isViewOpen(): Promise<boolean> {
return Promise.resolve(false);
}
@ -163,14 +148,6 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
return Promise.resolve(result.response === 0);
}
eventTrack(action: string, label?: string, options?: any) {
this.messagingService.send('analyticsEventTrack', {
action: action,
label: label,
options: options,
});
}
isDev(): boolean {
return isDev();
}

View File

@ -1,6 +1,5 @@
import * as Abstractions from './abstractions';
import * as Enums from './enums';
import * as Misc from './misc';
import * as Data from './models/data';
import * as Domain from './models/domain';
import * as Request from './models/request';
@ -8,4 +7,4 @@ import * as Response from './models/response';
import * as View from './models/view';
import * as Services from './services';
export { Abstractions, Enums, Data, Domain, Misc, Request, Response, Services, View };
export { Abstractions, Enums, Data, Domain, Request, Response, Services, View };

View File

@ -1,121 +0,0 @@
import { AppIdService } from '../abstractions/appId.service';
import { PlatformUtilsService } from '../abstractions/platformUtils.service';
import { StorageService } from '../abstractions/storage.service';
import { ConstantsService } from '../services/constants.service';
import { DeviceType } from '../enums/deviceType';
const GaObj = 'ga';
export const AnalyticsIds = {
[DeviceType.ChromeExtension]: 'UA-81915606-6',
[DeviceType.FirefoxExtension]: 'UA-81915606-7',
[DeviceType.OperaExtension]: 'UA-81915606-8',
[DeviceType.EdgeExtension]: 'UA-81915606-9',
[DeviceType.VivaldiExtension]: 'UA-81915606-15',
[DeviceType.SafariExtension]: 'UA-81915606-16',
[DeviceType.WindowsDesktop]: 'UA-81915606-17',
[DeviceType.LinuxDesktop]: 'UA-81915606-19',
[DeviceType.MacOsDesktop]: 'UA-81915606-18',
};
export class Analytics {
private gaTrackingId: string = null;
private defaultDisabled = false;
private appVersion: string;
constructor(win: Window, private gaFilter?: () => boolean,
private platformUtilsService?: PlatformUtilsService, private storageService?: StorageService,
private appIdService?: AppIdService, private dependencyResolver?: () => any) {
if (dependencyResolver != null) {
const deps = dependencyResolver();
if (platformUtilsService == null && deps.platformUtilsService) {
this.platformUtilsService = deps.platformUtilsService as PlatformUtilsService;
}
if (storageService == null && deps.storageService) {
this.storageService = deps.storageService as StorageService;
}
if (appIdService == null && deps.appIdService) {
this.appIdService = deps.appIdService as AppIdService;
}
}
this.platformUtilsService.getApplicationVersion().then(v => this.appVersion = v);
this.defaultDisabled = this.platformUtilsService.getDevice() === DeviceType.FirefoxExtension ||
this.platformUtilsService.isMacAppStore();
this.gaTrackingId = this.platformUtilsService.analyticsId();
(win as any).GoogleAnalyticsObject = GaObj;
(win as any)[GaObj] = async (action: string, param1: any, param2?: any) => {
await this.ga(action, param1, param2);
};
}
async ga(action: string, param1: any, param2?: any) {
return;
if (this.gaFilter != null && this.gaFilter()) {
return;
}
const disabled = await this.storageService.get<boolean>(ConstantsService.disableGaKey);
if ((this.defaultDisabled && disabled == null) || disabled != null && disabled) {
return;
}
if (action !== 'send' || !param1) {
return;
}
const gaAnonAppId = await this.appIdService.getAnonymousAppId();
const version = encodeURIComponent(this.appVersion);
let message = 'v=1&tid=' + this.gaTrackingId + '&cid=' + gaAnonAppId + '&cd1=' + version;
if (param1 === 'pageview' && param2) {
message += this.gaTrackPageView(param2);
} else if (typeof param1 === 'object' && param1.hitType === 'pageview') {
message += this.gaTrackPageView(param1.page);
} else if (param1 === 'event' && param2) {
message += this.gaTrackEvent(param2);
} else if (typeof param1 === 'object' && param1.hitType === 'event') {
message += this.gaTrackEvent(param1);
}
const request = new XMLHttpRequest();
request.open('POST', 'https://www.google-analytics.com/collect', true);
request.send(message);
}
private gaTrackEvent(options: any) {
return '&t=event&ec=' + (options.eventCategory ? encodeURIComponent(options.eventCategory) : 'Event') +
'&ea=' + encodeURIComponent(options.eventAction) +
(options.eventLabel ? '&el=' + encodeURIComponent(options.eventLabel) : '') +
(options.eventValue ? '&ev=' + encodeURIComponent(options.eventValue) : '') +
(options.page ? '&dp=' + this.cleanPagePath(options.page) : '');
}
private gaTrackPageView(pagePath: string) {
return '&t=pageview&dp=' + this.cleanPagePath(pagePath);
}
private cleanPagePath(pagePath: string) {
const paramIndex = pagePath.indexOf('?');
if (paramIndex > -1) {
pagePath = pagePath.substring(0, paramIndex);
}
if (pagePath.indexOf('!/') === 0 || pagePath.indexOf('#/') === 0) {
pagePath = pagePath.substring(1);
}
const pathParts = pagePath.split('/');
const newPathParts: string[] = [];
pathParts.forEach(p => {
if (p.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)) {
newPathParts.push('__guid__');
} else {
newPathParts.push(p);
}
});
return encodeURIComponent(newPathParts.join('/'));
}
}

View File

@ -1 +0,0 @@
export { Analytics } from './analytics';