refactor(analytics): migrate Batch 2-15: mobile-platform#26304
Conversation
|
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. |
…2-15_mobile-platform
…2-15_mobile-platform
…2-15_mobile-platform
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: The affected components are part of the BrowserTab which is used for:
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: |
| }) => { | ||
| const { colors } = useTheme(); | ||
| const { trackEvent, createEventBuilder } = useMetrics(); | ||
| const { trackEvent, createEventBuilder } = useAnalytics(); |
There was a problem hiding this comment.
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)
|





Description
Phase 2 analytics migration (Batch 2-15): migrate mobile-platform's In App Browser components (PhishingModal, Options, GestureWebViewWrapper) from
useMetricsto the newuseAnalyticshook.Reason: Deprecate MetaMetrics in favour of the shared analytics utility and AnalyticsController.
Changes: Browser
PhishingModal,Options, andGestureWebViewWrappernow useuseAnalyticsfromapp/components/hooks/useAnalytics/useAnalyticsand importMetaMetricsEventsfromapp/core/Analytics; test mocks updated to mockuseAnalyticsinstead ofuseMetrics.Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/MCWP-297 (Batch 2-15)
Manual testing steps
Screenshots/Recordings
N/A – analytics migration, no UI change.
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches analytics instrumentation paths; if
useAnalyticsbehavior differs fromuseMetrics, event tracking could regress, but no user-facing logic or security-sensitive flows are changed.Overview
Migrates in-app browser analytics wiring from
useMetricsto the newer shareduseAnalyticshook inGestureWebViewWrapper,Options, andPhishingModal, while keeping the same event emission sites.Updates
MetaMetricsEventsimports to come fromapp/core/Analytics(instead of viauseMetrics) and adjusts unit tests to mockuseAnalyticsaccordingly.Written by Cursor Bugbot for commit feabfa9. This will update automatically on new commits. Configure here.