Skip to content

refactor(analytics): D5 migrate MetaMetrics.getInstance() to analytics.trackEvent in ramps-controller#28339

Merged
NicolasMassart merged 4 commits into
mainfrom
refactor/26686_d5-ramp_migrate-metametrics
Apr 9, 2026
Merged

refactor(analytics): D5 migrate MetaMetrics.getInstance() to analytics.trackEvent in ramps-controller#28339
NicolasMassart merged 4 commits into
mainfrom
refactor/26686_d5-ramp_migrate-metametrics

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Description

Part of the ongoing analytics migration (#26686). This PR migrates the ramps-controller analytics event handler away from the legacy MetaMetrics singleton.

  • Replaces MetaMetrics.getInstance().trackEvent(...) with analytics.trackEvent(...)
  • Replaces MetricsEventBuilder with AnalyticsEventBuilder from util/analytics
  • Updates tests to mock util/analytics/analytics instead of the MetaMetrics singleton, using jest.mocked() per project standards

This is a prerequisite for deleting MetaMetrics.ts in Phase E1.

Changelog

CHANGELOG entry: null

Related issues

Fixes: #28324

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
Refactor-only migration of a single ramps analytics emitter from the legacy MetaMetrics singleton to the new analytics wrapper; main risk is accidental event shape/name changes due to the builder swap, covered by unit tests.

Overview
Migrates ramps order status analytics emission from the legacy MetaMetrics.getInstance().trackEvent(...) pathway to analytics.trackEvent(...), switching the event builder from MetricsEventBuilder to AnalyticsEventBuilder.

Updates the associated unit test to mock util/analytics/analytics (and wire analytics.trackEvent via jest.mocked()), while preserving the same event categories/properties expectations and error-logging behavior.

Reviewed by Cursor Bugbot for commit 00baca2. Bugbot is set up for automated code reviews on this repo. Configure here.

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

github-actions Bot commented Apr 2, 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 2, 2026
@github-actions github-actions Bot added the size-S label Apr 2, 2026
@NicolasMassart NicolasMassart marked this pull request as ready for review April 2, 2026 13:30
@NicolasMassart NicolasMassart enabled auto-merge April 2, 2026 13:30
@github-actions github-actions Bot added the risk-low Low testing needed · Low bug introduction risk label Apr 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 927511e1bb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@NicolasMassart NicolasMassart requested a review from a team as a code owner April 7, 2026 10:35
@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 7, 2026

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

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cbdc89e. Configure here.

@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 8, 2026
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeRamps
  • 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 focused refactoring of the analytics tracking mechanism in the ramps controller event handler. Specifically:

  1. analytics.ts: Replaces MetaMetrics.getInstance().trackEvent() with analytics.trackEvent() (new unified analytics utility), and replaces MetricsEventBuilder with AnalyticsEventBuilder. The functional behavior of tracking ramp order status changes (buy/sell completions, failures, etc.) remains identical.

  2. analytics.test.ts: Updates mocks to match the new implementation pattern.

This is an internal refactoring with no UI changes, no new features, and no changes to the ramps flow itself. The new analytics utility is already used in other parts of the codebase (confirmations/send.ts, bridge selectors, etc.), so it's a proven pattern.

The only risk is that the analytics events for on-ramp/off-ramp order status changes might not fire correctly if the new utility has different behavior. SmokeRamps is the appropriate tag to validate this. No other tags are needed as the change is isolated to the ramps analytics handler with no cross-cutting impact on other flows.

Performance Test Selection:
No performance impact expected. This is a simple analytics utility swap (MetaMetrics.getInstance() → analytics singleton) with no changes to UI rendering, data loading, state management, or critical user flow performance characteristics.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented Apr 8, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

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

@ieow ieow 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 Apr 9, 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 Apr 9, 2026
Merged via the queue into main with commit 24d0f3e Apr 9, 2026
93 checks passed
@NicolasMassart NicolasMassart deleted the refactor/26686_d5-ramp_migrate-metametrics branch April 9, 2026 15:28
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 9, 2026
@metamaskbot metamaskbot added the release-7.74.0 Issue or pull request that will be included in release 7.74.0 label Apr 9, 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.

Refactor(analytics): PR D5 migrate MetaMetrics.getInstance() to analytics.trackEvent in ramps-controller

4 participants