refactor(analytics): C3-a migrate security, wallet UI, navigation, and settings to useAnalytics#27855
Conversation
…etrics to useAnalytics Replace useMetrics/withMetricsAwareness/withAnalyticsAwareness with direct useAnalytics hook across ~17 files. Remove withAnalyticsAwareness HOC and its tests/types. Rename addTraitsToUser to identify in GeneralSettings. Update all corresponding test mocks.
|
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. |
…module calls Replace useAnalytics HOC wrapper pattern in ProtectYourWalletModal, ErrorBoundary, AdvancedSettings, and GeneralSettings with direct calls to analytics and AnalyticsEventBuilder from util/analytics, consistent with the migration pattern.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
|
✅ E2E Fixture Validation — Schema is up to date |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
This hook is responsible for handling connectivity changes and tracking analytics events (e.g., CONNECTION_DROPPED / CONNECTION_RESTORED) and optionally navigating to
The modification is an internal analytics hook swap with corresponding unit test updates. Since E2E tests do not validate analytics tracking internals and no user-facing behavior or navigation logic was altered, existing E2E flows should not be impacted. Therefore, no E2E smoke tags are required for safe validation of this change. Performance impact: None. The change only swaps analytics hook usage and test mocks, with no rendering, state management, or initialization changes. No performance tests are needed. Performance Test Selection: |
|




Description
Part of the C3 analytics migration (#26686). This PR covers the navigation hook and global test setup cleanup.
What changed:
useConnectionHandler.tsx: replacesuseMetricswithuseAnalytics— the tracked events (CONNECTION_DROPPED,CONNECTION_RESTORED) and navigation behaviour are unchangeduseConnectionHandler.test.ts: updates mocks fromuseMetrics/MetricsEventBuildertouseAnalytics/AnalyticsEventBuilderusingjest.mocked()andcreateMockUseAnalyticsHooktestSetup.js: removes the globalwithAnalyticsAwarenessHOC mock — the HOC is being deprecated and no longer needs a global stubThe rest of the original scope (TabBar, security/wallet UI components, Settings, Bridge) has been split into separate PRs for easier review by the respective code owners:
@MetaMask/design-system-engineers)@MetaMask/mobile-core-ux)@MetaMask/swaps-engineers)Changelog
CHANGELOG entry: null
Related issues
Ref: #26814
Manual testing steps
N/A
Screenshots/Recordings
Before
N/A
After
N/A
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Low risk refactor limited to analytics plumbing and Jest mocks; navigation timing and tracked event names remain the same.
Overview
Updates
useConnectionHandlerto calluseAnalytics(instead ofuseMetrics) while keeping the same offline navigation timeout and emitting the sameMetaMetricsEventsfor connection dropped/restored.Adjusts
useConnectionHandler.test.tsto mockuseAnalyticsviacreateMockUseAnalyticsHookand to build assertions withAnalyticsEventBuilder, and removes the now-unneeded globalwithAnalyticsAwarenessHOC mock fromtestSetup.js.Written by Cursor Bugbot for commit 21fe914. This will update automatically on new commits. Configure here.