Skip to content

refactor(analytics): migrate Batch 3-10: mobile-platform#26560

Merged
NicolasMassart merged 3 commits into
mainfrom
refactor/MCWP-297_analytics_migration_batch_3-10_mobile-platform
Feb 27, 2026
Merged

refactor(analytics): migrate Batch 3-10: mobile-platform#26560
NicolasMassart merged 3 commits into
mainfrom
refactor/MCWP-297_analytics_migration_batch_3-10_mobile-platform

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Description

Phase 3 analytics migration (Batch 3-10): migrate Onboarding/Account Import's ImportNewSecretRecoveryPhrase, ExperienceEnhancerModal, and Pna25BottomSheet from useMetrics/MetaMetrics to the new analytics system.

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

Changes: ImportNewSecretRecoveryPhrase, ExperienceEnhancerModal, and Pna25BottomSheet now use useAnalytics and AnalyticsEventBuilder from app/components/hooks/useAnalytics and app/util/analytics; test mocks updated to mock useAnalytics instead of useMetrics. ImportFromSecretRecoveryPhrase already used useAnalytics — no migration needed.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MCWP-302 (Batch 3-10)

Manual testing steps

Feature: Onboarding/Account Import analytics

  Scenario: user triggers an onboarding/account import flow event
    Given app is open and user is in an onboarding/account import flow

    When user performs an action that triggers analytics (e.g. import SRP completed, marketing consent modal accept/cancel, PNA25 notice viewed/closed)
    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

Medium Risk
Replaces the legacy useMetrics analytics hook with useAnalytics in onboarding/consent flows, which could change or break event emission/consent traits if the new builder/hook behavior differs. No functional UI changes, but tracking correctness is compliance- and telemetry-sensitive.

Overview
Migrates analytics instrumentation in ExperienceEnhancerModal, ImportNewSecretRecoveryPhrase, and Pna25BottomSheet from legacy useMetrics to useAnalytics, updating event/builder usage (e.g., SRP import completion and PNA25 notice events) while keeping existing MetaMetricsEvents names.

Updates Jest tests to mock useAnalytics and (for SRP import) swap MetricsEventBuilder references to AnalyticsEventBuilder, ensuring tracking assertions still validate emitted events/properties.

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

@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 requested a review from a team February 25, 2026 13:31
@NicolasMassart NicolasMassart added the team-mobile-platform Mobile Platform team label Feb 25, 2026
@NicolasMassart NicolasMassart self-assigned this Feb 25, 2026
@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue Feb 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
This PR is a pure refactoring change that migrates three components from using useMetrics hook to the new useAnalytics hook:

  1. ExperienceEnhancerModal - Analytics/marketing settings modal
  2. ImportNewSecretRecoveryPhrase - Multi-SRP import view (critical for multi-SRP architecture)
  3. Pna25BottomSheet - Legal notice bottom sheet

The changes are limited to:

  • Import path changes (useMetrics → useAnalytics)
  • Test mock updates to use new hook path
  • No functional or business logic changes

The hooks provide the same interface (trackEvent, addTraitsToUser, createEventBuilder), so this is a drop-in replacement.

Selected tags rationale:

  • SmokeWalletPlatform: ImportNewSecretRecoveryPhrase is part of multi-SRP wallet architecture
  • SmokeAccounts: Multi-SRP import relates to account management
  • SmokeIdentity: Multi-SRP flows relate to identity/sync features

While the risk is low (pure refactoring), running these tests provides confidence that the analytics hook migration doesn't break any critical user flows involving SRP import and account management.

Performance Test Selection:
This PR is a pure refactoring change that only modifies import paths for analytics hooks. No changes to UI rendering, data loading, state management, or any performance-critical code paths. The hooks provide the same interface, so there's no performance impact expected.

View GitHub Actions results

@Cal-L Cal-L 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

@NicolasMassart NicolasMassart added this pull request to the merge queue Feb 27, 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 27, 2026
Merged via the queue into main with commit 328da11 Feb 27, 2026
93 checks passed
@NicolasMassart NicolasMassart deleted the refactor/MCWP-297_analytics_migration_batch_3-10_mobile-platform branch February 27, 2026 19:34
@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 Feb 27, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 27, 2026
@metamaskbot metamaskbot added the release-7.69.0 Issue or pull request that will be included in release 7.69.0 label Feb 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants