Commit 391c74a
authored
fix: clear analytics queue on callback errors (#8934)
## Explanation
Clear persisted analytics queue entries once the platform adapter
delivery callback fires, even when the callback receives an error. This
aligns queue cleanup behavior with the previous Segment-backed
MetaMetrics flow and avoids repeatedly replaying malformed or
permanently failing events on restart.
## References
NA
For example:
* Needed for MetaMask/MetaMask-planning#7193
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] 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
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes when persisted analytics events are dropped versus retried;
events reported as failed by the adapter will not be re-sent after
restart, which is intentional but affects delivery reliability
semantics.
>
> **Overview**
> When persisted event-queue delivery runs, **`AnalyticsController` now
removes queued entries as soon as the platform adapter’s delivery
callback fires**, including when the callback passes an error. Failed
deliveries are still logged; the queue is no longer left intact for
those cases.
>
> That matches prior Segment-backed MetaMetrics behavior and stops
**replaying events that already failed delivery** (for example malformed
or permanently rejected payloads) on the next startup. **Queued items
are still retained if the adapter throws synchronously** before the
callback runs.
>
> Tests and the package changelog were updated for the new cleanup
behavior.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
18ab987. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent a565632 commit 391c74a
3 files changed
Lines changed: 7 additions & 14 deletions
File tree
- packages/analytics-controller
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
Lines changed: 3 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1301 | 1301 | | |
1302 | 1302 | | |
1303 | 1303 | | |
1304 | | - | |
| 1304 | + | |
1305 | 1305 | | |
1306 | 1306 | | |
1307 | 1307 | | |
| |||
1317 | 1317 | | |
1318 | 1318 | | |
1319 | 1319 | | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
1323 | | - | |
1324 | | - | |
1325 | | - | |
1326 | | - | |
1327 | | - | |
| 1320 | + | |
1328 | 1321 | | |
1329 | 1322 | | |
1330 | 1323 | | |
| |||
1360 | 1353 | | |
1361 | 1354 | | |
1362 | 1355 | | |
1363 | | - | |
| 1356 | + | |
1364 | 1357 | | |
1365 | 1358 | | |
1366 | 1359 | | |
1367 | 1360 | | |
1368 | 1361 | | |
1369 | 1362 | | |
1370 | 1363 | | |
1371 | | - | |
1372 | | - | |
1373 | | - | |
1374 | 1364 | | |
1375 | 1365 | | |
1376 | 1366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | | - | |
559 | 558 | | |
560 | 559 | | |
561 | 560 | | |
| |||
0 commit comments