fix(analytics-controller): preserve pre-consent queue on resetConsentDecision - #9284
Merged
gauthierpetetin merged 2 commits intoJun 26, 2026
Merged
Conversation
…Decision Keep install-time events buffered across undecided consent resets during onboarding restarts, matching legacy MetaMetricsController behavior where setParticipateInMetaMetrics(null) did not clear eventsBeforeMetricsOptIn. Co-authored-by: Cursor <cursoragent@cursor.com>
gauthierpetetin
temporarily deployed
to
default-branch
June 26, 2026 12:49 — with
GitHub Actions
Inactive
There was a problem hiding this comment.
Pull request overview
This PR adjusts AnalyticsController consent-reset behavior so that resetConsentDecision() no longer clears the pre-consent (undecided) event buffer, preserving install-time events across onboarding restarts while still clearing the delivery queue and returning consent flags to “undecided”.
Changes:
- Stop clearing
preConsentEventQueueinresetConsentDecision(); keep clearing the deliveryeventQueue. - Update JSDoc and action-type documentation to reflect the preserved pre-consent queue semantics.
- Update unit tests and add an Unreleased changelog entry describing the behavior change.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/analytics-controller/src/AnalyticsController.ts | Preserve preConsentEventQueue on resetConsentDecision(); update state JSDoc and method docs. |
| packages/analytics-controller/src/AnalyticsController.test.ts | Update tests to assert pre-consent queue is preserved on consent reset and delivery queue is still cleared. |
| packages/analytics-controller/src/AnalyticsController-method-action-types.ts | Align action documentation for resetConsentDecision with the new behavior. |
| packages/analytics-controller/CHANGELOG.md | Add Unreleased entry describing the consent-reset queue preservation change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Cursor <cursoragent@cursor.com>
NicolasMassart
approved these changes
Jun 26, 2026
gauthierpetetin
deleted the
fix/analytics-controller-preserve-pre-consent-on-reset
branch
June 26, 2026 13:59
pull Bot
pushed a commit
to Reality2byte/core
that referenced
this pull request
Jun 29, 2026
## Explanation Monorepo release that publishes the analytics consent reset fix: - **`@metamask/analytics-controller`** → **1.2.1** (patch) - Preserves the pre-consent event queue when calling `resetConsentDecision`, matching extension behavior for undecided consent resets during onboarding restarts ([MetaMask#9284](MetaMask#9284)). Root `package.json` is bumped from `1077.0.0` to `1078.0.0`. There are no application source changes in this diff. ## References - MetaMask#9284 ## 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] > **Low Risk** > Version and changelog-only release PR with no runtime code changes in the diff. > > **Overview** > **Release `1078.0.0`** bumps the root monorepo version and cuts **`@metamask/analytics-controller@1.2.1`**. > > The analytics package changelog is finalized for **1.2.1**, documenting the behavior change from [MetaMask#9284](MetaMask#9284): **`resetConsentDecision`** now **keeps the pre-consent event queue** (while still resetting consent and clearing the delivery queue), so onboarding restarts align with extension behavior. This PR does not change implementation code—only version numbers and release notes. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d2ed6ee. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Merged
7 tasks
pull Bot
pushed a commit
to Reality2byte/metamask-extension
that referenced
this pull request
Jul 28, 2026
…taMask#43869) ## **Description** Move consent decision state and pre-consent event queue from MetaMetricsController to AnalyticsController. It replaces this state: - MetaMetricsController's `completedMetaMetricsOnboarding` - MetaMetricsController's `eventsBeforeMetricsOptIn` by this state: - AnalyticsController's `consentDecisionMade` - AnalyticsController's `preConsentEventQueue` It leverage pre-consent event queue feature added to AnalyticsController in this PR: MetaMask/core#9252 (and this PR: MetaMask/core#9284) ## **Changelog** CHANGELOG entry: null ## **Related issues** Contributes to: MetaMask/MetaMask-planning#7337 ## **Manual testing steps** 1. Start the on-boarding until you land on MetaMetrics screen 2. Open inspector > Application > Extension storage > Local > AnalyticsController 3. Confirm `consentDecisionMade` is set to false 4. Confirm `preConsentEventQueue` includes a list of events 5. Get your analyticsId, open the Segment debugger, past your analyticsId in the search bar and confirm there are no events listed 6. Opt in to MetaMetrics on the MetaMetrics screen 7. Confirm the events previously listed in `preConsentEventQueue` now show up in Segment 8. Refresh the inspector 9. Confirm `consentDecisionMade` is now set to true 10. Confirm `preConsentEventQueue` is now empty ## **Screenshots/Recordings** NA ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches privacy/consent and what gets sent before/after opt-in, plus a persisted migration that reshapes queued events; incorrect gating could leak or drop analytics/Sentry data. > > **Overview** > **Analytics consent and pre-consent buffering now live on `AnalyticsController`**, replacing `MetaMetricsController.completedMetaMetricsOnboarding` and `eventsBeforeMetricsOptIn`. Call sites (background metrics gates, cookie handler, participation checks, Sentry) read **`consentDecisionMade`** and **`optedIn`** from analytics state only. > > **`MetaMetricsController` no longer queues or replays pre-consent events**—those messenger actions and state fields are removed. **`setParticipateInMetaMetrics`** delegates opt-in/out to `AnalyticsController:optIn` / `optOut`, uses **`resetConsentDecision`** when set to `null`, and still flushes/clears **trace** buffering locally. Init enables **`isPreConsentQueueEnabled`** on analytics (package bump to `@metamask/analytics-controller` ^1.2.1). > > **Install and OAuth paths** stop manual buffering: **`App Installed`** always goes through `trackEvent`, and OAuth injects **`trackEvent`** instead of `addEventBeforeMetricsOptIn`. Extension **`trackEvent`** only bails when basic external services are disabled; consent gating is assumed downstream in the controller queue. > > **Migration #220** copies consent from the old flag, migrates buffered events into `preConsentEventQueue` (including anonymous splits for sensitive properties), and strips the legacy MetaMetrics fields. Fixtures, types, and e2e metrics tests are updated to the new shape. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c0532b1. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
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
Keep install-time events buffered across undecided consent resets during onboarding restarts, matching legacy MetaMetricsController behavior where
setParticipateInMetaMetrics(null)did not cleareventsBeforeMetricsOptIn.References
None
Checklist
Note
Low Risk
Narrow behavior change in optional pre-consent analytics buffering; delivery queue clearing is unchanged and opt-out still clears pre-consent events.
Overview
resetConsentDecisionno longer wipes the pre-consent event buffer when onboarding restarts with consent still undecided. It still clears opt-in state, setsconsentDecisionMadeback to false, and empties the delivery queue—only the call to clear pre-consent events was removed.That aligns
AnalyticsControllerwith extension / legacy MetaMetrics behavior so install-time events queued before a decision can replay if the user opts in after a reset. JSDoc, action types, changelog, and tests were updated to match (including asserting the pre-consent queue is unchanged whileeventQueueis cleared).Reviewed by Cursor Bugbot for commit 12e7cab. Bugbot is set up for automated code reviews on this repo. Configure here.