1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

convert analytics and toaster to platform utils

This commit is contained in:
Kyle Spearrin
2018-10-03 10:33:04 -04:00
parent d4dd962193
commit 68ed8e51bd
21 changed files with 99 additions and 115 deletions

View File

@@ -4,6 +4,7 @@ import { SweetAlert } from 'sweetalert/typings/core';
import { DeviceType } from 'jslib/enums/deviceType';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { MessagingService } from 'jslib/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { Utils } from 'jslib/misc/utils';
@@ -16,7 +17,7 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
private browserCache: DeviceType = null;
constructor(private i18nService: I18nService) { }
constructor(private i18nService: I18nService, private messagingService: MessagingService) { }
getDevice(): DeviceType {
if (this.browserCache != null) {
@@ -143,8 +144,14 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
return true;
}
showToast(type: 'error' | 'success' | 'warning' | 'info', title: string, text: string, global?: any): void {
throw new Error('showToast not implemented');
showToast(type: 'error' | 'success' | 'warning' | 'info', title: string, text: string | string[],
options?: any): void {
this.messagingService.send('showToast', {
text: text,
title: title,
type: type,
options: options,
});
}
async showDialog(text: string, title?: string, confirmText?: string, cancelText?: string, type?: string) {
@@ -199,6 +206,14 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
return confirmed;
}
eventTrack(action: string, label?: string, options?: any) {
this.messagingService.send('analyticsEventTrack', {
action: action,
label: label,
options: options,
});
}
isDev(): boolean {
return process.env.ENV === 'development';
}