Skip to content

refactor(analytics): migrate Batch 2-14: notifications#26303

Merged
NicolasMassart merged 4 commits into
mainfrom
refactor/MCWP-297_analytics_migration_batch_2-14_notifications
Feb 20, 2026
Merged

refactor(analytics): migrate Batch 2-14: notifications#26303
NicolasMassart merged 4 commits into
mainfrom
refactor/MCWP-297_analytics_migration_batch_2-14_notifications

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Description

Phase 2 analytics migration (Batch 2-14): migrate Notifications' views, hooks, and services from the legacy MetaMetrics system to the new analytics system.

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

Changes: Notifications source files (index.tsx, OptIn, BlockExplorerFooter, AnnouncementCtaFooter, TransactionField, NetworkFeeField, OptIn.hooks) now use useAnalytics from app/components/hooks/useAnalytics/useAnalytics; FCMService.ts now uses analytics.trackEvent() and AnalyticsEventBuilder from app/util/analytics; all test mocks updated to mock the analytics utility instead of MetaMetrics.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MCWP-297 (Batch 2-14)

Manual testing steps

Feature: Notifications analytics

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

    When user performs an action that triggers analytics (e.g. mark all as read, view block explorer, opt in/cancel)
    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
Refactor-only analytics migration with no functional UI or notification-processing changes, but it could impact event emission if any import/mocking mismatch slips through.

Overview
Notifications screens/components and opt-in hooks now use useAnalytics instead of useMetrics for tracking detail-click and “mark all as read” events, with imports updated accordingly.

FCMService switches push-notification click tracking from MetaMetrics.getInstance().trackEvent/MetricsEventBuilder to the shared analytics.trackEvent with AnalyticsEventBuilder. All related unit tests are updated to mock useAnalytics/analytics and the new event builder APIs.

Written by Cursor Bugbot for commit 0b7f2e9. 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
@NicolasMassart NicolasMassart moved this to Needs dev review in PR review queue 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 marked this pull request as ready for review February 19, 2026 22:15
@NicolasMassart NicolasMassart requested a review from a team as a code owner February 19, 2026 22:15

@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 2 potential issues.

import { fireEvent, render } from '@testing-library/react-native';
import TransactionField from './TransactionField';
import * as useMetricsModule from '../../../../hooks/useMetrics';
import * as useAnalyticsModule from '../../../../hooks/useAnalytics/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.

Test still uses legacy MetricsEventBuilder instead of AnalyticsEventBuilder

Low Severity

TransactionField.test.tsx was partially migrated — useMetrics became useAnalytics, but the import and usage of MetricsEventBuilder (legacy) was not updated to AnalyticsEventBuilder (new). The sibling BlockExplorerFooter.test.tsx was fully migrated to AnalyticsEventBuilder. This leaves a stale dependency on the deprecated module that the PR intends to replace.

Additional Locations (1)

Fix in Cursor Fix in Web

MetaMetrics.getInstance().trackEvent(
MetricsEventBuilder.createEventBuilder(
analytics.trackEvent(
AnalyticsEventBuilder.createEventBuilder(

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.

FCMService saveDataRecording silently changed from true to false

Medium Severity

The migration from MetaMetrics.getInstance().trackEvent(...) to analytics.trackEvent(...) silently changes the saveDataRecording flag from true to false. The old MetaMetrics.trackEvent defaulted saveDataRecording to true and explicitly called .setSaveDataRecording(true) when rebuilding the event. The new code builds the event directly via AnalyticsEventBuilder.createEventBuilder(...) which defaults saveDataRecording to false (in createAnalyticsEvent), and .setSaveDataRecording(true) is never called. The useAnalytics hook handles this correctly by calling .setSaveDataRecording(saveDataRecording ?? true) in its trackEvent, but FCMService bypasses the hook.

Fix in Cursor Fix in Web

@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: SmokeNetworkAbstractions
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are a straightforward refactoring that migrates the Notifications feature from using the useMetrics hook to the new useAnalytics hook. All 14 changed files are in the Notifications feature area (app/components/Views/Notifications/ and app/util/notifications/). The changes are purely import replacements - switching from useMetrics to useAnalytics and from MetaMetrics singleton to analytics singleton. Both hooks have the same API (trackEvent, createEventBuilder, etc.), so there are no functional changes. All corresponding unit test files have been updated to mock the new hook. The notification E2E tests are tagged with SmokeNetworkAbstractions (as confirmed in the tag description: "Also covers notification settings flows"). Running SmokeNetworkAbstractions will verify that the notification flows still work correctly after the analytics hook migration.

Performance Test Selection:
No performance tests needed. The changes are purely import/hook migrations with no changes to rendering, data loading, or state management. The analytics hook replacement has the same API and behavior, so there's no impact on app performance.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@NicolasMassart NicolasMassart added this pull request to the merge queue Feb 20, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 20, 2026
@NicolasMassart NicolasMassart added this pull request to the merge queue Feb 20, 2026
Merged via the queue into main with commit 1410bac Feb 20, 2026
89 checks passed
@NicolasMassart NicolasMassart deleted the refactor/MCWP-297_analytics_migration_batch_2-14_notifications branch February 20, 2026 18:27
@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-M team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants