Repository navigation
chore(wallet): migrate Analytics and Geolocation init into wallet - #47284
Conversation
Own AnalyticsController through @metamask/wallet v19 so extension init only supplies client options and the init messenger. Co-authored-by: Cursor <cursoragent@cursor.com>
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
…s-controller-init Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # app/scripts/metamask-controller.js
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
✨ Files requiring CODEOWNER review ✨🫰 @MetaMask/core-platform (1 files, +6 -11)
👨🔧 @MetaMask/earn (2 files, +12 -8)
👨🔧 @MetaMask/extension-platform (1 files, +6 -11)
📜 @MetaMask/policy-reviewers (8 files, +168 -8)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. |
There was a problem hiding this comment.
🟡 Changes recommended
Missing LavaMoat permissions block protected background startup, and the migrated initializer loses existing regression coverage.
2 open issues
What changed in this PR
Moves AnalyticsController ownership into @metamask/wallet, while retaining extension-specific analytics configuration in wallet-init.
Changes:
- Upgrades
@metamask/walletto v19 and updates transitive dependencies. - Supplies analytics options through wallet initialization and retrieves the wallet-owned controller.
- Removes the legacy initializer and updates messenger imports and wiring tests.
| File | Description |
|---|---|
yarn.lock |
Locks wallet v19 and updated transitive dependencies. |
package.json |
Bumps the wallet dependency to v19. |
app/scripts/wallet-init/messengers/analytics-controller-messenger.ts |
Retains the extension analytics init messenger. |
app/scripts/wallet-init/messengers/analytics-controller-messenger.test.ts |
Tests init messenger delegation. |
app/scripts/wallet-init/instance-options/analytics-controller.ts |
Supplies extension-specific analytics options and setup. |
app/scripts/wallet-init/initialization.ts |
Passes analytics options to the wallet. |
app/scripts/wallet-init/initialization.test.ts |
Tests analytics option wiring. |
app/scripts/metamask-controller.js |
Retrieves analytics from the wallet instead of client initialization. |
app/scripts/messenger-client-init/messengers/index.ts |
Removes the legacy analytics messenger factory. |
app/scripts/messenger-client-init/analytics-controller-init.ts |
Deletes the extension-owned controller initializer. |
app/scripts/messenger-client-init/analytics-controller-init.test.ts |
Deletes the old initializer regression test. |
app/scripts/lib/createRPCMethodTrackingMiddleware.test.js |
Updates the analytics messenger import. |
app/scripts/controllers/analytics/platform-adapter.ts |
Updates the messenger type import. |
app/scripts/controllers/analytics/analytics.ts |
Updates the messenger type import. |
app/scripts/controllers/analytics/analytics.test.ts |
Updates the analytics messenger import. |
Review effort: Balanced
|
@metamaskbot update-policies |
|
No CI run found for this commit. Please wait for CI to start and retry |
|
@metamaskbot update-policies |
|
No CI run found for this commit. Please wait for CI to start and retry |
Cover getAnalyticsControllerInstanceOptions registering Chain Value Order and Perps Tab Badge mappings without duplicates. Co-authored-by: Cursor <cursoragent@cursor.com>
Allow @metamask/wallet to import @metamask/analytics-controller after the v19 bump across MV2 and MV3 policy variants. Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [ba026df]
⚡ Performance Benchmarks (Total: 🟢 11 pass · 🟡 0 warn · 🔴 0 fail)
Bundle Size Diffs [🚀 Bundle size reduced!]
|
|
@metamaskbot update-policies |
|
Policies updated. Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 👀 lavamoat/webpack/mv2/beta/policy.json changes differ from lavamoat/webpack/mv2/main/policy.json changes |
Builds ready [4da0313]
⚡ Performance Benchmarks (Total: 🟢 11 pass · 🟡 0 warn · 🔴 0 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [e7f32d4]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 5 warn · 🔴 2 fail)
Bundle Size Diffs [🚀 Bundle size reduced!]
|
|
|
@MetaMask/policy-reviewers LavaMoat policies are updated for the Intentional changes:
|
|
No release label on PR. Adding release label release-13.56.0 on PR, as PR was added to branch 13.56.0 when release was cut. |





Description
Bump
@metamask/walletto v20 (with@metamask/analytics-controller^4.1.0 and@metamask/geolocation-controller^2.0.0) and moveAnalyticsController,GeolocationController, andGeolocationApiServiceownership into the wallet package.Reason: Wallet now constructs and owns these controllers, so the extension should stop initializing them through messenger-client-init. Putting geolocation inside wallet also guarantees its action handlers are registered before
AnalyticsController.init()runs for returning opted-in users (location enrichment).Solution:
wallet-init(getAnalyticsControllerInstanceOptions,getGeolocationApiServiceInstanceOptions) and the analytics init messenger.wallet.getInstance('AnalyticsController')andwallet.getInstance('GeolocationController').GeolocationController:getGeolocation/GeolocationController:refreshGeolocation) instead of adding new legacy background API methods.Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
AnalyticsController,GeolocationController, or messenger factories.GeolocationController:getGeolocationDatahandler errors.Pre-merge author checklist
Pre-merge reviewer checklist