Skip to content

refactor(analytics): migrate Batch 2-13: card#26302

Merged
NicolasMassart merged 2 commits into
mainfrom
refactor/MCWP-297_analytics_migration_batch_2-13_card
Feb 20, 2026
Merged

refactor(analytics): migrate Batch 2-13: card#26302
NicolasMassart merged 2 commits into
mainfrom
refactor/MCWP-297_analytics_migration_batch_2-13_card

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Description

Phase 2 analytics migration (Batch 2-13): migrate Card's hooks, onboarding components, views, and UI components from useMetrics to the new analytics system.

Reason: Deprecate MetaMetrics in favour of the shared analytics utility and AnalyticsController.

Changes: All 27 Card source files now use useAnalytics from app/components/hooks/useAnalytics/useAnalytics and MetaMetricsEvents from app/core/Analytics. Test mocks updated to mock useAnalytics instead of useMetrics. 15 additional files were discovered via grep that were not in the original batch definition and have been included.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MCWP-297 (Batch 2-13)

Manual testing steps

Feature: Card analytics

  Scenario: user triggers a Card flow event
    Given app is open and user is in a Card flow

    When user performs an action that triggers analytics (e.g. card welcome page view, onboarding step, asset selection, spending limit change)
    Then the event is tracked on Mixpanel

Screenshots/Recordings

N/A – analytics migration, no UI change.

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
Largely mechanical import/mocking changes that should not affect runtime behavior beyond analytics emission; main risk is mismapped event constants or broken test mocks causing missing telemetry.

Overview
Migrates MetaMask Card UI (views, onboarding screens, bottom sheets, and related hooks) from the legacy useMetrics hook to the new useAnalytics hook, and switches event constants imports to MetaMetricsEvents from app/core/Analytics.

Updates unit tests accordingly by replacing useMetrics mocks with useAnalytics mocks and adjusting assertions to use the centralized MetaMetricsEvents constants (instead of string literals in mocks).

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

@NicolasMassart NicolasMassart self-assigned this Feb 19, 2026
@NicolasMassart NicolasMassart added the team-mobile-platform Mobile Platform team label Feb 19, 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 moved this to Needs dev review in PR review queue Feb 19, 2026
@NicolasMassart NicolasMassart marked this pull request as ready for review February 19, 2026 22:15
@NicolasMassart NicolasMassart requested a review from a team as a code owner February 19, 2026 22:15
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
This PR is a pure refactoring change that migrates all 51 Card feature files from using the useMetrics hook to the new useAnalytics hook. The changes are:

  1. Import path changes: Replacing useMetrics from hooks/useMetrics with useAnalytics from hooks/useAnalytics/useAnalytics, and importing MetaMetricsEvents from core/Analytics instead of the metrics hook.

  2. Hook usage: Replacing useMetrics() calls with useAnalytics() - both hooks provide the same API (trackEvent, createEventBuilder).

  3. Test updates: Updating mocks from useMetrics to useAnalytics in test files.

The useAnalytics hook is documented as providing "Analytics functions compatible with the useMetrics API", so this is a drop-in replacement. The changes are confined entirely to the Card feature (Views, components, hooks, and pushProvisioning).

Since this is a refactoring that affects only the Card feature's analytics implementation without changing any business logic or UI, the risk is low. However, running SmokeCard tests will verify that the Card feature still functions correctly after this migration and that analytics events are properly tracked.

Performance Test Selection:
This PR is a pure refactoring change that only updates import paths and hook usage from useMetrics to useAnalytics. The changes don't affect UI rendering, data loading, state management, or any performance-critical code paths. The analytics hooks are called the same way with the same API, so there's no performance impact expected.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@NicolasMassart NicolasMassart added this pull request to the merge queue Feb 20, 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 Feb 20, 2026
Merged via the queue into main with commit 3de8d42 Feb 20, 2026
92 checks passed
@NicolasMassart NicolasMassart deleted the refactor/MCWP-297_analytics_migration_batch_2-13_card branch February 20, 2026 08:36
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 20, 2026
@metamaskbot metamaskbot added the release-7.68.0 Issue or pull request that will be included in release 7.68.0 label Feb 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.68.0 Issue or pull request that will be included in release 7.68.0 size-M team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants