Summary
Remove the legacy MetaMetrics analytics system (app/core/Analytics/, useMetrics hook, withAnalyticsAwareness HOC, MetricsEventBuilder) and consolidate all analytics infrastructure into app/util/analytics/ + useAnalytics hook. Also rename the deprecated addTraitsToUser method to identify across the codebase.
The work is split into 22 PRs across 7 phases (A, C, D, E, N), ordered by dependency and scoped to minimize required reviewers (at most 1 additional code owner per PR beyond @MetaMask/mobile-platform). Phases E2–F2 were replaced by a 9-PR batch (N1–N9).
Known gap: MetaMetrics.events.ts is excluded from this issue (separate large migration).
Phase A: Infrastructure (platform-only, 3 PRs)
Foundation changes that enable all subsequent migrations. No consumer files touched.
PR A0 — Add identify() alias ✅
Add identify method to useAnalytics hook types + implementation, keeping addTraitsToUser as deprecated alias. Enables incremental consumer rename in later phases.
| CO |
@MetaMask/mobile-platform |
| Files |
useAnalytics.types.ts, useAnalytics.ts, __mocks__/useAnalytics.ts, useAnalytics.test.tsx |
| Issue |
#26808 |
PR A1 — Move infrastructure files via git mv ✅
Move SegmentPersistor, PrivacySegmentPlugin, constants, whenEngineReady, snapKeyring helper from app/core/Analytics/ to app/util/analytics/. Rename files and exported constants. Create missing whenEngineReady.test.ts.
| CO |
@MetaMask/mobile-platform |
| Files |
~8 moved files + ~4 import updates (platform-adapter.ts, analytics.ts, OAuthService.ts, SnapKeyring.ts) |
| Issue |
#26810 |
PR A2 — Split and relocate types ✅
Split MetaMetrics.types.ts into analytics.types.ts (transitional types, domain types) and analyticsDataDeletion.types.ts (data deletion types). Keep re-exports from old path for backward compat.
| CO |
@MetaMask/mobile-platform |
| Files |
~2 new type files + ~10 import path updates in app/util/analytics/, app/components/hooks/useAnalytics/, app/core/Engine/ |
| Issue |
#26811 |
Phase C: useMetrics → useAnalytics migration — platform/unowned files (5 PRs, ~63 files)
Migrate all useMetrics consumers owned by @MetaMask/mobile-platform or with no specific CODEOWNER. Each PR absorbs 1 additional team CO where files follow the same migration pattern.
PR C1 — HW Wallet + Wallet Recovery + Onboarding + web3auth (~21 files) ✅
| CO |
@MetaMask/mobile-platform + @MetaMask/web3auth (1 file) |
| Files |
LedgerSelectAccount, SelectHardware, LedgerConnect (2), ConnectQRHardware (2), AnimatedQRScanner, QRSigningDetails, LedgerConfirmationModal (2), WalletRestored (2), WalletResetNeeded, RestoreWallet, ImportNewSecretRecoveryPhrase (2), OnboardingSecuritySettings, ExperienceEnhancerModal, OnboardingGeneralSettings, NftGrid (2) |
| Issue |
#26812 |
PR C2 — Network + Accounts + Permissions + accounts-engineers (~22 files) ✅
| CO |
@MetaMask/mobile-platform + @MetaMask/accounts-engineers (8 files) |
| Files |
MultiRpcModal, NetworkMultiSelector (2), NetworkManager, ManageNetworks, NetworkModal, DeprecatedNetworkModal, AccountConnect, AddAccountActions (2), AccountActions, AccountRightButton, AccountPermissions, NetworkPermissionsConnected, PermissionApproval (2), BackupAndSyncToggle (2), BackupAndSyncFeaturesToggles (2), TurnOnBackupAndSync (2), MultichainAccountConnect, MultichainAddWalletActions |
| Issue |
#26813 |
PR C3 — Security + Wallet UI + Nav + Settings + HOC removal + swaps (~17 files) ✅
| CO |
@MetaMask/mobile-platform + @MetaMask/swaps-engineers (1 file) |
| Files |
HOC removal: AdvancedSettings, GeneralSettings, ProtectYourWalletModal + delete withAnalyticsAwareness.tsx, .types.ts, .test.tsx · Security: ProtectWalletMandatoryModal, BackupAlert, ScreenshotDeterrent · Wallet UI: BalanceEmptyState (2), ErrorBoundary, Carousel · Nav: TabBar, useConnectionHandler (2) · Settings: OptinMetrics · App Updates: UpdateNeeded, OTAUpdatesModal (2) · Swaps: useGoToPortfolioBridge.ts |
| Issue |
#26814 |
PR C4 — Simulation + NFT + Hooks + Misc + perps (~21 files) ✅
| CO |
@MetaMask/mobile-platform + @MetaMask/perps (1 file) |
| Files |
useSimulationMetrics (2), ShowDisplayNFTMediaSheet (2), FundActionMenu (2), useNftDetection (2), useBuildPortfolioUrl (2), usePromptSeedlessRelogin (2), DeleteWalletModal, BasicFunctionalityModal, TradeTabBarItem, DeepLinkModal.test, AccountBackupStep1 (2), TokenListItem.test.tsx, FeatureFlagOverride.test.tsx, NetworksManagementView.test.tsx, PerpsTransactionItem.test.tsx |
| Issue |
#26815 |
PR C5 — Predict (~2 files) ✅
| CO |
@MetaMask/mobile-platform + @MetaMask/predict (2 files) |
| Files |
PredictGTMModal.tsx, PredictGTMModal.test.tsx |
| Issue |
to be created |
Phase D: useMetrics → useAnalytics migration — team-specific files (4 PRs, ~51 files)
Files fully owned by a single team. Each PR has its own team reviewer(s).
PR D1 — Rewards (~31 files) ✅
| CO |
@MetaMask/rewards |
| Files |
Views (6): RewardsDashboard (2), RewardsReferralView (2), RewardsSettingsView (2) · Components (15): OnboardingIntroStep (2), OnboardingStep3 + test, ReferralDetails (2), RewardsUpdateRequired (2), RewardsClaimBottomSheetModal, ActiveBoosts, WaysToEarn (2), EndOfSeasonClaimBottomSheet (2), RewardSettingsAccountGroupList.test.tsx · Hooks (10): useLinkAccountAddress (2), useLinkAccountGroup (2), useOptIn (2), useOptout (2), useRewardOptinSummary (2) |
| Issue |
#26816 |
PR D2 — Earn/Stake (~14 files) ✅
| CO |
@MetaMask/metamask-earn |
| Files |
Stake source (10): GasImpactModal, ClaimBanner.tsx, StakingCta.tsx, FooterButtonGroup.tsx, RewardsCard.tsx, UnstakeTimeCard.tsx, StakingEarnings, StakeConfirmationView.tsx, UnstakeConfirmationView.tsx, tooltipMetaMetricsUtils.ts · Stake tests (2): GasImpactModal.test.tsx, FooterButtonGroup.test.tsx · Earn tests (2): EarnTokenList.test.tsx, TronStakingLearnMoreModal.test.tsx |
| Issue |
#26817 |
PR D4 — Notifications + Mobile Core UX (~4 files) ✅
| CO |
@MetaMask/notifications + @MetaMask/mobile-core-ux |
| Files |
MainNotificationToggle.hooks.test.tsx, Notification/List/index.tsx, Notification/List/index.test.tsx, MarketInsightsView.tsx |
| Issue |
#26818 |
PR D5 — Ramps MetaMetrics.getInstance() → analytics.trackEvent (~2 files) ✅
| CO |
@MetaMask/ramp |
| Files |
app/core/Engine/controllers/ramps-controller/event-handlers/analytics.ts + test |
| Issue |
#28324 |
Blocks F1: D5 must merge before MetaMetrics.ts can be deleted.
Phase E: addTraitsToUser → identify rename + missed useMetrics migrations (4 PRs)
Files already on useAnalytics that still call .addTraitsToUser, plus 3 useMetrics consumers that were missed in phases C/D. Requires A0 to land first. All 4 PRs must merge before F1 can land.
PR E1 — Rename in mobile-core-ux files + migrate AccountActions + stale mock cleanup 🔄 #30473
| CO |
@MetaMask/mobile-core-ux |
| Files |
BlockaidSettings.tsx, DisplayNFTMediaSettings, BatchAccountBalanceSettings, AutoDetectTokensSettings, useNetworkOperations.ts, useAddPopularNetwork.ts, NetworkManager/index.tsx, AccountActions.tsx (useMetrics→useAnalytics), AccountsMenu.test.tsx (stale mock cleanup) |
| Issue |
#26821 |
Phase E (continued) + Phase F: completed via new PRs
PR E2, E3, E4, F1, and F2 were cancelled and replaced by 9 scoped PRs executed in a single batch.
All 7 consumer-migration PRs are already merged; the 2 deletion PRs are open and awaiting merge.
PR N1 — Migrate unowned files ✅
Migrate useMetrics→useAnalytics, MetricsEventBuilder→AnalyticsEventBuilder,
addTraitsToUser→identify across unowned/platform files.
|
|
| PR |
#31249 |
| Status |
Merged |
| CO |
@MetaMask/mobile-platform |
PR N2 — Migrate web3auth/onboarding files ✅
Migrate MetricsEventBuilder→AnalyticsEventBuilder and useMetrics→useAnalytics in web3auth and onboarding files.
|
|
| PR |
#31250 |
| Status |
Merged |
| CO |
@MetaMask/web3auth |
PR N3 — Migrate assets files ✅
Migrate useMetrics→useAnalytics and MetricsEventBuilder→AnalyticsEventBuilder in assets files.
|
|
| PR |
#31251 |
| Status |
Merged |
| CO |
@MetaMask/metamask-assets |
PR N4 — Migrate transaction controller metrics (confirmations) ✅
Migrate MetricsEventBuilder→AnalyticsEventBuilder in transaction controller event-handler metrics.
|
|
| PR |
#31252 |
| Status |
Merged |
| CO |
@MetaMask/mobile-platform |
PR N5 — Remove stale MetricsEventBuilder mock (core-ux) ✅
Remove stale MetricsEventBuilder mock from AccountsMenu test.
|
|
| PR |
#31253 |
| Status |
Merged |
| CO |
@MetaMask/mobile-core-ux |
PR N6 — Migrate MetricsEventBuilder→AnalyticsEventBuilder in TransactionField test (engagement) ✅
|
|
| PR |
#31254 |
| Status |
Merged |
| CO |
@MetaMask/metamask-earn |
PR N7 — Rename addTraitsToUser→identify in EmptyStateCta test (earn) ✅
|
|
| PR |
#31255 |
| Status |
Merged |
| CO |
@MetaMask/metamask-earn |
PR N8 — Delete legacy analytics symbols + remove saveDataRecording chain 🔄
Delete useMetrics hook, MetaMetrics.ts, MetricsEventBuilder, withAnalyticsAwareness HOC,
convert MetaMetrics.types.ts to re-export barrel, and remove the saveDataRecording persistence chain.
|
|
| PR |
#31256 |
| Status |
Open — awaiting upstream PRs to merge |
| CO |
@MetaMask/mobile-platform |
PR N9 — Remove saveDataRecording field/method from AnalyticsEventBuilder 🔄
Remove saveDataRecording from AnalyticsTrackingEvent interface and setSaveDataRecording from
AnalyticsEventBuilderInterface; sweep all mocks. Blocked on N8 merging first.
|
|
| PR |
#31257 |
| Status |
Open — blocked on N8 |
| CO |
@MetaMask/mobile-platform |
Overall Summary
| Phase |
PRs |
Files |
Scope |
Code Owners |
| A (Infra) |
3 |
~24 |
identify alias + move files + split types |
platform / none |
| C (Migrate) |
5 |
~63 |
useMetrics → useAnalytics + HOC removal |
platform + 1 extra CO each |
| D (Teams) |
4 |
~51 |
useMetrics → useAnalytics in team-owned code |
1–2 teams each |
| N (Batch cleanup) |
9 |
~files |
consumer migrations + legacy deletion + saveDataRecording removal |
platform + 1 team each |
| Total |
22 |
~182 |
|
|
Dependency Graph
graph LR
A0[A0: identify alias] --> C["C1..C5\nplatform migrations"]
A0 --> D["D1..D5\nteam migrations"]
A0 --> E1[E1: core-ux rename]
A1[A1: move files] --> N8
A2[A2: split types] --> N8
C --> N1 & N2 & N3 & N4 & N5 & N6 & N7
D --> N1 & N2 & N3 & N4 & N5 & N6 & N7
E1 --> N8[N8: delete legacy symbols]
N1["N1: unowned ✅"] --> N8
N2["N2: web3auth ✅"] --> N8
N3["N3: assets ✅"] --> N8
N4["N4: confirmations ✅"] --> N8
N5["N5: core-ux mock ✅"] --> N8
N6["N6: engagement ✅"] --> N8
N7["N7: earn ✅"] --> N8
N8 --> N9[N9: saveDataRecording removal]
Deferred (not in this issue)
- Move
events/ subdirectory — blocked on MetaMetrics.events.ts migration
- Remove backward-compat types (
IMetaMetricsEvent, ITrackingEvent, isTrackingEvent) — blocked on MetaMetrics.events.ts migration
Acceptance Criteria
- Zero imports from
app/components/hooks/useMetrics/
- Zero imports from
app/core/Analytics/MetaMetrics.ts
- Zero calls to
.addTraitsToUser (all renamed to .identify)
app/components/hooks/useMetrics/ directory deleted
withAnalyticsAwareness HOC deleted
MetricsEventBuilder deleted
- Backward-compat re-exports in
app/core/Analytics/MetaMetrics.types.ts can remain until MetaMetrics.events.ts is migrated
Summary
Remove the legacy MetaMetrics analytics system (
app/core/Analytics/,useMetricshook,withAnalyticsAwarenessHOC,MetricsEventBuilder) and consolidate all analytics infrastructure intoapp/util/analytics/+useAnalyticshook. Also rename the deprecatedaddTraitsToUsermethod toidentifyacross the codebase.The work is split into 22 PRs across 7 phases (A, C, D, E, N), ordered by dependency and scoped to minimize required reviewers (at most 1 additional code owner per PR beyond
@MetaMask/mobile-platform). Phases E2–F2 were replaced by a 9-PR batch (N1–N9).Known gap:
MetaMetrics.events.tsis excluded from this issue (separate large migration).Phase A: Infrastructure (platform-only, 3 PRs)
Foundation changes that enable all subsequent migrations. No consumer files touched.
PR A0 — Add
identify()alias ✅Add
identifymethod touseAnalyticshook types + implementation, keepingaddTraitsToUseras deprecated alias. Enables incremental consumer rename in later phases.PR A1 — Move infrastructure files via
git mv✅Move
SegmentPersistor,PrivacySegmentPlugin,constants,whenEngineReady,snapKeyringhelper fromapp/core/Analytics/toapp/util/analytics/. Rename files and exported constants. Create missingwhenEngineReady.test.ts.PR A2 — Split and relocate types ✅
Split
MetaMetrics.types.tsintoanalytics.types.ts(transitional types, domain types) andanalyticsDataDeletion.types.ts(data deletion types). Keep re-exports from old path for backward compat.Phase C:
useMetrics→useAnalyticsmigration — platform/unowned files (5 PRs, ~63 files)Migrate all
useMetricsconsumers owned by@MetaMask/mobile-platformor with no specific CODEOWNER. Each PR absorbs 1 additional team CO where files follow the same migration pattern.PR C1 — HW Wallet + Wallet Recovery + Onboarding + web3auth (~21 files) ✅
PR C2 — Network + Accounts + Permissions + accounts-engineers (~22 files) ✅
PR C3 — Security + Wallet UI + Nav + Settings + HOC removal + swaps (~17 files) ✅
PR C4 — Simulation + NFT + Hooks + Misc + perps (~21 files) ✅
PR C5 — Predict (~2 files) ✅
Phase D:
useMetrics→useAnalyticsmigration — team-specific files (4 PRs, ~51 files)Files fully owned by a single team. Each PR has its own team reviewer(s).
PR D1 — Rewards (~31 files) ✅
PR D2 — Earn/Stake (~14 files) ✅
PR D4 — Notifications + Mobile Core UX (~4 files) ✅
PR D5 — Ramps
MetaMetrics.getInstance()→analytics.trackEvent(~2 files) ✅Phase E:
addTraitsToUser→identifyrename + misseduseMetricsmigrations (4 PRs)Files already on
useAnalyticsthat still call.addTraitsToUser, plus 3useMetricsconsumers that were missed in phases C/D. Requires A0 to land first. All 4 PRs must merge before F1 can land.PR E1 — Rename in mobile-core-ux files + migrate AccountActions + stale mock cleanup 🔄 #30473
Phase E (continued) + Phase F: completed via new PRs
PR N1 — Migrate unowned files ✅
Migrate useMetrics→useAnalytics, MetricsEventBuilder→AnalyticsEventBuilder,
addTraitsToUser→identify across unowned/platform files.
PR N2 — Migrate web3auth/onboarding files ✅
Migrate MetricsEventBuilder→AnalyticsEventBuilder and useMetrics→useAnalytics in web3auth and onboarding files.
PR N3 — Migrate assets files ✅
Migrate useMetrics→useAnalytics and MetricsEventBuilder→AnalyticsEventBuilder in assets files.
PR N4 — Migrate transaction controller metrics (confirmations) ✅
Migrate MetricsEventBuilder→AnalyticsEventBuilder in transaction controller event-handler metrics.
PR N5 — Remove stale MetricsEventBuilder mock (core-ux) ✅
Remove stale MetricsEventBuilder mock from AccountsMenu test.
PR N6 — Migrate MetricsEventBuilder→AnalyticsEventBuilder in TransactionField test (engagement) ✅
PR N7 — Rename addTraitsToUser→identify in EmptyStateCta test (earn) ✅
PR N8 — Delete legacy analytics symbols + remove saveDataRecording chain 🔄
Delete useMetrics hook, MetaMetrics.ts, MetricsEventBuilder, withAnalyticsAwareness HOC,
convert MetaMetrics.types.ts to re-export barrel, and remove the saveDataRecording persistence chain.
PR N9 — Remove saveDataRecording field/method from AnalyticsEventBuilder 🔄
Remove saveDataRecording from AnalyticsTrackingEvent interface and setSaveDataRecording from
AnalyticsEventBuilderInterface; sweep all mocks. Blocked on N8 merging first.
Overall Summary
Dependency Graph
Deferred (not in this issue)
events/subdirectory — blocked onMetaMetrics.events.tsmigrationIMetaMetricsEvent,ITrackingEvent,isTrackingEvent) — blocked onMetaMetrics.events.tsmigrationAcceptance Criteria
app/components/hooks/useMetrics/app/core/Analytics/MetaMetrics.ts.addTraitsToUser(all renamed to.identify)app/components/hooks/useMetrics/directory deletedwithAnalyticsAwarenessHOC deletedMetricsEventBuilderdeletedapp/core/Analytics/MetaMetrics.types.tscan remain untilMetaMetrics.events.tsis migrated