refactor(analytics): migrate RPC method tracking middleware#43886
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. |
✨ Files requiring CODEOWNER review ✨🫰 @MetaMask/core-platform (1 files, +21 -16)
|
Builds ready [b39ee47]
⚡ Performance Benchmarks (Total: 🟢 19 pass · 🟡 5 warn · 🔴 0 fail)
Bundle size diffs
|
b39ee47 to
627035e
Compare
Builds ready [627035e]
⚡ Performance Benchmarks (Total: 🟢 18 pass · 🟡 6 warn · 🔴 0 fail)
Bundle size diffs
|
627035e to
5dbc307
Compare
5dbc307 to
5489d46
Compare
5489d46 to
83cfdb3
Compare
83cfdb3 to
989342c
Compare
989342c to
2a9098d
Compare
Builds ready [2a9098d] [reused from 627035e]
⚡ Performance Benchmarks (Total: 🟢 18 pass · 🟡 6 warn · 🔴 0 fail)
Bundle sizes
|
2a9098d to
753ae21
Compare
753ae21 to
17e071d
Compare
Builds ready [b50b510] [reused from ce82cfe]
⚡ Performance Benchmarks (Total: 🟢 16 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs
|
Builds ready [8eed5b3]
⚡ Performance Benchmarks (Total: 🟢 13 pass · 🟡 11 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Replace metaMetricsController.trackEvent with createEventBuilder + trackEvent at RPC middleware call sites. Limit scope to middleware and its tests only. Co-authored-by: Cursor <cursoragent@cursor.com>
8eed5b3 to
e3d5572
Compare
There was a problem hiding this comment.
Pull request overview
This PR migrates RPC method tracking middleware analytics emissions from legacy MetaMetricsController.trackEvent call sites to the new background analytics helpers (createEventBuilder + trackEvent) to align with the ongoing analytics migration effort.
Changes:
- Replaced direct
metaMetricsController.trackEventusage increateRPCMethodTrackingMiddlewarewithcreateEventBuilder(...).build(...)+trackEvent(...). - Updated the middleware unit tests to spy on
AnalyticsController:trackEventand added a helper to normalize the new tracked-event call shape.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/scripts/lib/createRPCMethodTrackingMiddleware.js | Switches non-signature-fragment RPC tracking to the AnalyticsController-based createEventBuilder/trackEvent path. |
| app/scripts/lib/createRPCMethodTrackingMiddleware.test.js | Reworks assertions to validate the new AnalyticsController tracking call shape and initializes analytics test plumbing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Builds ready [e3d5572]
⚡ Performance Benchmarks (Total: 🟢 17 pass · 🟡 7 warn · 🔴 0 fail)
Bundle size diffs
|



Description
Sub-PR of umbrella tracker #43885.
Migrates MetaMetrics
trackEventcall sites in this CODEOWNERS domain tocreateEventBuilder+trackEventviauseAnalytics()(UI) orapp/scripts/controllers/analytics(background).Dependency note: Independent — RPC middleware only, can merge anytime.
Files in this PR: 8
Changelog
CHANGELOG entry: null
Related issues
Part of analytics migration umbrella: #43885
Manual testing steps
yarn start.Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Analytics plumbing swap with broad test updates; behavior should be equivalent aside from event payload structure. No RPC or security logic changes.
Overview
RPC method tracking middleware now emits non–signature-fragment analytics through
createEventBuilder+trackEventfromapp/scripts/controllers/analyticsinstead ofmetaMetricsController.trackEvent, for both the initial “requested” path and post-callback approve/reject flows. Signature flows still useMetaMetricsControllerevent fragments unchanged.Tests wire
configureAnalytics, spyAnalyticsController:trackEvent, and assert via agetTrackedEventCallhelper that maps the new event shape; several expectations were relaxed fromtoStrictEqualtotoMatchObjectwhere the builder payload differs from the old flat object.Reviewed by Cursor Bugbot for commit e3d5572. Bugbot is set up for automated code reviews on this repo. Configure here.