feat(bridge): emit SwapBridge failure_phase, error_code, and hash presence - #9949
feat(bridge): emit SwapBridge failure_phase, error_code, and hash presence#9949Battambang wants to merge 6 commits into
Conversation
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 0ac995f. Configure here.
|
@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. |
70a6371 to
18c3a0d
Compare
|
@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. |
e405382 to
9fa5c93
Compare
|
@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. |
add0474 to
45e4590
Compare
…sence Wire Quotes Error, submit Failed, EVM Failed, poll Failed, Submitted, and Completed to the classifiers from #9947. Mixpanel can now split quote vs broadcast vs source vs dest vs poll without parsing error_message.
…ed hash presence Promote broadcast, poll, or unknown to source_execution when history already has a source hash, so Mixpanel does not report a pre-broadcast failure after a source hash exists.
Quote fetch is pre-tx, so the emit changelog should not list source_hash_present or destination_hash_present on Quotes Error.
… use Move failure classifiers above getEVMTxPropertiesFromTransactionMeta so ESLint no-use-before-define passes.
45e4590 to
b13d916
Compare
|
@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. |

Explanation
Stacked on #9947 (schema + classifiers only). This PR emits the new Mixpanel fields so Failed is no longer a blended "on-chain" rate. Every value comes from the code path and hash presence, never from
error_message.What each event emits
bridge-controllerfailure_phase=quote,error_codefromgetQuoteFetchErrorCode(error)executeSubmitStrategy)bridge-status-controllergetSubmitFailureTelemetry(error)→broadcast, both hash flagsfalsebridge-status-controllersource_executionwhen the tx has a hash, elsebroadcast;error_codeunknownwhen the tx carries an error, elsemissing_error_objectbridge-status-controllerdestination_execution>source_execution>poll, from history src/dest hashesbridge-status-controllerfalse(emit is still before the submit strategy)bridge-status-controllerAlso added
promoteFailurePhase(new inbridge-status-controller/src/utils/metrics.ts) reconciles the phase reported by the emitting path with the combined hash presence — history flags OR-ed with any caller-supplied flags. It upgrades todestination_executionon a dest hash and tosource_executionon a source hash, but only frombroadcast/poll/unknown, so a genuine no-hash broadcast failure is never reclassified aspoll.On Failed, a caller-supplied
failure_phasewins over the status-derived one, and itserror_codeis kept (defaulting tounknown); when the caller supplies no phase, both come fromgetStatusFailureTelemetry.Ownership
bridge-status-controllerowns submit, poll, and EVM emit.bridge-controllerowns Quotes Error and the Failed property defaults — when a client omits them, Failed falls back tofailure_phase=unknown,error_code=unknown, and both hash flagsfalse, so the properties are always present in the payload.After #9947 merges, retarget this PR to
main.References
Checklist
Note
Low Risk
Additive Mixpanel/telemetry fields only; no changes to swap submission, signing, or funds handling.
Overview
Wires up the SwapBridge failure telemetry schema from #9947 so Unified SwapBridge analytics events carry structured
failure_phase,error_code, andsource_hash_present/destination_hash_presentinstead of inferring failure from free-texterror_message.bridge-controllersetsfailure_phase=quoteand a path-derivederror_codeon Quotes Error (viagetQuoteFetchErrorCodeat fetch time and defaults in the event builder). Failed events tracked from the client get explicit defaults (unknownphase/code, hash flagsfalse) when omitted.bridge-status-controllerattaches hash flags on Submitted (falseat emit), Completed (from bridge history), and Failed (submit catch usesgetSubmitFailureTelemetry; status/history paths usegetStatusFailureTelemetrypluspromoteFailurePhaseto align phase with combined hash presence). EVM tx-meta failure properties now include hash presence and broadcast vssource_executionphase.Changelogs and test snapshots are updated for the new payload fields.
Reviewed by Cursor Bugbot for commit b13d916. Bugbot is set up for automated code reviews on this repo. Configure here.