Skip to content

refactor(analytics): PR C1 useAnalytics for HW, recovery, onboarding#27738

Merged
NicolasMassart merged 3 commits into
mainfrom
refactor/26686_c1_hw-wallet-recovery-onboarding
Mar 20, 2026
Merged

refactor(analytics): PR C1 useAnalytics for HW, recovery, onboarding#27738
NicolasMassart merged 3 commits into
mainfrom
refactor/26686_c1_hw-wallet-recovery-onboarding

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Description

Part of the analytics cleanup workstream (#26686). Delivers PR C1: migrate useMetrics to useAnalytics in hardware wallet, wallet recovery, onboarding-adjacent, and related UI (~27 files).

  • Ledger / Bluetooth hardware: LedgerConfirmationModal, LedgerConnect (Scan, entry), and ConnectHardware/SelectHardware now call useAnalytics from app/components/hooks/useAnalytics/useAnalytics instead of useMetrics.
  • QR hardware: ConnectQRHardware (container + Instruction), AnimatedQRScanner, and QRSigningDetails use the same hook swap; event names and MetaMetricsEvents / builder usage stay as before.
  • Wallet recovery (web3auth-owned views): RestoreWallet, WalletRestored, and WalletResetNeeded (+ tests) migrated to useAnalytics.
  • Post-onboarding settings: OnboardingSuccess/OnboardingGeneralSettings, OnboardingSuccess/OnboardingSecuritySettings (+ test) migrated.
  • Other touchpoints in scope: ExperienceEnhancerModal, NftGrid and NftGridItemActionSheet tests—aligned with the C1 slice that includes onboarding-adjacent and shared UI still on legacy metrics.
  • Tests: jest.mock targets point at useAnalytics; mocks use createMockUseAnalyticsHook from app/util/test/analyticsMock. Where builders were referenced from tests, imports use AnalyticsEventBuilder from app/util/analytics/AnalyticsEventBuilder instead of MetricsEventBuilder.

No change to which events fire or their payloads—this is an API migration only, consistent with prior analytics refactors (e.g. PR A2 — split types from MetaMetrics).

Changelog

CHANGELOG entry: null

Related issues

Fixes: #26812

Refs: #26686

Manual testing steps

N/A — refactor-only; behavior and analytics events are unchanged. Unit tests cover updated mocks and components.

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

Medium Risk
Mostly a hook/API swap, but it touches user-facing hardware wallet and recovery/onboarding flows and can subtly change analytics payloads or break tracking if the new hook differs from useMetrics. One NFT tracking event (WALLET_ADD_COLLECTIBLES) also gains additional properties, changing event data.

Overview
Swaps analytics wiring across Ledger/QR hardware wallet UI, wallet recovery views, and onboarding success settings to use useAnalytics instead of useMetrics, including updating imports and call sites.

Updates unit tests to mock useAnalytics consistently via createMockUseAnalyticsHook/AnalyticsEventBuilder, and adjusts one NFT event (MetaMetricsEvents.WALLET_ADD_COLLECTIBLES) to include extra properties in its payload.

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

@NicolasMassart NicolasMassart self-assigned this Mar 20, 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.

@NicolasMassart NicolasMassart changed the title refactor(onboarding): migrate hardware and restore flows to useAnalytics refactor(analytics): PR C1 useAnalytics for HW, recovery, onboarding Mar 20, 2026
@NicolasMassart NicolasMassart added the team-mobile-platform Mobile Platform team label Mar 20, 2026
@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue Mar 20, 2026
# Conflicts:
#	app/components/UI/LedgerModals/LedgerConfirmationModal.test.tsx
#	app/components/UI/LedgerModals/LedgerConfirmationModal.tsx
@NicolasMassart NicolasMassart force-pushed the refactor/26686_c1_hw-wallet-recovery-onboarding branch from 2c22bd8 to bf5858f Compare March 20, 2026 13:32
@NicolasMassart NicolasMassart marked this pull request as ready for review March 20, 2026 14:50
@NicolasMassart NicolasMassart requested a review from a team as a code owner March 20, 2026 14:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf5858f7b5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/components/UI/NftGrid/NftGrid.tsx
@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Mar 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeWalletPlatform, SmokeIdentity
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:
All 27 changed files are migrating from the deprecated useMetrics hook to the new useAnalytics hook. This is a systematic refactoring across several feature areas:

  1. Hardware wallet flows (Ledger connect/scan, QR hardware wallet, SelectHardware, LedgerConfirmationModal, AnimatedQRScanner, QRSigningDetails, ConnectQRHardware, ConnectQRInstruction): These affect QR-based and Ledger hardware wallet account addition flows → SmokeAccounts (QR hardware wallet account addition is explicitly covered).

  2. Restore Wallet flow (RestoreWallet, WalletResetNeeded, WalletRestored): These are wallet recovery/SRP import screens → SmokeWalletPlatform (wallet lifecycle analytics, SRP import events).

  3. Onboarding success screens (OnboardingSecuritySettings, OnboardingGeneralSettings): These include analytics consent and backup/sync toggles → SmokeWalletPlatform (new wallet creation flow) and SmokeIdentity (BackupAndSyncToggle is present in GeneralSettings).

  4. ExperienceEnhancerModal: Changes addTraitsToUseridentify for marketing consent tracking. Both methods call analytics.identify() internally, so functionally identical. This modal appears during onboarding → SmokeWalletPlatform.

  5. NftGrid: Minor analytics property addition to WALLET_ADD_COLLECTIBLES event. Low risk, no functional change to UI.

The migration from useMetrics to useAnalytics is low-risk since both hooks expose the same API (trackEvent, createEventBuilder, isEnabled, identify/addTraitsToUser). The useMetrics hook is explicitly marked as deprecated in favor of useAnalytics. No functional logic changes, only analytics instrumentation updates.

Performance tests are not warranted as these are analytics hook migrations with no impact on rendering, data loading, or app startup performance.

Performance Test Selection:
All changes are analytics hook migrations (useMetrics → useAnalytics) with no impact on rendering performance, data loading, state management, or app startup. The NftGrid change adds analytics properties but doesn't affect rendering logic. No performance tests are warranted.

View GitHub Actions results

@github-actions

Copy link
Copy Markdown
Contributor

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

@ieow ieow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@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 20, 2026
@sonarqubecloud

Copy link
Copy Markdown

@NicolasMassart NicolasMassart added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit 5ef649e Mar 20, 2026
97 checks passed
@NicolasMassart NicolasMassart deleted the refactor/26686_c1_hw-wallet-recovery-onboarding branch March 20, 2026 16:30
@github-project-automation github-project-automation Bot moved this from Review finalised - Ready to be merged to Merged, Closed or Archived in PR review queue Mar 20, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 20, 2026
@metamaskbot metamaskbot added the release-7.72.0 Issue or pull request that will be included in release 7.72.0 label Mar 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.72.0 Issue or pull request that will be included in release 7.72.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-M team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

PR C1: migrate useMetrics to useAnalytics in HW Wallet, Wallet Recovery, Onboarding, web3auth (~21 files)

3 participants