Skip to content

chore(analytics): migrate MetricsEventBuilder→AnalyticsEventBuilder in transaction controller metrics (confirmations)#31252

Merged
NicolasMassart merged 3 commits into
mainfrom
analytics/pr4-confirmations
Jun 9, 2026
Merged

chore(analytics): migrate MetricsEventBuilder→AnalyticsEventBuilder in transaction controller metrics (confirmations)#31252
NicolasMassart merged 3 commits into
mainfrom
analytics/pr4-confirmations

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

Migrates the transaction controller event handler from the legacy MetricsEventBuilder to AnalyticsEventBuilder. Also removes the setSaveDataRecording call which was part of the now-removed data-recording chain.

Part of the analytics migration cleanup series. All changes are in files owned by the confirmations team.

Changelog

CHANGELOG entry: null

Related issues

Refs: #26686

Manual testing steps

N/A — analytics-only refactor, no behaviour change.

Screenshots/Recordings

Before

N/A

After

N/A

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
  • I've tested with a power user scenario
  • I've instrumented key operations with Sentry traces for production performance metrics

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.

Made with Cursor


Note

Low Risk
Analytics-only refactor with no user-facing behavior change; main nuance is omitting saveDataRecording on tracked events until the analytics-controller types align.

Overview
Transaction controller metrics now build events with AnalyticsEventBuilder instead of legacy MetricsEventBuilder, including generateEvent in utils.ts and the handlers in metrics.ts.

Tracking no longer calls setSaveDataRecording when forwarding events to AnalyticsController:trackEvent. A temporary initMessenger cast works around a type mismatch until @metamask/analytics-controller drops saveDataRecording from its event type.

Tests use a single mocked AnalyticsEventBuilder and assert against that builder for all transaction metric handlers.

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

…and remove setSaveDataRecording (confirmations)

Migrates transaction-controller utils.ts and metrics.ts from MetricsEventBuilder
to AnalyticsEventBuilder. Removes the two setSaveDataRecording(event.saveDataRecording)
calls from metrics.ts (F.2 - they are now inert since AnalyticsEventBuilder has no
saveDataRecording field). Updates metrics.test.ts accordingly.

Co-authored-by: Cursor <cursoragent@cursor.com>
@NicolasMassart NicolasMassart self-assigned this Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 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.

…cs test

Co-authored-by: Cursor <cursoragent@cursor.com>
@NicolasMassart NicolasMassart marked this pull request as draft June 9, 2026 09:43
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.04%. Comparing base (fb78130) to head (73d0789).
⚠️ Report is 46 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #31252      +/-   ##
==========================================
+ Coverage   82.94%   83.04%   +0.09%     
==========================================
  Files        5617     5683      +66     
  Lines      144783   145835    +1052     
  Branches    33663    33980     +317     
==========================================
+ Hits       120094   121112    +1018     
+ Misses      16614    16538      -76     
- Partials     8075     8185     +110     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@NicolasMassart NicolasMassart marked this pull request as ready for review June 9, 2026 10:39
@github-actions github-actions Bot added risk:high AI analysis: high risk and removed risk:medium AI analysis: medium risk labels Jun 9, 2026
@NicolasMassart NicolasMassart enabled auto-merge June 9, 2026 13:01
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes are confined to the transaction controller's analytics/metrics event handling layer:

  1. metrics.ts: Removes .setSaveDataRecording() calls (no longer needed) and adds a TypeScript type cast workaround for the AnalyticsController:trackEvent messenger call. This is purely a type compatibility fix - no behavioral change to transaction tracking logic.

  2. utils.ts: Migrates generateEvent() from MetricsEventBuilder to AnalyticsEventBuilder. Both builders have equivalent functionality; this is a refactoring to use the newer analytics infrastructure.

  3. metrics.test.ts: Test updates to reflect the above changes - consolidates mocks and updates assertions.

Impact Assessment:

  • These changes only affect how transaction analytics events are built and dispatched - not the transaction execution, confirmation UI, or any user-facing flows
  • The AnalyticsController:trackEvent call path remains the same; only the TypeScript typing around it changes
  • No controller state, transaction processing, or UI components are affected
  • The metrics.ts file is imported by transaction-controller-init.ts and Engine.ts, but the changes don't alter the function signatures or behavior

Why SmokeConfirmations:

  • Transaction confirmations are the primary user flow that exercises the transaction controller's event handlers
  • Running SmokeConfirmations validates that transaction events still fire correctly through the updated analytics builder path
  • This provides adequate coverage to verify the analytics refactoring didn't break event tracking during real transaction flows

Why NOT broader tags:

  • No changes to transaction execution logic, gas estimation, or confirmation UI
  • No changes to network, account, swap, or other subsystems
  • The change is isolated to analytics event building within the transaction controller metrics layer

Performance tests: Not needed - these are analytics/metrics code changes with no impact on rendering, data loading, or app performance.

Performance Test Selection:
The changes are limited to analytics event building and TypeScript type casting within the transaction controller's metrics handlers. No UI rendering, data loading, state management, or performance-sensitive code paths are affected.

View GitHub Actions results

@github-actions github-actions Bot added risk:medium AI analysis: medium risk and removed risk:high AI analysis: high risk labels Jun 9, 2026
@NicolasMassart NicolasMassart added this pull request to the merge queue Jun 9, 2026
Merged via the queue into main with commit d940072 Jun 9, 2026
101 checks passed
@NicolasMassart NicolasMassart deleted the analytics/pr4-confirmations branch June 9, 2026 14:04
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 9, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.82.0 Issue or pull request that will be included in release 7.82.0 label Jun 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.82.0 Issue or pull request that will be included in release 7.82.0 risk:medium AI analysis: medium risk size-M team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants