mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-28 17:27:50 +01:00
checkOnInstalled for safari
This commit is contained in:
parent
869446f7e7
commit
bd0ce5c316
@ -48,21 +48,10 @@ export default class RuntimeBackground {
|
||||
win.location.href = href;
|
||||
}
|
||||
}, true);
|
||||
} else {
|
||||
if (this.runtime.onInstalled) {
|
||||
this.runtime.onInstalled.addListener((details: any) => {
|
||||
(window as any).ga('send', {
|
||||
hitType: 'event',
|
||||
eventAction: 'onInstalled ' + details.reason,
|
||||
});
|
||||
|
||||
if (details.reason === 'install') {
|
||||
chrome.tabs.create({ url: 'https://bitwarden.com/browser-start/' });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
await this.checkOnInstalled();
|
||||
|
||||
BrowserApi.messageListener(async (msg: any, sender: any, sendResponse: any) => {
|
||||
await this.processMessage(msg, sender, sendResponse);
|
||||
});
|
||||
@ -260,6 +249,44 @@ export default class RuntimeBackground {
|
||||
}
|
||||
}
|
||||
|
||||
private async checkOnInstalled() {
|
||||
const gettingStartedUrl = 'https://bitwarden.com/browser-start/';
|
||||
|
||||
if (this.isSafari) {
|
||||
const installedVersionKey = 'installedVersion';
|
||||
const installedVersion = await this.storageService.get<string>(installedVersionKey);
|
||||
let reason: string = null;
|
||||
if (installedVersion == null) {
|
||||
reason = 'install';
|
||||
} else if (BrowserApi.getApplicationVersion() !== installedVersion) {
|
||||
reason = 'update';
|
||||
}
|
||||
|
||||
if (reason != null) {
|
||||
await this.storageService.save(installedVersionKey, BrowserApi.getApplicationVersion());
|
||||
(window as any).ga('send', {
|
||||
hitType: 'event',
|
||||
eventAction: 'onInstalled ' + reason,
|
||||
});
|
||||
}
|
||||
|
||||
if (reason === 'install') {
|
||||
BrowserApi.createNewTab(gettingStartedUrl);
|
||||
}
|
||||
} else if (this.runtime.onInstalled) {
|
||||
this.runtime.onInstalled.addListener((details: any) => {
|
||||
(window as any).ga('send', {
|
||||
hitType: 'event',
|
||||
eventAction: 'onInstalled ' + details.reason,
|
||||
});
|
||||
|
||||
if (details.reason === 'install') {
|
||||
BrowserApi.createNewTab(gettingStartedUrl);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async getDataForTab(tab: any, responseCommand: string) {
|
||||
const responseData: any = {};
|
||||
if (responseCommand === 'notificationBarDataResponse') {
|
||||
|
Loading…
Reference in New Issue
Block a user