Add input currency mode to Unified SwapBridge metrics#8909
Conversation
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
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 a3d4476. Configure here.
| ...(eventName === UnifiedSwapBridgeEventName.Completed && { | ||
| input_currency_mode: | ||
| historyItem.inputCurrencyMode ?? InputCurrencyMode.CRYPTO, | ||
| }), |
There was a problem hiding this comment.
Post-submission Failed events inconsistently omit input_currency_mode
Medium Severity
The input_currency_mode field is read from the history item only when eventName === Completed, but not when it's Failed. Pre-submission Failed events receive it via preConfirmationProperties, but post-submission Failed events (from polling status checks or #onTransactionFailed) go through #trackUnifiedSwapBridgeEvent without it. This creates inconsistent analytics data for the same event type — some Failed events include input_currency_mode and others don't, depending on when the failure occurred, even though inputCurrencyMode is persisted on the history item and available.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit a3d4476. Configure here.


Summary
input_currency_modeto Unified SwapBridge quote, submit, and completion metrics.InputCurrencyModeenum in@metamask/bridge-controllerwithfiatandcryptovalues.cryptofor backward compatibility.input_currency_modewithout local casts.Testing
@metamask/bridge-controllerand@metamask/bridge-status-controllerwith coverage disabled.Note
Low Risk
Analytics-only field additions with safe defaults; no changes to swap/bridge execution or auth.
Overview
Adds
input_currency_mode(fiat|crypto) to Unified SwapBridge analytics so clients can report whether the user entered the source amount in fiat or crypto.@metamask/bridge-controllerintroduces sharedInputCurrencyMode, exports it, and extends metrics types (includingInputChangedwithinput_currency_mode).BridgeControllerreads the mode from client event context and attaches it to Quotes Requested and Quotes Received, defaulting tocryptowhen omitted.@metamask/bridge-status-controllerthreads the mode from quote context through submit/intent flows, persists it on bridge history, includes it on pre-submit metrics viagetPreConfirmationPropertiesFromQuote, and emits it on Completed from stored history (again defaulting tocrypto).Test snapshots and changelogs are updated for the new payload field.
Reviewed by Cursor Bugbot for commit b3fdad6. Bugbot is set up for automated code reviews on this repo. Configure here.