Skip to content

refactor(analytics): D4 migrate useMetrics to useAnalytics in Notifications + Mobile Core UX#28297

Merged
NicolasMassart merged 3 commits into
mainfrom
refactor/26686_d4-notif-core-ux_use-analytics-migration
Apr 8, 2026
Merged

refactor(analytics): D4 migrate useMetrics to useAnalytics in Notifications + Mobile Core UX#28297
NicolasMassart merged 3 commits into
mainfrom
refactor/26686_d4-notif-core-ux_use-analytics-migration

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Description

Part of the analytics cleanup workstream migrating from the legacy useMetrics hook to the new useAnalytics hook.

This PR covers ~3 files in the Notifications and Mobile Core UX areas:

  • app/components/UI/Notification/List/index.tsx — replaces useMetrics with useAnalytics
  • app/components/UI/MarketInsights/Views/MarketInsightsView/MarketInsightsView.tsx — fixes MetaMetricsEvents import to source from core/Analytics directly
  • Tests updated to use createMockUseAnalyticsHook and jest.mocked() pattern instead of manual mock factories

Changelog

CHANGELOG entry: null

Related issues

Fixes: #26818

Manual testing steps

N/A

Screenshots/Recordings

Before

N/A

After

N/A

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 refactor limited to analytics plumbing and test mocks; primary risk is missing/incorrect event tracking due to hook or import changes.

Overview
Refactors Notifications analytics to use the new useAnalytics hook (instead of legacy useMetrics) when marking notifications read and emitting MetaMetricsEvents.NOTIFICATION_CLICKED.

Updates related tests to mock useAnalytics via createMockUseAnalyticsHook, and removes now-unused metrics mocking from MainNotificationToggle.hooks.test.tsx. Also aligns MarketInsightsView to import MetaMetricsEvents from core/Analytics.

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

@NicolasMassart NicolasMassart self-assigned this Apr 1, 2026
@github-actions

github-actions Bot commented Apr 1, 2026

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.

@metamaskbot metamaskbot added the team-mobile-platform Mobile Platform team label Apr 1, 2026
@github-actions github-actions Bot added the size-S label Apr 1, 2026
@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue Apr 2, 2026
@NicolasMassart NicolasMassart marked this pull request as ready for review April 2, 2026 08:32
@NicolasMassart NicolasMassart requested review from a team as code owners April 2, 2026 08:32

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is removing stale tests of analytics removed in #21858 last year

@github-actions github-actions Bot added the risk-low Low testing needed · Low bug introduction risk label Apr 2, 2026
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 2, 2026
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeWalletPlatform
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
The 4 changed files represent minor refactoring changes:

  1. MarketInsightsView.tsx: Import path fix only - MetaMetricsEvents moved from hooks/useMetrics to core/Analytics. Zero functional change.

  2. Notification/List/index.tsx: Analytics hook migration from useMetrics to useAnalytics. The notification list behavior is unchanged; only the analytics tracking implementation is refactored.

  3. Notification/List/index.test.tsx: Test mock updated to use useAnalytics mock pattern instead of useMetrics mock.

  4. MainNotificationToggle.hooks.test.tsx: Removed useMetrics mock since the hook no longer uses it; simplified test setup.

All changes are internal refactoring with no user-facing functional changes. The SmokeWalletPlatform tag is selected because:

  • MarketInsightsView is part of the Trending/market insights feature covered by SmokeWalletPlatform
  • Notification list is a wallet platform feature
  • This provides a reasonable smoke test to verify the analytics hook migration didn't break anything

No other tags are needed since: no confirmation flows changed, no account management changed, no network/chain logic changed, no swap/trade flows changed.

Performance Test Selection:
All changes are internal refactoring of analytics hook imports (useMetrics → useAnalytics) and import path fixes. No UI rendering changes, no data loading changes, no state management changes, and no performance-sensitive code paths were modified. Performance tests are not warranted.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented Apr 2, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
18 value mismatches detected (expected — fixture represents an existing user).
View details

@baptiste-marchand baptiste-marchand 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 Apr 7, 2026
@NicolasMassart NicolasMassart added this pull request to the merge queue Apr 8, 2026
Merged via the queue into main with commit 16c6205 Apr 8, 2026
152 of 153 checks passed
@NicolasMassart NicolasMassart deleted the refactor/26686_d4-notif-core-ux_use-analytics-migration branch April 8, 2026 10:12
@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 Apr 8, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 8, 2026
@weitingsun weitingsun added the release-7.74.0 Issue or pull request that will be included in release 7.74.0 label Apr 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.74.0 Issue or pull request that will be included in release 7.74.0 risk-low Low testing needed · Low bug introduction risk size-S team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

PR D4: migrate useMetrics to useAnalytics in Notifications + Mobile Core UX (~3 files)

5 participants