From 4a6e43be277e3ab6906a69b77364b79e6f7289c1 Mon Sep 17 00:00:00 2001 From: kvhnuke <10602065+kvhnuke@users.noreply.github.com> Date: Fri, 7 Jun 2024 12:35:09 -0700 Subject: [PATCH] devop: open pp as the first on install --- packages/extension/package.json | 2 +- packages/extension/src/libs/metrics/index.ts | 12 +++++---- .../extension/src/libs/utils/open-onboard.ts | 6 +++++ .../src/scripts/firefox/background.ts | 4 ++- .../create-wallet/double-check-phrase.vue | 6 +---- .../onboard/restore-wallet/type-password.vue | 10 +++----- packages/extension/src/ui/onboard/routes.ts | 25 +++++++++++++++---- .../src/ui/onboard/user-analytics.vue | 16 +++++++++--- 8 files changed, 53 insertions(+), 28 deletions(-) diff --git a/packages/extension/package.json b/packages/extension/package.json index 9e6c6c758..5df309989 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -1,6 +1,6 @@ { "name": "@enkryptcom/extension", - "version": "1.40.2", + "version": "1.40.3", "private": true, "scripts": { "zip": "cd dist; zip -r release.zip *;", diff --git a/packages/extension/src/libs/metrics/index.ts b/packages/extension/src/libs/metrics/index.ts index b0c338f0a..0848877f6 100644 --- a/packages/extension/src/libs/metrics/index.ts +++ b/packages/extension/src/libs/metrics/index.ts @@ -76,11 +76,13 @@ const trackDAppsEvents = ( }; const optOutofMetrics = (optOut: boolean) => { - metrics.setOptOut(false); - metrics.track("settings", { - event: SettingEventType.OptOut, - value: optOut ? 1 : 0, - }); + if (!process.env.IS_FIREFOX) { + metrics.setOptOut(false); + metrics.track("settings", { + event: SettingEventType.OptOut, + value: optOut ? 1 : 0, + }); + } metrics.setOptOut(optOut); }; diff --git a/packages/extension/src/libs/utils/open-onboard.ts b/packages/extension/src/libs/utils/open-onboard.ts index 69406a966..7facb9437 100644 --- a/packages/extension/src/libs/utils/open-onboard.ts +++ b/packages/extension/src/libs/utils/open-onboard.ts @@ -1,5 +1,11 @@ import Browser from "webextension-polyfill"; +export const openPrivacy = () => { + const onboardURL = Browser.runtime.getURL("onboard.html#/user-privacy"); + Browser.tabs.create({ + url: onboardURL, + }); +}; export default () => { const onboardURL = Browser.runtime.getURL("onboard.html"); Browser.tabs.create({ diff --git a/packages/extension/src/scripts/firefox/background.ts b/packages/extension/src/scripts/firefox/background.ts index 40aaae7ad..135e27646 100644 --- a/packages/extension/src/scripts/firefox/background.ts +++ b/packages/extension/src/scripts/firefox/background.ts @@ -11,7 +11,7 @@ import { import { InternalOnMessageResponse } from "@/types/messenger"; import { OnMessageResponse } from "@enkryptcom/types"; import Browser from "webextension-polyfill"; -import openOnboard from "@/libs/utils/open-onboard"; +import openOnboard, { openPrivacy } from "@/libs/utils/open-onboard"; import(/* webpackChunkName: "background-chunk" */ "@/libs/background").then( ({ default: BackgroundHandler }) => { @@ -42,5 +42,7 @@ import(/* webpackChunkName: "background-chunk" */ "@/libs/background").then( Browser.runtime.onInstalled.addListener((object) => { if (object.reason === "install") { openOnboard(); + } else if (object.reason === "update") { + openPrivacy(); } }); diff --git a/packages/extension/src/ui/onboard/create-wallet/double-check-phrase.vue b/packages/extension/src/ui/onboard/create-wallet/double-check-phrase.vue index d38ef3473..1ce04e1a7 100644 --- a/packages/extension/src/ui/onboard/create-wallet/double-check-phrase.vue +++ b/packages/extension/src/ui/onboard/create-wallet/double-check-phrase.vue @@ -59,11 +59,7 @@ const nextAction = () => { isInitializing.value = true; onboardInitializeWallets(phrase, password).then(() => { isInitializing.value = false; - if (process.env.IS_FIREFOX) { - router.push({ name: routes.userAnalytics.name }); - } else { - router.push({ name: routes.walletReady.name }); - } + router.push({ name: routes.walletReady.name }); }); }; diff --git a/packages/extension/src/ui/onboard/restore-wallet/type-password.vue b/packages/extension/src/ui/onboard/restore-wallet/type-password.vue index 4013f0345..586c5134f 100644 --- a/packages/extension/src/ui/onboard/restore-wallet/type-password.vue +++ b/packages/extension/src/ui/onboard/restore-wallet/type-password.vue @@ -44,13 +44,9 @@ const nextAction = () => { isInitializing.value = true; onboardInitializeWallets(store.mnemonic, store.password).then(() => { isInitializing.value = false; - if (process.env.IS_FIREFOX) { - router.push({ name: routes.userAnalytics.name }); - } else { - router.push({ - name: routes.walletReady.name, - }); - } + router.push({ + name: routes.walletReady.name, + }); }); } }; diff --git a/packages/extension/src/ui/onboard/routes.ts b/packages/extension/src/ui/onboard/routes.ts index 98d86e38d..4ddc25c20 100644 --- a/packages/extension/src/ui/onboard/routes.ts +++ b/packages/extension/src/ui/onboard/routes.ts @@ -8,9 +8,24 @@ let uiRoutes: RouteRecordRaw[] = []; uiRoutes = uiRoutes.concat(CreateWalletUI()); uiRoutes = uiRoutes.concat(RestoreWalletUI()); uiRoutes = uiRoutes.concat(HardwareWalletUI()); -const routes = [ - { path: "/", component: NewWallet, name: "new-wallet" }, - { path: "/user-analytics", component: UserAnalytics, name: "user-analytics" }, - ...uiRoutes, -]; +const routes = [...uiRoutes]; +if (process.env.IS_FIREFOX) { + routes.unshift({ + path: "/new-wallet", + component: NewWallet, + name: "new-wallet", + }); + routes.unshift({ + path: "/", + component: UserAnalytics, + name: "user-analytics", + }); + routes.unshift({ + path: "/user-privacy", + component: UserAnalytics, + name: "user-privacy", + }); +} else { + routes.unshift({ path: "/", component: NewWallet, name: "new-wallet" }); +} export default routes; diff --git a/packages/extension/src/ui/onboard/user-analytics.vue b/packages/extension/src/ui/onboard/user-analytics.vue index b964db721..edf07a7bb 100644 --- a/packages/extension/src/ui/onboard/user-analytics.vue +++ b/packages/extension/src/ui/onboard/user-analytics.vue @@ -35,10 +35,10 @@ import LogoBig from "@action/icons/common/logo-big.vue"; import BaseButton from "@action/components/base-button/index.vue"; import SettingsState from "@/libs/settings-state"; import { optOutofMetrics } from "@/libs/metrics"; -import { routes as cwalletRoutes } from "./create-wallet/routes"; -import { useRouter } from "vue-router"; +import { useRouter, useRoute } from "vue-router"; const router = useRouter(); +const route = useRoute(); const settingsState = new SettingsState(); @@ -47,7 +47,11 @@ const agree = async () => { enkryptSettings.isMetricsEnabled = true; await settingsState.setEnkryptSettings(enkryptSettings); optOutofMetrics(false); - router.push({ name: cwalletRoutes.walletReady.name }); + if (route.name === "user-privacy") { + window.close(); + } else { + router.push({ name: "new-wallet" }); + } }; const deny = async () => { @@ -55,7 +59,11 @@ const deny = async () => { enkryptSettings.isMetricsEnabled = false; await settingsState.setEnkryptSettings(enkryptSettings); optOutofMetrics(true); - router.push({ name: cwalletRoutes.walletReady.name }); + if (route.name === "user-privacy") { + window.close(); + } else { + router.push({ name: "new-wallet" }); + } };