@metamask-previews/analytics-controller 0.0.0-preview-be27197a → 0.0.0-preview-3d640a3d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +102 -183
  2. package/dist/AnalyticsController-method-action-types.cjs.map +1 -1
  3. package/dist/AnalyticsController-method-action-types.d.cts +24 -10
  4. package/dist/AnalyticsController-method-action-types.d.cts.map +1 -1
  5. package/dist/AnalyticsController-method-action-types.d.mts +24 -10
  6. package/dist/AnalyticsController-method-action-types.d.mts.map +1 -1
  7. package/dist/AnalyticsController-method-action-types.mjs.map +1 -1
  8. package/dist/AnalyticsController.cjs +77 -86
  9. package/dist/AnalyticsController.cjs.map +1 -1
  10. package/dist/AnalyticsController.d.cts +33 -37
  11. package/dist/AnalyticsController.d.cts.map +1 -1
  12. package/dist/AnalyticsController.d.mts +33 -37
  13. package/dist/AnalyticsController.d.mts.map +1 -1
  14. package/dist/AnalyticsController.mjs +76 -85
  15. package/dist/AnalyticsController.mjs.map +1 -1
  16. package/dist/AnalyticsPlatformAdapter.types.cjs.map +1 -1
  17. package/dist/AnalyticsPlatformAdapter.types.d.cts +15 -63
  18. package/dist/AnalyticsPlatformAdapter.types.d.cts.map +1 -1
  19. package/dist/AnalyticsPlatformAdapter.types.d.mts +15 -63
  20. package/dist/AnalyticsPlatformAdapter.types.d.mts.map +1 -1
  21. package/dist/AnalyticsPlatformAdapter.types.mjs.map +1 -1
  22. package/dist/index.cjs +4 -9
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +4 -5
  25. package/dist/index.d.cts.map +1 -1
  26. package/dist/index.d.mts +4 -5
  27. package/dist/index.d.mts.map +1 -1
  28. package/dist/index.mjs +3 -6
  29. package/dist/index.mjs.map +1 -1
  30. package/package.json +3 -2
  31. package/dist/AnalyticsPlatformAdapterSetupError.cjs +0 -17
  32. package/dist/AnalyticsPlatformAdapterSetupError.cjs.map +0 -1
  33. package/dist/AnalyticsPlatformAdapterSetupError.d.cts +0 -8
  34. package/dist/AnalyticsPlatformAdapterSetupError.d.cts.map +0 -1
  35. package/dist/AnalyticsPlatformAdapterSetupError.d.mts +0 -8
  36. package/dist/AnalyticsPlatformAdapterSetupError.d.mts.map +0 -1
  37. package/dist/AnalyticsPlatformAdapterSetupError.mjs +0 -13
  38. package/dist/AnalyticsPlatformAdapterSetupError.mjs.map +0 -1
  39. package/dist/analyticsControllerStateValidator.cjs +0 -34
  40. package/dist/analyticsControllerStateValidator.cjs.map +0 -1
  41. package/dist/analyticsControllerStateValidator.d.cts +0 -16
  42. package/dist/analyticsControllerStateValidator.d.cts.map +0 -1
  43. package/dist/analyticsControllerStateValidator.d.mts +0 -16
  44. package/dist/analyticsControllerStateValidator.d.mts.map +0 -1
  45. package/dist/analyticsControllerStateValidator.mjs +0 -29
  46. package/dist/analyticsControllerStateValidator.mjs.map +0 -1
  47. package/dist/selectors.cjs +0 -38
  48. package/dist/selectors.cjs.map +0 -1
  49. package/dist/selectors.d.cts +0 -11
  50. package/dist/selectors.d.cts.map +0 -1
  51. package/dist/selectors.d.mts +0 -11
  52. package/dist/selectors.d.mts.map +0 -1
  53. package/dist/selectors.mjs +0 -35
  54. package/dist/selectors.mjs.map +0 -1
@@ -14,9 +14,8 @@ var _AnalyticsController_platformAdapter;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.AnalyticsController = exports.getDefaultAnalyticsControllerState = exports.controllerName = void 0;
16
16
  const base_controller_1 = require("@metamask/base-controller");
17
- const analyticsControllerStateValidator_1 = require("./analyticsControllerStateValidator.cjs");
17
+ const uuid_1 = require("uuid");
18
18
  const AnalyticsLogger_1 = require("./AnalyticsLogger.cjs");
19
- const selectors_1 = require("./selectors.cjs");
20
19
  // === GENERAL ===
21
20
  /**
22
21
  * The name of the {@link AnalyticsController}, used to namespace the
@@ -24,45 +23,52 @@ const selectors_1 = require("./selectors.cjs");
24
23
  * when composed with other controllers.
25
24
  */
26
25
  exports.controllerName = 'AnalyticsController';
27
- /**
28
- * Returns default values for AnalyticsController state.
29
- *
30
- * Note: analyticsId is NOT included - it's an identity that must be
31
- * provided by the platform (generated once on first run, then persisted).
32
- *
33
- * @returns Default state without analyticsId
34
- */
35
- function getDefaultAnalyticsControllerState() {
36
- return {
37
- optedIn: false,
38
- };
39
- }
40
- exports.getDefaultAnalyticsControllerState = getDefaultAnalyticsControllerState;
41
26
  /**
42
27
  * The metadata for each property in {@link AnalyticsControllerState}.
43
- *
44
- * Note: `persist` is set to `false` for all fields because the platform
45
- * is responsible for persistence via the `stateChange` event listener.
46
28
  */
47
29
  const analyticsControllerMetadata = {
30
+ enabled: {
31
+ includeInStateLogs: true,
32
+ persist: true,
33
+ includeInDebugSnapshot: true,
34
+ usedInUi: true,
35
+ },
48
36
  optedIn: {
49
37
  includeInStateLogs: true,
50
- persist: false,
38
+ persist: true,
51
39
  includeInDebugSnapshot: true,
52
40
  usedInUi: true,
53
41
  },
54
42
  analyticsId: {
55
43
  includeInStateLogs: true,
56
- persist: false,
44
+ persist: true,
57
45
  includeInDebugSnapshot: true,
58
46
  usedInUi: false,
59
47
  },
60
48
  };
49
+ /**
50
+ * Constructs the default {@link AnalyticsController} state. This allows
51
+ * consumers to provide a partial state object when initializing the controller
52
+ * and also helps in constructing complete state objects for this controller in
53
+ * tests.
54
+ *
55
+ * @returns The default {@link AnalyticsController} state.
56
+ */
57
+ function getDefaultAnalyticsControllerState() {
58
+ return {
59
+ enabled: true,
60
+ optedIn: false,
61
+ analyticsId: (0, uuid_1.v4)(),
62
+ };
63
+ }
64
+ exports.getDefaultAnalyticsControllerState = getDefaultAnalyticsControllerState;
61
65
  // === MESSENGER ===
62
66
  const MESSENGER_EXPOSED_METHODS = [
63
67
  'trackEvent',
64
68
  'identify',
65
- 'trackView',
69
+ 'trackPage',
70
+ 'enable',
71
+ 'disable',
66
72
  'optIn',
67
73
  'optOut',
68
74
  ];
@@ -75,117 +81,103 @@ const MESSENGER_EXPOSED_METHODS = [
75
81
  * This controller follows the MetaMask controller pattern and integrates with the
76
82
  * messenger system to allow other controllers and components to track analytics events.
77
83
  * It delegates platform-specific implementation to an {@link AnalyticsPlatformAdapter}.
78
- *
79
- * Note: This controller does not persist state internally (`persist: false` in metadata).
80
- * The platform is responsible for:
81
- * - Providing the initial state (including a valid UUIDv4 analyticsId)
82
- * - Subscribing to `AnalyticsController:stateChange` event to persist changes
83
84
  */
84
85
  class AnalyticsController extends base_controller_1.BaseController {
85
86
  /**
86
87
  * Constructs an AnalyticsController instance.
87
88
  *
88
89
  * @param options - Controller options
89
- * @param options.state - Initial controller state. Must include a valid UUIDv4 `analyticsId`.
90
- * Use `getDefaultAnalyticsControllerState()` for default opt-in preferences.
90
+ * @param options.state - Initial controller state (defaults from getDefaultAnalyticsControllerState)
91
91
  * @param options.messenger - Messenger used to communicate with BaseController
92
92
  * @param options.platformAdapter - Platform adapter implementation for tracking
93
- * @throws Error if state.analyticsId is missing or not a valid UUIDv4
94
93
  */
95
- constructor({ state, messenger, platformAdapter, }) {
96
- const initialState = {
97
- ...getDefaultAnalyticsControllerState(),
98
- ...state,
99
- };
100
- (0, analyticsControllerStateValidator_1.validateAnalyticsControllerState)(initialState);
94
+ constructor({ state = {}, messenger, platformAdapter, }) {
101
95
  super({
102
96
  name: exports.controllerName,
103
97
  metadata: analyticsControllerMetadata,
104
- state: initialState,
98
+ state: {
99
+ ...getDefaultAnalyticsControllerState(),
100
+ ...state,
101
+ },
105
102
  messenger,
106
103
  });
107
104
  _AnalyticsController_platformAdapter.set(this, void 0);
108
105
  __classPrivateFieldSet(this, _AnalyticsController_platformAdapter, platformAdapter, "f");
109
106
  this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
110
107
  (0, AnalyticsLogger_1.projectLogger)('AnalyticsController initialized and ready', {
111
- enabled: selectors_1.analyticsControllerSelectors.selectEnabled(this.state),
108
+ enabled: this.state.enabled,
112
109
  optedIn: this.state.optedIn,
113
110
  analyticsId: this.state.analyticsId,
114
111
  });
115
- // Call onSetupCompleted lifecycle hook after initialization
116
- // State is already validated, so analyticsId is guaranteed to be a valid UUIDv4
117
- __classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f")
118
- .onSetupCompleted(this.state.analyticsId)
119
- .catch((error) => {
120
- // Log error but don't throw - adapter setup failure shouldn't break controller
121
- (0, AnalyticsLogger_1.projectLogger)('Error calling platformAdapter.onSetupCompleted', error);
122
- });
123
112
  }
124
113
  /**
125
114
  * Track an analytics event.
126
115
  *
127
116
  * Events are only tracked if analytics is enabled.
128
117
  *
129
- * @param event - Analytics event with properties and sensitive properties
118
+ * @param eventName - The name of the event
119
+ * @param properties - Event properties
130
120
  */
131
- trackEvent(event) {
121
+ trackEvent(eventName, properties = {}) {
132
122
  // Don't track if analytics is disabled
133
- if (!selectors_1.analyticsControllerSelectors.selectEnabled(this.state)) {
123
+ if (!this.state.enabled) {
134
124
  return;
135
125
  }
136
- // Derive sensitivity from presence of sensitiveProperties
137
- const hasSensitiveProperties = Object.keys(event.sensitiveProperties).length > 0;
138
- // if event does not have properties, send event without properties
139
- // and return to prevent any additional processing
140
- if (!event.hasProperties) {
141
- __classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").track(event.name);
142
- return;
143
- }
144
- // Track regular properties (without isSensitive flag - it's the default)
145
- // Note: Even if properties object is empty, we still send it to ensure
146
- // an event with user ID is tracked. When only sensitiveProperties exist,
147
- // this creates two events: one with empty props (user ID) and one with
148
- // sensitive props (anonymous ID), which is the expected behavior.
149
- __classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").track(event.name, {
150
- ...event.properties,
151
- });
152
- // Track sensitive properties in a separate event with isSensitive flag
153
- if (hasSensitiveProperties) {
154
- __classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").track(event.name, {
155
- ...event.properties,
156
- ...event.sensitiveProperties,
157
- isSensitive: true,
158
- });
159
- }
126
+ // Delegate to platform adapter
127
+ __classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").trackEvent(eventName, properties);
160
128
  }
161
129
  /**
162
130
  * Identify a user for analytics.
163
131
  *
132
+ * @param userId - The user identifier (e.g., metametrics ID)
164
133
  * @param traits - User traits/properties
165
134
  */
166
- identify(traits) {
167
- if (!selectors_1.analyticsControllerSelectors.selectEnabled(this.state)) {
135
+ identify(userId, traits) {
136
+ if (!this.state.enabled) {
168
137
  return;
169
138
  }
170
- // Delegate to platform adapter using the current analytics ID
171
- __classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").identify(this.state.analyticsId, traits);
139
+ // Update state with analytics ID
140
+ this.update((state) => {
141
+ state.analyticsId = userId;
142
+ });
143
+ // Delegate to platform adapter if supported
144
+ if (__classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").identify) {
145
+ __classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").identify(userId, traits);
146
+ }
172
147
  }
173
148
  /**
174
- * Track a page or screen view.
149
+ * Track a page view.
175
150
  *
176
- * @param name - The identifier/name of the page or screen being viewed (e.g., "home", "settings", "wallet")
177
- * @param properties - Optional properties associated with the view
151
+ * @param pageName - The name of the page
152
+ * @param properties - Page properties
178
153
  */
179
- trackView(name, properties) {
180
- if (!selectors_1.analyticsControllerSelectors.selectEnabled(this.state)) {
154
+ trackPage(pageName, properties) {
155
+ if (!this.state.enabled) {
181
156
  return;
182
157
  }
183
- // Delegate to platform adapter
184
- __classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").view(name, properties);
158
+ // Delegate to platform adapter if supported
159
+ if (__classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").trackPage) {
160
+ __classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").trackPage(pageName, properties);
161
+ }
162
+ }
163
+ /**
164
+ * Enable analytics tracking.
165
+ */
166
+ enable() {
167
+ this.update((state) => {
168
+ state.enabled = true;
169
+ });
170
+ }
171
+ /**
172
+ * Disable analytics tracking.
173
+ */
174
+ disable() {
175
+ this.update((state) => {
176
+ state.enabled = false;
177
+ });
185
178
  }
186
179
  /**
187
180
  * Opt in to analytics.
188
- * This updates the user's opt-in status.
189
181
  */
190
182
  optIn() {
191
183
  this.update((state) => {
@@ -194,7 +186,6 @@ class AnalyticsController extends base_controller_1.BaseController {
194
186
  }
195
187
  /**
196
188
  * Opt out of analytics.
197
- * This updates the user's opt-in status.
198
189
  */
199
190
  optOut() {
200
191
  this.update((state) => {
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsController.cjs","sourceRoot":"","sources":["../src/AnalyticsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA2D;AAI3D,+FAAuF;AACvF,2DAAkD;AAOlD,+CAA2D;AAE3D,kBAAkB;AAElB;;;;GAIG;AACU,QAAA,cAAc,GAAG,qBAAqB,CAAC;AAqBpD;;;;;;;GAOG;AACH,SAAgB,kCAAkC;IAIhD,OAAO;QACL,OAAO,EAAE,KAAK;KACf,CAAC;AACJ,CAAC;AAPD,gFAOC;AAED;;;;;GAKG;AACH,MAAM,2BAA2B,GAAG;IAClC,OAAO,EAAE;QACP,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,WAAW,EAAE;QACX,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;CACgD,CAAC;AAEpD,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,YAAY;IACZ,UAAU;IACV,WAAW;IACX,OAAO;IACP,QAAQ;CACA,CAAC;AAuEX;;;;;;;;;;;;;;GAcG;AACH,MAAa,mBAAoB,SAAQ,gCAIxC;IAGC;;;;;;;;;OASG;IACH,YAAY,EACV,KAAK,EACL,SAAS,EACT,eAAe,GACY;QAC3B,MAAM,YAAY,GAA6B;YAC7C,GAAG,kCAAkC,EAAE;YACvC,GAAG,KAAK;SACT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EAAE;YACpB,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAtJD,kDAsJC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { AnalyticsControllerMethodActions } from './AnalyticsController-method-action-types';\nimport { validateAnalyticsControllerState } from './analyticsControllerStateValidator';\nimport { projectLogger } from './AnalyticsLogger';\nimport type {\n AnalyticsPlatformAdapter,\n AnalyticsEventProperties,\n AnalyticsUserTraits,\n AnalyticsTrackingEvent,\n} from './AnalyticsPlatformAdapter.types';\nimport { analyticsControllerSelectors } from './selectors';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link AnalyticsController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nexport const controllerName = 'AnalyticsController';\n\n// === STATE ===\n\n/**\n * Describes the shape of the state object for {@link AnalyticsController}.\n */\nexport type AnalyticsControllerState = {\n /**\n * Whether the user has opted in to analytics.\n */\n optedIn: boolean;\n\n /**\n * User's UUIDv4 analytics identifier.\n * This is an identity (unique per user), not a preference.\n * Must be provided by the platform - the controller does not generate it.\n */\n analyticsId: string;\n};\n\n/**\n * Returns default values for AnalyticsController state.\n *\n * Note: analyticsId is NOT included - it's an identity that must be\n * provided by the platform (generated once on first run, then persisted).\n *\n * @returns Default state without analyticsId\n */\nexport function getDefaultAnalyticsControllerState(): Omit<\n AnalyticsControllerState,\n 'analyticsId'\n> {\n return {\n optedIn: false,\n };\n}\n\n/**\n * The metadata for each property in {@link AnalyticsControllerState}.\n *\n * Note: `persist` is set to `false` for all fields because the platform\n * is responsible for persistence via the `stateChange` event listener.\n */\nconst analyticsControllerMetadata = {\n optedIn: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n analyticsId: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n} satisfies StateMetadata<AnalyticsControllerState>;\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'trackEvent',\n 'identify',\n 'trackView',\n 'optIn',\n 'optOut',\n] as const;\n\n/**\n * Returns the state of the {@link AnalyticsController}.\n */\nexport type AnalyticsControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AnalyticsControllerState\n>;\n\n/**\n * Actions that {@link AnalyticsControllerMessenger} exposes to other consumers.\n */\nexport type AnalyticsControllerActions =\n | AnalyticsControllerGetStateAction\n | AnalyticsControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link AnalyticsControllerMessenger} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Event emitted when the state of the {@link AnalyticsController} changes.\n */\nexport type AnalyticsControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AnalyticsControllerState\n>;\n\n/**\n * Events that {@link AnalyticsControllerMessenger} exposes to other consumers.\n */\nexport type AnalyticsControllerEvents = AnalyticsControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link AnalyticsControllerMessenger} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link AnalyticsController}.\n */\nexport type AnalyticsControllerMessenger = Messenger<\n typeof controllerName,\n AnalyticsControllerActions | AllowedActions,\n AnalyticsControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * The options that AnalyticsController takes.\n */\nexport type AnalyticsControllerOptions = {\n /**\n * Initial controller state. Must include a valid UUIDv4 `analyticsId`.\n * The platform is responsible for generating and persisting the analyticsId.\n */\n state: AnalyticsControllerState;\n /**\n * Messenger used to communicate with BaseController and other controllers.\n */\n messenger: AnalyticsControllerMessenger;\n /**\n * Platform adapter implementation for tracking events.\n */\n platformAdapter: AnalyticsPlatformAdapter;\n};\n\n/**\n * The AnalyticsController manages analytics tracking across platforms (Mobile/Extension).\n * It provides a unified interface for tracking events, identifying users, and managing\n * analytics preferences while delegating platform-specific implementation to an\n * {@link AnalyticsPlatformAdapter}.\n *\n * This controller follows the MetaMask controller pattern and integrates with the\n * messenger system to allow other controllers and components to track analytics events.\n * It delegates platform-specific implementation to an {@link AnalyticsPlatformAdapter}.\n *\n * Note: This controller does not persist state internally (`persist: false` in metadata).\n * The platform is responsible for:\n * - Providing the initial state (including a valid UUIDv4 analyticsId)\n * - Subscribing to `AnalyticsController:stateChange` event to persist changes\n */\nexport class AnalyticsController extends BaseController<\n 'AnalyticsController',\n AnalyticsControllerState,\n AnalyticsControllerMessenger\n> {\n readonly #platformAdapter: AnalyticsPlatformAdapter;\n\n /**\n * Constructs an AnalyticsController instance.\n *\n * @param options - Controller options\n * @param options.state - Initial controller state. Must include a valid UUIDv4 `analyticsId`.\n * Use `getDefaultAnalyticsControllerState()` for default opt-in preferences.\n * @param options.messenger - Messenger used to communicate with BaseController\n * @param options.platformAdapter - Platform adapter implementation for tracking\n * @throws Error if state.analyticsId is missing or not a valid UUIDv4\n */\n constructor({\n state,\n messenger,\n platformAdapter,\n }: AnalyticsControllerOptions) {\n const initialState: AnalyticsControllerState = {\n ...getDefaultAnalyticsControllerState(),\n ...state,\n };\n\n validateAnalyticsControllerState(initialState);\n\n super({\n name: controllerName,\n metadata: analyticsControllerMetadata,\n state: initialState,\n messenger,\n });\n\n this.#platformAdapter = platformAdapter;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n projectLogger('AnalyticsController initialized and ready', {\n enabled: analyticsControllerSelectors.selectEnabled(this.state),\n optedIn: this.state.optedIn,\n analyticsId: this.state.analyticsId,\n });\n\n // Call onSetupCompleted lifecycle hook after initialization\n // State is already validated, so analyticsId is guaranteed to be a valid UUIDv4\n this.#platformAdapter\n .onSetupCompleted(this.state.analyticsId)\n .catch((error) => {\n // Log error but don't throw - adapter setup failure shouldn't break controller\n projectLogger('Error calling platformAdapter.onSetupCompleted', error);\n });\n }\n\n /**\n * Track an analytics event.\n *\n * Events are only tracked if analytics is enabled.\n *\n * @param event - Analytics event with properties and sensitive properties\n */\n trackEvent(event: AnalyticsTrackingEvent): void {\n // Don't track if analytics is disabled\n if (!analyticsControllerSelectors.selectEnabled(this.state)) {\n return;\n }\n\n // Derive sensitivity from presence of sensitiveProperties\n const hasSensitiveProperties =\n Object.keys(event.sensitiveProperties).length > 0;\n\n // if event does not have properties, send event without properties\n // and return to prevent any additional processing\n if (!event.hasProperties) {\n this.#platformAdapter.track(event.name);\n return;\n }\n\n // Track regular properties (without isSensitive flag - it's the default)\n // Note: Even if properties object is empty, we still send it to ensure\n // an event with user ID is tracked. When only sensitiveProperties exist,\n // this creates two events: one with empty props (user ID) and one with\n // sensitive props (anonymous ID), which is the expected behavior.\n this.#platformAdapter.track(event.name, {\n ...event.properties,\n });\n\n // Track sensitive properties in a separate event with isSensitive flag\n if (hasSensitiveProperties) {\n this.#platformAdapter.track(event.name, {\n ...event.properties,\n ...event.sensitiveProperties,\n isSensitive: true,\n });\n }\n }\n\n /**\n * Identify a user for analytics.\n *\n * @param traits - User traits/properties\n */\n identify(traits?: AnalyticsUserTraits): void {\n if (!analyticsControllerSelectors.selectEnabled(this.state)) {\n return;\n }\n\n // Delegate to platform adapter using the current analytics ID\n this.#platformAdapter.identify(this.state.analyticsId, traits);\n }\n\n /**\n * Track a page or screen view.\n *\n * @param name - The identifier/name of the page or screen being viewed (e.g., \"home\", \"settings\", \"wallet\")\n * @param properties - Optional properties associated with the view\n */\n trackView(name: string, properties?: AnalyticsEventProperties): void {\n if (!analyticsControllerSelectors.selectEnabled(this.state)) {\n return;\n }\n\n // Delegate to platform adapter\n this.#platformAdapter.view(name, properties);\n }\n\n /**\n * Opt in to analytics.\n * This updates the user's opt-in status.\n */\n optIn(): void {\n this.update((state) => {\n state.optedIn = true;\n });\n }\n\n /**\n * Opt out of analytics.\n * This updates the user's opt-in status.\n */\n optOut(): void {\n this.update((state) => {\n state.optedIn = false;\n });\n }\n}\n"]}
1
+ {"version":3,"file":"AnalyticsController.cjs","sourceRoot":"","sources":["../src/AnalyticsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA2D;AAE3D,+BAAoC;AAGpC,2DAAkD;AAMlD,kBAAkB;AAElB;;;;GAIG;AACU,QAAA,cAAc,GAAG,qBAAqB,CAAC;AAwBpD;;GAEG;AACH,MAAM,2BAA2B,GAAG;IAClC,OAAO,EAAE;QACP,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,OAAO,EAAE;QACP,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,WAAW,EAAE;QACX,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;CACgD,CAAC;AAEpD;;;;;;;GAOG;AACH,SAAgB,kCAAkC;IAChD,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,IAAA,SAAM,GAAE;KACtB,CAAC;AACJ,CAAC;AAND,gFAMC;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,YAAY;IACZ,UAAU;IACV,WAAW;IACX,QAAQ;IACR,SAAS;IACT,OAAO;IACP,QAAQ;CACA,CAAC;AAgEX;;;;;;;;;GASG;AACH,MAAa,mBAAoB,SAAQ,gCAIxC;IAGC;;;;;;;OAOG;IACH,YAAY,EACV,KAAK,GAAG,EAAE,EACV,SAAS,EACT,eAAe,GACY;QAC3B,KAAK,CAAC;YACJ,IAAI,EAAE,sBAAc;YACpB,QAAQ,EAAE,2BAA2B;YACrC,KAAK,EAAE;gBACL,GAAG,kCAAkC,EAAE;gBACvC,GAAG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ACT,CAAC;QAED,4CAA4C;QAC5C,IAAI,uBAAA,IAAI,4CAAiB,CAAC,SAAS,EAAE,CAAC;YACpC,uBAAA,IAAI,4CAAiB,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3ID,kDA2IC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport type { AnalyticsControllerMethodActions } from './AnalyticsController-method-action-types';\nimport { projectLogger } from './AnalyticsLogger';\nimport type {\n AnalyticsPlatformAdapter,\n AnalyticsEventProperties,\n} from './AnalyticsPlatformAdapter.types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link AnalyticsController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nexport const controllerName = 'AnalyticsController';\n\n// === STATE ===\n\n/**\n * Describes the shape of the state object for {@link AnalyticsController}.\n */\nexport type AnalyticsControllerState = {\n /**\n * Whether analytics tracking is enabled\n */\n enabled: boolean;\n\n /**\n * Whether the user has opted in to analytics\n */\n optedIn: boolean;\n\n /**\n * User's UUIDv4 analytics identifier\n */\n analyticsId: string;\n};\n\n/**\n * The metadata for each property in {@link AnalyticsControllerState}.\n */\nconst analyticsControllerMetadata = {\n enabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n optedIn: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n analyticsId: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n} satisfies StateMetadata<AnalyticsControllerState>;\n\n/**\n * Constructs the default {@link AnalyticsController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link AnalyticsController} state.\n */\nexport function getDefaultAnalyticsControllerState(): AnalyticsControllerState {\n return {\n enabled: true,\n optedIn: false,\n analyticsId: uuidv4(),\n };\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'trackEvent',\n 'identify',\n 'trackPage',\n 'enable',\n 'disable',\n 'optIn',\n 'optOut',\n] as const;\n\n/**\n * Returns the state of the {@link AnalyticsController}.\n */\nexport type AnalyticsControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AnalyticsControllerState\n>;\n\n/**\n * Actions that {@link AnalyticsControllerMessenger} exposes to other consumers.\n */\nexport type AnalyticsControllerActions =\n | AnalyticsControllerGetStateAction\n | AnalyticsControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link AnalyticsControllerMessenger} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Event emitted when the state of the {@link AnalyticsController} changes.\n */\nexport type AnalyticsControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AnalyticsControllerState\n>;\n\n/**\n * Events that {@link AnalyticsControllerMessenger} exposes to other consumers.\n */\nexport type AnalyticsControllerEvents = AnalyticsControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link AnalyticsControllerMessenger} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link AnalyticsController}.\n */\nexport type AnalyticsControllerMessenger = Messenger<\n typeof controllerName,\n AnalyticsControllerActions | AllowedActions,\n AnalyticsControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * The options that AnalyticsController takes.\n */\nexport type AnalyticsControllerOptions = {\n state?: Partial<AnalyticsControllerState>;\n messenger: AnalyticsControllerMessenger;\n /**\n * Platform adapter implementation for tracking events\n */\n platformAdapter: AnalyticsPlatformAdapter;\n};\n\n/**\n * The AnalyticsController manages analytics tracking across platforms (Mobile/Extension).\n * It provides a unified interface for tracking events, identifying users, and managing\n * analytics preferences while delegating platform-specific implementation to an\n * {@link AnalyticsPlatformAdapter}.\n *\n * This controller follows the MetaMask controller pattern and integrates with the\n * messenger system to allow other controllers and components to track analytics events.\n * It delegates platform-specific implementation to an {@link AnalyticsPlatformAdapter}.\n */\nexport class AnalyticsController extends BaseController<\n 'AnalyticsController',\n AnalyticsControllerState,\n AnalyticsControllerMessenger\n> {\n readonly #platformAdapter: AnalyticsPlatformAdapter;\n\n /**\n * Constructs an AnalyticsController instance.\n *\n * @param options - Controller options\n * @param options.state - Initial controller state (defaults from getDefaultAnalyticsControllerState)\n * @param options.messenger - Messenger used to communicate with BaseController\n * @param options.platformAdapter - Platform adapter implementation for tracking\n */\n constructor({\n state = {},\n messenger,\n platformAdapter,\n }: AnalyticsControllerOptions) {\n super({\n name: controllerName,\n metadata: analyticsControllerMetadata,\n state: {\n ...getDefaultAnalyticsControllerState(),\n ...state,\n },\n messenger,\n });\n\n this.#platformAdapter = platformAdapter;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n projectLogger('AnalyticsController initialized and ready', {\n enabled: this.state.enabled,\n optedIn: this.state.optedIn,\n analyticsId: this.state.analyticsId,\n });\n }\n\n /**\n * Track an analytics event.\n *\n * Events are only tracked if analytics is enabled.\n *\n * @param eventName - The name of the event\n * @param properties - Event properties\n */\n trackEvent(\n eventName: string,\n properties: AnalyticsEventProperties = {},\n ): void {\n // Don't track if analytics is disabled\n if (!this.state.enabled) {\n return;\n }\n\n // Delegate to platform adapter\n this.#platformAdapter.trackEvent(eventName, properties);\n }\n\n /**\n * Identify a user for analytics.\n *\n * @param userId - The user identifier (e.g., metametrics ID)\n * @param traits - User traits/properties\n */\n identify(userId: string, traits?: AnalyticsEventProperties): void {\n if (!this.state.enabled) {\n return;\n }\n\n // Update state with analytics ID\n this.update((state) => {\n state.analyticsId = userId;\n });\n\n // Delegate to platform adapter if supported\n if (this.#platformAdapter.identify) {\n this.#platformAdapter.identify(userId, traits);\n }\n }\n\n /**\n * Track a page view.\n *\n * @param pageName - The name of the page\n * @param properties - Page properties\n */\n trackPage(pageName: string, properties?: AnalyticsEventProperties): void {\n if (!this.state.enabled) {\n return;\n }\n\n // Delegate to platform adapter if supported\n if (this.#platformAdapter.trackPage) {\n this.#platformAdapter.trackPage(pageName, properties);\n }\n }\n\n /**\n * Enable analytics tracking.\n */\n enable(): void {\n this.update((state) => {\n state.enabled = true;\n });\n }\n\n /**\n * Disable analytics tracking.\n */\n disable(): void {\n this.update((state) => {\n state.enabled = false;\n });\n }\n\n /**\n * Opt in to analytics.\n */\n optIn(): void {\n this.update((state) => {\n state.optedIn = true;\n });\n }\n\n /**\n * Opt out of analytics.\n */\n optOut(): void {\n this.update((state) => {\n state.optedIn = false;\n });\n }\n}\n"]}
@@ -2,7 +2,7 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@meta
2
2
  import { BaseController } from "@metamask/base-controller";
3
3
  import type { Messenger } from "@metamask/messenger";
4
4
  import type { AnalyticsControllerMethodActions } from "./AnalyticsController-method-action-types.cjs";
5
- import type { AnalyticsPlatformAdapter, AnalyticsEventProperties, AnalyticsUserTraits, AnalyticsTrackingEvent } from "./AnalyticsPlatformAdapter.types.cjs";
5
+ import type { AnalyticsPlatformAdapter, AnalyticsEventProperties } from "./AnalyticsPlatformAdapter.types.cjs";
6
6
  /**
7
7
  * The name of the {@link AnalyticsController}, used to namespace the
8
8
  * controller's actions and events and to namespace the controller's state data
@@ -14,25 +14,27 @@ export declare const controllerName = "AnalyticsController";
14
14
  */
15
15
  export type AnalyticsControllerState = {
16
16
  /**
17
- * Whether the user has opted in to analytics.
17
+ * Whether analytics tracking is enabled
18
+ */
19
+ enabled: boolean;
20
+ /**
21
+ * Whether the user has opted in to analytics
18
22
  */
19
23
  optedIn: boolean;
20
24
  /**
21
- * User's UUIDv4 analytics identifier.
22
- * This is an identity (unique per user), not a preference.
23
- * Must be provided by the platform - the controller does not generate it.
25
+ * User's UUIDv4 analytics identifier
24
26
  */
25
27
  analyticsId: string;
26
28
  };
27
29
  /**
28
- * Returns default values for AnalyticsController state.
29
- *
30
- * Note: analyticsId is NOT included - it's an identity that must be
31
- * provided by the platform (generated once on first run, then persisted).
30
+ * Constructs the default {@link AnalyticsController} state. This allows
31
+ * consumers to provide a partial state object when initializing the controller
32
+ * and also helps in constructing complete state objects for this controller in
33
+ * tests.
32
34
  *
33
- * @returns Default state without analyticsId
35
+ * @returns The default {@link AnalyticsController} state.
34
36
  */
35
- export declare function getDefaultAnalyticsControllerState(): Omit<AnalyticsControllerState, 'analyticsId'>;
37
+ export declare function getDefaultAnalyticsControllerState(): AnalyticsControllerState;
36
38
  /**
37
39
  * Returns the state of the {@link AnalyticsController}.
38
40
  */
@@ -66,17 +68,10 @@ export type AnalyticsControllerMessenger = Messenger<typeof controllerName, Anal
66
68
  * The options that AnalyticsController takes.
67
69
  */
68
70
  export type AnalyticsControllerOptions = {
69
- /**
70
- * Initial controller state. Must include a valid UUIDv4 `analyticsId`.
71
- * The platform is responsible for generating and persisting the analyticsId.
72
- */
73
- state: AnalyticsControllerState;
74
- /**
75
- * Messenger used to communicate with BaseController and other controllers.
76
- */
71
+ state?: Partial<AnalyticsControllerState>;
77
72
  messenger: AnalyticsControllerMessenger;
78
73
  /**
79
- * Platform adapter implementation for tracking events.
74
+ * Platform adapter implementation for tracking events
80
75
  */
81
76
  platformAdapter: AnalyticsPlatformAdapter;
82
77
  };
@@ -89,11 +84,6 @@ export type AnalyticsControllerOptions = {
89
84
  * This controller follows the MetaMask controller pattern and integrates with the
90
85
  * messenger system to allow other controllers and components to track analytics events.
91
86
  * It delegates platform-specific implementation to an {@link AnalyticsPlatformAdapter}.
92
- *
93
- * Note: This controller does not persist state internally (`persist: false` in metadata).
94
- * The platform is responsible for:
95
- * - Providing the initial state (including a valid UUIDv4 analyticsId)
96
- * - Subscribing to `AnalyticsController:stateChange` event to persist changes
97
87
  */
98
88
  export declare class AnalyticsController extends BaseController<'AnalyticsController', AnalyticsControllerState, AnalyticsControllerMessenger> {
99
89
  #private;
@@ -101,11 +91,9 @@ export declare class AnalyticsController extends BaseController<'AnalyticsContro
101
91
  * Constructs an AnalyticsController instance.
102
92
  *
103
93
  * @param options - Controller options
104
- * @param options.state - Initial controller state. Must include a valid UUIDv4 `analyticsId`.
105
- * Use `getDefaultAnalyticsControllerState()` for default opt-in preferences.
94
+ * @param options.state - Initial controller state (defaults from getDefaultAnalyticsControllerState)
106
95
  * @param options.messenger - Messenger used to communicate with BaseController
107
96
  * @param options.platformAdapter - Platform adapter implementation for tracking
108
- * @throws Error if state.analyticsId is missing or not a valid UUIDv4
109
97
  */
110
98
  constructor({ state, messenger, platformAdapter, }: AnalyticsControllerOptions);
111
99
  /**
@@ -113,30 +101,38 @@ export declare class AnalyticsController extends BaseController<'AnalyticsContro
113
101
  *
114
102
  * Events are only tracked if analytics is enabled.
115
103
  *
116
- * @param event - Analytics event with properties and sensitive properties
104
+ * @param eventName - The name of the event
105
+ * @param properties - Event properties
117
106
  */
118
- trackEvent(event: AnalyticsTrackingEvent): void;
107
+ trackEvent(eventName: string, properties?: AnalyticsEventProperties): void;
119
108
  /**
120
109
  * Identify a user for analytics.
121
110
  *
111
+ * @param userId - The user identifier (e.g., metametrics ID)
122
112
  * @param traits - User traits/properties
123
113
  */
124
- identify(traits?: AnalyticsUserTraits): void;
114
+ identify(userId: string, traits?: AnalyticsEventProperties): void;
125
115
  /**
126
- * Track a page or screen view.
116
+ * Track a page view.
127
117
  *
128
- * @param name - The identifier/name of the page or screen being viewed (e.g., "home", "settings", "wallet")
129
- * @param properties - Optional properties associated with the view
118
+ * @param pageName - The name of the page
119
+ * @param properties - Page properties
120
+ */
121
+ trackPage(pageName: string, properties?: AnalyticsEventProperties): void;
122
+ /**
123
+ * Enable analytics tracking.
124
+ */
125
+ enable(): void;
126
+ /**
127
+ * Disable analytics tracking.
130
128
  */
131
- trackView(name: string, properties?: AnalyticsEventProperties): void;
129
+ disable(): void;
132
130
  /**
133
131
  * Opt in to analytics.
134
- * This updates the user's opt-in status.
135
132
  */
136
133
  optIn(): void;
137
134
  /**
138
135
  * Opt out of analytics.
139
- * This updates the user's opt-in status.
140
136
  */
141
137
  optOut(): void;
142
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsController.d.cts","sourceRoot":"","sources":["../src/AnalyticsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,KAAK,EAAE,gCAAgC,EAAE,sDAAkD;AAGlG,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACvB,6CAAyC;AAK1C;;;;GAIG;AACH,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAIpD;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;O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mC,CAAC;AAE5E;;GAEG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG,SAAS,CAClD,OAAO,cAAc,EACrB,0BAA0B,GAAG,cAAc,EAC3C,yBAAyB,GAAG,aAAa,CAC1C,CAAC;AAIF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC1C,SAAS,EAAE,4BAA4B,CAAC;IACxC;;OAEG;IACH,eAAe,EAAE,wBAAwB,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;GASG;AACH,qBAAa,mBAAoB,SAAQ,cAAc,CACrD,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,CAC7B;;IAGC;;;;;;;OAOG;gBACS,EACV,KAAU,EACV,SAAS,EACT,eAAe,GAChB,EAAE,0BAA0B;IAyB7B;;;;;;;OAOG;IACH,UAAU,CACR,SAAS,EAAE,MAAM,EACjB,UAAU,GAAE,wBAA6B,GACxC,IAAI;IAUP;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,wBAAwB,GAAG,IAAI;IAgBjE;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,wBAAwB,GAAG,IAAI;IAWxE;;OAEG;IACH,MAAM,IAAI,IAAI;IAMd;;OAEG;IACH,OAAO,IAAI,IAAI;IAMf;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,MAAM,IAAI,IAAI;CAKf"}
@@ -2,7 +2,7 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@meta
2
2
  import { BaseController } from "@metamask/base-controller";
3
3
  import type { Messenger } from "@metamask/messenger";
4
4
  import type { AnalyticsControllerMethodActions } from "./AnalyticsController-method-action-types.mjs";
5
- import type { AnalyticsPlatformAdapter, AnalyticsEventProperties, AnalyticsUserTraits, AnalyticsTrackingEvent } from "./AnalyticsPlatformAdapter.types.mjs";
5
+ import type { AnalyticsPlatformAdapter, AnalyticsEventProperties } from "./AnalyticsPlatformAdapter.types.mjs";
6
6
  /**
7
7
  * The name of the {@link AnalyticsController}, used to namespace the
8
8
  * controller's actions and events and to namespace the controller's state data
@@ -14,25 +14,27 @@ export declare const controllerName = "AnalyticsController";
14
14
  */
15
15
  export type AnalyticsControllerState = {
16
16
  /**
17
- * Whether the user has opted in to analytics.
17
+ * Whether analytics tracking is enabled
18
+ */
19
+ enabled: boolean;
20
+ /**
21
+ * Whether the user has opted in to analytics
18
22
  */
19
23
  optedIn: boolean;
20
24
  /**
21
- * User's UUIDv4 analytics identifier.
22
- * This is an identity (unique per user), not a preference.
23
- * Must be provided by the platform - the controller does not generate it.
25
+ * User's UUIDv4 analytics identifier
24
26
  */
25
27
  analyticsId: string;
26
28
  };
27
29
  /**
28
- * Returns default values for AnalyticsController state.
29
- *
30
- * Note: analyticsId is NOT included - it's an identity that must be
31
- * provided by the platform (generated once on first run, then persisted).
30
+ * Constructs the default {@link AnalyticsController} state. This allows
31
+ * consumers to provide a partial state object when initializing the controller
32
+ * and also helps in constructing complete state objects for this controller in
33
+ * tests.
32
34
  *
33
- * @returns Default state without analyticsId
35
+ * @returns The default {@link AnalyticsController} state.
34
36
  */
35
- export declare function getDefaultAnalyticsControllerState(): Omit<AnalyticsControllerState, 'analyticsId'>;
37
+ export declare function getDefaultAnalyticsControllerState(): AnalyticsControllerState;
36
38
  /**
37
39
  * Returns the state of the {@link AnalyticsController}.
38
40
  */
@@ -66,17 +68,10 @@ export type AnalyticsControllerMessenger = Messenger<typeof controllerName, Anal
66
68
  * The options that AnalyticsController takes.
67
69
  */
68
70
  export type AnalyticsControllerOptions = {
69
- /**
70
- * Initial controller state. Must include a valid UUIDv4 `analyticsId`.
71
- * The platform is responsible for generating and persisting the analyticsId.
72
- */
73
- state: AnalyticsControllerState;
74
- /**
75
- * Messenger used to communicate with BaseController and other controllers.
76
- */
71
+ state?: Partial<AnalyticsControllerState>;
77
72
  messenger: AnalyticsControllerMessenger;
78
73
  /**
79
- * Platform adapter implementation for tracking events.
74
+ * Platform adapter implementation for tracking events
80
75
  */
81
76
  platformAdapter: AnalyticsPlatformAdapter;
82
77
  };
@@ -89,11 +84,6 @@ export type AnalyticsControllerOptions = {
89
84
  * This controller follows the MetaMask controller pattern and integrates with the
90
85
  * messenger system to allow other controllers and components to track analytics events.
91
86
  * It delegates platform-specific implementation to an {@link AnalyticsPlatformAdapter}.
92
- *
93
- * Note: This controller does not persist state internally (`persist: false` in metadata).
94
- * The platform is responsible for:
95
- * - Providing the initial state (including a valid UUIDv4 analyticsId)
96
- * - Subscribing to `AnalyticsController:stateChange` event to persist changes
97
87
  */
98
88
  export declare class AnalyticsController extends BaseController<'AnalyticsController', AnalyticsControllerState, AnalyticsControllerMessenger> {
99
89
  #private;
@@ -101,11 +91,9 @@ export declare class AnalyticsController extends BaseController<'AnalyticsContro
101
91
  * Constructs an AnalyticsController instance.
102
92
  *
103
93
  * @param options - Controller options
104
- * @param options.state - Initial controller state. Must include a valid UUIDv4 `analyticsId`.
105
- * Use `getDefaultAnalyticsControllerState()` for default opt-in preferences.
94
+ * @param options.state - Initial controller state (defaults from getDefaultAnalyticsControllerState)
106
95
  * @param options.messenger - Messenger used to communicate with BaseController
107
96
  * @param options.platformAdapter - Platform adapter implementation for tracking
108
- * @throws Error if state.analyticsId is missing or not a valid UUIDv4
109
97
  */
110
98
  constructor({ state, messenger, platformAdapter, }: AnalyticsControllerOptions);
111
99
  /**
@@ -113,30 +101,38 @@ export declare class AnalyticsController extends BaseController<'AnalyticsContro
113
101
  *
114
102
  * Events are only tracked if analytics is enabled.
115
103
  *
116
- * @param event - Analytics event with properties and sensitive properties
104
+ * @param eventName - The name of the event
105
+ * @param properties - Event properties
117
106
  */
118
- trackEvent(event: AnalyticsTrackingEvent): void;
107
+ trackEvent(eventName: string, properties?: AnalyticsEventProperties): void;
119
108
  /**
120
109
  * Identify a user for analytics.
121
110
  *
111
+ * @param userId - The user identifier (e.g., metametrics ID)
122
112
  * @param traits - User traits/properties
123
113
  */
124
- identify(traits?: AnalyticsUserTraits): void;
114
+ identify(userId: string, traits?: AnalyticsEventProperties): void;
125
115
  /**
126
- * Track a page or screen view.
116
+ * Track a page view.
127
117
  *
128
- * @param name - The identifier/name of the page or screen being viewed (e.g., "home", "settings", "wallet")
129
- * @param properties - Optional properties associated with the view
118
+ * @param pageName - The name of the page
119
+ * @param properties - Page properties
120
+ */
121
+ trackPage(pageName: string, properties?: AnalyticsEventProperties): void;
122
+ /**
123
+ * Enable analytics tracking.
124
+ */
125
+ enable(): void;
126
+ /**
127
+ * Disable analytics tracking.
130
128
  */
131
- trackView(name: string, properties?: AnalyticsEventProperties): void;
129
+ disable(): void;
132
130
  /**
133
131
  * Opt in to analytics.
134
- * This updates the user's opt-in status.
135
132
  */
136
133
  optIn(): void;
137
134
  /**
138
135
  * Opt out of analytics.
139
- * This updates the user's opt-in status.
140
136
  */
141
137
  optOut(): void;
142
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsController.d.mts","sourceRoot":"","sources":["../src/AnalyticsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,KAAK,EAAE,gCAAgC,EAAE,sDAAkD;AAGlG,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACvB,6CAAyC;AAK1C;;;;GAIG;AACH,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAIpD;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CA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