# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] ### Changed - Bump `@metamask/utils` from `^12.0.2` to `^12.1.0` ([#11796](https://github.com/MetaMask/core/pull/11796)) ## [4.4.0] ### Added - Add `marketingConsentSyncPending` state to `AnalyticsController` to record a marketing consent choice made on this device that has not been saved to the user's account yet ([#11469](https://github.com/MetaMask/core/pull/11469)) - The field is persisted, defaults to `false`, and can be read with the new `selectMarketingConsentSyncPending` selector. - Add `applyRemoteMarketingConsent` method and `AnalyticsController:applyRemoteMarketingConsent` action ([#11469](https://github.com/MetaMask/core/pull/11469)) - Applies a marketing consent value read from the user's account, with the same side effects as `optInToMarketing` / `optOutOfMarketing`, without marking it as waiting to be saved. - Does nothing while a local choice is waiting to be saved, or if the same value is already decided. - Add `clearMarketingConsentSyncPending` method and `AnalyticsController:clearMarketingConsentSyncPending` action ([#11469](https://github.com/MetaMask/core/pull/11469)) - Clears `marketingConsentSyncPending` if local marketing consent still matches the given value, so a newer local choice stays pending. ### Changed - Bump `@metamask/utils` from `^12.0.1` to `^12.0.2` ([#11474](https://github.com/MetaMask/core/pull/11474)) - `optInToMarketing` and `optOutOfMarketing` now set `marketingConsentSyncPending` to `true` in the same state update as the consent change ([#11469](https://github.com/MetaMask/core/pull/11469)) - `resetMarketingConsentDecision` now sets `marketingConsentSyncPending` to `false` ([#11469](https://github.com/MetaMask/core/pull/11469)) - Bump `uuid` from `^14.0.2` to `^14.0.3` ([#11645](https://github.com/MetaMask/core/pull/11645)) ## [4.3.1] ### Changed - Bump `@metamask/config-registry-controller` from `^5.0.0` to `^6.0.0` ([#11447](https://github.com/MetaMask/core/pull/11447)) ## [4.3.0] ### Added - Allow an optional `properties` argument on `trackErrorAsAnalytics` so callers can attach extra payload fields such as `anonymous: true` while keeping sanitized `source` and `error_message` ([#11355](https://github.com/MetaMask/core/pull/11355)) ## [4.2.0] ### Added - Add `trackErrorAsAnalytics` on `AnalyticsController` to report caught errors as `Error Occurred` events with a unique `source` and a sanitized `error_message`, bounded by sampling, deduplication, and a per-session cap ([#11051](https://github.com/MetaMask/core/pull/11051)) ### Changed - Bump `@metamask/utils` from `^12.0.0` to `^12.0.1` ([#11107](https://github.com/MetaMask/core/pull/11107)) - Bump `uuid` from `^11.1.1` to `^14.0.2` ([#10941](https://github.com/MetaMask/core/pull/10941), [#11179](https://github.com/MetaMask/core/pull/11179), [#11305](https://github.com/MetaMask/core/pull/11305)) ## [4.1.0] ### Added - Add support for Node.js 26 ([#10981](https://github.com/MetaMask/core/pull/10981)) ### Changed - Accept partial initial `state` as long as `analyticsId` is provided ([#10901](https://github.com/MetaMask/core/pull/10901)) - Bump `@metamask/base-controller` from `^10.0.0` to `^10.1.0` ([#10864](https://github.com/MetaMask/core/pull/10864)) ## [4.0.0] ### Changed - **BREAKING:** `AnalyticsControllerMessenger` requires `ConfigRegistryController:getState` in its allowed actions and `ConfigRegistryController:stateChanged` in its allowed events ([#10448](https://github.com/MetaMask/core/pull/10448)) - Update `AnalyticsController.init` to listen for ConfigRegistryController state changes and update in-memory event-purpose classification when the version differs ([#10448](https://github.com/MetaMask/core/pull/10448)) - Add `@metamask/config-registry-controller` `^4.0.0` as a dependency ([#10448](https://github.com/MetaMask/core/pull/10448)) - Bump `lodash-es` from `^4.17.21` to `^4.18.1` ([#10447](https://github.com/MetaMask/core/pull/10447)) - Bump `@metamask/config-registry-controller` from `^4.0.0` to `^5.0.0` ([#10658](https://github.com/MetaMask/core/pull/10658)) ## [3.2.0] ### Added - Add `marketingCampaignCookieId` state field and `setMarketingCampaignCookieId` action to `AnalyticsController`; the field is automatically set to `null` when the user calls `optOutOfMarketing` or `resetMarketingConsentDecision` ([#10373](https://github.com/MetaMask/core/pull/10373)) ## [3.1.0] ### Added - Add independent marketing consent and purpose-aware event classification ([#10232](https://github.com/MetaMask/core/pull/10232)) - Adds `optedInToMarketing`, `optInToMarketing` / `optOutOfMarketing` / `resetMarketingConsentDecision`, and a persisted `eventsConfig` whose unlisted events default to product-only - Named `track` and `view` payloads are delivered once with their allowed purposes in `context.consent.categoryPreferences` and their capture-time config version in `context.eventsConfigVersion` - Queues and fragments retain capture-time purpose classification so config changes cannot reclassify captured events. Mixed-purpose fragments classify each declared lifecycle event independently ### Changed - Bump `uuid` from `^8.3.2` to `^11.1.1` ([#10117](https://github.com/MetaMask/core/pull/10117), [#10243](https://github.com/MetaMask/core/pull/10243)) - Bump `@metamask/utils` from `^11.12.0` to `^12.0.0` ([#10192](https://github.com/MetaMask/core/pull/10192)) ## [3.0.0] ### Changed - **BREAKING:** Drop CommonJS support ([#9536](https://github.com/MetaMask/core/pull/9536)) - This package is now ESM-only, but can still be used in CommonJS projects via `require(esm)` in modern Node.js versions (22+), or dynamic imports in older Node.js versions. - **BREAKING:** Bump minimum Node.js version to 22 ([#9976](https://github.com/MetaMask/core/pull/9976)) - **BREAKING:** Bump TypeScript target to ES2022 ([#10019](https://github.com/MetaMask/core/pull/10019)) - This package now ships ES2022 code, requiring a compatible modern environment or bundler configuration to consume. - Bump `@metamask/base-controller` from `^9.1.0` to `^10.0.0` ([#10160](https://github.com/MetaMask/core/pull/10160)) - Bump `@metamask/geolocation-controller` from `^1.0.0` to `^2.0.0` ([#10160](https://github.com/MetaMask/core/pull/10160)) - Bump `@metamask/messenger` from `^2.0.0` to `^3.0.0` ([#10160](https://github.com/MetaMask/core/pull/10160)) ## [2.1.0] ### Added - Add optional event fragments to `AnalyticsController` (disabled by default via `isEventFragmentsEnabled`), letting clients accumulate analytics properties across a user journey and optionally emit an initial, success, or failure event for it ([#10055](https://github.com/MetaMask/core/pull/10055)) ### Changed - Bump `@metamask/utils` from `^11.11.0` to `^11.12.0` ([#10076](https://github.com/MetaMask/core/pull/10076)) ## [2.0.0] ### Changed - **BREAKING:** Optionally enrich non-anonymous track, identify, and view payloads with the user's `country_code`, `region`, and `timezone` under `context.location`, gated behind the new `isGeolocationEnabled` constructor option (default `false`) ([#9691](https://github.com/MetaMask/core/pull/9691), [#9728](https://github.com/MetaMask/core/pull/9728)) - `AnalyticsController.init` and `AnalyticsController.optIn` are now asynchronous and return a `Promise`, so await them before tracking events - When enabled, geolocation is resolved via `GeolocationController:getGeolocationData` (which compositions must register) only after the user opts in, so location is never requested before they consent to analytics; queued pre-consent events are then enriched on replay (anonymous payloads excluded) - Adds `@metamask/geolocation-controller` `^0.1.3` as a dependency - Bump `@metamask/messenger` from `^1.2.0` to `^2.0.0` ([#9392](https://github.com/MetaMask/core/pull/9392)) - Bump `@metamask/geolocation-controller` from `^0.1.3` to `^1.0.0` ([#9735](https://github.com/MetaMask/core/pull/9735)) ## [1.2.1] ### Changed - Preserve the pre-consent event queue when calling `resetConsentDecision`, matching extension behavior for undecided consent resets during onboarding restarts ([#9284](https://github.com/MetaMask/core/pull/9284)) ## [1.2.0] ### Added - Add optional pre-consent event queue to `AnalyticsController` (disabled by default via `isPreConsentQueueEnabled`), with a `consentDecisionMade` state field, `selectConsentDecisionMade` selector, and `resetConsentDecision` action ([#9252](https://github.com/MetaMask/core/pull/9252)) ### Changed - Bump `@metamask/utils` from `^11.9.0` to `^11.11.0` ([#9074](https://github.com/MetaMask/core/pull/9074)) ## [1.1.1] ### Fixed - Clear persisted analytics event queue entries after the delivery callback runs, including when the callback reports an error. ([#8934](https://github.com/MetaMask/core/pull/8934)) ## [1.1.0] ### Added - Optional persisted event queue support in `AnalyticsController`, disabled by default. ([#8797](https://github.com/MetaMask/core/pull/8797)) - Add optional analytics context on `trackEvent`, `identify`, and `trackView` to forward platform-specific context to `AnalyticsPlatformAdapter` implementations ([#8835](https://github.com/MetaMask/core/pull/8835)) - Optional `skipUUIDv4Check` on `AnalyticsPlatformAdapter` to allow non-UUIDv4 `analyticsId` strings when constructing `AnalyticsController` ([#8543](https://github.com/MetaMask/core/pull/8543)) ### Changed - Mark `analyticsId` as persisted (`persist: true`) in `AnalyticsController` state metadata so it is saved and restored with `optedIn` when using a persisted controller composition ([#8542](https://github.com/MetaMask/core/pull/8542)) - Bump `@metamask/messenger` from `^1.0.0` to `^1.2.0` ([#8364](https://github.com/MetaMask/core/pull/8364), [#8373](https://github.com/MetaMask/core/pull/8373), [#8632](https://github.com/MetaMask/core/pull/8632)) - Bump `@metamask/base-controller` from `^9.0.1` to `^9.1.0` ([#8457](https://github.com/MetaMask/core/pull/8457)) ## [1.0.1] ### Changed - Bump `@metamask/base-controller` from `^9.0.0` to `^9.0.1` ([#8317](https://github.com/MetaMask/core/pull/8317)) - Bump `@metamask/messenger` from `^0.3.0` to `^1.0.0` ([#8317](https://github.com/MetaMask/core/pull/8317)) - Upgrade `@metamask/utils` from `^11.8.1` to `^11.9.0` ([#7511](https://github.com/MetaMask/core/pull/7511)) ## [1.0.0] ### Added - Initial release of @metamask/analytics-controller. ([#7017](https://github.com/MetaMask/core/pull/7017), [#7202](https://github.com/MetaMask/core/pull/7202)) [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@4.4.0...HEAD [4.4.0]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@4.3.1...@metamask/analytics-controller@4.4.0 [4.3.1]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@4.3.0...@metamask/analytics-controller@4.3.1 [4.3.0]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@4.2.0...@metamask/analytics-controller@4.3.0 [4.2.0]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@4.1.0...@metamask/analytics-controller@4.2.0 [4.1.0]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@4.0.0...@metamask/analytics-controller@4.1.0 [4.0.0]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@3.2.0...@metamask/analytics-controller@4.0.0 [3.2.0]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@3.1.0...@metamask/analytics-controller@3.2.0 [3.1.0]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@3.0.0...@metamask/analytics-controller@3.1.0 [3.0.0]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@2.1.0...@metamask/analytics-controller@3.0.0 [2.1.0]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@2.0.0...@metamask/analytics-controller@2.1.0 [2.0.0]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@1.2.1...@metamask/analytics-controller@2.0.0 [1.2.1]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@1.2.0...@metamask/analytics-controller@1.2.1 [1.2.0]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@1.1.1...@metamask/analytics-controller@1.2.0 [1.1.1]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@1.1.0...@metamask/analytics-controller@1.1.1 [1.1.0]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@1.0.1...@metamask/analytics-controller@1.1.0 [1.0.1]: https://github.com/MetaMask/core/compare/@metamask/analytics-controller@1.0.0...@metamask/analytics-controller@1.0.1 [1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/analytics-controller@1.0.0