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

refactor and cleanup analytics class

This commit is contained in:
Kyle Spearrin
2018-01-19 16:19:24 -05:00
parent 34e2cc2e39
commit ee036db2dd
7 changed files with 62 additions and 81 deletions

View File

@@ -1,5 +1,6 @@
import { BrowserApi } from '../browser/browserApi';
import Analytics from '../scripts/analytics';
import MainBackground from './main.background';
import {
@@ -13,7 +14,7 @@ export default class ContextMenusBackground {
private contextMenus: any;
constructor(private main: MainBackground, private cipherService: CipherService,
private passwordGenerationService: PasswordGenerationService) {
private passwordGenerationService: PasswordGenerationService, private analytics: Analytics) {
this.contextMenus = chrome.contextMenus;
}
@@ -38,7 +39,7 @@ export default class ContextMenusBackground {
UtilsService.copyToClipboard(password);
this.passwordGenerationService.addHistory(password);
(window as any).ga('send', {
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Generated Password From Context Menu',
});
@@ -61,19 +62,19 @@ export default class ContextMenusBackground {
}
if (info.parentMenuItemId === 'autofill') {
(window as any).ga('send', {
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Autofilled From Context Menu',
});
await this.startAutofillPage(cipher);
} else if (info.parentMenuItemId === 'copy-username') {
(window as any).ga('send', {
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Copied Username From Context Menu',
});
UtilsService.copyToClipboard(cipher.login.username);
} else if (info.parentMenuItemId === 'copy-password') {
(window as any).ga('send', {
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Copied Password From Context Menu',
});