Skip to content

feat(analytics-controller): add persisted event queue#8797

Open
gauthierpetetin wants to merge 6 commits into
mainfrom
feat/analytics-controller-event-queue
Open

feat(analytics-controller): add persisted event queue#8797
gauthierpetetin wants to merge 6 commits into
mainfrom
feat/analytics-controller-event-queue

Conversation

@gauthierpetetin
Copy link
Copy Markdown
Contributor

@gauthierpetetin gauthierpetetin commented May 13, 2026

Explanation

Adds optional persisted event queue support to @metamask/analytics-controller.

The feature is disabled by default and can be enabled by clients that do not have SDK-level persistence. When enabled, final analytics payloads are persisted before delivery and removed only after the platform adapter reports successful delivery.

References

NA

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
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Adds optional persistence/replay of analytics delivery payloads and changes adapter method signatures to accept delivery callbacks/options, which could affect client adapters if typings/implementations aren’t updated. Default behavior is unchanged when the feature flag is off.

Overview
Adds an opt-in persisted delivery queue to AnalyticsController (isEventQueuePersistenceEnabled) that stores track/identify/view adapter payloads by messageId until the adapter acknowledges success via a callback, and replays queued payloads on init (dropping invalid entries and clearing the queue when opted out).

Extends AnalyticsPlatformAdapter methods to accept optional AnalyticsDeliveryOptions (messageId, timestamp, callback), adds eventQueue to controller state metadata as persisted but excluded from logs/debug snapshots/UI, and updates docs, exports, deps (uuid), and tests to cover the new behavior.

Reviewed by Cursor Bugbot for commit 0a79f0e. Bugbot is set up for automated code reviews on this repo. Configure here.

@gauthierpetetin gauthierpetetin marked this pull request as ready for review May 13, 2026 13:52
@gauthierpetetin gauthierpetetin requested review from a team as code owners May 13, 2026 13:52
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 c43147b. Configure here.

Comment thread packages/analytics-controller/src/AnalyticsController.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant