fix: add location property to unified swap bridge events#7931
Open
sahar-fehri wants to merge 7 commits intomainfrom
Open
fix: add location property to unified swap bridge events#7931sahar-fehri wants to merge 7 commits intomainfrom
sahar-fehri wants to merge 7 commits intomainfrom
Conversation
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
7 tasks
| propertiesFromClient.location | ||
| ) { | ||
| this.#location = propertiesFromClient.location; | ||
| } |
There was a problem hiding this comment.
Location state can leak between flows
Medium Severity
#location is only persisted when the event is ButtonClicked. Internal events like InputChanged and QuotesValidationFailed read this.#location, and resetState does not clear it. Flows that start without ButtonClicked or without calling setLocation can inherit a stale location from a previous flow, causing incorrect attribution.
Additional Locations (1)
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
Adds the location property (entry point) to every Unified SwapBridge event, enabling analytics to trace a user's origin regardless of where they are in the swap/bridge flow.
How to test locally
Add this console log in
bridge-controller.tsinsidetrackUnifiedSwapBridgeEvent, right before thethis.#trackMetaMetricsFncall:Then go through a swap flow and check the console for
[SwapBridgeEvent]lines. Every event should show the correctlocation.References
Checklist
Note
Medium Risk
Introduces a new required analytics field and changes public types/method signatures (
RequiredEventContextFromClient,submitTx,submitIntent), which may break downstream consumers or alter event payloads if not adopted correctly.Overview
All Unified SwapBridge analytics events now carry a required
location(entry point) for consistent attribution across the entire swap/bridge flow, including internally-fired events and post-submission status events.In
bridge-controller, a default/stored#locationis introduced withsetLocation()and is also captured from the initialButtonClickedevent;#getEventPropertiesfalls back to this stored value when the client doesn’t provide one, and theMetaMetricsSwapsEventSourceenum gainsTrendingExploreand is exported publicly.In
bridge-status-controller,locationis persisted onBridgeHistoryItem, accepted inStartPollingForBridgeTxStatusArgs, and plumbed throughsubmitTx/submitIntentsoSubmitted/Completed/Failed/PollingStatusUpdated/StatusValidationFailedevents include the originating location; snapshots/changelogs are updated accordingly.Written by Cursor Bugbot for commit 774dc90. This will update automatically on new commits. Configure here.