Skip to content

refactor(analytics): C3-a migrate security, wallet UI, navigation, and settings to useAnalytics#27855

Merged
NicolasMassart merged 10 commits intomainfrom
refactor/26686_c3_security-wallet-ui-nav-settings-hoc
Mar 31, 2026
Merged

refactor(analytics): C3-a migrate security, wallet UI, navigation, and settings to useAnalytics#27855
NicolasMassart merged 10 commits intomainfrom
refactor/26686_c3_security-wallet-ui-nav-settings-hoc

Conversation

@NicolasMassart
Copy link
Copy Markdown
Contributor

@NicolasMassart NicolasMassart commented Mar 24, 2026

Description

Part of the C3 analytics migration (#26686). This PR covers the navigation hook and global test setup cleanup.

What changed:

  • useConnectionHandler.tsx: replaces useMetrics with useAnalytics — the tracked events (CONNECTION_DROPPED, CONNECTION_RESTORED) and navigation behaviour are unchanged
  • useConnectionHandler.test.ts: updates mocks from useMetrics/MetricsEventBuilder to useAnalytics/AnalyticsEventBuilder using jest.mocked() and createMockUseAnalyticsHook
  • testSetup.js: removes the global withAnalyticsAwareness HOC mock — the HOC is being deprecated and no longer needs a global stub

The 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:

  • #27983 — TabBar (@MetaMask/design-system-engineers)
  • #27984 — Security/wallet UI components & Settings (@MetaMask/mobile-core-ux)
  • #27985 — Bridge hook (@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

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
Low risk refactor limited to analytics plumbing and Jest mocks; navigation timing and tracked event names remain the same.

Overview
Updates useConnectionHandler to call useAnalytics (instead of useMetrics) while keeping the same offline navigation timeout and emitting the same MetaMetricsEvents for connection dropped/restored.

Adjusts useConnectionHandler.test.ts to mock useAnalytics via createMockUseAnalyticsHook and to build assertions with AnalyticsEventBuilder, and removes the now-unneeded global withAnalyticsAwareness HOC mock from testSetup.js.

Written by Cursor Bugbot for commit 21fe914. This will update automatically on new commits. Configure here.

…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.
@NicolasMassart NicolasMassart self-assigned this Mar 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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.

@metamaskbot metamaskbot added the team-mobile-platform Mobile Platform team label Mar 24, 2026
@github-project-automation github-project-automation bot moved this to Needs dev review in PR review queue Mar 24, 2026
@NicolasMassart NicolasMassart changed the title refactor(analytics): migrate security, wallet UI, navigation, and settings to useAnalytics refactor(analytics): C3 migrate security, wallet UI, navigation, and settings to useAnalytics Mar 24, 2026
@NicolasMassart NicolasMassart marked this pull request as ready for review March 24, 2026 16:44
@NicolasMassart NicolasMassart requested review from a team as code owners March 24, 2026 16:44
@github-actions github-actions bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Mar 25, 2026
…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.
@github-actions github-actions bot added size-L risk-medium Moderate testing recommended · Possible bug introduction risk and removed size-M risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
@github-actions github-actions bot added risk-high Extensive testing required · High bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 25, 2026
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 3 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
17 value mismatches detected (expected — fixture represents an existing user).
View details

@github-actions github-actions bot added size-S risk-low Low testing needed · Low bug introduction risk and removed size-L risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 26, 2026
@NicolasMassart NicolasMassart requested review from a team and removed request for a team March 26, 2026 17:37
@NicolasMassart NicolasMassart changed the title refactor(analytics): C3 migrate security, wallet UI, navigation, and settings to useAnalytics refactor(analytics): C3 migrate useConnectionHandler and remove withAnalyticsAwareness from test setup Mar 26, 2026
@NicolasMassart NicolasMassart changed the title refactor(analytics): C3 migrate useConnectionHandler and remove withAnalyticsAwareness from test setup refactor(analytics): C3-a migrate security, wallet UI, navigation, and settings to useAnalytics Mar 26, 2026
@NicolasMassart NicolasMassart marked this pull request as draft March 26, 2026 17:54
@NicolasMassart NicolasMassart marked this pull request as ready for review March 27, 2026 17:34
@github-actions github-actions bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are limited to the useConnectionHandler hook and its associated unit test and test setup. Specifically:

  • Replaced useMetrics with useAnalytics hook.
  • Updated event builder from MetricsEventBuilder to AnalyticsEventBuilder.
  • Adjusted Jest mocks accordingly in unit tests and test setup.

This hook is responsible for handling connectivity changes and tracking analytics events (e.g., CONNECTION_DROPPED / CONNECTION_RESTORED) and optionally navigating to OfflineModeView. There are no changes to:

  • Core Engine or Controllers
  • Navigation structure or route names
  • UI components or rendering logic
  • Transaction, network, account, trade, card, perps, predictions, ramps, snaps, or multi-chain flows
  • Performance-sensitive areas (rendering, startup, asset loading, swaps, onboarding)

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:
No UI, rendering, startup, network, asset loading, or critical user flow changes. The change is limited to analytics hook wiring and unit test mocks, with no measurable performance impact.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@NicolasMassart NicolasMassart added this pull request to the merge queue Mar 31, 2026
@github-project-automation github-project-automation bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Mar 31, 2026
Merged via the queue into main with commit f41f4f6 Mar 31, 2026
67 checks passed
@NicolasMassart NicolasMassart deleted the refactor/26686_c3_security-wallet-ui-nav-settings-hoc branch March 31, 2026 16:16
@github-actions github-actions bot locked and limited conversation to collaborators Mar 31, 2026
@weitingsun weitingsun added release-7.73.0 Issue or pull request that will be included in release 7.73.0 and removed release-100.10.0 labels Mar 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.73.0 Issue or pull request that will be included in release 7.73.0 risk-low Low testing needed · Low bug introduction risk size-S team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants