Skip to content

refactor(analytics): migrate Batch 1-6: web3auth#25713

Merged
NicolasMassart merged 3 commits intomainfrom
refactor/MCWP-297_analytics_migration_batch_1-6_web3auth
Feb 6, 2026
Merged

refactor(analytics): migrate Batch 1-6: web3auth#25713
NicolasMassart merged 3 commits intomainfrom
refactor/MCWP-297_analytics_migration_batch_1-6_web3auth

Conversation

@NicolasMassart
Copy link
Copy Markdown
Contributor

@NicolasMassart NicolasMassart commented Feb 5, 2026

Description

Migrate Onboarding component to use useAnalytics hook instead of deprecated useMetrics.

Changelog

CHANGELOG entry: null

Related issues

Fixes: MCWP-297 (Batch 1-6)

Manual testing steps

Feature: Onboarding analytics tracking

  Scenario: user creates a new wallet
    Given app is open and user is on the onboarding screen

    When user taps "Start exploring now" to create a new wallet
    Then WALLET_SETUP_STARTED event is tracked (Mixpanel)

  Scenario: user imports an existing wallet
    Given app is open and user is on the onboarding screen

    When user taps "Import using Secret Recovery Phrase" to import a wallet
    Then WALLET_IMPORT_STARTED event is tracked (Mixpanel)

  Scenario: user completes OAuth login
    Given app is open and user starts OAuth login flow

    When user successfully completes Google or Apple OAuth login
    Then SOCIAL_LOGIN_COMPLETED event is tracked (Mixpanel)

Screenshots/Recordings

Before

After

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
Refactor limited to analytics hook wiring and test synchronization; minimal behavioral change risk beyond potential timing/consent regressions in onboarding analytics flows.

Overview
Onboarding now uses useAnalytics instead of deprecated useMetrics, shifting consent/enablement calls to the new analytics hook while keeping existing onboarding/OAuth tracking behavior.

Tests were updated to mock useAnalytics and treat optIn/optOut as async, adding a flushPromises helper and waitFor assertions to reduce timing-related flakiness around navigation and analytics calls.

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

Migrate Onboarding component to use useAnalytics hook instead of deprecated useMetrics.
Both hooks provide identical API (enable(), isEnabled() methods), so all existing usage
patterns remain unchanged.

Part of Phase 1 analytics migration (Batch 1-6).
Related: MCWP-297
@NicolasMassart NicolasMassart requested a review from a team as a code owner February 5, 2026 14:53
@NicolasMassart NicolasMassart self-assigned this Feb 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 5, 2026

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 Feb 5, 2026
@NicolasMassart NicolasMassart added team-onboarding Onboarding team team-mobile-platform Mobile Platform team and removed team-mobile-platform Mobile Platform team labels Feb 5, 2026
@NicolasMassart NicolasMassart moved this to Needs dev review in PR review queue Feb 5, 2026
@github-actions github-actions bot added size-M and removed size-XS labels Feb 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 5, 2026

🔍 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:
This PR is a straightforward refactoring change that migrates the Onboarding component from the deprecated useMetrics hook to the new useAnalytics hook. Both hooks have identical APIs and implementations - they both use the same underlying analytics module for tracking events, opt-in/opt-out, and user traits. The change is purely internal and does not affect any user-facing functionality.

The test file changes are updating mocks to use the new useAnalytics hook and improving async test handling with flushPromises() and waitFor() patterns.

Key observations:

  1. The useMetrics hook is explicitly marked as @deprecated with a comment to use useAnalytics instead
  2. Both hooks have the same method signatures: trackEvent, enable, addTraitsToUser, createDataDeletionTask, etc.
  3. Both hooks use the same analytics module from ../../../util/analytics/analytics
  4. No E2E tests directly test analytics/metrics functionality
  5. The Onboarding component's user-facing behavior is unchanged

No E2E tests are needed because:

  • This is an internal refactoring with no functional changes
  • Analytics tracking is not tested by E2E tests
  • The user-facing onboarding flow remains identical

Performance Test Selection:
No performance tests needed. This change is a pure refactoring that replaces one analytics hook with another that has identical implementation. Both useMetrics and useAnalytics hooks use the same underlying analytics module and have the same API. There are no changes to UI rendering, data loading, state management, or any code paths that could affect app performance.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

@grvgoel81 grvgoel81 left a comment

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 Feb 6, 2026
@NicolasMassart NicolasMassart added this pull request to the merge queue Feb 6, 2026
Merged via the queue into main with commit 8d8707f Feb 6, 2026
58 checks passed
@NicolasMassart NicolasMassart deleted the refactor/MCWP-297_analytics_migration_batch_1-6_web3auth branch February 6, 2026 10:10
@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 6, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2026
@metamaskbot metamaskbot added the release-7.66.0 Issue or pull request that will be included in release 7.66.0 label Feb 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants