Repository navigation
feat(analytics): replace Error occured with Error Occurred via trackErrorAsAnalytics - #47657
Conversation
…rrorAsAnalytics Co-authored-by: Cursor <cursoragent@cursor.com>
|
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/confirmations (1 files, +1 -0)
👨🔧 @MetaMask/core-extension-ux (2 files, +7 -6)
👨🔧 @MetaMask/product-safety (1 files, +5 -1)
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Builds ready [fa767f5]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 3 warn · 🔴 3 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
|
@metamaskbot update-policies |
|
Policies updated. Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 👀 lavamoat/webpack/mv2/beta/policy.json changes differ from lavamoat/webpack/mv2/main/policy.json changes |
…enerate LavaMoat policies Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [27f2327]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 2 warn · 🔴 3 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
…tion Co-authored-by: Cursor <cursoragent@cursor.com>
…or-occured-with-error-occurred
Builds ready [308541d]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 1 warn · 🔴 4 fail)
Bundle Size Diffs
|
There was a problem hiding this comment.
🟡 Changes recommended
The new hook test lacks coverage for consent gating, forwarding without an analytics ID, and isolation of rejected background requests.
1 open issue
What changed in this PR
Migrates MetaMetrics deletion-error reporting to the standardized Error Occurred event through AnalyticsController:trackErrorAsAnalytics.
Changes:
- Updates
@metamask/analytics-controllerto^4.3.0. - Adds UI action and hook support, including error serialization, consent checks, and background-request failure handling.
- Migrates both deletion flows, removes the obsolete event name, and updates tests and mocks.
| File | Description |
|---|---|
yarn.lock |
Locks analytics-controller to 4.3.0. |
ui/store/actions.ts |
Adds error serialization and background forwarding. |
ui/store/actions.track-error-as-analytics.test.ts |
Tests error serialization and forwarded properties. |
ui/pages/settings/privacy-tab/delete-metametrics-modal.tsx |
Migrates privacy-modal error reporting. |
ui/pages/settings/privacy-tab/delete-metametrics-data-item.test.tsx |
Extends the analytics mock. |
ui/pages/confirmations/components/simulation-details/useSimulationMetrics.test.ts |
Updates the hook mock interface. |
ui/hooks/useAnalytics.ts |
Exposes consent-gated error reporting with failure isolation. |
ui/hooks/useAnalytics.test.tsx |
Tests opted-in error forwarding. |
ui/components/app/product-safety/scam-questionnaire/useScamQuestionnaireMetrics.test.ts |
Updates the hook mock interface. |
ui/components/app/clear-metametrics-data/clear-metametrics-data.tsx |
Migrates legacy deletion-modal error reporting. |
ui/components/app/clear-metametrics-data/clear-metametrics-data.test.tsx |
Updates deletion-error tracking assertions. |
ui/__mocks__/useAnalytics.ts |
Adds the shared error-reporting mock. |
shared/constants/metametrics.ts |
Removes the obsolete ErrorOccured event. |
package.json |
Raises the analytics-controller dependency to ^4.3.0. |
Review effort: Balanced
…re isolation Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [631d08d]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 2 warn · 🔴 4 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
| } catch { | ||
| // Swallow background RPC failures. Error reporting must not break UI. | ||
| } |
There was a problem hiding this comment.
Would it make sense to move this try-catch block into the action definition if it's going to be required in every ui-side call site?
There was a problem hiding this comment.
Makes sense, it's now updated in this commit: 3ed067b
…e store action Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [3ed067b]
⚡ Performance Benchmarks (Total: 🟢 10 pass · 🟡 1 warn · 🔴 2 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [dee026c]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 3 warn · 🔴 3 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
|





Description
Replace the Extension
Error occuredMetaMetrics event with the standardizedError Occurredevent from@metamask/analytics-controller, emitted through the newAnalyticsController:trackErrorAsAnalyticsaction.Reason:
Error occuredis a one-off, typo'd Extension event with no category structure aligned with the new analytics system. Core addedtrackErrorAsAnalyticsonAnalyticsControllerto report caught errors asError Occurredevents with a uniquesourceand a sanitizederror_message, bounded by sampling, deduplication, and a per-session cap. Aligning Extension on this event unifies error tracking across MetaMask clients.Solution:
@metamask/analytics-controllerto^4.2.0(introducestrackErrorAsAnalytics).AnalyticsController:trackErrorAsAnalyticson the analytics init messenger.trackErrorAsAnalyticsbackground helper, a MetaMask controller API entry, a UI store action, and auseAnalytics().trackErrorAsAnalyticshook method.Error occuredcall sites (MetaMetrics data deletion flows) totrackErrorAsAnalyticswith uniquesourcevalues (clear-metametrics-data,delete-metametrics-modal).MetaMetricsEventName.ErrorOccuredenum entry.Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
[MetaMask Extension [Dev]]Segment sourceyarn start).[MetaMask Extension [Dev]]Segment source's debugger, and confirm an anonymousError Occurredevent is emitted withsourceset todelete-metametrics-modaland a sanitizederror_message.Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Analytics-only change with consent gating and no changes to deletion or wallet logic; main risk is mis-tagged error telemetry if consent rules regress.
Overview
Upgrades
@metamask/analytics-controllerto ^4.3.0 and replaces the legacyError occuredMetaMetrics event with the controller’sError Occurredflow viatrackErrorAsAnalytics.UI → background path:
useAnalytics()exposestrackErrorAsAnalytics, gated like other analytics (skips when opted out; still sends when consent is undecided). The UI store action normalizes errors withgetErrorMessage, mapsexcludeMetaMetricsIdto anonymous reporting, addsenvironment_type, and RPCsAnalyticsController:trackErrorAsAnalytics(failures are swallowed).Call sites: MetaMetrics data deletion modals (
clear-metametrics-data,delete-metametrics-modal) now report failures with distinctsourcevalues instead ofMetaMetricsEventName.ErrorOccured, which is removed frommetametrics.ts.Tests: Hooks, store action, mocks, and deletion UI tests cover forwarding, opt-out, serialization, and RPC error handling.
Reviewed by Cursor Bugbot for commit dee026c. Bugbot is set up for automated code reviews on this repo. Configure here.