refactor(analytics): migrate Batch 2-14: notifications#26303
Conversation
|
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. |
| import { fireEvent, render } from '@testing-library/react-native'; | ||
| import TransactionField from './TransactionField'; | ||
| import * as useMetricsModule from '../../../../hooks/useMetrics'; | ||
| import * as useAnalyticsModule from '../../../../hooks/useAnalytics/useAnalytics'; |
There was a problem hiding this comment.
Test still uses legacy MetricsEventBuilder instead of AnalyticsEventBuilder
Low Severity
TransactionField.test.tsx was partially migrated — useMetrics became useAnalytics, but the import and usage of MetricsEventBuilder (legacy) was not updated to AnalyticsEventBuilder (new). The sibling BlockExplorerFooter.test.tsx was fully migrated to AnalyticsEventBuilder. This leaves a stale dependency on the deprecated module that the PR intends to replace.
Additional Locations (1)
| MetaMetrics.getInstance().trackEvent( | ||
| MetricsEventBuilder.createEventBuilder( | ||
| analytics.trackEvent( | ||
| AnalyticsEventBuilder.createEventBuilder( |
There was a problem hiding this comment.
FCMService saveDataRecording silently changed from true to false
Medium Severity
The migration from MetaMetrics.getInstance().trackEvent(...) to analytics.trackEvent(...) silently changes the saveDataRecording flag from true to false. The old MetaMetrics.trackEvent defaulted saveDataRecording to true and explicitly called .setSaveDataRecording(true) when rebuilding the event. The new code builds the event directly via AnalyticsEventBuilder.createEventBuilder(...) which defaults saveDataRecording to false (in createAnalyticsEvent), and .setSaveDataRecording(true) is never called. The useAnalytics hook handles this correctly by calling .setSaveDataRecording(saveDataRecording ?? true) in its trackEvent, but FCMService bypasses the hook.
…2-14_notifications
…2-14_notifications
…2-14_notifications
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|





Description
Phase 2 analytics migration (Batch 2-14): migrate Notifications' views, hooks, and services from the legacy MetaMetrics system to the new analytics system.
Reason: Deprecate MetaMetrics in favour of the shared analytics utility and AnalyticsController.
Changes: Notifications source files (
index.tsx,OptIn,BlockExplorerFooter,AnnouncementCtaFooter,TransactionField,NetworkFeeField,OptIn.hooks) now useuseAnalyticsfromapp/components/hooks/useAnalytics/useAnalytics;FCMService.tsnow usesanalytics.trackEvent()andAnalyticsEventBuilderfromapp/util/analytics; all test mocks updated to mock the analytics utility instead of MetaMetrics.Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/MCWP-297 (Batch 2-14)
Manual testing steps
Screenshots/Recordings
N/A – analytics migration, no UI change.
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Refactor-only analytics migration with no functional UI or notification-processing changes, but it could impact event emission if any import/mocking mismatch slips through.
Overview
Notifications screens/components and opt-in hooks now use
useAnalyticsinstead ofuseMetricsfor tracking detail-click and “mark all as read” events, with imports updated accordingly.FCMServiceswitches push-notification click tracking fromMetaMetrics.getInstance().trackEvent/MetricsEventBuilderto the sharedanalytics.trackEventwithAnalyticsEventBuilder. All related unit tests are updated to mockuseAnalytics/analyticsand the new event builder APIs.Written by Cursor Bugbot for commit 0b7f2e9. This will update automatically on new commits. Configure here.