From 2ca8ac573b9276a824170b81c9328781c8da8537 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 3 Oct 2018 09:42:11 -0400 Subject: [PATCH] move toaster and analytics to platform utils --- jslib | 2 +- src/app/accounts/environment.component.ts | 10 ++-- src/app/accounts/hint.component.ts | 11 ++-- src/app/accounts/lock.component.ts | 9 +--- src/app/accounts/login.component.ts | 12 ++--- src/app/accounts/premium.component.ts | 8 +-- src/app/accounts/register.component.ts | 7 +-- src/app/accounts/settings.component.ts | 2 +- .../accounts/two-factor-options.component.ts | 6 +-- src/app/accounts/two-factor.component.ts | 9 +--- src/app/app.component.ts | 54 ++++++++++++++++--- src/app/services.module.ts | 2 +- src/app/vault/add-edit.component.ts | 7 +-- src/app/vault/attachments.component.ts | 9 +--- src/app/vault/export.component.ts | 9 +--- src/app/vault/folder-add-edit.component.ts | 6 +-- .../password-generator-history.component.ts | 10 ++-- src/app/vault/password-generator.component.ts | 14 ++--- src/app/vault/password-history.component.ts | 10 ++-- src/app/vault/view.component.ts | 12 ++--- 20 files changed, 91 insertions(+), 118 deletions(-) diff --git a/jslib b/jslib index 45341ec408..6b3dc2344f 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 45341ec408319cbf69a4772e503a3991ae770a49 +Subproject commit 6b3dc2344f2db167cbc404d83fa4602a1ca93ef8 diff --git a/src/app/accounts/environment.component.ts b/src/app/accounts/environment.component.ts index 0bf262497f..c1fee19454 100644 --- a/src/app/accounts/environment.component.ts +++ b/src/app/accounts/environment.component.ts @@ -1,10 +1,8 @@ import { Component } from '@angular/core'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { EnvironmentService } from 'jslib/abstractions/environment.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { EnvironmentComponent as BaseEnvironmentComponent } from 'jslib/angular/components/environment.component'; @@ -13,8 +11,8 @@ import { EnvironmentComponent as BaseEnvironmentComponent } from 'jslib/angular/ templateUrl: 'environment.component.html', }) export class EnvironmentComponent extends BaseEnvironmentComponent { - constructor(analytics: Angulartics2, toasterService: ToasterService, - environmentService: EnvironmentService, i18nService: I18nService) { - super(analytics, toasterService, environmentService, i18nService); + constructor(platformUtilsService: PlatformUtilsService, environmentService: EnvironmentService, + i18nService: I18nService) { + super(platformUtilsService, environmentService, i18nService); } } diff --git a/src/app/accounts/hint.component.ts b/src/app/accounts/hint.component.ts index bb84ff02f9..f9c89ed6e8 100644 --- a/src/app/accounts/hint.component.ts +++ b/src/app/accounts/hint.component.ts @@ -1,11 +1,9 @@ import { Component } from '@angular/core'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { ApiService } from 'jslib/abstractions/api.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { HintComponent as BaseHintComponent } from 'jslib/angular/components/hint.component'; @@ -14,9 +12,8 @@ import { HintComponent as BaseHintComponent } from 'jslib/angular/components/hin templateUrl: 'hint.component.html', }) export class HintComponent extends BaseHintComponent { - constructor(router: Router, analytics: Angulartics2, - toasterService: ToasterService, i18nService: I18nService, - apiService: ApiService) { - super(router, analytics, toasterService, i18nService, apiService); + constructor(router: Router, platformUtilsService: PlatformUtilsService, + i18nService: I18nService, apiService: ApiService) { + super(router, i18nService, apiService, platformUtilsService); } } diff --git a/src/app/accounts/lock.component.ts b/src/app/accounts/lock.component.ts index 39fced9b16..c82f1e632b 100644 --- a/src/app/accounts/lock.component.ts +++ b/src/app/accounts/lock.component.ts @@ -1,9 +1,6 @@ import { Component } from '@angular/core'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { CryptoService } from 'jslib/abstractions/crypto.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; import { MessagingService } from 'jslib/abstractions/messaging.service'; @@ -17,11 +14,9 @@ import { LockComponent as BaseLockComponent } from 'jslib/angular/components/loc templateUrl: 'lock.component.html', }) export class LockComponent extends BaseLockComponent { - constructor(router: Router, analytics: Angulartics2, - toasterService: ToasterService, i18nService: I18nService, + constructor(router: Router, i18nService: I18nService, platformUtilsService: PlatformUtilsService, messagingService: MessagingService, userService: UserService, cryptoService: CryptoService) { - super(router, analytics, toasterService, i18nService, platformUtilsService, - messagingService, userService, cryptoService); + super(router, i18nService, platformUtilsService, messagingService, userService, cryptoService); } } diff --git a/src/app/accounts/login.component.ts b/src/app/accounts/login.component.ts index ad534198f1..4ccdff9aee 100644 --- a/src/app/accounts/login.component.ts +++ b/src/app/accounts/login.component.ts @@ -6,13 +6,11 @@ import { } from '@angular/core'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { EnvironmentComponent } from './environment.component'; import { AuthService } from 'jslib/abstractions/auth.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { StorageService } from 'jslib/abstractions/storage.service'; import { SyncService } from 'jslib/abstractions/sync.service'; @@ -27,10 +25,10 @@ export class LoginComponent extends BaseLoginComponent { @ViewChild('environment', { read: ViewContainerRef }) environmentModal: ViewContainerRef; constructor(authService: AuthService, router: Router, - analytics: Angulartics2, toasterService: ToasterService, - i18nService: I18nService, private syncService: SyncService, - private componentFactoryResolver: ComponentFactoryResolver, storageService: StorageService) { - super(authService, router, analytics, toasterService, i18nService, storageService); + i18nService: I18nService, syncService: SyncService, + private componentFactoryResolver: ComponentFactoryResolver, storageService: StorageService, + platformUtilsService: PlatformUtilsService) { + super(authService, router, platformUtilsService, i18nService, storageService); super.onSuccessfulLogin = () => { return syncService.fullSync(true); }; diff --git a/src/app/accounts/premium.component.ts b/src/app/accounts/premium.component.ts index b7c1fb143b..e8c515714c 100644 --- a/src/app/accounts/premium.component.ts +++ b/src/app/accounts/premium.component.ts @@ -1,8 +1,5 @@ import { Component } from '@angular/core'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { ApiService } from 'jslib/abstractions/api.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; @@ -15,9 +12,8 @@ import { PremiumComponent as BasePremiumComponent } from 'jslib/angular/componen templateUrl: 'premium.component.html', }) export class PremiumComponent extends BasePremiumComponent { - constructor(analytics: Angulartics2, toasterService: ToasterService, - i18nService: I18nService, platformUtilsService: PlatformUtilsService, + constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService, tokenService: TokenService, apiService: ApiService) { - super(analytics, toasterService, i18nService, platformUtilsService, tokenService, apiService); + super(i18nService, platformUtilsService, tokenService, apiService); } } diff --git a/src/app/accounts/register.component.ts b/src/app/accounts/register.component.ts index c49cdb9254..5db5d6dae9 100644 --- a/src/app/accounts/register.component.ts +++ b/src/app/accounts/register.component.ts @@ -1,9 +1,6 @@ import { Component } from '@angular/core'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { ApiService } from 'jslib/abstractions/api.service'; import { AuthService } from 'jslib/abstractions/auth.service'; import { CryptoService } from 'jslib/abstractions/crypto.service'; @@ -19,11 +16,9 @@ import { RegisterComponent as BaseRegisterComponent } from 'jslib/angular/compon }) export class RegisterComponent extends BaseRegisterComponent { constructor(authService: AuthService, router: Router, - analytics: Angulartics2, toasterService: ToasterService, i18nService: I18nService, cryptoService: CryptoService, apiService: ApiService, stateService: StateService, platformUtilsService: PlatformUtilsService) { - super(authService, router, analytics, toasterService, i18nService, cryptoService, apiService, stateService, - platformUtilsService); + super(authService, router, i18nService, cryptoService, apiService, stateService, platformUtilsService); } } diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index 9aae95548a..64b90bdae1 100644 --- a/src/app/accounts/settings.component.ts +++ b/src/app/accounts/settings.component.ts @@ -39,7 +39,7 @@ export class SettingsComponent implements OnInit { themeOptions: any[]; constructor(private analytics: Angulartics2, private toasterService: ToasterService, - private i18nService: I18nService, private platformUtilsService: PlatformUtilsService, + i18nService: I18nService, private platformUtilsService: PlatformUtilsService, private storageService: StorageService, private lockService: LockService, private stateService: StateService, private messagingService: MessagingService) { this.lockOptions = [ diff --git a/src/app/accounts/two-factor-options.component.ts b/src/app/accounts/two-factor-options.component.ts index 6ab0be4faa..6db002adc2 100644 --- a/src/app/accounts/two-factor-options.component.ts +++ b/src/app/accounts/two-factor-options.component.ts @@ -1,9 +1,6 @@ import { Component } from '@angular/core'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { AuthService } from 'jslib/abstractions/auth.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; @@ -18,8 +15,7 @@ import { }) export class TwoFactorOptionsComponent extends BaseTwoFactorOptionsComponent { constructor(authService: AuthService, router: Router, - analytics: Angulartics2, toasterService: ToasterService, i18nService: I18nService, platformUtilsService: PlatformUtilsService) { - super(authService, router, analytics, toasterService, i18nService, platformUtilsService, window); + super(authService, router, i18nService, platformUtilsService, window); } } diff --git a/src/app/accounts/two-factor.component.ts b/src/app/accounts/two-factor.component.ts index 21b9981fa9..06aed82404 100644 --- a/src/app/accounts/two-factor.component.ts +++ b/src/app/accounts/two-factor.component.ts @@ -7,9 +7,6 @@ import { import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { TwoFactorOptionsComponent } from './two-factor-options.component'; import { TwoFactorProviderType } from 'jslib/enums/twoFactorProviderType'; @@ -32,12 +29,10 @@ export class TwoFactorComponent extends BaseTwoFactorComponent { @ViewChild('twoFactorOptions', { read: ViewContainerRef }) twoFactorOptionsModal: ViewContainerRef; constructor(authService: AuthService, router: Router, - analytics: Angulartics2, toasterService: ToasterService, i18nService: I18nService, apiService: ApiService, - platformUtilsService: PlatformUtilsService, private syncService: SyncService, + platformUtilsService: PlatformUtilsService, syncService: SyncService, environmentService: EnvironmentService, private componentFactoryResolver: ComponentFactoryResolver) { - super(authService, router, analytics, toasterService, i18nService, apiService, - platformUtilsService, window, environmentService); + super(authService, router, i18nService, apiService, platformUtilsService, window, environmentService); super.onSuccessfulLogin = () => { return syncService.fullSync(true); }; diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 0cf4d96fab..32ac6fe483 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,10 @@ -import { ToasterConfig } from 'angular2-toaster'; +import { + BodyOutputType, + Toast, + ToasterConfig, + ToasterContainerComponent, + ToasterService, +} from 'angular2-toaster'; import { Angulartics2GoogleAnalytics } from 'angulartics2/ga'; import { @@ -6,17 +12,18 @@ import { ComponentFactoryResolver, NgZone, OnInit, + SecurityContext, Type, ViewChild, ViewContainerRef, } from '@angular/core'; +import { DomSanitizer } from '@angular/platform-browser'; import { Router } from '@angular/router'; import { PremiumComponent } from './accounts/premium.component'; import { SettingsComponent } from './accounts/settings.component'; import { PasswordGeneratorHistoryComponent } from './vault/password-generator-history.component'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { ModalComponent } from 'jslib/angular/components/modal.component'; @@ -33,7 +40,6 @@ import { LockService } from 'jslib/abstractions/lock.service'; import { MessagingService } from 'jslib/abstractions/messaging.service'; import { NotificationsService } from 'jslib/abstractions/notifications.service'; import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service'; -import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { SearchService } from 'jslib/abstractions/search.service'; import { SettingsService } from 'jslib/abstractions/settings.service'; import { StorageService } from 'jslib/abstractions/storage.service'; @@ -80,13 +86,11 @@ export class AppComponent implements OnInit { private passwordGenerationService: PasswordGenerationService, private cipherService: CipherService, private authService: AuthService, private router: Router, private analytics: Angulartics2, private toasterService: ToasterService, private i18nService: I18nService, - private platformUtilsService: PlatformUtilsService, private ngZone: NgZone, + private sanitizer: DomSanitizer, private ngZone: NgZone, private lockService: LockService, private storageService: StorageService, private cryptoService: CryptoService, private componentFactoryResolver: ComponentFactoryResolver, private messagingService: MessagingService, private collectionService: CollectionService, - private searchService: SearchService, private notificationsService: NotificationsService) { - (window as any).BitwardenToasterService = toasterService; - } + private searchService: SearchService, private notificationsService: NotificationsService) { } ngOnInit() { this.ngZone.runOutsideAngular(() => { @@ -136,6 +140,15 @@ export class AppComponent implements OnInit { this.openModal( PasswordGeneratorHistoryComponent, this.passwordHistoryRef); break; + case 'showToast': + await this.showToast(message); + break; + case 'analyticsEventTrack': + this.analytics.eventTrack.next({ + action: message.action, + properties: { label: message.label }, + }); + break; default: } }); @@ -226,4 +239,31 @@ export class AppComponent implements OnInit { this.modal = null; }); } + + private async showToast(msg: any) { + const toast: Toast = { + type: msg.type, + title: msg.title, + }; + if (typeof (msg.text) === 'string') { + toast.body = msg.text; + } else if (msg.text.length === 1) { + toast.body = msg.text[0]; + } else { + let message = ''; + msg.text.forEach((t: string) => + message += ('

' + this.sanitizer.sanitize(SecurityContext.HTML, t) + '

')); + toast.body = message; + toast.bodyOutputType = BodyOutputType.TrustedHtml; + } + if (msg.options != null) { + if (msg.options.trustedHtml === true) { + toast.bodyOutputType = BodyOutputType.TrustedHtml; + } + if (msg.options.timeout != null && msg.options.timeout > 0) { + toast.timeout = msg.options.timeout; + } + } + this.toasterService.popAsync(toast); + } } diff --git a/src/app/services.module.ts b/src/app/services.module.ts index 604eaa2bfa..efe56a0f86 100644 --- a/src/app/services.module.ts +++ b/src/app/services.module.ts @@ -79,9 +79,9 @@ import { UserService as UserServiceAbstraction } from 'jslib/abstractions/user.s const logService = new ElectronLogService(); const i18nService = new I18nService(window.navigator.language, './locales'); const stateService = new StateService(); -const platformUtilsService = new ElectronPlatformUtilsService(i18nService, true); const broadcasterService = new BroadcasterService(); const messagingService = new ElectronRendererMessagingService(broadcasterService); +const platformUtilsService = new ElectronPlatformUtilsService(i18nService, messagingService, true); const storageService: StorageServiceAbstraction = new LowdbStorageService(null, remote.app.getPath('userData')); const secureStorageService: StorageServiceAbstraction = new ElectronRendererSecureStorageService(); const cryptoFunctionService: CryptoFunctionServiceAbstraction = new WebCryptoFunctionService(window, diff --git a/src/app/vault/add-edit.component.ts b/src/app/vault/add-edit.component.ts index 132f94d269..abac4518db 100644 --- a/src/app/vault/add-edit.component.ts +++ b/src/app/vault/add-edit.component.ts @@ -3,9 +3,6 @@ import { OnChanges, } from '@angular/core'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { AuditService } from 'jslib/abstractions/audit.service'; import { CipherService } from 'jslib/abstractions/cipher.service'; import { FolderService } from 'jslib/abstractions/folder.service'; @@ -22,10 +19,8 @@ import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/componen export class AddEditComponent extends BaseAddEditComponent implements OnChanges { constructor(cipherService: CipherService, folderService: FolderService, i18nService: I18nService, platformUtilsService: PlatformUtilsService, - analytics: Angulartics2, toasterService: ToasterService, auditService: AuditService, stateService: StateService) { - super(cipherService, folderService, i18nService, platformUtilsService, analytics, - toasterService, auditService, stateService); + super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService); } async ngOnChanges() { diff --git a/src/app/vault/attachments.component.ts b/src/app/vault/attachments.component.ts index 22e738046c..16dfdf8241 100644 --- a/src/app/vault/attachments.component.ts +++ b/src/app/vault/attachments.component.ts @@ -1,8 +1,5 @@ import { Component } from '@angular/core'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { CipherService } from 'jslib/abstractions/cipher.service'; import { CryptoService } from 'jslib/abstractions/crypto.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; @@ -16,11 +13,9 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from 'jslib/angular/ templateUrl: 'attachments.component.html', }) export class AttachmentsComponent extends BaseAttachmentsComponent { - constructor(cipherService: CipherService, analytics: Angulartics2, - toasterService: ToasterService, i18nService: I18nService, + constructor(cipherService: CipherService, i18nService: I18nService, cryptoService: CryptoService, userService: UserService, platformUtilsService: PlatformUtilsService) { - super(cipherService, analytics, toasterService, i18nService, cryptoService, userService, - platformUtilsService, window); + super(cipherService, i18nService, cryptoService, userService, platformUtilsService, window); } } diff --git a/src/app/vault/export.component.ts b/src/app/vault/export.component.ts index a8b1437cf6..b7aa9ea40c 100644 --- a/src/app/vault/export.component.ts +++ b/src/app/vault/export.component.ts @@ -1,6 +1,3 @@ -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { Component } from '@angular/core'; import { CryptoService } from 'jslib/abstractions/crypto.service'; @@ -15,10 +12,8 @@ import { ExportComponent as BaseExportComponent } from 'jslib/angular/components templateUrl: 'export.component.html', }) export class ExportComponent extends BaseExportComponent { - constructor(analytics: Angulartics2, toasterService: ToasterService, - cryptoService: CryptoService, i18nService: I18nService, + constructor(cryptoService: CryptoService, i18nService: I18nService, platformUtilsService: PlatformUtilsService, exportService: ExportService) { - super(analytics, toasterService, cryptoService, i18nService, platformUtilsService, - exportService, window); + super(cryptoService, i18nService, platformUtilsService, exportService, window); } } diff --git a/src/app/vault/folder-add-edit.component.ts b/src/app/vault/folder-add-edit.component.ts index 685a8d09c5..e811b58b08 100644 --- a/src/app/vault/folder-add-edit.component.ts +++ b/src/app/vault/folder-add-edit.component.ts @@ -1,8 +1,5 @@ import { Component } from '@angular/core'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { FolderService } from 'jslib/abstractions/folder.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; @@ -17,8 +14,7 @@ import { }) export class FolderAddEditComponent extends BaseFolderAddEditComponent { constructor(folderService: FolderService, i18nService: I18nService, - analytics: Angulartics2, toasterService: ToasterService, platformUtilsService: PlatformUtilsService) { - super(folderService, i18nService, analytics, toasterService, platformUtilsService); + super(folderService, i18nService, platformUtilsService); } } diff --git a/src/app/vault/password-generator-history.component.ts b/src/app/vault/password-generator-history.component.ts index e1d47a41f8..85732f2ba0 100644 --- a/src/app/vault/password-generator-history.component.ts +++ b/src/app/vault/password-generator-history.component.ts @@ -1,6 +1,3 @@ -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { Component } from '@angular/core'; import { I18nService } from 'jslib/abstractions/i18n.service'; @@ -16,9 +13,8 @@ import { templateUrl: 'password-generator-history.component.html', }) export class PasswordGeneratorHistoryComponent extends BasePasswordGeneratorHistoryComponent { - constructor(passwordGenerationService: PasswordGenerationService, analytics: Angulartics2, - platformUtilsService: PlatformUtilsService, i18nService: I18nService, - toasterService: ToasterService) { - super(passwordGenerationService, analytics, platformUtilsService, i18nService, toasterService, window); + constructor(passwordGenerationService: PasswordGenerationService, platformUtilsService: PlatformUtilsService, + i18nService: I18nService) { + super(passwordGenerationService, platformUtilsService, i18nService, window); } } diff --git a/src/app/vault/password-generator.component.ts b/src/app/vault/password-generator.component.ts index a48e011c0b..2899335535 100644 --- a/src/app/vault/password-generator.component.ts +++ b/src/app/vault/password-generator.component.ts @@ -1,9 +1,4 @@ -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - -import { - Component, -} from '@angular/core'; +import { Component } from '@angular/core'; import { I18nService } from 'jslib/abstractions/i18n.service'; import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service'; @@ -18,9 +13,8 @@ import { templateUrl: 'password-generator.component.html', }) export class PasswordGeneratorComponent extends BasePasswordGeneratorComponent { - constructor(passwordGenerationService: PasswordGenerationService, analytics: Angulartics2, - platformUtilsService: PlatformUtilsService, i18nService: I18nService, - toasterService: ToasterService) { - super(passwordGenerationService, analytics, platformUtilsService, i18nService, toasterService, window); + constructor(passwordGenerationService: PasswordGenerationService, platformUtilsService: PlatformUtilsService, + i18nService: I18nService) { + super(passwordGenerationService, platformUtilsService, i18nService, window); } } diff --git a/src/app/vault/password-history.component.ts b/src/app/vault/password-history.component.ts index dd1247c3b8..3d791454f1 100644 --- a/src/app/vault/password-history.component.ts +++ b/src/app/vault/password-history.component.ts @@ -1,6 +1,3 @@ -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { Component } from '@angular/core'; import { CipherService } from 'jslib/abstractions/cipher.service'; @@ -16,9 +13,8 @@ import { templateUrl: 'password-history.component.html', }) export class PasswordHistoryComponent extends BasePasswordHistoryComponent { - constructor(cipherService: CipherService, analytics: Angulartics2, - platformUtilsService: PlatformUtilsService, i18nService: I18nService, - toasterService: ToasterService) { - super(cipherService, analytics, platformUtilsService, i18nService, toasterService, window); + constructor(cipherService: CipherService, platformUtilsService: PlatformUtilsService, + i18nService: I18nService) { + super(cipherService, platformUtilsService, i18nService, window); } } diff --git a/src/app/vault/view.component.ts b/src/app/vault/view.component.ts index 4f41ebc274..9ccfd4ab5e 100644 --- a/src/app/vault/view.component.ts +++ b/src/app/vault/view.component.ts @@ -7,9 +7,6 @@ import { Output, } from '@angular/core'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - import { AuditService } from 'jslib/abstractions/audit.service'; import { CipherService } from 'jslib/abstractions/cipher.service'; import { CryptoService } from 'jslib/abstractions/crypto.service'; @@ -33,14 +30,13 @@ export class ViewComponent extends BaseViewComponent implements OnChanges { @Output() onViewCipherPasswordHistory = new EventEmitter(); constructor(cipherService: CipherService, totpService: TotpService, - tokenService: TokenService, toasterService: ToasterService, + tokenService: TokenService, i18nService: I18nService, cryptoService: CryptoService, platformUtilsService: PlatformUtilsService, - i18nService: I18nService, analytics: Angulartics2, auditService: AuditService, broadcasterService: BroadcasterService, ngZone: NgZone, changeDetectorRef: ChangeDetectorRef, userService: UserService) { - super(cipherService, totpService, tokenService, toasterService, cryptoService, platformUtilsService, - i18nService, analytics, auditService, window, broadcasterService, ngZone, changeDetectorRef, userService); + super(cipherService, totpService, tokenService, i18nService, cryptoService, platformUtilsService, + auditService, window, broadcasterService, ngZone, changeDetectorRef, userService); } async ngOnChanges() { @@ -48,7 +44,7 @@ export class ViewComponent extends BaseViewComponent implements OnChanges { } viewHistory() { - this.analytics.eventTrack.next({ action: 'View Password History' }); + this.platformUtilsService.eventTrack('View Password History'); this.onViewCipherPasswordHistory.emit(this.cipher); } }