refactor(analytics): migrate orphan UX contacts and chrome events#44374
Conversation
Part of analytics migration umbrella #43885 (15a · UX contacts + chrome).
|
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/accounts-engineers (2 files, +68 -63)
👨🔧 @MetaMask/core-extension-ux (2 files, +68 -63)
👨🔧 @MetaMask/product-safety (1 files, +11 -12)
|
Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [c50fd4e]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 7 warn · 🔴 2 fail)
Bundle sizes
|
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
This PR continues the analytics migration by replacing remaining legacy MetaMetricsContext.trackEvent usage in UX “contacts + chrome” surfaces with the newer useAnalytics() hook and createEventBuilder event shape, and updates unit tests accordingly.
Changes:
- Migrated multiple UI components/pages from
MetaMetricsContexttouseAnalytics()+createEventBuilder(...)...build(). - Updated event payload construction to the new
{ name, properties, sensitiveProperties }format. - Refactored related Jest tests to mock
useAnalyticsand assert the new event shape.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/pages/contacts/contacts-list-page.tsx | Migrates contacts list page view/click events to useAnalytics + builder. |
| ui/pages/contacts/contact-details-page.tsx | Migrates contact details view/edit/delete events to builder format. |
| ui/pages/contacts/components/edit-contact-form.tsx | Migrates “contact updated” tracking to builder format. |
| ui/pages/contacts/components/add-contact-form.tsx | Migrates QR scanner + “contact added” tracking to builder format. |
| ui/components/ui/qr-code-view/qr-code-view.tsx | Migrates “public address copied” tracking to builder format. |
| ui/components/multichain/account-overview/carousel.tsx | Migrates banner display/select/dismiss tracking to builder format. |
| ui/components/multichain/account-overview/carousel.test.tsx | Updates carousel tests to mock useAnalytics + assert built event shape. |
| ui/components/app/update-modal/update-modal.tsx | Migrates force-upgrade modal tracking to builder format. |
| ui/components/app/update-modal/update-modal.test.tsx | Updates update-modal tests for useAnalytics + built event shape. |
| ui/components/app/terms-of-use-popup/terms-of-use-popup.js | Migrates terms-of-use “shown” tracking to builder format. |
| ui/components/app/terms-of-use-popup/terms-of-use-popup-container.tsx | Migrates terms-of-use “accepted” tracking to builder format. |
| ui/components/app/product-safety/scam-questionnaire/useScamQuestionnaireMetrics.ts | Migrates scam questionnaire metrics helper to use builder. |
| ui/components/app/permission-page-container/permission-page-container.component.js | Adapts permission page to accept legacy payloads and forward via builder. |
| ui/components/app/password-outdated-modal/password-outdated-modal.tsx | Migrates password-outdated modal “viewed” tracking to builder format. |
| ui/components/app/password-outdated-modal/password-outdated-modal.test.tsx | Updates password-outdated modal tests for useAnalytics + built event shape. |
| ui/components/app/multichain-transaction-details-modal/multichain-transaction-details-modal.tsx | Migrates external-link click tracking to builder format. |
| ui/components/app/multichain-transaction-details-modal/multichain-transaction-details-modal.test.tsx | Updates multichain transaction details modal tests for useAnalytics. |
| ui/components/app/modals/pna25-modal/pna25-modal.tsx | Migrates PNA25 notice tracking to builder format. |
| ui/components/app/modals/pna25-modal/pna25-modal.test.tsx | Updates PNA25 modal tests for useAnalytics + built event shape. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ckEvent Add hasTrackedView-style ref guards so mount and page-view metrics do not re-fire when useAnalytics trackEvent identity changes during metrics init. Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [c1f3db5]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 8 warn · 🔴 0 fail)
Bundle sizes
|
Builds ready [c1f3db5]
⚡ Performance Benchmarks (Total: 🟢 16 pass · 🟡 8 warn · 🔴 0 fail)
Bundle sizes
|
ccharly
left a comment
There was a problem hiding this comment.
LGTM for accounts:
ui/components/multichain/account-overview/carousel.test.tsx
ui/components/multichain/account-overview/carousel.tsx
…s-chrome Co-authored-by: Cursor <cursoragent@cursor.com>
9a011e4
|
Builds ready [9a011e4]
⚡ Performance Benchmarks (Total: 🟢 16 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|


Description
Migrates remaining legacy
MetaMetricsContext.trackEvent/trackMetaMetricsEventcall sites in the UX (contacts, modals, carousel, permission page) domain touseAnalytics()+createEventBuilder(ortrackAnalyticsEventfor Redux thunks).Part of umbrella tracker #43885 (15a · UX contacts + chrome).
Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
yarn start).Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Mechanical analytics API migration with test coverage updates; contact events still use sensitive properties for addresses, and view dedupe refs reduce duplicate metrics rather than changing product behavior.
Overview
This PR finishes migrating UX “chrome” surfaces (contacts, modals, carousel, permission connect, QR copy, scam questionnaire) from legacy
MetaMetricsContext.trackEventtouseAnalytics()withcreateEventBuilder(...).build(), aligning payloads with the shared analytics shape (name,properties,sensitiveProperties).Production code swaps
useContext(MetaMetricsContext)for the hook and rebuilds each event via the builder (categories, properties, and contact-relatedaddSensitivePropertieswhere addresses are sent).PermissionPageContainerwraps the hook in a small adapter so the base component still receives a legacy-shapedtrackEventcallback. Several mount/view effects gain refs so impressions are not double-fired when dependencies re-run (password outdated, terms of use, force-upgrade modal, contacts list/details).Tests drop
MetaMetricsContext.Providerwrappers in favor ofjest.mock('.../useAnalytics')using the realcreateEventBuilder, and assertions are updated to the built event object.Reviewed by Cursor Bugbot for commit 9a011e4. Bugbot is set up for automated code reviews on this repo. Configure here.