refactor(analytics): D1 migrate Rewards from useMetrics to useAnalytics#28262
Conversation
Replace all useMetrics usages in the Rewards module with useAnalytics, import MetaMetricsEvents from core/Analytics instead of hooks/useMetrics, and add createMockEventBuilder factory to analyticsMock to eliminate inline builder boilerplate across test files.
|
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. |
|
✅ E2E Fixture Validation — Schema is up to date |
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.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|




Important
Creates a dependency on D2 #28263 for createMockEventBuilder added in
app/util/test/analyticsMock.ts.if this PR has to be reverted, you also have to revert D2 #28263
Description
Part of #26686 (PR D1 — Rewards).
The
useMetricshook is deprecated in favour ofuseAnalytics, which integrates with the newAnalyticsControllervia the messenger pattern. This PR migrates alluseMetricsusages in the Rewards module.What changed:
useMetricswithuseAnalyticsacross all Rewards components, views, and hooks (14 source files).MetaMetricsEventsimports to come directly fromcore/Analyticsinstead of the deprecatedhooks/useMetricsre-export.useAnalyticsinstead ofuseMetrics, using thecreateMockUseAnalyticsHookfactory for consistency.createMockEventBuilderfactory function toapp/util/test/analyticsMock.tsto eliminate repeated inline event-builder mock boilerplate across test files.Changelog
CHANGELOG entry: null
Related issues
Fixes: #26816
Refs: #26686
Manual testing steps
Screenshots/Recordings
Before
N/A
After
N/A
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches Rewards analytics/identify calls and event constant wiring; while behavior should be equivalent, mistakes could drop or mislabel telemetry and user-trait updates (opt-in/out, account-linking). Functional UI behavior is otherwise unchanged.
Overview
Migrates the Rewards module off deprecated
useMetricstouseAnalytics, and switchesMetaMetricsEventsimports to come directly fromcore/Analytics.Updates Rewards hooks and screens to use
identifyin place ofaddTraitsToUserwhere traits are set (e.g., opt-in/out and opt-in summary), and refactors unit tests to mockuseAnalyticsconsistently via shared factories.Adds
createMockEventBuildertoutil/test/analyticsMock.tsto standardize event-builder mocks and reduce repeated inline test boilerplate.Written by Cursor Bugbot for commit 147520c. This will update automatically on new commits. Configure here.