Skip to content

refactor(analytics): migrate Batch 3-13: mobile-platform#26584

Merged
NicolasMassart merged 3 commits into
mainfrom
refactor/MCWP-297_analytics_migration_batch_3-13_mobile-platform
Mar 1, 2026
Merged

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

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Description

Phase 3 analytics migration (Batch 3-13): migrate Network Management's components and hooks from useMetrics to the new analytics system (useAnalytics).

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

Changes: ManageNetworks, NetworkMultiSelector, NetworkManager, and MultiRpcModal now use useAnalytics from app/components/hooks/useAnalytics/useAnalytics and import MetaMetricsEvents from app/core/Analytics; test mocks updated to mock useAnalytics instead of useMetrics.

Changelog

CHANGELOG entry: null

Related issues

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

Manual testing steps

Feature: Network Management analytics

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

    When user performs an action that triggers analytics (e.g. switch network, open network manager, accept multi-RPC modal)
    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
Low risk UI refactor that only swaps analytics plumbing; primary risk is missing/misnamed events if the new useAnalytics hook or MetaMetricsEvents import differs from the old useMetrics behavior.

Overview
Switches Network Management UI surfaces (e.g., ManageNetworks, NetworkManager, NetworkMultiSelector, and MultiRpcModal) from useMetrics to the shared useAnalytics hook while keeping existing event tracking calls (trackEvent/createEventBuilder).

Updates unit tests to mock useAnalytics instead of useMetrics, and adjusts event constant imports/expectations to use MetaMetricsEvents from core/Analytics/MetaMetrics.events where applicable.

Written by Cursor Bugbot for commit 3c6fb53. 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 self-assigned this Feb 25, 2026
@NicolasMassart NicolasMassart added the team-mobile-platform Mobile Platform team label Feb 25, 2026
@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue Feb 25, 2026
@NicolasMassart NicolasMassart requested a review from a team February 27, 2026 09:44

@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
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 27, 2026
@NicolasMassart NicolasMassart enabled auto-merge March 1, 2026 10:27
@github-actions

github-actions Bot commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeNetworkAbstractions
  • 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 network-related UI components from the useMetrics hook to the new useAnalytics hook. The affected components are:

  1. ManageNetworks.tsx - Network management component used in onboarding settings
  2. NetworkManager/index.tsx - Main network manager component used in app navigation
  3. NetworkMultiSelector.tsx - Multi-network selection component used in Trending and CustomNetworkSelector
  4. MultiRpcModal.tsx - RPC modal used in wallet view and security settings

The changes are purely internal - swapping one analytics hook for another with the same API (trackEvent, createEventBuilder, addTraitsToUser). No functional changes to the UI or behavior are introduced.

The test files have been updated to mock useAnalytics instead of useMetrics, which is appropriate for the refactoring.

Since all affected components are network management related, SmokeNetworkAbstractions is the appropriate tag to verify the network management UI still functions correctly after the hook migration. The risk is low because:

  1. The API is identical between the two hooks
  2. Unit tests have been updated to reflect the change
  3. No business logic or UI changes are introduced

Performance Test Selection:
This PR is a pure refactoring change that migrates analytics hooks from useMetrics to useAnalytics. The changes do not affect UI rendering performance, data loading, state management, or any critical user flows. The hook swap maintains the same API and functionality, so no performance impact is expected.

View GitHub Actions results

@NicolasMassart NicolasMassart added this pull request to the merge queue Mar 1, 2026
Merged via the queue into main with commit 2a3ee4d Mar 1, 2026
55 of 57 checks passed
@NicolasMassart NicolasMassart deleted the refactor/MCWP-297_analytics_migration_batch_3-13_mobile-platform branch March 1, 2026 11:07
@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 1, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 1, 2026
@metamaskbot metamaskbot added the release-7.69.0 Issue or pull request that will be included in release 7.69.0 label Mar 1, 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