Uh oh!
There was an error while loading. Please reload this page.
feat(perps): add PREVIOUS_LEVERAGE to Perps analytics event properties - #9881
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
abretonc7s
marked this pull request as ready for review
August 14, 2026 13:48
abretonc7stemporarily deployed
to
default-branch
August 14, 2026 13:48 — with
GitHub Actions
Inactive
Co-authored-by: Cursor <cursoragent@cursor.com>
Bigshmow
approved these changes
Aug 15, 2026
Uh oh!
There was an error while loading. Please reload this page.
pullBot
pushed a commit
to dmrazzy/core
that referenced
this pull request
Aug 19, 2026
## Explanation Release `@metamask/perps-controller` **12.1.0**. No other packages. Minor bump. New public API: - Optional `PerpsPerformance.onControllerConstructed` post-hydration hook - `PerpsTracer.setMeasurement` overload that takes a trace ID - `PERPS_EVENT_PROPERTY.PREVIOUS_LEVERAGE` (`previous_leverage`) Also retargets market/user preload measurements onto their named traces and drops wallet addresses from user-preload trace data. No breaking changes. Existing 3-arg `setMeasurement` callers and clients that omit the new hook keep compiling. ## References - MetaMask#9906 - MetaMask#9881 ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Perp UI Interaction
leverage_changedevents need a Segment propertyprevious_leverage. Clients import keys fromPERPS_EVENT_PROPERTYin@metamask/perps-controller; that object hadLEVERAGE,LEVERAGE_USED, andDEFAULT_LEVERAGEbut notPREVIOUS_LEVERAGE. Mobile TAT-3743 currently ships an interim local constant so payloads are not unknown camelCasepreviousLeverage.This change adds
PERPS_EVENT_PROPERTY.PREVIOUS_LEVERAGE(previous_leverage) next to the other leverage keys, documents it on Perp UI Interactionleverage_changedin the MetaMetrics reference (eventNames.ts), and records it in the Unreleased changelog so the next published@metamask/perps-controllerversion includes the key.PERPS_EVENT_PROPERTYis already a package-root export; no new export path is required. This is additive and non-breaking.Validation: targeted Jest on
eventNames.test.ts(63 passing), changelog validate, changed-file ESLint/oxfmt, and a headless recipe that imports the constant and asserts strict equality.References
PERPS_ANALYTICS_PREVIOUS_LEVERAGE). After this package is published, Mobile should bump@metamask/perps-controllerand drop that interim constant.Checklist
as constkey, same pattern asPERPS_MODE/ROE_SIGNScreenshots/Recordings
Note
Low Risk
Additive analytics constant and documentation only; no runtime trading, auth, or persistence behavior changes.
Overview
Adds
PERPS_EVENT_PROPERTY.PREVIOUS_LEVERAGE(previous_leverage) so Perp UI Interactionleverage_changedevents can send the prior leverage using the shared@metamask/perps-controllercontract instead of client-local constants.Documents the property on
LEVERAGE_CHANGEDineventNames.ts, records it under Unreleased in the package changelog, and adds a Jest assertion that the key exports asprevious_leverage.Reviewed by Cursor Bugbot for commit ddf75bd. Bugbot is set up for automated code reviews on this repo. Configure here.