1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

move eventTrack analytics to platform utils

This commit is contained in:
Kyle Spearrin
2018-10-03 00:03:49 -04:00
parent f793ff0aa5
commit ad31527b8d
20 changed files with 52 additions and 104 deletions

8
package-lock.json generated
View File

@@ -229,14 +229,6 @@
"integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=",
"dev": true "dev": true
}, },
"angulartics2": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/angulartics2/-/angulartics2-6.3.0.tgz",
"integrity": "sha512-5BwRYCLF6ypBl7rlarW403v4AdotIldJhN+2rQeTIw/rTtngJ4SewNhf4zlRnKBSItlhbZRrDJBl9uR2TUuCdw==",
"requires": {
"tslib": "^1.9.0"
}
},
"ansi-align": { "ansi-align": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-2.0.0.tgz", "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-2.0.0.tgz",

View File

@@ -69,7 +69,6 @@
"@angular/upgrade": "6.1.7", "@angular/upgrade": "6.1.7",
"@aspnet/signalr": "1.0.3", "@aspnet/signalr": "1.0.3",
"@aspnet/signalr-protocol-msgpack": "1.0.3", "@aspnet/signalr-protocol-msgpack": "1.0.3",
"angulartics2": "6.3.0",
"core-js": "2.5.7", "core-js": "2.5.7",
"electron-log": "2.2.14", "electron-log": "2.2.14",
"electron-updater": "3.0.3", "electron-updater": "3.0.3",

View File

@@ -25,6 +25,7 @@ export abstract class PlatformUtilsService {
options?: any) => void; options?: any) => void;
showDialog: (text: string, title?: string, confirmText?: string, cancelText?: string, showDialog: (text: string, title?: string, confirmText?: string, cancelText?: string,
type?: string) => Promise<boolean>; type?: string) => Promise<boolean>;
eventTrack: (action: string, label?: string, options?: any) => void;
isDev: () => boolean; isDev: () => boolean;
isSelfHost: () => boolean; isSelfHost: () => boolean;
copyToClipboard: (text: string, options?: any) => void; copyToClipboard: (text: string, options?: any) => void;

View File

@@ -4,8 +4,6 @@ import {
Output, Output,
} from '@angular/core'; } from '@angular/core';
import { Angulartics2 } from 'angulartics2';
import { CipherType } from '../../enums/cipherType'; import { CipherType } from '../../enums/cipherType';
import { FieldType } from '../../enums/fieldType'; import { FieldType } from '../../enums/fieldType';
import { SecureNoteType } from '../../enums/secureNoteType'; import { SecureNoteType } from '../../enums/secureNoteType';
@@ -60,7 +58,6 @@ export class AddEditComponent {
constructor(protected cipherService: CipherService, protected folderService: FolderService, constructor(protected cipherService: CipherService, protected folderService: FolderService,
protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
protected analytics: Angulartics2,
protected auditService: AuditService, protected stateService: StateService) { protected auditService: AuditService, protected stateService: StateService) {
this.typeOptions = [ this.typeOptions = [
{ name: i18nService.t('typeLogin'), value: CipherType.Login }, { name: i18nService.t('typeLogin'), value: CipherType.Login },
@@ -167,7 +164,7 @@ export class AddEditComponent {
this.formPromise = this.saveCipher(cipher); this.formPromise = this.saveCipher(cipher);
await this.formPromise; await this.formPromise;
this.cipher.id = cipher.id; this.cipher.id = cipher.id;
this.analytics.eventTrack.next({ action: this.editMode ? 'Edited Cipher' : 'Added Cipher' }); this.platformUtilsService.eventTrack(this.editMode ? 'Edited Cipher' : 'Added Cipher');
this.platformUtilsService.showToast('success', null, this.platformUtilsService.showToast('success', null,
this.i18nService.t(this.editMode ? 'editedItem' : 'addedItem')); this.i18nService.t(this.editMode ? 'editedItem' : 'addedItem'));
this.onSavedCipher.emit(this.cipher); this.onSavedCipher.emit(this.cipher);
@@ -236,7 +233,7 @@ export class AddEditComponent {
try { try {
this.deletePromise = this.deleteCipher(); this.deletePromise = this.deleteCipher();
await this.deletePromise; await this.deletePromise;
this.analytics.eventTrack.next({ action: 'Deleted Cipher' }); this.platformUtilsService.eventTrack('Deleted Cipher');
this.platformUtilsService.showToast('success', null, this.i18nService.t('deletedItem')); this.platformUtilsService.showToast('success', null, this.i18nService.t('deletedItem'));
this.onDeletedCipher.emit(this.cipher); this.onDeletedCipher.emit(this.cipher);
} catch { } } catch { }
@@ -259,13 +256,13 @@ export class AddEditComponent {
} }
togglePassword() { togglePassword() {
this.analytics.eventTrack.next({ action: 'Toggled Password on Edit' }); this.platformUtilsService.eventTrack('Toggled Password on Edit');
this.showPassword = !this.showPassword; this.showPassword = !this.showPassword;
document.getElementById('loginPassword').focus(); document.getElementById('loginPassword').focus();
} }
toggleCardCode() { toggleCardCode() {
this.analytics.eventTrack.next({ action: 'Toggled CardCode on Edit' }); this.platformUtilsService.eventTrack('Toggled CardCode on Edit');
this.showCardCode = !this.showCardCode; this.showCardCode = !this.showCardCode;
document.getElementById('cardCode').focus(); document.getElementById('cardCode').focus();
} }
@@ -294,7 +291,7 @@ export class AddEditComponent {
return; return;
} }
this.analytics.eventTrack.next({ action: 'Check Password' }); this.platformUtilsService.eventTrack('Check Password');
this.checkPasswordPromise = this.auditService.passwordLeaked(this.cipher.login.password); this.checkPasswordPromise = this.auditService.passwordLeaked(this.cipher.login.password);
const matches = await this.checkPasswordPromise; const matches = await this.checkPasswordPromise;
this.checkPasswordPromise = null; this.checkPasswordPromise = null;

View File

@@ -5,8 +5,6 @@ import {
Output, Output,
} from '@angular/core'; } from '@angular/core';
import { Angulartics2 } from 'angulartics2';
import { CipherService } from '../../abstractions/cipher.service'; import { CipherService } from '../../abstractions/cipher.service';
import { CryptoService } from '../../abstractions/crypto.service'; import { CryptoService } from '../../abstractions/crypto.service';
import { I18nService } from '../../abstractions/i18n.service'; import { I18nService } from '../../abstractions/i18n.service';
@@ -30,8 +28,7 @@ export class AttachmentsComponent implements OnInit {
formPromise: Promise<any>; formPromise: Promise<any>;
deletePromises: { [id: string]: Promise<any>; } = {}; deletePromises: { [id: string]: Promise<any>; } = {};
constructor(protected cipherService: CipherService, protected analytics: Angulartics2, constructor(protected cipherService: CipherService, protected i18nService: I18nService,
protected i18nService: I18nService,
protected cryptoService: CryptoService, protected userService: UserService, protected cryptoService: CryptoService, protected userService: UserService,
protected platformUtilsService: PlatformUtilsService, protected win: Window) { } protected platformUtilsService: PlatformUtilsService, protected win: Window) { }
@@ -85,7 +82,7 @@ export class AttachmentsComponent implements OnInit {
this.formPromise = this.saveCipherAttachment(files[0]); this.formPromise = this.saveCipherAttachment(files[0]);
this.cipherDomain = await this.formPromise; this.cipherDomain = await this.formPromise;
this.cipher = await this.cipherDomain.decrypt(); this.cipher = await this.cipherDomain.decrypt();
this.analytics.eventTrack.next({ action: 'Added Attachment' }); this.platformUtilsService.eventTrack('Added Attachment');
this.platformUtilsService.showToast('success', null, this.i18nService.t('attachmentSaved')); this.platformUtilsService.showToast('success', null, this.i18nService.t('attachmentSaved'));
this.onUploadedAttachment.emit(); this.onUploadedAttachment.emit();
} catch { } } catch { }
@@ -112,7 +109,7 @@ export class AttachmentsComponent implements OnInit {
try { try {
this.deletePromises[attachment.id] = this.deleteCipherAttachment(attachment.id); this.deletePromises[attachment.id] = this.deleteCipherAttachment(attachment.id);
await this.deletePromises[attachment.id]; await this.deletePromises[attachment.id];
this.analytics.eventTrack.next({ action: 'Deleted Attachment' }); this.platformUtilsService.eventTrack('Deleted Attachment');
this.platformUtilsService.showToast('success', null, this.i18nService.t('deletedAttachment')); this.platformUtilsService.showToast('success', null, this.i18nService.t('deletedAttachment'));
const i = this.cipher.attachments.indexOf(attachment); const i = this.cipher.attachments.indexOf(attachment);
if (i > -1) { if (i > -1) {

View File

@@ -3,8 +3,6 @@ import {
Output, Output,
} from '@angular/core'; } from '@angular/core';
import { Angulartics2 } from 'angulartics2';
import { EnvironmentService } from '../../abstractions/environment.service'; import { EnvironmentService } from '../../abstractions/environment.service';
import { I18nService } from '../../abstractions/i18n.service'; import { I18nService } from '../../abstractions/i18n.service';
import { PlatformUtilsService } from '../../abstractions/platformUtils.service'; import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
@@ -20,8 +18,8 @@ export class EnvironmentComponent {
baseUrl: string; baseUrl: string;
showCustom = false; showCustom = false;
constructor(protected analytics: Angulartics2, protected platformUtilsService: PlatformUtilsService, constructor(protected platformUtilsService: PlatformUtilsService, protected environmentService: EnvironmentService,
protected environmentService: EnvironmentService, protected i18nService: I18nService) { protected i18nService: I18nService) {
this.baseUrl = environmentService.baseUrl || ''; this.baseUrl = environmentService.baseUrl || '';
this.webVaultUrl = environmentService.webVaultUrl || ''; this.webVaultUrl = environmentService.webVaultUrl || '';
this.apiUrl = environmentService.apiUrl || ''; this.apiUrl = environmentService.apiUrl || '';
@@ -48,7 +46,7 @@ export class EnvironmentComponent {
this.iconsUrl = resUrls.icons; this.iconsUrl = resUrls.icons;
this.notificationsUrl = resUrls.notifications; this.notificationsUrl = resUrls.notifications;
this.analytics.eventTrack.next({ action: 'Set Environment URLs' }); this.platformUtilsService.eventTrack('Set Environment URLs');
this.platformUtilsService.showToast('success', null, this.i18nService.t('environmentSaved')); this.platformUtilsService.showToast('success', null, this.i18nService.t('environmentSaved'));
this.saved(); this.saved();
} }

View File

@@ -1,5 +1,3 @@
import { Angulartics2 } from 'angulartics2';
import { import {
EventEmitter, EventEmitter,
Output, Output,
@@ -17,8 +15,7 @@ export class ExportComponent {
masterPassword: string; masterPassword: string;
showPassword = false; showPassword = false;
constructor(protected analytics: Angulartics2, constructor(protected cryptoService: CryptoService, protected i18nService: I18nService,
protected cryptoService: CryptoService, protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService, protected exportService: ExportService, protected platformUtilsService: PlatformUtilsService, protected exportService: ExportService,
protected win: Window) { } protected win: Window) { }
@@ -35,7 +32,7 @@ export class ExportComponent {
try { try {
this.formPromise = this.getExportData(); this.formPromise = this.getExportData();
const data = await this.formPromise; const data = await this.formPromise;
this.analytics.eventTrack.next({ action: 'Exported Data' }); this.platformUtilsService.eventTrack('Exported Data');
this.downloadFile(data); this.downloadFile(data);
this.saved(); this.saved();
} catch { } } catch { }
@@ -46,7 +43,7 @@ export class ExportComponent {
} }
togglePassword() { togglePassword() {
this.analytics.eventTrack.next({ action: 'Toggled Master Password on Export' }); this.platformUtilsService.eventTrack('Toggled Master Password on Export');
this.showPassword = !this.showPassword; this.showPassword = !this.showPassword;
document.getElementById('masterPassword').focus(); document.getElementById('masterPassword').focus();
} }

View File

@@ -5,8 +5,6 @@ import {
Output, Output,
} from '@angular/core'; } from '@angular/core';
import { Angulartics2 } from 'angulartics2';
import { FolderService } from '../../abstractions/folder.service'; import { FolderService } from '../../abstractions/folder.service';
import { I18nService } from '../../abstractions/i18n.service'; import { I18nService } from '../../abstractions/i18n.service';
import { PlatformUtilsService } from '../../abstractions/platformUtils.service'; import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
@@ -25,7 +23,7 @@ export class FolderAddEditComponent implements OnInit {
deletePromise: Promise<any>; deletePromise: Promise<any>;
constructor(protected folderService: FolderService, protected i18nService: I18nService, constructor(protected folderService: FolderService, protected i18nService: I18nService,
protected analytics: Angulartics2, protected platformUtilsService: PlatformUtilsService) { } protected platformUtilsService: PlatformUtilsService) { }
async ngOnInit() { async ngOnInit() {
this.editMode = this.folderId != null; this.editMode = this.folderId != null;
@@ -51,7 +49,7 @@ export class FolderAddEditComponent implements OnInit {
const folder = await this.folderService.encrypt(this.folder); const folder = await this.folderService.encrypt(this.folder);
this.formPromise = this.folderService.saveWithServer(folder); this.formPromise = this.folderService.saveWithServer(folder);
await this.formPromise; await this.formPromise;
this.analytics.eventTrack.next({ action: this.editMode ? 'Edited Folder' : 'Added Folder' }); this.platformUtilsService.eventTrack(this.editMode ? 'Edited Folder' : 'Added Folder');
this.platformUtilsService.showToast('success', null, this.platformUtilsService.showToast('success', null,
this.i18nService.t(this.editMode ? 'editedFolder' : 'addedFolder')); this.i18nService.t(this.editMode ? 'editedFolder' : 'addedFolder'));
this.onSavedFolder.emit(this.folder); this.onSavedFolder.emit(this.folder);
@@ -72,7 +70,7 @@ export class FolderAddEditComponent implements OnInit {
try { try {
this.deletePromise = this.folderService.deleteWithServer(this.folder.id); this.deletePromise = this.folderService.deleteWithServer(this.folder.id);
await this.deletePromise; await this.deletePromise;
this.analytics.eventTrack.next({ action: 'Deleted Folder' }); this.platformUtilsService.eventTrack('Deleted Folder');
this.platformUtilsService.showToast('success', null, this.i18nService.t('deletedFolder')); this.platformUtilsService.showToast('success', null, this.i18nService.t('deletedFolder'));
this.onDeletedFolder.emit(this.folder); this.onDeletedFolder.emit(this.folder);
} catch { } } catch { }

View File

@@ -1,5 +1,4 @@
import { import {
Component,
EventEmitter, EventEmitter,
Input, Input,
Output, Output,

View File

@@ -1,7 +1,5 @@
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Angulartics2 } from 'angulartics2';
import { PasswordHintRequest } from '../../models/request/passwordHintRequest'; import { PasswordHintRequest } from '../../models/request/passwordHintRequest';
import { ApiService } from '../../abstractions/api.service'; import { ApiService } from '../../abstractions/api.service';
@@ -14,9 +12,8 @@ export class HintComponent {
protected successRoute = 'login'; protected successRoute = 'login';
constructor(protected router: Router, protected analytics: Angulartics2, constructor(protected router: Router, protected i18nService: I18nService,
protected i18nService: I18nService, protected apiService: ApiService, protected apiService: ApiService, protected platformUtilsService: PlatformUtilsService) { }
protected platformUtilsService: PlatformUtilsService) { }
async submit() { async submit() {
if (this.email == null || this.email === '') { if (this.email == null || this.email === '') {
@@ -33,7 +30,7 @@ export class HintComponent {
try { try {
this.formPromise = this.apiService.postPasswordHint(new PasswordHintRequest(this.email)); this.formPromise = this.apiService.postPasswordHint(new PasswordHintRequest(this.email));
await this.formPromise; await this.formPromise;
this.analytics.eventTrack.next({ action: 'Requested Hint' }); this.platformUtilsService.eventTrack('Requested Hint');
this.platformUtilsService.showToast('success', null, this.i18nService.t('masterPassSent')); this.platformUtilsService.showToast('success', null, this.i18nService.t('masterPassSent'));
this.router.navigate([this.successRoute]); this.router.navigate([this.successRoute]);
} catch { } } catch { }

View File

@@ -1,7 +1,5 @@
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Angulartics2 } from 'angulartics2';
import { CryptoService } from '../../abstractions/crypto.service'; import { CryptoService } from '../../abstractions/crypto.service';
import { I18nService } from '../../abstractions/i18n.service'; import { I18nService } from '../../abstractions/i18n.service';
import { MessagingService } from '../../abstractions/messaging.service'; import { MessagingService } from '../../abstractions/messaging.service';
@@ -14,8 +12,7 @@ export class LockComponent {
protected successRoute: string = 'vault'; protected successRoute: string = 'vault';
constructor(protected router: Router, protected analytics: Angulartics2, constructor(protected router: Router, protected i18nService: I18nService,
protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService, protected messagingService: MessagingService, protected platformUtilsService: PlatformUtilsService, protected messagingService: MessagingService,
protected userService: UserService, protected cryptoService: CryptoService) { } protected userService: UserService, protected cryptoService: CryptoService) { }
@@ -52,7 +49,7 @@ export class LockComponent {
} }
togglePassword() { togglePassword() {
this.analytics.eventTrack.next({ action: 'Toggled Master Password on Unlock' }); this.platformUtilsService.eventTrack('Toggled Master Password on Unlock');
this.showPassword = !this.showPassword; this.showPassword = !this.showPassword;
document.getElementById('masterPassword').focus(); document.getElementById('masterPassword').focus();
} }

View File

@@ -4,8 +4,6 @@ import {
} from '@angular/core'; } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Angulartics2 } from 'angulartics2';
import { AuthResult } from '../../models/domain/authResult'; import { AuthResult } from '../../models/domain/authResult';
import { AuthService } from '../../abstractions/auth.service'; import { AuthService } from '../../abstractions/auth.service';
@@ -34,8 +32,8 @@ export class LoginComponent implements OnInit {
protected successRoute = 'vault'; protected successRoute = 'vault';
constructor(protected authService: AuthService, protected router: Router, constructor(protected authService: AuthService, protected router: Router,
protected analytics: Angulartics2, protected platformUtilsService: PlatformUtilsService, protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService,
protected i18nService: I18nService, private storageService: StorageService) { } private storageService: StorageService) { }
async ngOnInit() { async ngOnInit() {
if (this.email == null || this.email === '') { if (this.email == null || this.email === '') {
@@ -80,13 +78,13 @@ export class LoginComponent implements OnInit {
await this.storageService.remove(Keys.rememberedEmail); await this.storageService.remove(Keys.rememberedEmail);
} }
if (response.twoFactor) { if (response.twoFactor) {
this.analytics.eventTrack.next({ action: 'Logged In To Two-step' }); this.platformUtilsService.eventTrack('Logged In To Two-step');
this.router.navigate([this.twoFactorRoute]); this.router.navigate([this.twoFactorRoute]);
} else { } else {
if (this.onSuccessfulLogin != null) { if (this.onSuccessfulLogin != null) {
this.onSuccessfulLogin(); this.onSuccessfulLogin();
} }
this.analytics.eventTrack.next({ action: 'Logged In' }); this.platformUtilsService.eventTrack('Logged In');
if (this.onSuccessfulLoginNavigate != null) { if (this.onSuccessfulLoginNavigate != null) {
this.onSuccessfulLoginNavigate(); this.onSuccessfulLoginNavigate();
} else { } else {
@@ -97,7 +95,7 @@ export class LoginComponent implements OnInit {
} }
togglePassword() { togglePassword() {
this.analytics.eventTrack.next({ action: 'Toggled Master Password on Login' }); this.platformUtilsService.eventTrack('Toggled Master Password on Login');
this.showPassword = !this.showPassword; this.showPassword = !this.showPassword;
document.getElementById('masterPassword').focus(); document.getElementById('masterPassword').focus();
} }

View File

@@ -1,5 +1,3 @@
import { Angulartics2 } from 'angulartics2';
import { OnInit } from '@angular/core'; import { OnInit } from '@angular/core';
import { I18nService } from '../../abstractions/i18n.service'; import { I18nService } from '../../abstractions/i18n.service';
@@ -11,7 +9,7 @@ import { GeneratedPasswordHistory } from '../../models/domain/generatedPasswordH
export class PasswordGeneratorHistoryComponent implements OnInit { export class PasswordGeneratorHistoryComponent implements OnInit {
history: GeneratedPasswordHistory[] = []; history: GeneratedPasswordHistory[] = [];
constructor(protected passwordGenerationService: PasswordGenerationService, protected analytics: Angulartics2, constructor(protected passwordGenerationService: PasswordGenerationService,
protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService,
private win: Window) { } private win: Window) { }
@@ -25,7 +23,7 @@ export class PasswordGeneratorHistoryComponent implements OnInit {
} }
copy(password: string) { copy(password: string) {
this.analytics.eventTrack.next({ action: 'Copied Historical Password' }); this.platformUtilsService.eventTrack('Copied Historical Password');
const copyOptions = this.win != null ? { window: this.win } : null; const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(password, copyOptions); this.platformUtilsService.copyToClipboard(password, copyOptions);
this.platformUtilsService.showToast('info', null, this.platformUtilsService.showToast('info', null,

View File

@@ -1,5 +1,3 @@
import { Angulartics2 } from 'angulartics2';
import { import {
EventEmitter, EventEmitter,
Input, Input,
@@ -20,7 +18,7 @@ export class PasswordGeneratorComponent implements OnInit {
showOptions = false; showOptions = false;
avoidAmbiguous = false; avoidAmbiguous = false;
constructor(protected passwordGenerationService: PasswordGenerationService, protected analytics: Angulartics2, constructor(protected passwordGenerationService: PasswordGenerationService,
protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService,
private win: Window) { } private win: Window) { }
@@ -28,14 +26,14 @@ export class PasswordGeneratorComponent implements OnInit {
this.options = await this.passwordGenerationService.getOptions(); this.options = await this.passwordGenerationService.getOptions();
this.avoidAmbiguous = !this.options.ambiguous; this.avoidAmbiguous = !this.options.ambiguous;
this.password = await this.passwordGenerationService.generatePassword(this.options); this.password = await this.passwordGenerationService.generatePassword(this.options);
this.analytics.eventTrack.next({ action: 'Generated Password' }); this.platformUtilsService.eventTrack('Generated Password');
await this.passwordGenerationService.addHistory(this.password); await this.passwordGenerationService.addHistory(this.password);
} }
async sliderChanged() { async sliderChanged() {
this.saveOptions(false); this.saveOptions(false);
await this.passwordGenerationService.addHistory(this.password); await this.passwordGenerationService.addHistory(this.password);
this.analytics.eventTrack.next({ action: 'Regenerated Password' }); this.platformUtilsService.eventTrack('Regenerated Password');
} }
async sliderInput() { async sliderInput() {
@@ -55,11 +53,11 @@ export class PasswordGeneratorComponent implements OnInit {
async regenerate() { async regenerate() {
this.password = await this.passwordGenerationService.generatePassword(this.options); this.password = await this.passwordGenerationService.generatePassword(this.options);
await this.passwordGenerationService.addHistory(this.password); await this.passwordGenerationService.addHistory(this.password);
this.analytics.eventTrack.next({ action: 'Regenerated Password' }); this.platformUtilsService.eventTrack('Regenerated Password');
} }
copy() { copy() {
this.analytics.eventTrack.next({ action: 'Copied Generated Password' }); this.platformUtilsService.eventTrack('Copied Generated Password');
const copyOptions = this.win != null ? { window: this.win } : null; const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(this.password, copyOptions); this.platformUtilsService.copyToClipboard(this.password, copyOptions);
this.platformUtilsService.showToast('info', null, this.platformUtilsService.showToast('info', null,
@@ -67,7 +65,7 @@ export class PasswordGeneratorComponent implements OnInit {
} }
select() { select() {
this.analytics.eventTrack.next({ action: 'Selected Generated Password' }); this.platformUtilsService.eventTrack('Selected Generated Password');
this.onSelected.emit(this.password); this.onSelected.emit(this.password);
} }

View File

@@ -1,5 +1,3 @@
import { Angulartics2 } from 'angulartics2';
import { OnInit } from '@angular/core'; import { OnInit } from '@angular/core';
import { CipherService } from '../../abstractions/cipher.service'; import { CipherService } from '../../abstractions/cipher.service';
@@ -12,9 +10,8 @@ export class PasswordHistoryComponent implements OnInit {
cipherId: string; cipherId: string;
history: PasswordHistoryView[] = []; history: PasswordHistoryView[] = [];
constructor(protected cipherService: CipherService, protected analytics: Angulartics2, constructor(protected cipherService: CipherService, protected platformUtilsService: PlatformUtilsService,
protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService, protected i18nService: I18nService, private win: Window) { }
private win: Window) { }
async ngOnInit() { async ngOnInit() {
const cipher = await this.cipherService.get(this.cipherId); const cipher = await this.cipherService.get(this.cipherId);
@@ -23,7 +20,7 @@ export class PasswordHistoryComponent implements OnInit {
} }
copy(password: string) { copy(password: string) {
this.analytics.eventTrack.next({ action: 'Copied Password History' }); this.platformUtilsService.eventTrack('Copied Password History');
const copyOptions = this.win != null ? { window: this.win } : null; const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(password, copyOptions); this.platformUtilsService.copyToClipboard(password, copyOptions);
this.platformUtilsService.showToast('info', null, this.platformUtilsService.showToast('info', null,

View File

@@ -1,7 +1,5 @@
import { OnInit } from '@angular/core'; import { OnInit } from '@angular/core';
import { Angulartics2 } from 'angulartics2';
import { ApiService } from '../../abstractions/api.service'; import { ApiService } from '../../abstractions/api.service';
import { I18nService } from '../../abstractions/i18n.service'; import { I18nService } from '../../abstractions/i18n.service';
import { PlatformUtilsService } from '../../abstractions/platformUtils.service'; import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
@@ -12,8 +10,7 @@ export class PremiumComponent implements OnInit {
price: number = 10; price: number = 10;
refreshPromise: Promise<any>; refreshPromise: Promise<any>;
constructor(protected analytics: Angulartics2, constructor(protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
protected tokenService: TokenService, protected apiService: ApiService) { } protected tokenService: TokenService, protected apiService: ApiService) { }
async ngOnInit() { async ngOnInit() {
@@ -33,7 +30,7 @@ export class PremiumComponent implements OnInit {
const confirmed = await this.platformUtilsService.showDialog(this.i18nService.t('premiumPurchaseAlert'), const confirmed = await this.platformUtilsService.showDialog(this.i18nService.t('premiumPurchaseAlert'),
this.i18nService.t('premiumPurchase'), this.i18nService.t('yes'), this.i18nService.t('cancel')); this.i18nService.t('premiumPurchase'), this.i18nService.t('yes'), this.i18nService.t('cancel'));
if (confirmed) { if (confirmed) {
this.analytics.eventTrack.next({ action: 'Clicked Purchase Premium' }); this.platformUtilsService.eventTrack('Clicked Purchase Premium');
this.platformUtilsService.launchUri('https://vault.bitwarden.com/#/?premium=purchase'); this.platformUtilsService.launchUri('https://vault.bitwarden.com/#/?premium=purchase');
} }
} }
@@ -42,7 +39,7 @@ export class PremiumComponent implements OnInit {
const confirmed = await this.platformUtilsService.showDialog(this.i18nService.t('premiumManageAlert'), const confirmed = await this.platformUtilsService.showDialog(this.i18nService.t('premiumManageAlert'),
this.i18nService.t('premiumManage'), this.i18nService.t('yes'), this.i18nService.t('cancel')); this.i18nService.t('premiumManage'), this.i18nService.t('yes'), this.i18nService.t('cancel'));
if (confirmed) { if (confirmed) {
this.analytics.eventTrack.next({ action: 'Clicked Manage Membership' }); this.platformUtilsService.eventTrack('Clicked Manage Membership');
this.platformUtilsService.launchUri('https://vault.bitwarden.com/#/?premium=manage'); this.platformUtilsService.launchUri('https://vault.bitwarden.com/#/?premium=manage');
} }
} }

View File

@@ -1,7 +1,5 @@
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Angulartics2 } from 'angulartics2';
import { KeysRequest } from '../../models/request/keysRequest'; import { KeysRequest } from '../../models/request/keysRequest';
import { RegisterRequest } from '../../models/request/registerRequest'; import { RegisterRequest } from '../../models/request/registerRequest';
@@ -26,7 +24,6 @@ export class RegisterComponent {
protected successRoute = 'login'; protected successRoute = 'login';
constructor(protected authService: AuthService, protected router: Router, constructor(protected authService: AuthService, protected router: Router,
protected analytics: Angulartics2,
protected i18nService: I18nService, protected cryptoService: CryptoService, protected i18nService: I18nService, protected cryptoService: CryptoService,
protected apiService: ApiService, protected stateService: StateService, protected apiService: ApiService, protected stateService: StateService,
protected platformUtilsService: PlatformUtilsService) { } protected platformUtilsService: PlatformUtilsService) { }
@@ -79,14 +76,14 @@ export class RegisterComponent {
try { try {
this.formPromise = this.apiService.postRegister(request); this.formPromise = this.apiService.postRegister(request);
await this.formPromise; await this.formPromise;
this.analytics.eventTrack.next({ action: 'Registered' }); this.platformUtilsService.eventTrack('Registered');
this.platformUtilsService.showToast('success', null, this.i18nService.t('newAccountCreated')); this.platformUtilsService.showToast('success', null, this.i18nService.t('newAccountCreated'));
this.router.navigate([this.successRoute], { queryParams: { email: this.email } }); this.router.navigate([this.successRoute], { queryParams: { email: this.email } });
} catch { } } catch { }
} }
togglePassword(confirmField: boolean) { togglePassword(confirmField: boolean) {
this.analytics.eventTrack.next({ action: 'Toggled Master Password on Register' }); this.platformUtilsService.eventTrack('Toggled Master Password on Register');
this.showPassword = !this.showPassword; this.showPassword = !this.showPassword;
document.getElementById(confirmField ? 'masterPasswordRetype' : 'masterPassword').focus(); document.getElementById(confirmField ? 'masterPasswordRetype' : 'masterPassword').focus();
} }

View File

@@ -6,8 +6,6 @@ import {
} from '@angular/core'; } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Angulartics2 } from 'angulartics2';
import { TwoFactorProviderType } from '../../enums/twoFactorProviderType'; import { TwoFactorProviderType } from '../../enums/twoFactorProviderType';
import { AuthService } from '../../abstractions/auth.service'; import { AuthService } from '../../abstractions/auth.service';
@@ -21,7 +19,6 @@ export class TwoFactorOptionsComponent implements OnInit {
providers: any[] = []; providers: any[] = [];
constructor(protected authService: AuthService, protected router: Router, constructor(protected authService: AuthService, protected router: Router,
protected analytics: Angulartics2,
protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
protected win: Window) { } protected win: Window) { }
@@ -34,7 +31,7 @@ export class TwoFactorOptionsComponent implements OnInit {
} }
recover() { recover() {
this.analytics.eventTrack.next({ action: 'Selected Recover' }); this.platformUtilsService.eventTrack('Selected Recover');
this.platformUtilsService.launchUri('https://help.bitwarden.com/article/lost-two-step-device/'); this.platformUtilsService.launchUri('https://help.bitwarden.com/article/lost-two-step-device/');
this.onRecoverSelected.emit(); this.onRecoverSelected.emit();
} }

View File

@@ -4,8 +4,6 @@ import {
} from '@angular/core'; } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Angulartics2 } from 'angulartics2';
import { DeviceType } from '../../enums/deviceType'; import { DeviceType } from '../../enums/deviceType';
import { TwoFactorProviderType } from '../../enums/twoFactorProviderType'; import { TwoFactorProviderType } from '../../enums/twoFactorProviderType';
@@ -42,7 +40,6 @@ export class TwoFactorComponent implements OnInit, OnDestroy {
protected successRoute = 'vault'; protected successRoute = 'vault';
constructor(protected authService: AuthService, protected router: Router, constructor(protected authService: AuthService, protected router: Router,
protected analytics: Angulartics2,
protected i18nService: I18nService, protected apiService: ApiService, protected i18nService: I18nService, protected apiService: ApiService,
protected platformUtilsService: PlatformUtilsService, protected win: Window, protected platformUtilsService: PlatformUtilsService, protected win: Window,
protected environmentService: EnvironmentService) { protected environmentService: EnvironmentService) {
@@ -168,7 +165,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy {
if (this.onSuccessfulLogin != null) { if (this.onSuccessfulLogin != null) {
this.onSuccessfulLogin(); this.onSuccessfulLogin();
} }
this.analytics.eventTrack.next({ action: 'Logged In From Two-step' }); this.platformUtilsService.eventTrack('Logged In From Two-step');
if (this.onSuccessfulLoginNavigate != null) { if (this.onSuccessfulLoginNavigate != null) {
this.onSuccessfulLoginNavigate(); this.onSuccessfulLoginNavigate();
} else { } else {

View File

@@ -8,8 +8,6 @@ import {
Output, Output,
} from '@angular/core'; } from '@angular/core';
import { Angulartics2 } from 'angulartics2';
import { CipherType } from '../../enums/cipherType'; import { CipherType } from '../../enums/cipherType';
import { FieldType } from '../../enums/fieldType'; import { FieldType } from '../../enums/fieldType';
@@ -49,9 +47,8 @@ export class ViewComponent implements OnDestroy, OnInit {
private totpInterval: any; private totpInterval: any;
constructor(protected cipherService: CipherService, protected totpService: TotpService, constructor(protected cipherService: CipherService, protected totpService: TotpService,
protected tokenService: TokenService, protected tokenService: TokenService, protected i18nService: I18nService,
protected cryptoService: CryptoService, protected platformUtilsService: PlatformUtilsService, protected cryptoService: CryptoService, protected platformUtilsService: PlatformUtilsService,
protected i18nService: I18nService, protected analytics: Angulartics2,
protected auditService: AuditService, protected win: Window, protected auditService: AuditService, protected win: Window,
protected broadcasterService: BroadcasterService, protected ngZone: NgZone, protected broadcasterService: BroadcasterService, protected ngZone: NgZone,
protected changeDetectorRef: ChangeDetectorRef, protected userService: UserService) { } protected changeDetectorRef: ChangeDetectorRef, protected userService: UserService) { }
@@ -100,12 +97,12 @@ export class ViewComponent implements OnDestroy, OnInit {
} }
togglePassword() { togglePassword() {
this.analytics.eventTrack.next({ action: 'Toggled Password' }); this.platformUtilsService.eventTrack('Toggled Password');
this.showPassword = !this.showPassword; this.showPassword = !this.showPassword;
} }
toggleCardCode() { toggleCardCode() {
this.analytics.eventTrack.next({ action: 'Toggled Card Code' }); this.platformUtilsService.eventTrack('Toggled Card Code');
this.showCardCode = !this.showCardCode; this.showCardCode = !this.showCardCode;
} }
@@ -114,7 +111,7 @@ export class ViewComponent implements OnDestroy, OnInit {
return; return;
} }
this.analytics.eventTrack.next({ action: 'Check Password' }); this.platformUtilsService.eventTrack('Check Password');
this.checkPasswordPromise = this.auditService.passwordLeaked(this.cipher.login.password); this.checkPasswordPromise = this.auditService.passwordLeaked(this.cipher.login.password);
const matches = await this.checkPasswordPromise; const matches = await this.checkPasswordPromise;
@@ -136,7 +133,7 @@ export class ViewComponent implements OnDestroy, OnInit {
return; return;
} }
this.analytics.eventTrack.next({ action: 'Launched Login URI' }); this.platformUtilsService.eventTrack('Launched Login URI');
this.platformUtilsService.launchUri(uri.uri); this.platformUtilsService.launchUri(uri.uri);
} }
@@ -145,7 +142,7 @@ export class ViewComponent implements OnDestroy, OnInit {
return; return;
} }
this.analytics.eventTrack.next({ action: 'Copied ' + aType }); this.platformUtilsService.eventTrack('Copied ' + aType);
const copyOptions = this.win != null ? { window: this.win } : null; const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(value, copyOptions); this.platformUtilsService.copyToClipboard(value, copyOptions);
this.platformUtilsService.showToast('info', null, this.platformUtilsService.showToast('info', null,