feat(analytics): add possibility to deliver event directly through AnalyticsController (without MetaMetricsController)
Description
This PR adds the possibility to deliver events directly through AnalyticsController, bypassing MetaMetricsController for new callers.
Once this PR is merged, we'll start migrating all events from the codebase one by one so they all get delivered directly through AnalyticsController.
This brings us one step further to the ultimate goal, which is to remove MetaMetricsController from the codebase.
This PR also aligns the syntax of how events are called with Mobile, so contributors have the same experience across both clients:
trackEvent(
createEventBuilder(MetaMetricsEventName.AppOpened)
.addCategory(MetaMetricsEventCategory.App)
.addProperties(
activeTabDomain ? { active_tab_domain: activeTabDomain } : {},
)
.build({ environmentType }),
);
This PR only migrates two events, to provide examples of how it will look after the migration:
- One event emitted by background:
AppOpened - One event emitted by UI:
ThemeChanged
flowchart TB
subgraph Before["Before"]
direction TB
LegacyUI1["UI callers"] --> MMC1["MetaMetricsController"]
LegacyBG1["Background callers"] --> MMC1
MMC1 --> AC1["AnalyticsController"]
AC1 --> SDK1["Segment SDK"]
end
subgraph After["After"]
direction TB
LegacyUI2["Legacy UI callers"] --> MMC2["MetaMetricsController (shim)"]
LegacyBG2["Legacy background callers"] --> MMC2
MMC2 --> Analytics["analytics.ts"]
NewUI["New UI callers"] --> Analytics
NewBG["New background callers"] --> Analytics
Analytics --> AC2["AnalyticsController"]
AC2 --> SDK2["Segment SDK"]
end
Before ~~~ After
Changelog
CHANGELOG entry: null
Related issues
Fixes: https://github.com/MetaMask/MetaMask-planning/issues/7337
Manual testing steps
- Go through all manual testing steps listed in this PR: https://github.com/MetaMask/metamask-extension/pull/42885
- Test
AppOpenedlooks the same as onmainbranch - Test
ThemeChangedlooks the same as onmainbranch
Screenshots/Recordings
NA
Pre-merge author checklist
- [x] I've followed MetaMask Contributor Docs and MetaMask Extension Coding Standards.
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using JSDoc format if applicable
- [x] I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
Pre-merge reviewer checklist
- [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
[!NOTE] Medium Risk Touches metrics consent, PII/anonymization, and Segment delivery for all shimmed events; behavior is heavily tested but regressions would affect product analytics broadly.
Overview Introduces a shared
analyticsdelivery layer (configureAnalytics,trackEvent,identify,trackPage) that enrichescreateEventBuilderevents (locale, chain, AB tests, anonymous/UTM rules) and sends them toAnalyticsControllerthrough a restricted messenger.
MetaMetricsControllerbecomes a thin shim: legacytrackEvent/identify/trackPagestill validate payloads but forward into the new module. Background exposestrackAnalyticsEvent; UI addsuseAnalyticswith the same builder API and opt-in buffering behavior.Example migrations: background
AppOpenedand settingsThemeChanged. A/B test helpers now key off eventnameinstead of legacy payload shape.Reviewed by Cursor Bugbot for commit 83507b30b05cbbd33c56f3625d9e572485997139. Bugbot is set up for automated code reviews on this repo. Configure here.
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.
✨ Files requiring CODEOWNER review ✨
👨🔧 @MetaMask/core-extension-ux (2 files, +43 -13)
- 📁 ui/
- 📁 pages/
- 📁 settings/
- 📁 preferences-and-display-tab/
- 📄
theme-sub-page.test.tsx+31 -2 - 📄
theme-sub-page.tsx+12 -11
- 📄
- 📁 preferences-and-display-tab/
- 📁 settings/
- 📁 pages/
Baseline (latest main): 4a32a05 | Date: 6/19/2026 | Pipeline: 27830776968 | Baseline logs 📈 Results compared to the previous 5 runs on main 🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds) 📈 Results compared to the previous 5 runs on main 🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds) 📈 Results compared to the previous 5 runs on main 🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds) 📈 Results compared to the previous 5 runs on mainBuilds ready [9fc4318]
⚡ Performance Benchmarks (Total: 🟢 17 pass · 🟡 8 warn · 🔴 0 fail)
Interaction Benchmarks · Samples: 5
Benchmark chrome-webpack firefox-webpack loadNewAccount
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] confirmTx
[Sentry log · main/release]🟢 [CI log] 🟢 [CI log] bridgeUserActions
[Sentry log · main/release]🟢 [CI log] 🟢 [CI log] loadNewAccount/load_new_account: -12%loadNewAccount/total: -12%loadNewAccount/inp: +34%bridgeUserActions/bridge_load_asset_picker: -11%bridgeUserActions/longTaskCount: -17%bridgeUserActions/longTaskTotalDuration: -13%loadNewAccount/load_new_account: +75%loadNewAccount/total: +75%loadNewAccount/inp: -18%loadNewAccount/fcp: -53%loadNewAccount/lcp: +1321%confirmTx/confirm_tx: +11%confirmTx/longTaskCount: -100%confirmTx/longTaskTotalDuration: -100%confirmTx/longTaskMaxDuration: -100%confirmTx/tbt: -100%confirmTx/total: +11%confirmTx/fcp: -47%confirmTx/lcp: +1176%bridgeUserActions/bridge_load_page: +117%bridgeUserActions/bridge_load_asset_picker: +72%bridgeUserActions/longTaskCount: -100%bridgeUserActions/longTaskTotalDuration: -100%bridgeUserActions/longTaskMaxDuration: -100%bridgeUserActions/tbt: -100%bridgeUserActions/total: +20%bridgeUserActions/lcp: +1097%loadNewAccount/LCP: p75 2.6sStartup Benchmarks · Samples: 100
Benchmark chrome-webpack firefox-webpack startupStandardHome
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] loadScriptsstartupPowerUserHome
[Sentry log · main/release]🟡 [CI log] 🟡 [CI log] startupPowerUserHome/initialActions: -12%startupPowerUserHome/longTaskCount: +13%startupStandardHome/domInteractive: +21%startupStandardHome/backgroundConnect: +18%startupStandardHome/firstReactRender: +15%startupStandardHome/setupStore: +16%startupStandardHome/inp: +100%startupStandardHome/fcp: +24%startupPowerUserHome/domInteractive: +24%startupPowerUserHome/backgroundConnect: +13%startupPowerUserHome/setupStore: +11%startupPowerUserHome/numNetworkReqs: +15%startupPowerUserHome/fcp: +16%startupPowerUserHome/INP: p75 448msstartupPowerUserHome/LCP: p75 3.0sUser Journey Benchmarks · Samples: 5 · mock API
Benchmark chrome-webpack firefox-webpack onboardingImportWallet
[Sentry log · main/release]🟢 [CI log] 🟢 [CI log] onboardingNewWallet
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] totalassetDetails
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] solanaAssetDetails
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] importSrpHome
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] sendTransactions
[Sentry log · main/release]🟢 [CI log] 🟢 [CI log] swap
[Sentry log · main/release]🟢 [CI log] 🟢 [CI log] onboardingImportWallet/metricsToWalletReadyScreen: -11%onboardingImportWallet/doneButtonToHomeScreen: -86%onboardingImportWallet/openAccountMenuToAccountListLoaded: -98%onboardingImportWallet/longTaskCount: -78%onboardingImportWallet/longTaskTotalDuration: -94%onboardingImportWallet/longTaskMaxDuration: -91%onboardingImportWallet/tbt: -98%onboardingImportWallet/total: -85%onboardingNewWallet/doneButtonToAssetList: -25%onboardingNewWallet/longTaskTotalDuration: -24%onboardingNewWallet/tbt: -24%onboardingNewWallet/total: -21%solanaAssetDetails/assetClickToPriceChart: +30%solanaAssetDetails/longTaskCount: +400%solanaAssetDetails/longTaskTotalDuration: +374%solanaAssetDetails/longTaskMaxDuration: +374%solanaAssetDetails/tbt: +348%solanaAssetDetails/total: +30%solanaAssetDetails/cls: -79%importSrpHome/loginToHomeScreen: -11%importSrpHome/openAccountMenuAfterLogin: +26%importSrpHome/homeAfterImportWithNewWallet: -29%importSrpHome/longTaskCount: -21%importSrpHome/longTaskTotalDuration: -24%importSrpHome/longTaskMaxDuration: +14%importSrpHome/tbt: -20%importSrpHome/total: -26%importSrpHome/inp: -25%importSrpHome/lcp: -11%importSrpHome/cls: -70%sendTransactions/openSendPageFromHome: +47%sendTransactions/inp: -25%sendTransactions/cls: -79%assetDetails/FCP: p75 1.9ssolanaAssetDetails/FCP: p75 1.9simportSrpHome/FCP: p75 1.9sDapp Page Load Benchmarks · Samples: 100
Benchmark chrome-webpack dappPageLoad
[Sentry log · main/release]🟢 [CI log] dappPageLoad/pageLoadTime: +23%dappPageLoad/domContentLoaded: +19%dappPageLoad/firstPaint: +11%dappPageLoad/firstContentfulPaint: +11%Bundle size diffs [🚨 Warning! Bundle size has increased!]
Baseline (latest main): ebb43d9 | Date: 6/19/2026 | Pipeline: 27835595549 | Baseline logs 📈 Results compared to the previous 5 runs on main 🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds) 📈 Results compared to the previous 5 runs on main 🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds) 📈 Results compared to the previous 5 runs on main 🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds) 📈 Results compared to the previous 5 runs on mainBuilds ready [83507b3]
⚡ Performance Benchmarks (Total: 🟢 14 pass · 🟡 11 warn · 🔴 0 fail)
Interaction Benchmarks · Samples: 5
Benchmark chrome-webpack firefox-webpack loadNewAccount
[Sentry log · main/release]🟡 [CI log] 🟢 [CI log] load_new_accountconfirmTx
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] bridgeUserActions
[Sentry log · main/release]🟢 [CI log] 🟢 [CI log] bridge_search_tokenloadNewAccount/inp: -30%loadNewAccount/lcp: -11%confirmTx/inp: +30%bridgeUserActions/bridge_load_page: +11%bridgeUserActions/bridge_load_asset_picker: -15%bridgeUserActions/longTaskCount: -17%bridgeUserActions/longTaskMaxDuration: +11%bridgeUserActions/tbt: +21%bridgeUserActions/inp: -22%loadNewAccount/load_new_account: +611%loadNewAccount/total: +611%loadNewAccount/inp: -30%loadNewAccount/fcp: -50%loadNewAccount/lcp: +1102%confirmTx/confirm_tx: +13%confirmTx/longTaskCount: -100%confirmTx/longTaskTotalDuration: -100%confirmTx/longTaskMaxDuration: -100%confirmTx/tbt: -100%confirmTx/total: +13%confirmTx/inp: -17%confirmTx/lcp: +1115%bridgeUserActions/bridge_load_page: +150%bridgeUserActions/bridge_load_asset_picker: +102%bridgeUserActions/bridge_search_token: +191%bridgeUserActions/longTaskCount: -100%bridgeUserActions/longTaskTotalDuration: -100%bridgeUserActions/longTaskMaxDuration: -100%bridgeUserActions/tbt: -100%bridgeUserActions/total: +185%bridgeUserActions/inp: -22%bridgeUserActions/lcp: +1060%loadNewAccount/FCP: p75 1.8sconfirmTx/FCP: p75 1.8sStartup Benchmarks · Samples: 100
Benchmark chrome-webpack firefox-webpack startupStandardHome
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] loadScriptsstartupPowerUserHome
[Sentry log · main/release]🟡 [CI log] 🟡 [CI log] startupPowerUserHome/domInteractive: +10%startupPowerUserHome/initialActions: +14%startupStandardHome/domInteractive: +25%startupStandardHome/backgroundConnect: +14%startupStandardHome/setupStore: +10%startupStandardHome/inp: +50%startupStandardHome/fcp: +25%startupPowerUserHome/backgroundConnect: -32%startupPowerUserHome/setupStore: +19%startupPowerUserHome/INP: p75 504msstartupPowerUserHome/LCP: p75 2.8sUser Journey Benchmarks · Samples: 5 · mock API
Benchmark chrome-webpack firefox-webpack onboardingImportWallet
[Sentry log · main/release]🟢 [CI log] 🟢 [CI log] onboardingNewWallet
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] totalassetDetails
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] solanaAssetDetails
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] importSrpHome
[Sentry log · main/release]🟡 [CI log] 🟡 [CI log] sendTransactions
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] swap
[Sentry log · main/release]🟢 [CI log] 🟢 [CI log] onboardingImportWallet/srpButtonToSrpForm: +12%onboardingImportWallet/confirmSrpToPwForm: +14%onboardingImportWallet/pwFormToMetricsScreen: +20%onboardingImportWallet/doneButtonToHomeScreen: -85%onboardingImportWallet/openAccountMenuToAccountListLoaded: -79%onboardingImportWallet/longTaskCount: -78%onboardingImportWallet/longTaskTotalDuration: -94%onboardingImportWallet/longTaskMaxDuration: -91%onboardingImportWallet/tbt: -98%onboardingImportWallet/total: -83%onboardingNewWallet/agreeButtonToOnboardingSuccess: -12%onboardingNewWallet/doneButtonToAssetList: -21%onboardingNewWallet/longTaskCount: -50%onboardingNewWallet/longTaskTotalDuration: -55%onboardingNewWallet/longTaskMaxDuration: -25%onboardingNewWallet/tbt: -67%onboardingNewWallet/total: -17%solanaAssetDetails/assetClickToPriceChart: -56%solanaAssetDetails/total: -56%solanaAssetDetails/cls: -77%importSrpHome/loginToHomeScreen: -16%importSrpHome/openAccountMenuAfterLogin: +95%importSrpHome/homeAfterImportWithNewWallet: -48%importSrpHome/longTaskCount: -34%importSrpHome/longTaskTotalDuration: -38%importSrpHome/longTaskMaxDuration: -13%importSrpHome/tbt: -41%importSrpHome/total: -42%importSrpHome/inp: +20%importSrpHome/lcp: -64%importSrpHome/cls: -65%sendTransactions/openSendPageFromHome: +11%sendTransactions/inp: -11%sendTransactions/cls: -74%importSrpHome/INP: p75 296msassetDetails/FCP: p75 1.9ssolanaAssetDetails/FCP: p75 1.9simportSrpHome/FCP: p75 1.9ssendTransactions/FCP: p75 1.8sDapp Page Load Benchmarks · Samples: 100
Benchmark chrome-webpack dappPageLoad
[Sentry log · main/release]🟢 [CI log] dappPageLoad/pageLoadTime: +22%dappPageLoad/domContentLoaded: +18%dappPageLoad/firstPaint: +15%dappPageLoad/firstContentfulPaint: +15%Bundle size diffs [🚨 Warning! Bundle size has increased!]
Thanks for the review @itsyoboieltr , I've created issue that I'll handle in different PRs:
- https://github.com/MetaMask/MetaMask-planning/issues/7350
- https://github.com/MetaMask/MetaMask-planning/issues/7351
Quality Gate passed
Issues
11 New issues
0 Accepted issues
Measures
0 Security Hotspots
88.9% Coverage on New Code
0.0% Duplication on New Code
Baseline (latest main): d7394d6 | Date: 6/25/2026 | Pipeline: 28159496066 | Baseline logs 📈 Results compared to the previous 5 runs on main 🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds) 📈 Results compared to the previous 5 runs on main 🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds) 📈 Results compared to the previous 5 runs on main 🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)Builds ready [5797167]
⚡ Performance Benchmarks (Total: 🟢 12 pass · 🟡 12 warn · 🔴 0 fail)
Interaction Benchmarks · Samples: 5
Benchmark chrome-webpack firefox-webpack loadNewAccount
[Sentry log · main/release]🟡 [CI log] 🟢 [CI log] confirmTx
[Sentry log · main/release]🟡 [CI log] 🟢 [CI log] bridgeUserActions
[Sentry log · main/release]🟡 [CI log] 🟢 [CI log] bridge_load_pageloadNewAccount/inp: +13%confirmTx/tbt: +13%confirmTx/inp: -14%bridgeUserActions/bridge_load_page: +13%bridgeUserActions/longTaskCount: -38%bridgeUserActions/longTaskTotalDuration: -22%bridgeUserActions/longTaskMaxDuration: +11%bridgeUserActions/tbt: +23%bridgeUserActions/inp: -22%bridgeUserActions/cls: +25%loadNewAccount/load_new_account: +62%loadNewAccount/total: +62%loadNewAccount/inp: -27%loadNewAccount/fcp: -52%loadNewAccount/lcp: +1073%confirmTx/confirm_tx: +11%confirmTx/longTaskCount: -100%confirmTx/longTaskTotalDuration: -100%confirmTx/longTaskMaxDuration: -100%confirmTx/tbt: -100%confirmTx/total: +11%confirmTx/inp: -22%confirmTx/fcp: -53%confirmTx/lcp: +1096%bridgeUserActions/bridge_load_page: +1897%bridgeUserActions/bridge_load_asset_picker: +58%bridgeUserActions/longTaskCount: -100%bridgeUserActions/longTaskTotalDuration: -100%bridgeUserActions/longTaskMaxDuration: -100%bridgeUserActions/tbt: -100%bridgeUserActions/total: +181%bridgeUserActions/inp: -30%bridgeUserActions/fcp: -52%bridgeUserActions/lcp: +1111%loadNewAccount/FCP: p75 1.8sconfirmTx/FCP: p75 1.8sbridgeUserActions/FCP: p75 1.8sStartup Benchmarks · Samples: 100
Benchmark chrome-webpack firefox-webpack startupStandardHome
[Sentry log · main/release]🟢 [CI log] 🟢 [CI log] startupPowerUserHome
[Sentry log · main/release]– 🟡 [CI log] startupStandardHome/uiStartup: +12%startupStandardHome/load: +12%startupStandardHome/domContentLoaded: +12%startupStandardHome/firstPaint: +19%startupStandardHome/backgroundConnect: +15%startupStandardHome/loadScripts: +12%startupStandardHome/setupStore: +14%startupStandardHome/numNetworkReqs: +13%startupStandardHome/longTaskTotalDuration: +12%startupStandardHome/longTaskMaxDuration: +12%startupStandardHome/tbt: +14%startupStandardHome/fcp: +12%startupStandardHome/lcp: -22%startupStandardHome/domInteractive: +14%startupStandardHome/initialActions: +11%startupStandardHome/fcp: +11%startupPowerUserHome/uiStartup: -27%startupPowerUserHome/load: -23%startupPowerUserHome/domContentLoaded: -23%startupPowerUserHome/domInteractive: -32%startupPowerUserHome/backgroundConnect: -43%startupPowerUserHome/firstReactRender: -26%startupPowerUserHome/loadScripts: -23%startupPowerUserHome/setupStore: -18%startupPowerUserHome/numNetworkReqs: +11%startupPowerUserHome/inp: -31%startupPowerUserHome/fcp: -32%startupPowerUserHome/lcp: -28%startupPowerUserHome/LCP: p75 2.6sUser Journey Benchmarks · Samples: 5 · mock API
Benchmark chrome-webpack firefox-webpack onboardingImportWallet
[Sentry log · main/release]🟢 [CI log] 🟢 [CI log] onboardingNewWallet
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] totalassetDetails
[Sentry log · main/release]🟡 [CI log] 🟡 [CI log] solanaAssetDetails
[Sentry log · main/release]🟢 [CI log] 🟡 [CI log] importSrpHome
[Sentry log · main/release]🟡 [CI log] 🟡 [CI log] sendTransactions
[Sentry log · main/release]🟡 [CI log] 🟡 [CI log] swap
[Sentry log · main/release]🟢 [CI log] 🟢 [CI log] onboardingImportWallet/srpButtonToSrpForm: +12%onboardingImportWallet/confirmSrpToPwForm: +11%onboardingImportWallet/pwFormToMetricsScreen: +15%onboardingImportWallet/metricsToWalletReadyScreen: +16%onboardingImportWallet/doneButtonToHomeScreen: -79%onboardingImportWallet/openAccountMenuToAccountListLoaded: -89%onboardingImportWallet/longTaskCount: -76%onboardingImportWallet/longTaskTotalDuration: -91%onboardingImportWallet/longTaskMaxDuration: -87%onboardingImportWallet/tbt: -95%onboardingImportWallet/total: -80%onboardingNewWallet/doneButtonToAssetList: -38%onboardingNewWallet/longTaskCount: -58%onboardingNewWallet/longTaskTotalDuration: -56%onboardingNewWallet/longTaskMaxDuration: -27%onboardingNewWallet/tbt: -57%onboardingNewWallet/total: -33%solanaAssetDetails/assetClickToPriceChart: -54%solanaAssetDetails/total: -54%solanaAssetDetails/inp: +38%solanaAssetDetails/cls: +41%importSrpHome/openAccountMenuAfterLogin: +19%importSrpHome/homeAfterImportWithNewWallet: -44%importSrpHome/longTaskTotalDuration: -16%importSrpHome/longTaskMaxDuration: -11%importSrpHome/tbt: -16%importSrpHome/total: -35%importSrpHome/inp: -23%importSrpHome/fcp: +30%importSrpHome/cls: -67%sendTransactions/openSendPageFromHome: +12%sendTransactions/selectTokenToSendFormLoaded: -44%sendTransactions/longTaskCount: -100%sendTransactions/longTaskTotalDuration: -100%sendTransactions/longTaskMaxDuration: -100%sendTransactions/tbt: -100%sendTransactions/inp: -24%sendTransactions/cls: -89%assetDetails/FCP: p75 1.8simportSrpHome/FCP: p75 2.1ssendTransactions/FCP: p75 1.8sassetDetails/FCP: p75 1.8ssolanaAssetDetails/FCP: p75 1.8simportSrpHome/FCP: p75 1.8ssendTransactions/FCP: p75 1.9sDapp Page Load Benchmarks · Samples: 100
Benchmark chrome-webpack dappPageLoad
[Sentry log · main/release]🟢 [CI log] Bundle size diffs [🚨 Warning! Bundle size has increased!]