feat: track active tab domain and environment type on SwapBridge events#43540
Draft
ameliejyc wants to merge 15 commits into
Draft
feat: track active tab domain and environment type on SwapBridge events#43540ameliejyc wants to merge 15 commits into
ameliejyc wants to merge 15 commits into
Conversation
…events-allowlist-only-x-com-v-1-2
Contributor
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨🔄 @MetaMask/swaps-engineers (2 files, +7 -0)
|
4 tasks
Builds ready [642f210] [reused from 38a1bc4]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
amitabh94
pushed a commit
to amitabh94/core
that referenced
this pull request
Jun 16, 2026
…icked event properties (MetaMask#9121) ## Explanation For this [core extension UX ticket](https://consensyssoftware.atlassian.net/browse/CEUX-1092), we want to embellish the Unified SwapBridge Button Clicked event with the `environment_type` of the UI context. These metrics do already include environment type, but they always have the value `background` as that is the context used when they are emitted. We want to however have the UI context for this metric so we can track `sidepanel` vs `popup` etc. So this PR modifies the `Unified SwapBridge Button Clicked` event properties (exported via `RequiredEventContextFromClient` in `@metamask/bridge-controller`) to add optional `environment_type` to be able to pass this data in directly at the call site where the values are either `sidepanel`, `popup` or `fullscreen`. Client side PR [here](MetaMask/metamask-extension#43540). ## References * Part fixes: https://consensyssoftware.atlassian.net/browse/CEUX-1092 ## 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 - [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
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.
Description
Depends on MetaMask/core#9121.
Extends Unified SwapBridge MetaMetrics events:
active_tab_domainon Submitted and ButtonClicked events — Adds the active browser tab's origin asactive_tab_domaintoUnified SwapBridge SubmittedandUnified SwapBridge ButtonClickedevents. The property is allowlist-gated: only origins matching the LaunchDarkly-sourcedextension-ux-active-domain-metricsflag (default:x.com,twitter.com) are recorded.environment_typepromoted to top-level MetaMetrics field for all SwapBridge events —environment_typewas previously embedded inside thepropertiesbag. It is now hoisted to the top-levelenvironmentTypefield on thetrackEventpayload, consistent with how other MetaMask events are tracked. This fixes a bug where bothenvironmentTypeandenvironment_typewere showing in these metrics.For the UI-triggered event
Unified SwapBridge ButtonClicked, the UI passesenvironment_typeexplicitly so the accurate popup/sidepanel/fullscreen context is captured; background-originated events fall back togetEnvironmentType()(which returns'background').A change on
@metamask/bridge-controlleraddsenvironment_type?: stringto theRequiredEventContextFromClientBase[ButtonClicked]type so the UI can pass the property without a type error.Changelog
CHANGELOG entry: null
Related issues
Fixes: CEUX-1092
Manual testing steps
x.comUnified SwapBridge ButtonClickedSegment event includesactive_tab_domain: "https://x.com"andenvironment_type: "popup"at the top levelUnified SwapBridge Submittedincludesactive_tab_domaingoogle.com) — verifyactive_tab_domainis absent from both eventsenvironment_typereflects"fullscreen"Expected payloads:
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist