Commit fb079df
authored
feat: add feature_id and batch_id to Unified SwapBridge events (MetaMask#8964)
## Explanation
### Metrics changes
- Add new `Unified SwapBridge` event properties
- `feature_id` (all events)
- `batch_sell` (Submitted, Completed, Failed for BatchSell)
- Publish Submitted/Completed/Failed events for quickBuy and batchSell
features
### fetchQuotes changes
- Make `featureId` a required param of `fetchQuotes` to identify callers
- Update transaction-pay-controller's `fetchQuotes` call
### batch-sell submission changes
- Pre-generate batchId and append it to batch-sell events
- Pass batchId to transaction-controller to propagate it to the tx meta
Client-side updates
- run `yarn lint:tsc` to see where `feature_id` needs to be added, then
fix the type errors
- search for `fetchQuotes` usages and add FeatureId
<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:
* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->
## References
<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?
For example:
* Fixes #12345
* Related to #67890
-->
Fixes https://consensyssoftware.atlassian.net/browse/SWAPS-4468
## 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
- [ ] 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
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Breaking changes to `fetchQuotes` and required `feature_id` on all
clients and internal callers; transaction submission and metrics
behavior changed for batch sell and feature-gated status events.
>
> **Overview**
> Standardizes **Unified SwapBridge** analytics with a required
**`feature_id`** on every event and renames/expands **`FeatureId`**
values to Segment-style strings (e.g. `unified_swap_bridge`,
`quick_buy_follow_trading`, `batch_sell`).
>
> **Breaking API changes in `bridge-controller`:** callers must pass
**`feature_id`** in quote/metrics context and supply a **`FeatureId`**
when calling **`fetchQuotes`** (no longer optional). Quote streaming and
validation-failure tracking thread **`feature_id`** through fetch/SSE
paths and onto quote objects.
>
> **`bridge-status-controller`:** pre-generates **`batch_id`** for batch
sell via **`generateBatchId`**, passes it into transaction batches and
includes it on **Submitted / Completed / Failed** events. Status metrics
are emitted for **`ALLOWED_FEATURE_IDS_FOR_STATUS_EVENTS`** (unified
swap/bridge, quick buy variants, batch sell) instead of broadly
suppressing events when a feature id is set (e.g. perps).
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
83d02b0. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 569e061 commit fb079df
35 files changed
Lines changed: 678 additions & 304 deletions
File tree
- packages
- bridge-controller
- src
- __snapshots__
- utils
- metrics
- bridge-status-controller
- src
- __snapshots__
- strategy
- utils
- test
- transaction-controller
- src
- utils
- transaction-pay-controller
- src/strategy/bridge
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
12 | 22 | | |
13 | 23 | | |
14 | 24 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
| 89 | + | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| |||
93 | 96 | | |
94 | 97 | | |
95 | 98 | | |
| 99 | + | |
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
| |||
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
| 113 | + | |
109 | 114 | | |
110 | 115 | | |
111 | 116 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| 57 | + | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
| |||
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| 77 | + | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| |||
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
| 106 | + | |
102 | 107 | | |
103 | 108 | | |
104 | 109 | | |
| |||
127 | 132 | | |
128 | 133 | | |
129 | 134 | | |
| 135 | + | |
130 | 136 | | |
131 | 137 | | |
132 | 138 | | |
| |||
152 | 158 | | |
153 | 159 | | |
154 | 160 | | |
| 161 | + | |
155 | 162 | | |
156 | 163 | | |
157 | 164 | | |
| |||
213 | 220 | | |
214 | 221 | | |
215 | 222 | | |
| 223 | + | |
216 | 224 | | |
217 | 225 | | |
218 | 226 | | |
| |||
222 | 230 | | |
223 | 231 | | |
224 | 232 | | |
| 233 | + | |
225 | 234 | | |
226 | 235 | | |
227 | 236 | | |
| |||
231 | 240 | | |
232 | 241 | | |
233 | 242 | | |
| 243 | + | |
234 | 244 | | |
235 | 245 | | |
236 | 246 | | |
| |||
240 | 250 | | |
241 | 251 | | |
242 | 252 | | |
| 253 | + | |
243 | 254 | | |
244 | 255 | | |
245 | 256 | | |
| |||
253 | 264 | | |
254 | 265 | | |
255 | 266 | | |
| 267 | + | |
256 | 268 | | |
257 | 269 | | |
258 | 270 | | |
| |||
278 | 290 | | |
279 | 291 | | |
280 | 292 | | |
| 293 | + | |
281 | 294 | | |
282 | 295 | | |
283 | 296 | | |
| |||
339 | 352 | | |
340 | 353 | | |
341 | 354 | | |
| 355 | + | |
342 | 356 | | |
343 | 357 | | |
344 | 358 | | |
| |||
348 | 362 | | |
349 | 363 | | |
350 | 364 | | |
| 365 | + | |
351 | 366 | | |
352 | 367 | | |
353 | 368 | | |
| |||
357 | 372 | | |
358 | 373 | | |
359 | 374 | | |
| 375 | + | |
360 | 376 | | |
361 | 377 | | |
362 | 378 | | |
| |||
366 | 382 | | |
367 | 383 | | |
368 | 384 | | |
| 385 | + | |
369 | 386 | | |
370 | 387 | | |
371 | 388 | | |
| |||
379 | 396 | | |
380 | 397 | | |
381 | 398 | | |
| 399 | + | |
382 | 400 | | |
383 | 401 | | |
384 | 402 | | |
| |||
0 commit comments