From b3e0281ee82e11d7b35f52ecd5cd4086913737f6 Mon Sep 17 00:00:00 2001 From: kvhnuke <10602065+kvhnuke@users.noreply.github.com> Date: Thu, 23 May 2024 13:07:37 -0700 Subject: [PATCH] devop: ff pp changes --- packages/extension/package.json | 2 +- .../extension/src/libs/metrics/amplitude.ts | 46 +++++----- .../src/manifest/manifest-firefox.json | 3 +- packages/extension/src/ui/onboard/App.vue | 1 + .../create-wallet/double-check-phrase.vue | 6 +- .../src/ui/onboard/create-wallet/routes.ts | 6 ++ .../src/ui/onboard/restore-wallet/routes.ts | 6 ++ .../onboard/restore-wallet/type-password.vue | 10 ++- packages/extension/src/ui/onboard/routes.ts | 2 + .../src/ui/onboard/user-analytics.vue | 88 +++++++++++++++++++ yarn.lock | 75 +++++++--------- 11 files changed, 173 insertions(+), 72 deletions(-) create mode 100644 packages/extension/src/ui/onboard/user-analytics.vue diff --git a/packages/extension/package.json b/packages/extension/package.json index b5f4127ce..f1c563fe0 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -21,7 +21,7 @@ "watch-vue-firefox": "cross-env BROWSER='firefox' vue-cli-service build --watch --no-clean" }, "dependencies": { - "@amplitude/analytics-browser": "2.5.3", + "@amplitude/analytics-browser": "^2.8.0", "@babel/runtime": "^7.24.5", "@enkryptcom/extension-bridge": "workspace:^", "@enkryptcom/hw-wallets": "workspace:^", diff --git a/packages/extension/src/libs/metrics/amplitude.ts b/packages/extension/src/libs/metrics/amplitude.ts index 2ca127398..714462124 100644 --- a/packages/extension/src/libs/metrics/amplitude.ts +++ b/packages/extension/src/libs/metrics/amplitude.ts @@ -28,28 +28,30 @@ class Metrics { const settingsState = new SettingsState(); settingsState.getEnkryptSettings().then((set) => { this.installedTime = set.installedTimestamp; - init("apikey", { - instanceName: process.env.IS_DEV - ? "enkrypt-extension-dev" - : "enkrypt-extension", - optOut: !set.isMetricsEnabled, - serverUrl: process.env.IS_DEV - ? "https://analytics-enkrypt-dev.mewwallet.dev/record" - : "https://analytics-enkrypt.mewwallet.dev/record", - appVersion: process.env.PACKAGE_VERSION as string, - trackingOptions: { - ipAddress: false, - }, - userId: set.randomUserID, - useBatch: true, - identityStorage: "none", - logLevel: Types.LogLevel.None, - defaultTracking: { - formInteractions: false, - pageViews: false, - sessions: false, - }, - }); + if (typeof window !== "undefined") { + init("apikey", { + instanceName: process.env.IS_DEV + ? "enkrypt-extension-dev" + : "enkrypt-extension", + optOut: !set.isMetricsEnabled, + serverUrl: process.env.IS_DEV + ? "https://analytics-enkrypt-dev.mewwallet.dev/record" + : "https://analytics-enkrypt.mewwallet.dev/record", + appVersion: process.env.PACKAGE_VERSION as string, + trackingOptions: { + ipAddress: false, + }, + userId: set.randomUserID, + useBatch: true, + identityStorage: "none", + sessionTimeout: 15 * 60 * 1000, // 15 mins + logLevel: Types.LogLevel.None, + defaultTracking: { + formInteractions: false, + pageViews: false, + }, + }); + } }); } track(event: string, options: Record) { diff --git a/packages/extension/src/manifest/manifest-firefox.json b/packages/extension/src/manifest/manifest-firefox.json index 378efca83..79e361684 100644 --- a/packages/extension/src/manifest/manifest-firefox.json +++ b/packages/extension/src/manifest/manifest-firefox.json @@ -41,5 +41,6 @@ "gecko": { "strict_min_version": "100.0" } - } + }, + "content_security_policy": "script-src 'self' 'unsafe-eval' 'wasm-unsafe-eval'" } diff --git a/packages/extension/src/ui/onboard/App.vue b/packages/extension/src/ui/onboard/App.vue index bba4c5cfc..81a1d3278 100644 --- a/packages/extension/src/ui/onboard/App.vue +++ b/packages/extension/src/ui/onboard/App.vue @@ -43,6 +43,7 @@ const isShowBackButton = () => { return ( route.name && route.name != "new-wallet" && + route.name != "user-analytics" && route.name != "create-wallet-wallet-ready" && route.name != "restore-wallet-wallet-ready" && !(route.name as string).includes("hardware-wallet") 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 1ce04e1a7..d38ef3473 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,7 +59,11 @@ const nextAction = () => { isInitializing.value = true; onboardInitializeWallets(phrase, password).then(() => { isInitializing.value = false; - router.push({ name: routes.walletReady.name }); + if (process.env.IS_FIREFOX) { + router.push({ name: routes.userAnalytics.name }); + } else { + router.push({ name: routes.walletReady.name }); + } }); }; diff --git a/packages/extension/src/ui/onboard/create-wallet/routes.ts b/packages/extension/src/ui/onboard/create-wallet/routes.ts index 828365aed..07a953310 100644 --- a/packages/extension/src/ui/onboard/create-wallet/routes.ts +++ b/packages/extension/src/ui/onboard/create-wallet/routes.ts @@ -3,6 +3,7 @@ import TypePassword from "./type-password.vue"; import RecoveryPhrase from "./recovery-phrase.vue"; import CheckPhrase from "./double-check-phrase.vue"; import WalletReady from "./wallet-ready.vue"; +import UserAnalytics from "../user-analytics.vue"; import { RouteRecordRaw } from "vue-router"; export const routes = { pickPassword: { @@ -25,6 +26,11 @@ export const routes = { name: "check-phrase", component: CheckPhrase, }, + userAnalytics: { + path: "user-analytics", + name: "user-analytics", + component: UserAnalytics, + }, walletReady: { path: "wallet-ready", name: "wallet-ready", diff --git a/packages/extension/src/ui/onboard/restore-wallet/routes.ts b/packages/extension/src/ui/onboard/restore-wallet/routes.ts index 1d229bcf5..0e93d0154 100644 --- a/packages/extension/src/ui/onboard/restore-wallet/routes.ts +++ b/packages/extension/src/ui/onboard/restore-wallet/routes.ts @@ -4,6 +4,7 @@ import EnterRecoveryPhrase from "./enter-recovery-phrase.vue"; import PickPassword from "./pick-password.vue"; import TypePassword from "./type-password.vue"; import WalletReady from "../create-wallet/wallet-ready.vue"; +import UserAnalytics from "../user-analytics.vue"; import { RouteRecordRaw } from "vue-router"; export const routes = { start: { @@ -31,6 +32,11 @@ export const routes = { name: "type-password", component: TypePassword, }, + userAnalytics: { + path: "user-analytics", + name: "user-analytics", + component: UserAnalytics, + }, walletReady: { path: "wallet-ready", name: "wallet-ready", 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 586c5134f..4013f0345 100644 --- a/packages/extension/src/ui/onboard/restore-wallet/type-password.vue +++ b/packages/extension/src/ui/onboard/restore-wallet/type-password.vue @@ -44,9 +44,13 @@ const nextAction = () => { isInitializing.value = true; onboardInitializeWallets(store.mnemonic, store.password).then(() => { isInitializing.value = false; - router.push({ - name: routes.walletReady.name, - }); + if (process.env.IS_FIREFOX) { + router.push({ name: routes.userAnalytics.name }); + } else { + 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 7a07e77fb..98d86e38d 100644 --- a/packages/extension/src/ui/onboard/routes.ts +++ b/packages/extension/src/ui/onboard/routes.ts @@ -1,5 +1,6 @@ import { RouteRecordRaw } from "vue-router"; import NewWallet from "./new-wallet.vue"; +import UserAnalytics from "./user-analytics.vue"; import CreateWalletUI from "./create-wallet/routes"; import RestoreWalletUI from "./restore-wallet/routes"; import HardwareWalletUI from "./hardware-wallet/routes"; @@ -9,6 +10,7 @@ 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, ]; export default routes; diff --git a/packages/extension/src/ui/onboard/user-analytics.vue b/packages/extension/src/ui/onboard/user-analytics.vue new file mode 100644 index 000000000..8b73ee937 --- /dev/null +++ b/packages/extension/src/ui/onboard/user-analytics.vue @@ -0,0 +1,88 @@ + + + + diff --git a/yarn.lock b/yarn.lock index 1c1cb6333..28a0c92f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -30,29 +30,28 @@ __metadata: languageName: node linkType: hard -"@amplitude/analytics-browser@npm:2.5.3": - version: 2.5.3 - resolution: "@amplitude/analytics-browser@npm:2.5.3" - dependencies: - "@amplitude/analytics-client-common": ^2.1.1 - "@amplitude/analytics-core": ^2.2.2 - "@amplitude/analytics-types": ^2.5.0 - "@amplitude/plugin-page-view-tracking-browser": ^2.2.3 - "@amplitude/plugin-web-attribution-browser": ^2.1.4 +"@amplitude/analytics-browser@npm:2.8.0": + version: 2.8.0 + resolution: "@amplitude/analytics-browser@npm:2.8.0" + dependencies: + "@amplitude/analytics-client-common": ^2.2.0 + "@amplitude/analytics-core": ^2.2.8 + "@amplitude/analytics-types": ^2.5.1 + "@amplitude/plugin-page-view-tracking-browser": ^2.2.12 tslib: ^2.4.1 - checksum: 9d67fa579bbe06d7b1f4c5df152f9dd669716c4ef79f97f3ee9ed5c74b27b3092752434eca0beb5b557473d8cbfcc1c93cbf336e87039ae31197df8f73f1bbf4 + checksum: 3f7cbec435ef7aa1393f608afff374d42543a64fe5019b3849c137c98918246ef4b905079d85893a2a88fba510749b5a0ac0685848551620187c21cbac7a4ea6 languageName: node linkType: hard -"@amplitude/analytics-client-common@npm:^2.1.1, @amplitude/analytics-client-common@npm:^2.1.5": - version: 2.1.5 - resolution: "@amplitude/analytics-client-common@npm:2.1.5" +"@amplitude/analytics-client-common@npm:^2.2.0": + version: 2.2.0 + resolution: "@amplitude/analytics-client-common@npm:2.2.0" dependencies: "@amplitude/analytics-connector": ^1.4.8 - "@amplitude/analytics-core": ^2.2.6 - "@amplitude/analytics-types": ^2.5.0 + "@amplitude/analytics-core": ^2.2.8 + "@amplitude/analytics-types": ^2.5.1 tslib: ^2.4.1 - checksum: 1443f3c5bed5c18ebe88c9e4583ed4f8f75625c4eb3726c1f55f3f45910bc36df70ccef6e8606395c1550e4e05c8f845f1904ec220652e31cbff06b38a098c57 + checksum: eb9a7a122a6b02a16abcae6c9e112b04ed1e0c7430619334fea323e95ada9f894638dcd86c1e6cbcd7aeee6cdeb0f2e0ff13de1c10b7790774174b018a3d21ee languageName: node linkType: hard @@ -63,43 +62,31 @@ __metadata: languageName: node linkType: hard -"@amplitude/analytics-core@npm:^2.2.2, @amplitude/analytics-core@npm:^2.2.6": - version: 2.2.6 - resolution: "@amplitude/analytics-core@npm:2.2.6" +"@amplitude/analytics-core@npm:^2.2.8": + version: 2.2.8 + resolution: "@amplitude/analytics-core@npm:2.2.8" dependencies: - "@amplitude/analytics-types": ^2.5.0 + "@amplitude/analytics-types": ^2.5.1 tslib: ^2.4.1 - checksum: 6579044b7efdfb232320b5dd7ab1c43be7c29fba90a3978242ce8467e7437b6756a1298c7d8813bedabc55a00a1c1abeb2f952c56779f554544f6610ef5307b5 + checksum: a7a70b1124bf25bfb4fee74ec2d9124fce05bd31147a61ecf6dcfa307ba150e4114cd68fba336ddeb8d6b53ee6c2f4ed561fdc329dd652955daea848887baafc languageName: node linkType: hard -"@amplitude/analytics-types@npm:^2.5.0": - version: 2.5.0 - resolution: "@amplitude/analytics-types@npm:2.5.0" - checksum: c2f0d4514d4d1772794dd6209df2311368076aaa2555b03763a9fcc21d4d861996fd1c13cd1c29a8d9f801470b20e56b2d47c3c4f35e76a3f8ab9ce2de3efcd9 - languageName: node - linkType: hard - -"@amplitude/plugin-page-view-tracking-browser@npm:^2.2.3": - version: 2.2.8 - resolution: "@amplitude/plugin-page-view-tracking-browser@npm:2.2.8" - dependencies: - "@amplitude/analytics-client-common": ^2.1.5 - "@amplitude/analytics-types": ^2.5.0 - tslib: ^2.4.1 - checksum: d6759f2df86765ca9488548bb80bf46b719c4a8a36ebd95ccc403ec70211a4e177df163e0765895a64314e8dafe1b69727a64924eb83f47e4c4eae478806257a +"@amplitude/analytics-types@npm:^2.5.1": + version: 2.5.1 + resolution: "@amplitude/analytics-types@npm:2.5.1" + checksum: 7b46ed1fbe856990ac71ee3d9a9185f16f286a17f5bbd93560d03b608a6696deeb6c7cf42b9937889b38266f97e8b22a59f132177cdfd682da4b30accb3ae1b4 languageName: node linkType: hard -"@amplitude/plugin-web-attribution-browser@npm:^2.1.4": - version: 2.1.9 - resolution: "@amplitude/plugin-web-attribution-browser@npm:2.1.9" +"@amplitude/plugin-page-view-tracking-browser@npm:^2.2.12": + version: 2.2.12 + resolution: "@amplitude/plugin-page-view-tracking-browser@npm:2.2.12" dependencies: - "@amplitude/analytics-client-common": ^2.1.5 - "@amplitude/analytics-core": ^2.2.6 - "@amplitude/analytics-types": ^2.5.0 + "@amplitude/analytics-client-common": ^2.2.0 + "@amplitude/analytics-types": ^2.5.1 tslib: ^2.4.1 - checksum: 7b49abaaa479f2114f4dd8100e4c99fb0e84be338a80d07f614814396825064144ede2fea57789e0d8f0abcde21597b23851d7efc99a602df8633db0ff4970b7 + checksum: 5073f93fbf4e58e3907954b7d2070d936e67cdf8a9e5f665ea60777c970622a0c211767ade22326c5a5062d7c4149d5cd0a9688e88ff29beddb1cf61f28e6415 languageName: node linkType: hard @@ -2559,7 +2546,7 @@ __metadata: version: 0.0.0-use.local resolution: "@enkryptcom/extension@workspace:packages/extension" dependencies: - "@amplitude/analytics-browser": 2.5.3 + "@amplitude/analytics-browser": 2.8.0 "@babel/plugin-transform-class-static-block": ^7.24.4 "@babel/runtime": ^7.24.5 "@enkryptcom/extension-bridge": "workspace:^"