@metamask-previews/analytics-controller 0.0.0-preview-b8454d32

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 (46) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE +6 -0
  3. package/LICENSE.APACHE2 +201 -0
  4. package/LICENSE.MIT +21 -0
  5. package/README.md +198 -0
  6. package/dist/AnalyticsController-method-action-types.cjs +7 -0
  7. package/dist/AnalyticsController-method-action-types.cjs.map +1 -0
  8. package/dist/AnalyticsController-method-action-types.d.cts +70 -0
  9. package/dist/AnalyticsController-method-action-types.d.cts.map +1 -0
  10. package/dist/AnalyticsController-method-action-types.d.mts +70 -0
  11. package/dist/AnalyticsController-method-action-types.d.mts.map +1 -0
  12. package/dist/AnalyticsController-method-action-types.mjs +6 -0
  13. package/dist/AnalyticsController-method-action-types.mjs.map +1 -0
  14. package/dist/AnalyticsController.cjs +205 -0
  15. package/dist/AnalyticsController.cjs.map +1 -0
  16. package/dist/AnalyticsController.d.cts +140 -0
  17. package/dist/AnalyticsController.d.cts.map +1 -0
  18. package/dist/AnalyticsController.d.mts +140 -0
  19. package/dist/AnalyticsController.d.mts.map +1 -0
  20. package/dist/AnalyticsController.mjs +200 -0
  21. package/dist/AnalyticsController.mjs.map +1 -0
  22. package/dist/AnalyticsLogger.cjs +8 -0
  23. package/dist/AnalyticsLogger.cjs.map +1 -0
  24. package/dist/AnalyticsLogger.d.cts +5 -0
  25. package/dist/AnalyticsLogger.d.cts.map +1 -0
  26. package/dist/AnalyticsLogger.d.mts +5 -0
  27. package/dist/AnalyticsLogger.d.mts.map +1 -0
  28. package/dist/AnalyticsLogger.mjs +5 -0
  29. package/dist/AnalyticsLogger.mjs.map +1 -0
  30. package/dist/AnalyticsPlatformAdapter.types.cjs +3 -0
  31. package/dist/AnalyticsPlatformAdapter.types.cjs.map +1 -0
  32. package/dist/AnalyticsPlatformAdapter.types.d.cts +33 -0
  33. package/dist/AnalyticsPlatformAdapter.types.d.cts.map +1 -0
  34. package/dist/AnalyticsPlatformAdapter.types.d.mts +33 -0
  35. package/dist/AnalyticsPlatformAdapter.types.d.mts.map +1 -0
  36. package/dist/AnalyticsPlatformAdapter.types.mjs +2 -0
  37. package/dist/AnalyticsPlatformAdapter.types.mjs.map +1 -0
  38. package/dist/index.cjs +9 -0
  39. package/dist/index.cjs.map +1 -0
  40. package/dist/index.d.cts +9 -0
  41. package/dist/index.d.cts.map +1 -0
  42. package/dist/index.d.mts +9 -0
  43. package/dist/index.d.mts.map +1 -0
  44. package/dist/index.mjs +4 -0
  45. package/dist/index.mjs.map +1 -0
  46. package/package.json +74 -0
@@ -0,0 +1,200 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _AnalyticsController_platformAdapter;
13
+ import { BaseController } from "@metamask/base-controller";
14
+ import { v4 as uuidv4 } from "uuid";
15
+ import { projectLogger } from "./AnalyticsLogger.mjs";
16
+ // === GENERAL ===
17
+ /**
18
+ * The name of the {@link AnalyticsController}, used to namespace the
19
+ * controller's actions and events and to namespace the controller's state data
20
+ * when composed with other controllers.
21
+ */
22
+ export const controllerName = 'AnalyticsController';
23
+ /**
24
+ * The metadata for each property in {@link AnalyticsControllerState}.
25
+ */
26
+ const analyticsControllerMetadata = {
27
+ enabled: {
28
+ includeInStateLogs: true,
29
+ persist: true,
30
+ includeInDebugSnapshot: true,
31
+ usedInUi: true,
32
+ },
33
+ optedIn: {
34
+ includeInStateLogs: true,
35
+ persist: true,
36
+ includeInDebugSnapshot: true,
37
+ usedInUi: true,
38
+ },
39
+ analyticsId: {
40
+ includeInStateLogs: false,
41
+ persist: true,
42
+ includeInDebugSnapshot: false,
43
+ usedInUi: false,
44
+ },
45
+ };
46
+ /**
47
+ * Constructs the default {@link AnalyticsController} state. This allows
48
+ * consumers to provide a partial state object when initializing the controller
49
+ * and also helps in constructing complete state objects for this controller in
50
+ * tests.
51
+ *
52
+ * @returns The default {@link AnalyticsController} state.
53
+ */
54
+ export function getDefaultAnalyticsControllerState() {
55
+ return {
56
+ enabled: true,
57
+ optedIn: false,
58
+ analyticsId: uuidv4(),
59
+ };
60
+ }
61
+ // === MESSENGER ===
62
+ const MESSENGER_EXPOSED_METHODS = [
63
+ 'trackEvent',
64
+ 'identify',
65
+ 'trackPage',
66
+ 'enable',
67
+ 'disable',
68
+ 'optIn',
69
+ 'optOut',
70
+ ];
71
+ /**
72
+ * The AnalyticsController manages analytics tracking across platforms (Mobile/Extension).
73
+ * It provides a unified interface for tracking events, identifying users, and managing
74
+ * analytics preferences while delegating platform-specific implementation to an
75
+ * {@link AnalyticsPlatformAdapter}.
76
+ *
77
+ * This controller follows the MetaMask controller pattern and integrates with the
78
+ * messenger system to allow other controllers and components to track analytics events.
79
+ * It delegates platform-specific implementation to an {@link AnalyticsPlatformAdapter}.
80
+ */
81
+ export class AnalyticsController extends BaseController {
82
+ /**
83
+ * Constructs an AnalyticsController instance.
84
+ *
85
+ * @param options - Controller options
86
+ * @param options.state - Initial controller state (defaults from getDefaultAnalyticsControllerState)
87
+ * @param options.messenger - Messenger used to communicate with BaseController
88
+ * @param options.platformAdapter - Platform adapter implementation for tracking
89
+ */
90
+ constructor({ state = {}, messenger, platformAdapter, }) {
91
+ const defaultState = getDefaultAnalyticsControllerState();
92
+ // Use analyticsId from state if provided, otherwise use the one from defaultState
93
+ const analyticsId = state.analyticsId !== undefined
94
+ ? state.analyticsId
95
+ : defaultState.analyticsId;
96
+ const mergedState = {
97
+ ...defaultState,
98
+ ...state,
99
+ analyticsId,
100
+ };
101
+ super({
102
+ name: controllerName,
103
+ metadata: analyticsControllerMetadata,
104
+ state: mergedState,
105
+ messenger,
106
+ });
107
+ _AnalyticsController_platformAdapter.set(this, void 0);
108
+ __classPrivateFieldSet(this, _AnalyticsController_platformAdapter, platformAdapter, "f");
109
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
110
+ projectLogger('AnalyticsController initialized and ready', {
111
+ enabled: this.state.enabled,
112
+ optedIn: this.state.optedIn,
113
+ analyticsId: this.state.analyticsId,
114
+ });
115
+ }
116
+ /**
117
+ * Track an analytics event.
118
+ *
119
+ * Events are only tracked if analytics is enabled.
120
+ *
121
+ * @param eventName - The name of the event
122
+ * @param properties - Event properties
123
+ */
124
+ trackEvent(eventName, properties = {}) {
125
+ // Don't track if analytics is disabled
126
+ if (!this.state.enabled) {
127
+ return;
128
+ }
129
+ // Delegate to platform adapter
130
+ __classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").trackEvent(eventName, properties);
131
+ }
132
+ /**
133
+ * Identify a user for analytics.
134
+ *
135
+ * @param userId - The user identifier (e.g., metametrics ID)
136
+ * @param traits - User traits/properties
137
+ */
138
+ identify(userId, traits) {
139
+ if (!this.state.enabled) {
140
+ return;
141
+ }
142
+ // Update state with analytics ID
143
+ this.update((state) => {
144
+ state.analyticsId = userId;
145
+ });
146
+ // Delegate to platform adapter if supported
147
+ if (__classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").identify) {
148
+ __classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").identify(userId, traits);
149
+ }
150
+ }
151
+ /**
152
+ * Track a page view.
153
+ *
154
+ * @param pageName - The name of the page
155
+ * @param properties - Page properties
156
+ */
157
+ trackPage(pageName, properties) {
158
+ if (!this.state.enabled) {
159
+ return;
160
+ }
161
+ // Delegate to platform adapter if supported
162
+ if (__classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").trackPage) {
163
+ __classPrivateFieldGet(this, _AnalyticsController_platformAdapter, "f").trackPage(pageName, properties);
164
+ }
165
+ }
166
+ /**
167
+ * Enable analytics tracking.
168
+ */
169
+ enable() {
170
+ this.update((state) => {
171
+ state.enabled = true;
172
+ });
173
+ }
174
+ /**
175
+ * Disable analytics tracking.
176
+ */
177
+ disable() {
178
+ this.update((state) => {
179
+ state.enabled = false;
180
+ });
181
+ }
182
+ /**
183
+ * Opt in to analytics.
184
+ */
185
+ optIn() {
186
+ this.update((state) => {
187
+ state.optedIn = true;
188
+ });
189
+ }
190
+ /**
191
+ * Opt out of analytics.
192
+ */
193
+ optOut() {
194
+ this.update((state) => {
195
+ state.optedIn = false;
196
+ });
197
+ }
198
+ }
199
+ _AnalyticsController_platformAdapter = new WeakMap();
200
+ //# sourceMappingURL=AnalyticsController.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsController.mjs","sourceRoot":"","sources":["../src/AnalyticsController.ts"],"names":[],"mappings":"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","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: false,\n persist: true,\n includeInDebugSnapshot: false,\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 const defaultState = getDefaultAnalyticsControllerState();\n // Use analyticsId from state if provided, otherwise use the one from defaultState\n const analyticsId: string =\n state.analyticsId !== undefined\n ? state.analyticsId\n : defaultState.analyticsId;\n const mergedState: AnalyticsControllerState = {\n ...defaultState,\n ...state,\n analyticsId,\n };\n\n super({\n name: controllerName,\n metadata: analyticsControllerMetadata,\n state: mergedState,\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"]}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /* istanbul ignore file */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.createModuleLogger = exports.projectLogger = void 0;
5
+ const utils_1 = require("@metamask/utils");
6
+ Object.defineProperty(exports, "createModuleLogger", { enumerable: true, get: function () { return utils_1.createModuleLogger; } });
7
+ exports.projectLogger = (0, utils_1.createProjectLogger)('analytics-controller');
8
+ //# sourceMappingURL=AnalyticsLogger.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsLogger.cjs","sourceRoot":"","sources":["../src/AnalyticsLogger.ts"],"names":[],"mappings":";AAAA,0BAA0B;;;AAE1B,2CAA0E;AAIjE,mGAJqB,0BAAkB,OAIrB;AAFd,QAAA,aAAa,GAAG,IAAA,2BAAmB,EAAC,sBAAsB,CAAC,CAAC","sourcesContent":["/* istanbul ignore file */\n\nimport { createProjectLogger, createModuleLogger } from '@metamask/utils';\n\nexport const projectLogger = createProjectLogger('analytics-controller');\n\nexport { createModuleLogger };\n"]}
@@ -0,0 +1,5 @@
1
+ /// <reference types="debug" />
2
+ import { createModuleLogger } from "@metamask/utils";
3
+ export declare const projectLogger: import("debug").Debugger;
4
+ export { createModuleLogger };
5
+ //# sourceMappingURL=AnalyticsLogger.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsLogger.d.cts","sourceRoot":"","sources":["../src/AnalyticsLogger.ts"],"names":[],"mappings":";AAEA,OAAO,EAAuB,kBAAkB,EAAE,wBAAwB;AAE1E,eAAO,MAAM,aAAa,0BAA8C,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="debug" />
2
+ import { createModuleLogger } from "@metamask/utils";
3
+ export declare const projectLogger: import("debug").Debugger;
4
+ export { createModuleLogger };
5
+ //# sourceMappingURL=AnalyticsLogger.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsLogger.d.mts","sourceRoot":"","sources":["../src/AnalyticsLogger.ts"],"names":[],"mappings":";AAEA,OAAO,EAAuB,kBAAkB,EAAE,wBAAwB;AAE1E,eAAO,MAAM,aAAa,0BAA8C,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ /* istanbul ignore file */
2
+ import { createProjectLogger, createModuleLogger } from "@metamask/utils";
3
+ export const projectLogger = createProjectLogger('analytics-controller');
4
+ export { createModuleLogger };
5
+ //# sourceMappingURL=AnalyticsLogger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsLogger.mjs","sourceRoot":"","sources":["../src/AnalyticsLogger.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,wBAAwB;AAE1E,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["/* istanbul ignore file */\n\nimport { createProjectLogger, createModuleLogger } from '@metamask/utils';\n\nexport const projectLogger = createProjectLogger('analytics-controller');\n\nexport { createModuleLogger };\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AnalyticsPlatformAdapter.types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsPlatformAdapter.types.cjs","sourceRoot":"","sources":["../src/AnalyticsPlatformAdapter.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Json } from '@metamask/utils';\n\n/**\n * Analytics event properties\n */\nexport type AnalyticsEventProperties = Record<string, Json>;\n\n/**\n * Platform adapter interface for analytics tracking\n * Implementations should handle platform-specific details (Segment SDK, etc.)\n */\nexport type AnalyticsPlatformAdapter = {\n /**\n * Track an analytics event\n *\n * @param eventName - The name of the event\n * @param properties - Event properties\n */\n trackEvent(eventName: string, properties: AnalyticsEventProperties): void;\n\n /**\n * Identify a user\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\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};\n"]}
@@ -0,0 +1,33 @@
1
+ import type { Json } from "@metamask/utils";
2
+ /**
3
+ * Analytics event properties
4
+ */
5
+ export type AnalyticsEventProperties = Record<string, Json>;
6
+ /**
7
+ * Platform adapter interface for analytics tracking
8
+ * Implementations should handle platform-specific details (Segment SDK, etc.)
9
+ */
10
+ export type AnalyticsPlatformAdapter = {
11
+ /**
12
+ * Track an analytics event
13
+ *
14
+ * @param eventName - The name of the event
15
+ * @param properties - Event properties
16
+ */
17
+ trackEvent(eventName: string, properties: AnalyticsEventProperties): void;
18
+ /**
19
+ * Identify a user
20
+ *
21
+ * @param userId - The user identifier (e.g., metametrics ID)
22
+ * @param traits - User traits/properties
23
+ */
24
+ identify?(userId: string, traits?: AnalyticsEventProperties): void;
25
+ /**
26
+ * Track a page view
27
+ *
28
+ * @param pageName - The name of the page
29
+ * @param properties - Page properties
30
+ */
31
+ trackPage?(pageName: string, properties?: AnalyticsEventProperties): void;
32
+ };
33
+ //# sourceMappingURL=AnalyticsPlatformAdapter.types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsPlatformAdapter.types.d.cts","sourceRoot":"","sources":["../src/AnalyticsPlatformAdapter.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAE5C;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;OAKG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAE1E;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAEnE;;;;;OAKG;IACH,SAAS,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;CAC3E,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { Json } from "@metamask/utils";
2
+ /**
3
+ * Analytics event properties
4
+ */
5
+ export type AnalyticsEventProperties = Record<string, Json>;
6
+ /**
7
+ * Platform adapter interface for analytics tracking
8
+ * Implementations should handle platform-specific details (Segment SDK, etc.)
9
+ */
10
+ export type AnalyticsPlatformAdapter = {
11
+ /**
12
+ * Track an analytics event
13
+ *
14
+ * @param eventName - The name of the event
15
+ * @param properties - Event properties
16
+ */
17
+ trackEvent(eventName: string, properties: AnalyticsEventProperties): void;
18
+ /**
19
+ * Identify a user
20
+ *
21
+ * @param userId - The user identifier (e.g., metametrics ID)
22
+ * @param traits - User traits/properties
23
+ */
24
+ identify?(userId: string, traits?: AnalyticsEventProperties): void;
25
+ /**
26
+ * Track a page view
27
+ *
28
+ * @param pageName - The name of the page
29
+ * @param properties - Page properties
30
+ */
31
+ trackPage?(pageName: string, properties?: AnalyticsEventProperties): void;
32
+ };
33
+ //# sourceMappingURL=AnalyticsPlatformAdapter.types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsPlatformAdapter.types.d.mts","sourceRoot":"","sources":["../src/AnalyticsPlatformAdapter.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAE5C;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;OAKG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAE1E;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAEnE;;;;;OAKG;IACH,SAAS,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;CAC3E,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AnalyticsPlatformAdapter.types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsPlatformAdapter.types.mjs","sourceRoot":"","sources":["../src/AnalyticsPlatformAdapter.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Json } from '@metamask/utils';\n\n/**\n * Analytics event properties\n */\nexport type AnalyticsEventProperties = Record<string, Json>;\n\n/**\n * Platform adapter interface for analytics tracking\n * Implementations should handle platform-specific details (Segment SDK, etc.)\n */\nexport type AnalyticsPlatformAdapter = {\n /**\n * Track an analytics event\n *\n * @param eventName - The name of the event\n * @param properties - Event properties\n */\n trackEvent(eventName: string, properties: AnalyticsEventProperties): void;\n\n /**\n * Identify a user\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\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};\n"]}
package/dist/index.cjs ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDefaultAnalyticsControllerState = exports.AnalyticsController = void 0;
4
+ // Export controller class
5
+ var AnalyticsController_1 = require("./AnalyticsController.cjs");
6
+ Object.defineProperty(exports, "AnalyticsController", { enumerable: true, get: function () { return AnalyticsController_1.AnalyticsController; } });
7
+ var AnalyticsController_2 = require("./AnalyticsController.cjs");
8
+ Object.defineProperty(exports, "getDefaultAnalyticsControllerState", { enumerable: true, get: function () { return AnalyticsController_2.getDefaultAnalyticsControllerState; } });
9
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,0BAA0B;AAC1B,iEAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAW5B,iEAA2E;AAAlE,yIAAA,kCAAkC,OAAA","sourcesContent":["// Export controller class\nexport { AnalyticsController } from './AnalyticsController';\nexport type { AnalyticsControllerOptions } from './AnalyticsController';\n\n// Export types\nexport type {\n AnalyticsEventProperties,\n AnalyticsPlatformAdapter,\n} from './AnalyticsPlatformAdapter.types';\n\n// Export state types and utilities\nexport type { AnalyticsControllerState } from './AnalyticsController';\nexport { getDefaultAnalyticsControllerState } from './AnalyticsController';\n\n// Export messenger types\nexport type { AnalyticsControllerMessenger } from './AnalyticsController';\n\n// Export action and event types\nexport type {\n AnalyticsControllerActions,\n AnalyticsControllerEvents,\n AnalyticsControllerGetStateAction,\n AnalyticsControllerStateChangeEvent,\n controllerName,\n} from './AnalyticsController';\nexport type {\n AnalyticsControllerTrackEventAction,\n AnalyticsControllerIdentifyAction,\n AnalyticsControllerTrackPageAction,\n AnalyticsControllerEnableAction,\n AnalyticsControllerDisableAction,\n AnalyticsControllerOptInAction,\n AnalyticsControllerOptOutAction,\n AnalyticsControllerMethodActions,\n} from './AnalyticsController-method-action-types';\n"]}
@@ -0,0 +1,9 @@
1
+ export { AnalyticsController } from "./AnalyticsController.cjs";
2
+ export type { AnalyticsControllerOptions } from "./AnalyticsController.cjs";
3
+ export type { AnalyticsEventProperties, AnalyticsPlatformAdapter, } from "./AnalyticsPlatformAdapter.types.cjs";
4
+ export type { AnalyticsControllerState } from "./AnalyticsController.cjs";
5
+ export { getDefaultAnalyticsControllerState } from "./AnalyticsController.cjs";
6
+ export type { AnalyticsControllerMessenger } from "./AnalyticsController.cjs";
7
+ export type { AnalyticsControllerActions, AnalyticsControllerEvents, AnalyticsControllerGetStateAction, AnalyticsControllerStateChangeEvent, controllerName, } from "./AnalyticsController.cjs";
8
+ export type { AnalyticsControllerTrackEventAction, AnalyticsControllerIdentifyAction, AnalyticsControllerTrackPageAction, AnalyticsControllerEnableAction, AnalyticsControllerDisableAction, AnalyticsControllerOptInAction, AnalyticsControllerOptOutAction, AnalyticsControllerMethodActions, } from "./AnalyticsController-method-action-types.cjs";
9
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAC5D,YAAY,EAAE,0BAA0B,EAAE,kCAA8B;AAGxE,YAAY,EACV,wBAAwB,EACxB,wBAAwB,GACzB,6CAAyC;AAG1C,YAAY,EAAE,wBAAwB,EAAE,kCAA8B;AACtE,OAAO,EAAE,kCAAkC,EAAE,kCAA8B;AAG3E,YAAY,EAAE,4BAA4B,EAAE,kCAA8B;AAG1E,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,iCAAiC,EACjC,mCAAmC,EACnC,cAAc,GACf,kCAA8B;AAC/B,YAAY,EACV,mCAAmC,EACnC,iCAAiC,EACjC,kCAAkC,EAClC,+BAA+B,EAC/B,gCAAgC,EAChC,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,GACjC,sDAAkD"}
@@ -0,0 +1,9 @@
1
+ export { AnalyticsController } from "./AnalyticsController.mjs";
2
+ export type { AnalyticsControllerOptions } from "./AnalyticsController.mjs";
3
+ export type { AnalyticsEventProperties, AnalyticsPlatformAdapter, } from "./AnalyticsPlatformAdapter.types.mjs";
4
+ export type { AnalyticsControllerState } from "./AnalyticsController.mjs";
5
+ export { getDefaultAnalyticsControllerState } from "./AnalyticsController.mjs";
6
+ export type { AnalyticsControllerMessenger } from "./AnalyticsController.mjs";
7
+ export type { AnalyticsControllerActions, AnalyticsControllerEvents, AnalyticsControllerGetStateAction, AnalyticsControllerStateChangeEvent, controllerName, } from "./AnalyticsController.mjs";
8
+ export type { AnalyticsControllerTrackEventAction, AnalyticsControllerIdentifyAction, AnalyticsControllerTrackPageAction, AnalyticsControllerEnableAction, AnalyticsControllerDisableAction, AnalyticsControllerOptInAction, AnalyticsControllerOptOutAction, AnalyticsControllerMethodActions, } from "./AnalyticsController-method-action-types.mjs";
9
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAC5D,YAAY,EAAE,0BAA0B,EAAE,kCAA8B;AAGxE,YAAY,EACV,wBAAwB,EACxB,wBAAwB,GACzB,6CAAyC;AAG1C,YAAY,EAAE,wBAAwB,EAAE,kCAA8B;AACtE,OAAO,EAAE,kCAAkC,EAAE,kCAA8B;AAG3E,YAAY,EAAE,4BAA4B,EAAE,kCAA8B;AAG1E,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,iCAAiC,EACjC,mCAAmC,EACnC,cAAc,GACf,kCAA8B;AAC/B,YAAY,EACV,mCAAmC,EACnC,iCAAiC,EACjC,kCAAkC,EAClC,+BAA+B,EAC/B,gCAAgC,EAChC,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,GACjC,sDAAkD"}
package/dist/index.mjs ADDED
@@ -0,0 +1,4 @@
1
+ // Export controller class
2
+ export { AnalyticsController } from "./AnalyticsController.mjs";
3
+ export { getDefaultAnalyticsControllerState } from "./AnalyticsController.mjs";
4
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAW5D,OAAO,EAAE,kCAAkC,EAAE,kCAA8B","sourcesContent":["// Export controller class\nexport { AnalyticsController } from './AnalyticsController';\nexport type { AnalyticsControllerOptions } from './AnalyticsController';\n\n// Export types\nexport type {\n AnalyticsEventProperties,\n AnalyticsPlatformAdapter,\n} from './AnalyticsPlatformAdapter.types';\n\n// Export state types and utilities\nexport type { AnalyticsControllerState } from './AnalyticsController';\nexport { getDefaultAnalyticsControllerState } from './AnalyticsController';\n\n// Export messenger types\nexport type { AnalyticsControllerMessenger } from './AnalyticsController';\n\n// Export action and event types\nexport type {\n AnalyticsControllerActions,\n AnalyticsControllerEvents,\n AnalyticsControllerGetStateAction,\n AnalyticsControllerStateChangeEvent,\n controllerName,\n} from './AnalyticsController';\nexport type {\n AnalyticsControllerTrackEventAction,\n AnalyticsControllerIdentifyAction,\n AnalyticsControllerTrackPageAction,\n AnalyticsControllerEnableAction,\n AnalyticsControllerDisableAction,\n AnalyticsControllerOptInAction,\n AnalyticsControllerOptOutAction,\n AnalyticsControllerMethodActions,\n} from './AnalyticsController-method-action-types';\n"]}
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@metamask-previews/analytics-controller",
3
+ "version": "0.0.0-preview-b8454d32",
4
+ "description": "Common Analytics controller for event tracking",
5
+ "keywords": [
6
+ "MetaMask",
7
+ "Ethereum"
8
+ ],
9
+ "homepage": "https://github.com/MetaMask/core/tree/main/packages/analytics-controller#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/MetaMask/core/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/MetaMask/core.git"
16
+ },
17
+ "license": "MIT",
18
+ "sideEffects": false,
19
+ "exports": {
20
+ ".": {
21
+ "import": {
22
+ "types": "./dist/index.d.mts",
23
+ "default": "./dist/index.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./dist/index.d.cts",
27
+ "default": "./dist/index.cjs"
28
+ }
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "main": "./dist/index.cjs",
33
+ "types": "./dist/index.d.cts",
34
+ "files": [
35
+ "dist/"
36
+ ],
37
+ "scripts": {
38
+ "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
39
+ "build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
40
+ "build:docs": "typedoc",
41
+ "changelog:update": "../../scripts/update-changelog.sh @metamask/analytics-controller",
42
+ "changelog:validate": "../../scripts/validate-changelog.sh @metamask/analytics-controller",
43
+ "publish:preview": "yarn npm publish --tag preview",
44
+ "since-latest-release": "../../scripts/since-latest-release.sh",
45
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
46
+ "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
47
+ "test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
48
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
49
+ },
50
+ "dependencies": {
51
+ "@metamask/base-controller": "^9.0.0",
52
+ "@metamask/messenger": "^0.3.0",
53
+ "@metamask/utils": "^11.8.1",
54
+ "uuid": "^8.3.2"
55
+ },
56
+ "devDependencies": {
57
+ "@metamask/auto-changelog": "^3.4.4",
58
+ "@ts-bridge/cli": "^0.6.4",
59
+ "@types/jest": "^27.4.1",
60
+ "deepmerge": "^4.2.2",
61
+ "jest": "^27.5.1",
62
+ "ts-jest": "^27.1.4",
63
+ "typedoc": "^0.24.8",
64
+ "typedoc-plugin-missing-exports": "^2.0.0",
65
+ "typescript": "~5.2.2"
66
+ },
67
+ "engines": {
68
+ "node": "^18.18 || >=20"
69
+ },
70
+ "publishConfig": {
71
+ "access": "public",
72
+ "registry": "https://registry.npmjs.org/"
73
+ }
74
+ }