Skip to content

feat(perps): add PREVIOUS_LEVERAGE to Perps analytics event properties - #9881

Merged
abretonc7s merged 2 commits into
mainfrom
TAT-3767-feat-add-previous-leverage-perps-an
Aug 15, 2026
Merged

feat(perps): add PREVIOUS_LEVERAGE to Perps analytics event properties#9881
abretonc7s merged 2 commits into
mainfrom
TAT-3767-feat-add-previous-leverage-perps-an

Conversation

@abretonc7s

@abretonc7sabretonc7s commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Explanation

Perp UI Interaction leverage_changed events need a Segment property previous_leverage. Clients import keys from PERPS_EVENT_PROPERTY in @metamask/perps-controller; that object had LEVERAGE, LEVERAGE_USED, and DEFAULT_LEVERAGE but not PREVIOUS_LEVERAGE. Mobile TAT-3743 currently ships an interim local constant so payloads are not unknown camelCase previousLeverage.

This change adds PERPS_EVENT_PROPERTY.PREVIOUS_LEVERAGE (previous_leverage) next to the other leverage keys, documents it on Perp UI Interaction leverage_changed in the MetaMetrics reference (eventNames.ts), and records it in the Unreleased changelog so the next published @metamask/perps-controller version includes the key. PERPS_EVENT_PROPERTY is 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

  • https://consensyssoftware.atlassian.net/browse/TAT-3767
  • Relates to TAT-3743 (Mobile interim PERPS_ANALYTICS_PREVIOUS_LEVERAGE). After this package is published, Mobile should bump @metamask/perps-controller and drop that interim constant.
  • No Extension follow-up: Extension does not emit this property.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them — not applicable: additive as const key, same pattern as PERPS_MODE / ROE_SIGN

Screenshots/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 Interaction leverage_changed events can send the prior leverage using the shared @metamask/perps-controller contract instead of client-local constants.

Documents the property on LEVERAGE_CHANGED in eventNames.ts, records it under Unreleased in the package changelog, and adds a Jest assertion that the key exports as previous_leverage.

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

Co-authored-by: Cursor <cursoragent@cursor.com>
@abretonc7sabretonc7s changed the title chore: prepare farmslot publication pkg-071d46bc-mssz8dtvfeat(perps): add PREVIOUS_LEVERAGE to Perps analytics event propertiesAug 14, 2026
@abretonc7s
abretonc7s marked this pull request as ready for review August 14, 2026 13:48
@abretonc7s
abretonc7s requested review from a team as code ownersAugust 14, 2026 13:48
Co-authored-by: Cursor <cursoragent@cursor.com>
@abretonc7s
abretonc7s added this pull request to the merge queueAug 15, 2026
Merged via the queue into main with commit 0a63f1aAug 15, 2026
46 checks passed
@abretonc7s
abretonc7s deleted the TAT-3767-feat-add-previous-leverage-perps-an branch August 15, 2026 04:57
@abretonc7sabretonc7s mentioned this pull request Aug 19, 2026
4 tasks
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
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@abretonc7s@Bigshmow