Skip to content

refactor(analytics): migrate Batch 2-15: mobile-platform#26304

Merged
NicolasMassart merged 4 commits into
mainfrom
refactor/MCWP-297_analytics_migration_batch_2-15_mobile-platform
Feb 20, 2026
Merged

refactor(analytics): migrate Batch 2-15: mobile-platform#26304
NicolasMassart merged 4 commits into
mainfrom
refactor/MCWP-297_analytics_migration_batch_2-15_mobile-platform

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Description

Phase 2 analytics migration (Batch 2-15): migrate mobile-platform's In App Browser components (PhishingModal, Options, GestureWebViewWrapper) from useMetrics to the new useAnalytics hook.

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

Changes: Browser PhishingModal, Options, and GestureWebViewWrapper 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-297 (Batch 2-15)

Manual testing steps

Feature: In App Browser analytics

  Scenario: user triggers a browser flow event
    Given app is open and user is in the in-app browser

    When user performs an action that triggers analytics (e.g. swipe back/forward, pull to refresh, open in browser, add to favorites, phishing modal display)
    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
Touches analytics instrumentation paths; if useAnalytics behavior differs from useMetrics, event tracking could regress, but no user-facing logic or security-sensitive flows are changed.

Overview
Migrates in-app browser analytics wiring from useMetrics to the newer shared useAnalytics hook in GestureWebViewWrapper, Options, and PhishingModal, while keeping the same event emission sites.

Updates MetaMetricsEvents imports to come from app/core/Analytics (instead of via useMetrics) and adjusts unit tests to mock useAnalytics accordingly.

Written by Cursor Bugbot for commit feabfa9. 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 23:47
@NicolasMassart NicolasMassart requested review from a team and MarioAslau February 19, 2026 23:49

@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

@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
@NicolasMassart NicolasMassart moved this from Review finalised - Ready to be merged to Needs dev review in PR review queue Feb 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: FlaskBuildTests, SmokeNetworkExpansion, SmokeMultiChainAPI
  • 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 straightforward refactoring that migrates from useMetrics hook to useAnalytics hook in three BrowserTab components: GestureWebViewWrapper, Options, and PhishingModal. The changes are purely import substitutions - both hooks expose the same API (trackEvent and createEventBuilder), so no functional behavior changes.

The affected components are part of the BrowserTab which is used for:

  1. Snaps functionality (dApp connections via browser) - FlaskBuildTests
  2. Multi-chain dApp connections - SmokeNetworkExpansion
  3. CAIP-25 session API tests - SmokeMultiChainAPI

While the risk is low (simple hook migration with compatible API), these browser components are foundational for dApp interactions. Running browser-related tests ensures the analytics migration doesn't inadvertently break any tracking or component behavior in these critical flows.

The test files were also updated to mock the new hook correctly, which is a good sign of proper test maintenance.

Performance Test Selection:
This PR only changes analytics hook imports from useMetrics to useAnalytics. The changes are purely refactoring with no impact on rendering, data loading, or app performance. The useAnalytics hook has the same API as useMetrics and the underlying analytics tracking mechanism doesn't affect UI performance. No performance tests are needed.

View GitHub Actions results

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

}) => {
const { colors } = useTheme();
const { trackEvent, createEventBuilder } = useMetrics();
const { trackEvent, createEventBuilder } = useAnalytics();

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.

Legacy event properties silently dropped after analytics migration

High Severity

Switching createEventBuilder from MetricsEventBuilder (via useMetrics) to AnalyticsEventBuilder (via useAnalytics) silently drops the pre-defined properties on legacy IMetaMetricsEvent objects. MetricsEventBuilder copies event.properties (e.g., { action, name }) into the tracking event, but AnalyticsEventBuilder only extracts category as the event name and starts with empty properties: {}. This affects BROWSER_SWIPE_BACK, BROWSER_SWIPE_FORWARD, BROWSER_PULL_REFRESH, DAPP_OPEN_IN_BROWSER, and DAPP_ADD_TO_FAVORITE — all sharing category: 'Dapp View' and distinguished solely by their name property, which is now lost.

Additional Locations (1)

Fix in Cursor Fix in Web

@sonarqubecloud

Copy link
Copy Markdown

@NicolasMassart NicolasMassart added this pull request to the merge queue Feb 20, 2026
Merged via the queue into main with commit 5f0b29d Feb 20, 2026
94 checks passed
@NicolasMassart NicolasMassart deleted the refactor/MCWP-297_analytics_migration_batch_2-15_mobile-platform branch February 20, 2026 13:03
@github-project-automation github-project-automation Bot moved this from Needs dev review to Merged, Closed or Archived in PR review queue Feb 20, 2026
@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-S team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants