refactor(analytics): migrate home activity and wallet overview events#43899
Conversation
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/core-extension-ux (9 files, +139 -126)
|
|
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 [a27042a]
⚡ Performance Benchmarks (Total: 🟢 11 pass · 🟡 13 warn · 🔴 0 fail)
Bundle size diffs [🚀 Bundle size reduced!]
|
a27042a to
4769b79
Compare
Builds ready [4769b79]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 9 warn · 🔴 0 fail)
Bundle size diffs [🚀 Bundle size reduced!]
|
4769b79 to
7937385
Compare
7937385 to
d717c61
Compare
Builds ready [d717c61] [reused from 7937385]
⚡ Performance Benchmarks (Total: 🟢 11 pass · 🟡 6 warn · 🔴 0 fail)
Bundle sizes
|
d717c61 to
a3af07d
Compare
a3af07d to
9c09bc8
Compare
9c09bc8 to
6bf75e4
Compare
Builds ready [6bf75e4] [reused from 7937385]
⚡ Performance Benchmarks (Total: 🟢 11 pass · 🟡 6 warn · 🔴 0 fail)
Bundle sizes
|
6bf75e4 to
067ea23
Compare
067ea23 to
f0a97bb
Compare
Builds ready [e71f8b2]
⚡ Performance Benchmarks (Total: 🟢 14 pass · 🟡 9 warn · 🔴 1 fail)
Bundle size diffs
|
There was a problem hiding this comment.
Pull request overview
Migrates Home/Activity/Wallet Overview MetaMetrics event tracking away from MetaMetricsContext.trackEvent to the new useAnalytics() + createEventBuilder().build() flow (and updates the associated unit tests/mocks), aligning this domain with the analytics migration umbrella (#43885).
Changes:
- Replaced legacy
trackEvent({ event, category, properties }, options)call sites withcreateEventBuilder(event).addCategory(...).addProperties(...).build()+trackEvent(builtEvent). - Updated tests to mock
useAnalytics()instead of wiringMetaMetricsContext. - Made
txDataSelectorresilient whenconfirmTransactionis absent (optional chaining).
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/components/app/balance-empty-state/balance-empty-state.tsx | Migrates “empty buy banner” tracking to useAnalytics + builder. |
| ui/components/app/transaction-activity-empty-state/transaction-activity-empty-state.tsx | Migrates “activity empty state” add-funds tracking to builder. |
| ui/components/app/transaction-list-item-details/transaction-list-item-details.container.js | Wraps legacy event payloads into builder-built events via useAnalytics. |
| ui/components/app/transaction-list-item/transaction-list-item.component.js | Migrates activity details open/close tracking to builder events. |
| ui/components/app/transaction-list-item/transaction-list-item.component.test.js | Updates metrics assertions/mocking for builder-shaped events. |
| ui/components/app/wallet-overview/coin-buttons.tsx | Migrates wallet overview button metrics (send/buy/receive/batch sell) to builder. |
| ui/components/app/wallet-overview/coin-overview.tsx | Migrates portfolio/receive tracking to builder events. |
| ui/components/app/wallet-overview/eth-overview.test.js | Updates tests to mock useAnalytics and assert builder-shaped payloads. |
| ui/components/app/wallet-overview/non-evm-overview.test.tsx | Updates tests to mock useAnalytics and assert builder-shaped payloads. |
| ui/hooks/usePendingTransactionCancelSpeedUpHandlers.ts | Migrates cancel/speed-up click tracking to builder events. |
| ui/pages/activity/activity-list.tsx | Migrates activity details opened/closed tracking to builder events. |
| ui/pages/activity/useActivityScreenOpened.test.ts | Updates hook test to mock useAnalytics and assert built event shape. |
| ui/pages/activity/useActivityScreenOpened.ts | Migrates “ActivityScreenOpened” tracking to builder events. |
| ui/pages/home/beta-and-flask-home-footer.component.tsx | Migrates footer support-link tracking to builder events + segment page context. |
| ui/pages/home/home.component.test.tsx | Updates tests to mock useAnalytics/useSegmentContext rather than MetaMetricsContext. |
| ui/pages/home/home.component.tsx | Migrates home tracking to builder events and threads segment page title for legacy property inclusion. |
| ui/selectors/confirm-transaction.js | Makes txDataSelector null-safe with optional chaining. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e71f8b2. Configure here.
Pass excludeMetaMetricsId: false via builder.build() so send-flow events are not forced to anonymous handling after the migration. Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [f5ce3ff]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 8 warn · 🔴 1 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Keep main's refactored functional Home component and apply the PR's useAnalytics migration for SupportLinkClicked tracking. Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [4447a7e]
⚡ Performance Benchmarks (Total: 🟢 16 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Resolve conflict in non-evm-overview.test.tsx by keeping useAnalytics mock pattern and main's simplified store setup. Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [8f0ef50]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 9 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
…t-item test The merge left two useAnalytics mocks where the second override used a plain jest.fn(), so mockTrackEvent was never called in CI. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Builds ready [5594606]
⚡ Performance Benchmarks (Total: 🟢 12 pass · 🟡 11 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: 26
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
Low Risk
Analytics-only refactor with no transaction or auth logic changes; main risk is mis-fired or dropped metrics if builder mapping diverges from prior payloads.
Overview
Replaces
MetaMetricsContextwithuseAnalytics()andcreateEventBuilder(...).build()for navigation and activity metrics across home, wallet overview, empty states, activity list, and pending-tx cancel/speed-up handlers. Event names and property payloads stay the same; only the wiring and built-event shape change.Support link clicks on home and beta/flask footer now pull page title from
useSegmentContext()into event properties instead of usingcontextPropsIntoEventProperties.transaction-list-item-detailskeeps a smalltrackLegacyEventadapter so the connected details view still receives a legacy-styletrackEventcallback.Unit tests drop
MetaMetricsContext.Providerwrappers, mockuseAnalytics, and assert the new built events (name,properties.category,sensitiveProperties).Reviewed by Cursor Bugbot for commit 5594606. Bugbot is set up for automated code reviews on this repo. Configure here.