refactor(analytics): migrate accounts hardware wallet events#43895
Conversation
✨ Files requiring CODEOWNER review ✨🔑 @MetaMask/accounts-engineers (8 files, +163 -125)
✅ @MetaMask/confirmations (1 files, +16 -4)
🔄 @MetaMask/swaps-engineers (2 files, +19 -5)
|
Builds ready [f0e5f34]
⚡ Performance Benchmarks (Total: 🟢 13 pass · 🟡 11 warn · 🔴 0 fail)
Bundle size diffs
|
f0e5f34 to
666bb7a
Compare
|
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. |
Builds ready [666bb7a]
⚡ Performance Benchmarks (Total: 🟢 17 pass · 🟡 7 warn · 🔴 0 fail)
Bundle size diffs
|
666bb7a to
2e585bd
Compare
2e585bd to
9ee224b
Compare
9ee224b to
25de312
Compare
25de312 to
e5e573f
Compare
e5e573f to
1cdc159
Compare
Builds ready [1cdc159] [reused from 2e585bd]
⚡ Performance Benchmarks (Total: 🟢 12 pass · 🟡 5 warn · 🔴 0 fail)
Bundle sizes
|
1cdc159 to
855f895
Compare
855f895 to
05305fe
Compare
Drop dual-path MetaMetricsContext compatibility and use the createEventBuilder-based API only, matching other migration PRs. Co-authored-by: Cursor <cursoragent@cursor.com>
Match the store/actions alias pattern so webpack resolves relative useAnalytics imports to the Storybook mock at each import depth. Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve useHardwareWalletMetrics.test.tsx conflict by keeping the useAnalytics mock instead of the MetaMetricsContext wrapper from main. Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [8dd5a15]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 10 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Fix Test lint TypeScript error after trackHardwareWalletRecoveryConnectCtaClicked now expects AnalyticsEvent trackEvent from useAnalytics. Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [32e9bc2]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 9 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
…modal Remove static createEventBuilder import and pass hook-provided builder through trackHwRecoveryEvent and callback dependency arrays. Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [a4b3e3a]
⚡ Performance Benchmarks (Total: 🟢 16 pass · 🟡 7 warn · 🔴 1 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
ccharly
left a comment
There was a problem hiding this comment.
LGTM for accounts:
ui/contexts/hardware-wallets/useHardwareWalletMetrics.test.tsx
ui/contexts/hardware-wallets/useHardwareWalletMetrics.ts
ui/pages/create-account/connect-hardware/account-list.tsx
ui/pages/create-account/connect-hardware/index.test.tsx
ui/pages/create-account/connect-hardware/index.tsx
ui/pages/create-account/connect-hardware/select-hardware.stories.tsx
ui/pages/create-account/connect-hardware/select-hardware.test.tsx
ui/pages/create-account/connect-hardware/select-hardware.tsx
…ardware Keep all useAnalytics Storybook aliases from both sides and use main's typed useAnalytics mock. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Builds ready [f9ca58f]
⚡ Performance Benchmarks (Total: 🟢 18 pass · 🟡 6 warn · 🔴 1 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|



Description
Sub-PR of umbrella tracker #43885.
Migrates MetaMetrics
trackEventcall sites in this CODEOWNERS domain tocreateEventBuilder+trackEventviauseAnalytics()(UI) orapp/scripts/controllers/analytics(background).Dependency note: Can merge in parallel with other domain PRs after PR1.
Files in this PR: 25
Changelog
CHANGELOG entry: null
Related issues
Part of analytics migration umbrella: #43885
Manual testing steps
yarn start.Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches many hardware-wallet and confirmation analytics paths; event shape changes (name vs event, category in properties) could affect Segment payloads if downstream consumers assumed the old MetaMetrics object shape.
Overview
Migrates accounts / hardware wallet MetaMetrics call sites from
MetaMetricsContexttouseAnalytics()withcreateEventBuilder→trackEvent, aligned with the umbrella analytics migration.Hardware recovery & QR flows (
HardwareWalletErrorModal,BaseQrReader, QR utils) now build events via the shared builder instead of plain{ category, event, properties }objects; helpers likebuildQrCameraRecoveryTrackEventArgsreturnAnalyticsEvent(name+properties, withcategoryon properties). Connect hardware pages and inline recovery CTAs (bridge footer, confirmation reconnect,trackHardwareWalletRecoveryConnectCtaClicked) follow the same pattern; connect-CTA tracking uses try/catch instead of.catch()on a promise.Tests & Storybook drop
MetaMetricsContextwrappers andjest.mockuseAnalytics(often with realcreateEventBuilder); assertions switch fromcall[0].eventtocall[0].name..storybook/main.jsadds/adjusts webpack aliases so Storybook resolvesuseAnalyticsmocks.Reviewed by Cursor Bugbot for commit f9ca58f. Bugbot is set up for automated code reviews on this repo. Configure here.