feat: add metrics to perps#41337
Conversation
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/perps (22 files, +864 -161)
|
Builds ready [7a74f84]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [65daac1]
⚡ Performance Benchmarks
Dapp page load benchmarks: data not available. Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [39d26ab]
⚡ Performance Benchmarks (Total: 🟢 18 pass · 🟡 0 warn · 🔴 0 fail)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [f2f3a73]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
geositta
left a comment
There was a problem hiding this comment.
looks good, thanks for adding the has_perp_balance check for account !== null and the home tab change.
Builds ready [45b53de]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [afe6811]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [7ea9233]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 b6d2245. Configure here.
|
Builds ready [b6d2245]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|




Description
Adds initial metrics to Perps in extension. Should align well with the metrics we collect on mobile. One key point that we are capturing here is
environment_typewhich differentiates whether events are being sent is sidepanel, popup, or full screen.This is important, since we will soon be introducing full-screen only features, and it would be helpful to track this type of retention across different environment types. Sidepanel is the default, and I expect the majority of the events to be sourced from here.
Changelog
CHANGELOG entry: Adds initial metrics to Perps for extension
Related issues
Fixes:
Manual testing steps
Configure Sentry tracking locally as per guidelines in
development/README.mdand verify that proper events are being sent:You can also configure the
SENTRY_WRITE_KEYto point at Mixpanel'sMetaMask Extension [Dev]dashboard and verify that events are sent as expected:Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Introduces new analytics plumbing (MetaMetrics messenger action + Perps infrastructure deps) and adds tracking across many Perps UI flows; risk is mainly incorrect/duplicate event emission or payload shape drift rather than functional behavior changes.
Overview
Adds first-class Perps analytics wiring in extension by making
createPerpsInfrastructureaccept deps and forwardingmetrics.trackPerpsEventintoMetaMetricsController:trackEventwith Perps category + injected timestamp.Introduces shared Perps analytics constants/events in
shared/constants/perps-events.ts(to avoid Jest ESM import issues) plus a Jest manual mock for@metamask/perps-controller, and expands MetaMetrics enums to include Perps event names/categories.Adds a new
usePerpsEventTrackinghook (imperative + declarative “fire once” API with optionalresetKey) and instruments Perps pages/modals/interactions (market list/detail, order entry, close/cancel/withdraw, margin, TP/SL, tutorial, sliders/filters/search) to emit screen-view, UI interaction, transaction, risk-management, and error events; updates/extends tests accordingly.Reviewed by Cursor Bugbot for commit b6d2245. Bugbot is set up for automated code reviews on this repo. Configure here.