feat: add batch sell metrics#9272
Open
infiniteflower wants to merge 8 commits into
Open
Conversation
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Contributor
Author
|
@metamaskbot publish-previews |
10 tasks
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
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 free
to 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
This PR revises Batch Sell analytics in
@metamask/bridge-controller.It narrows the Batch Sell metrics surface to the five supported events, updates the event payload types and controller assembly to emit the exact Batch Sell property schema, and removes legacy Batch Sell event names that are no longer used. Batch Sell chain IDs are now supplied by the client for these events so metrics can be emitted before quote request state exists.
It also fixes Batch Sell quote metadata so
sentAmount.usdis calculated with each quote's own source token exchange rate. Previously,selectBridgeQuotesWithMetadataderived one source token rate from the first quote request and applied it to every quote, which made later Batch Sell source tokens incorrect when their prices differed from the first token.Tests cover the revised Batch Sell event payloads and the per-source-token USD regression for
selectBatchSellQuotes.References
Related to: MetaMask/metamask-mobile#32439, https://github.com/Consensys/segment-schema/pull/639
Checklist
Note
Medium Risk
Touches shared metrics typing and quote USD calculation used by Batch Sell UI; consumers must adopt new event names and client chain/location fields, but scope is analytics and display metadata rather than transaction execution.
Overview
Adds five Batch Sell analytics events (
BatchSellMetricsEventName) with dedicated payload types,BatchSellMetricsLocation, and wiring throughtrackUnifiedSwapBridgeEvent/#getEventProperties. Batch Sell events use client-supplied chain IDs and their own location enum (not unifiedfeature_id/ swap-bridge context).setLocation/getLocationand metrics typing now use the broaderBridgeControllerMetricsEventNameandBridgeControllerMetricsLocationunions.Fixes Batch Sell quote metadata:
selectBridgeQuotesWithMetadataresolves each quote’s source token exchange rate from that quote’ssrcAssetinstead of reusing the first quote request’s source rate, sosentAmount.usdis correct when multiple source tokens differ in price.Exports new constants/types from the package index; tests cover Batch Sell event payloads and per-token USD in
selectBatchSellQuotes.Reviewed by Cursor Bugbot for commit 97015b3. Bugbot is set up for automated code reviews on this repo. Configure here.