@metamask-previews/analytics-controller 0.0.0-preview-d21b3dc → 0.0.0-preview-a5935709

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 +208 -105
  2. package/dist/AnalyticsController-method-action-types.cjs.map +1 -1
  3. package/dist/AnalyticsController-method-action-types.d.cts +28 -26
  4. package/dist/AnalyticsController-method-action-types.d.cts.map +1 -1
  5. package/dist/AnalyticsController-method-action-types.d.mts +28 -26
  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 +110 -73
  9. package/dist/AnalyticsController.cjs.map +1 -1
  10. package/dist/AnalyticsController.d.cts +50 -32
  11. package/dist/AnalyticsController.d.cts.map +1 -1
  12. package/dist/AnalyticsController.d.mts +50 -32
  13. package/dist/AnalyticsController.d.mts.map +1 -1
  14. package/dist/AnalyticsController.mjs +109 -72
  15. package/dist/AnalyticsController.mjs.map +1 -1
  16. package/dist/AnalyticsPlatformAdapter.types.cjs.map +1 -1
  17. package/dist/AnalyticsPlatformAdapter.types.d.cts +63 -15
  18. package/dist/AnalyticsPlatformAdapter.types.d.cts.map +1 -1
  19. package/dist/AnalyticsPlatformAdapter.types.d.mts +63 -15
  20. package/dist/AnalyticsPlatformAdapter.types.d.mts.map +1 -1
  21. package/dist/AnalyticsPlatformAdapter.types.mjs.map +1 -1
  22. package/dist/AnalyticsPlatformAdapterSetupError.cjs +17 -0
  23. package/dist/AnalyticsPlatformAdapterSetupError.cjs.map +1 -0
  24. package/dist/AnalyticsPlatformAdapterSetupError.d.cts +8 -0
  25. package/dist/AnalyticsPlatformAdapterSetupError.d.cts.map +1 -0
  26. package/dist/AnalyticsPlatformAdapterSetupError.d.mts +8 -0
  27. package/dist/AnalyticsPlatformAdapterSetupError.d.mts.map +1 -0
  28. package/dist/AnalyticsPlatformAdapterSetupError.mjs +13 -0
  29. package/dist/AnalyticsPlatformAdapterSetupError.mjs.map +1 -0
  30. package/dist/analyticsControllerStateValidator.cjs +34 -0
  31. package/dist/analyticsControllerStateValidator.cjs.map +1 -0
  32. package/dist/analyticsControllerStateValidator.d.cts +16 -0
  33. package/dist/analyticsControllerStateValidator.d.cts.map +1 -0
  34. package/dist/analyticsControllerStateValidator.d.mts +16 -0
  35. package/dist/analyticsControllerStateValidator.d.mts.map +1 -0
  36. package/dist/analyticsControllerStateValidator.mjs +29 -0
  37. package/dist/analyticsControllerStateValidator.mjs.map +1 -0
  38. package/dist/index.cjs +9 -4
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +5 -4
  41. package/dist/index.d.cts.map +1 -1
  42. package/dist/index.d.mts +5 -4
  43. package/dist/index.d.mts.map +1 -1
  44. package/dist/index.mjs +6 -3
  45. package/dist/index.mjs.map +1 -1
  46. package/dist/selectors.cjs +43 -0
  47. package/dist/selectors.cjs.map +1 -0
  48. package/dist/selectors.d.cts +12 -0
  49. package/dist/selectors.d.cts.map +1 -0
  50. package/dist/selectors.d.mts +12 -0
  51. package/dist/selectors.d.mts.map +1 -0
  52. package/dist/selectors.mjs +40 -0
  53. package/dist/selectors.mjs.map +1 -0
  54. package/package.json +2 -3
@@ -3,37 +3,85 @@ import type { Json } from "@metamask/utils";
3
3
  * Analytics event properties
4
4
  */
5
5
  export type AnalyticsEventProperties = Record<string, Json>;
6
+ /**
7
+ * User traits/properties for analytics identification
8
+ */
9
+ export type AnalyticsUserTraits = Record<string, Json>;
10
+ /**
11
+ * Event properties structure with two distinct properties lists for regular and sensitive data.
12
+ * Similar to ITrackingEvent from legacy analytics but decoupled for platform agnosticism.
13
+ * Sensitivity is derived from the presence of sensitiveProperties (if sensitiveProperties has keys, the event is sensitive).
14
+ */
15
+ export type AnalyticsTrackingEvent = {
16
+ readonly name: string;
17
+ properties: AnalyticsEventProperties;
18
+ sensitiveProperties: AnalyticsEventProperties;
19
+ /**
20
+ * Legacy property handled by the mobile app.
21
+ * This property is ignored by the analytics controller and will be removed from the type in the future.
22
+ * The mobile app will use the future analytics privacy controller to handle this functionality.
23
+ */
24
+ saveDataRecording: boolean;
25
+ readonly hasProperties: boolean;
26
+ };
6
27
  /**
7
28
  * Platform adapter interface for analytics tracking
8
29
  * Implementations should handle platform-specific details (Segment SDK, etc.)
9
- *
10
- * @todo This type is work in progress and will be updated as we
11
- * integrate with the new analytics system on mobile.
12
- * We have this draft type to help us iterate on the implementation.
13
- * It will be updated with proper types as we create the mobile adapter
14
- * And the controller package will be released only when this is completed.
15
30
  */
16
31
  export type AnalyticsPlatformAdapter = {
17
32
  /**
18
- * Track an analytics event
33
+ * Track an analytics event.
34
+ *
35
+ * This is the same as trackEvent in the old analytics system
19
36
  *
20
37
  * @param eventName - The name of the event
21
- * @param properties - Event properties
38
+ * @param properties - Event properties. If not provided, the event has no properties.
39
+ * The privacy plugin should check for `isSensitive === true` to determine if an event contains sensitive data.
22
40
  */
23
- trackEvent(eventName: string, properties: AnalyticsEventProperties): void;
41
+ track(eventName: string, properties?: AnalyticsEventProperties): void;
24
42
  /**
25
- * Identify a user
43
+ * Identify a user with traits.
26
44
  *
27
45
  * @param userId - The user identifier (e.g., metametrics ID)
28
46
  * @param traits - User traits/properties
29
47
  */
30
- identify?(userId: string, traits?: AnalyticsEventProperties): void;
48
+ identify(userId: string, traits?: AnalyticsUserTraits): void;
31
49
  /**
32
- * Track a page view
50
+ * Track a UI unit (page or screen) view depending on the platform
51
+ *
52
+ * This method delegates to platform-specific Segment SDK methods:
53
+ * - Web adapters should call `analytics.page(name, properties)`
54
+ * - Mobile adapters should call `analytics.screen(name, properties)`
55
+ *
56
+ * @param name - The identifier/name of the page or screen being viewed (e.g., "home", "settings", "wallet")
57
+ * @param properties - Optional properties associated with the view
58
+ */
59
+ view(name: string, properties?: AnalyticsEventProperties): void;
60
+ /**
61
+ * Lifecycle hook called after the AnalyticsController is fully initialized.
62
+ *
63
+ * This hook allows platform-specific adapters to perform setup that requires
64
+ * access to the controller's state (e.g., analyticsId).
65
+ *
66
+ * The controller calls this method once after initialization, passing the
67
+ * analyticsId from controller state. The analyticsId is guaranteed to be set
68
+ * when this method is called - this is the definition of "completed" setup.
69
+ *
70
+ * @param analyticsId - The analytics ID from controller state. Always set (never empty).
71
+ * @throws {AnalyticsPlatformAdapterSetupError} May throw errors during setup (e.g., configuration errors, network failures).
72
+ * Errors thrown by this method are caught and logged by the controller, but do not prevent
73
+ * controller initialization from completing successfully.
33
74
  *
34
- * @param pageName - The name of the page
35
- * @param properties - Page properties
75
+ * @example
76
+ * ```typescript
77
+ * async onSetupCompleted(analyticsId: string): Promise<void> {
78
+ * // Add platform-specific plugins that require analyticsId
79
+ * client.add({
80
+ * plugin: new PrivacyPlugin(analyticsId),
81
+ * });
82
+ * }
83
+ * ```
36
84
  */
37
- trackPage?(pageName: string, properties?: AnalyticsEventProperties): void;
85
+ onSetupCompleted(analyticsId: string): Promise<void>;
38
86
  };
39
87
  //# sourceMappingURL=AnalyticsPlatformAdapter.types.d.mts.map
@@ -1 +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;;;;;;;;;GASG;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"}
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;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAEvD;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,wBAAwB,CAAC;IACrC,mBAAmB,EAAE,wBAAwB,CAAC;IAC9C;;;;OAIG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;;;;OAQG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAEtE;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAE7D;;;;;;;;;OASG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAEhE;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD,CAAC"}
@@ -1 +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 *\n * @todo This type is work in progress and will be updated as we\n * integrate with the new analytics system on mobile.\n * We have this draft type to help us iterate on the implementation.\n * It will be updated with proper types as we create the mobile adapter\n * And the controller package will be released only when this is completed.\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"]}
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 * User traits/properties for analytics identification\n */\nexport type AnalyticsUserTraits = Record<string, Json>;\n\n/**\n * Event properties structure with two distinct properties lists for regular and sensitive data.\n * Similar to ITrackingEvent from legacy analytics but decoupled for platform agnosticism.\n * Sensitivity is derived from the presence of sensitiveProperties (if sensitiveProperties has keys, the event is sensitive).\n */\nexport type AnalyticsTrackingEvent = {\n readonly name: string;\n properties: AnalyticsEventProperties;\n sensitiveProperties: AnalyticsEventProperties;\n /**\n * Legacy property handled by the mobile app.\n * This property is ignored by the analytics controller and will be removed from the type in the future.\n * The mobile app will use the future analytics privacy controller to handle this functionality.\n */\n saveDataRecording: boolean;\n readonly hasProperties: boolean;\n};\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 * This is the same as trackEvent in the old analytics system\n *\n * @param eventName - The name of the event\n * @param properties - Event properties. If not provided, the event has no properties.\n * The privacy plugin should check for `isSensitive === true` to determine if an event contains sensitive data.\n */\n track(eventName: string, properties?: AnalyticsEventProperties): void;\n\n /**\n * Identify a user with traits.\n *\n * @param userId - The user identifier (e.g., metametrics ID)\n * @param traits - User traits/properties\n */\n identify(userId: string, traits?: AnalyticsUserTraits): void;\n\n /**\n * Track a UI unit (page or screen) view depending on the platform\n *\n * This method delegates to platform-specific Segment SDK methods:\n * - Web adapters should call `analytics.page(name, properties)`\n * - Mobile adapters should call `analytics.screen(name, properties)`\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 view(name: string, properties?: AnalyticsEventProperties): void;\n\n /**\n * Lifecycle hook called after the AnalyticsController is fully initialized.\n *\n * This hook allows platform-specific adapters to perform setup that requires\n * access to the controller's state (e.g., analyticsId).\n *\n * The controller calls this method once after initialization, passing the\n * analyticsId from controller state. The analyticsId is guaranteed to be set\n * when this method is called - this is the definition of \"completed\" setup.\n *\n * @param analyticsId - The analytics ID from controller state. Always set (never empty).\n * @throws {AnalyticsPlatformAdapterSetupError} May throw errors during setup (e.g., configuration errors, network failures).\n * Errors thrown by this method are caught and logged by the controller, but do not prevent\n * controller initialization from completing successfully.\n *\n * @example\n * ```typescript\n * async onSetupCompleted(analyticsId: string): Promise<void> {\n * // Add platform-specific plugins that require analyticsId\n * client.add({\n * plugin: new PrivacyPlugin(analyticsId),\n * });\n * }\n * ```\n */\n onSetupCompleted(analyticsId: string): Promise<void>;\n};\n"]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnalyticsPlatformAdapterSetupError = void 0;
4
+ /**
5
+ * Error thrown when platform adapter setup fails during the onSetupCompleted lifecycle hook.
6
+ */
7
+ class AnalyticsPlatformAdapterSetupError extends Error {
8
+ constructor(message, cause) {
9
+ super(message);
10
+ this.name = this.constructor.name;
11
+ if (cause) {
12
+ this.cause = cause;
13
+ }
14
+ }
15
+ }
16
+ exports.AnalyticsPlatformAdapterSetupError = AnalyticsPlatformAdapterSetupError;
17
+ //# sourceMappingURL=AnalyticsPlatformAdapterSetupError.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsPlatformAdapterSetupError.cjs","sourceRoot":"","sources":["../src/AnalyticsPlatformAdapterSetupError.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,kCAAmC,SAAQ,KAAK;IAG3D,YAAY,OAAe,EAAE,KAAa;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAVD,gFAUC","sourcesContent":["/**\n * Error thrown when platform adapter setup fails during the onSetupCompleted lifecycle hook.\n */\nexport class AnalyticsPlatformAdapterSetupError extends Error {\n cause?: Error;\n\n constructor(message: string, cause?: Error) {\n super(message);\n this.name = this.constructor.name;\n if (cause) {\n this.cause = cause;\n }\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Error thrown when platform adapter setup fails during the onSetupCompleted lifecycle hook.
3
+ */
4
+ export declare class AnalyticsPlatformAdapterSetupError extends Error {
5
+ cause?: Error;
6
+ constructor(message: string, cause?: Error);
7
+ }
8
+ //# sourceMappingURL=AnalyticsPlatformAdapterSetupError.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsPlatformAdapterSetupError.d.cts","sourceRoot":"","sources":["../src/AnalyticsPlatformAdapterSetupError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,KAAK;IAC3D,KAAK,CAAC,EAAE,KAAK,CAAC;gBAEF,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAO3C"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Error thrown when platform adapter setup fails during the onSetupCompleted lifecycle hook.
3
+ */
4
+ export declare class AnalyticsPlatformAdapterSetupError extends Error {
5
+ cause?: Error;
6
+ constructor(message: string, cause?: Error);
7
+ }
8
+ //# sourceMappingURL=AnalyticsPlatformAdapterSetupError.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsPlatformAdapterSetupError.d.mts","sourceRoot":"","sources":["../src/AnalyticsPlatformAdapterSetupError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,KAAK;IAC3D,KAAK,CAAC,EAAE,KAAK,CAAC;gBAEF,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAO3C"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Error thrown when platform adapter setup fails during the onSetupCompleted lifecycle hook.
3
+ */
4
+ export class AnalyticsPlatformAdapterSetupError extends Error {
5
+ constructor(message, cause) {
6
+ super(message);
7
+ this.name = this.constructor.name;
8
+ if (cause) {
9
+ this.cause = cause;
10
+ }
11
+ }
12
+ }
13
+ //# sourceMappingURL=AnalyticsPlatformAdapterSetupError.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsPlatformAdapterSetupError.mjs","sourceRoot":"","sources":["../src/AnalyticsPlatformAdapterSetupError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,kCAAmC,SAAQ,KAAK;IAG3D,YAAY,OAAe,EAAE,KAAa;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * Error thrown when platform adapter setup fails during the onSetupCompleted lifecycle hook.\n */\nexport class AnalyticsPlatformAdapterSetupError extends Error {\n cause?: Error;\n\n constructor(message: string, cause?: Error) {\n super(message);\n this.name = this.constructor.name;\n if (cause) {\n this.cause = cause;\n }\n }\n}\n"]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateAnalyticsControllerState = exports.isValidUUIDv4 = void 0;
4
+ /**
5
+ * UUIDv4 format regex pattern.
6
+ * Format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
7
+ * - x is any hexadecimal digit [0-9a-f]
8
+ * - 4 indicates UUID version 4
9
+ * - y is the variant indicator [89ab]
10
+ */
11
+ const UUID_V4_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
12
+ /**
13
+ * Validates that a string is a valid UUIDv4 format.
14
+ *
15
+ * @param value - The string to validate
16
+ * @returns True if the string matches UUIDv4 format
17
+ */
18
+ function isValidUUIDv4(value) {
19
+ return typeof value === 'string' && UUID_V4_REGEX.test(value);
20
+ }
21
+ exports.isValidUUIDv4 = isValidUUIDv4;
22
+ /**
23
+ * Validates that the analytics state has a valid UUIDv4 analyticsId.
24
+ *
25
+ * @param state - The analytics controller state to validate
26
+ * @throws Error if analyticsId is missing or not a valid UUIDv4
27
+ */
28
+ function validateAnalyticsControllerState(state) {
29
+ if (!state.analyticsId || !isValidUUIDv4(state.analyticsId)) {
30
+ throw new Error(`Invalid analyticsId: expected a valid UUIDv4, but got ${JSON.stringify(state.analyticsId)}`);
31
+ }
32
+ }
33
+ exports.validateAnalyticsControllerState = validateAnalyticsControllerState;
34
+ //# sourceMappingURL=analyticsControllerStateValidator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsControllerStateValidator.cjs","sourceRoot":"","sources":["../src/analyticsControllerStateValidator.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,MAAM,aAAa,GACjB,yEAAyE,CAAC;AAE5E;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,KAAa;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAFD,sCAEC;AAED;;;;;GAKG;AACH,SAAgB,gCAAgC,CAC9C,KAA+B;IAE/B,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CACb,yDAAyD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAC7F,CAAC;IACJ,CAAC;AACH,CAAC;AARD,4EAQC","sourcesContent":["import type { AnalyticsControllerState } from './AnalyticsController';\n\n/**\n * UUIDv4 format regex pattern.\n * Format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\n * - x is any hexadecimal digit [0-9a-f]\n * - 4 indicates UUID version 4\n * - y is the variant indicator [89ab]\n */\nconst UUID_V4_REGEX =\n /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;\n\n/**\n * Validates that a string is a valid UUIDv4 format.\n *\n * @param value - The string to validate\n * @returns True if the string matches UUIDv4 format\n */\nexport function isValidUUIDv4(value: string): boolean {\n return typeof value === 'string' && UUID_V4_REGEX.test(value);\n}\n\n/**\n * Validates that the analytics state has a valid UUIDv4 analyticsId.\n *\n * @param state - The analytics controller state to validate\n * @throws Error if analyticsId is missing or not a valid UUIDv4\n */\nexport function validateAnalyticsControllerState(\n state: AnalyticsControllerState,\n): void {\n if (!state.analyticsId || !isValidUUIDv4(state.analyticsId)) {\n throw new Error(\n `Invalid analyticsId: expected a valid UUIDv4, but got ${JSON.stringify(state.analyticsId)}`,\n );\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import type { AnalyticsControllerState } from "./AnalyticsController.cjs";
2
+ /**
3
+ * Validates that a string is a valid UUIDv4 format.
4
+ *
5
+ * @param value - The string to validate
6
+ * @returns True if the string matches UUIDv4 format
7
+ */
8
+ export declare function isValidUUIDv4(value: string): boolean;
9
+ /**
10
+ * Validates that the analytics state has a valid UUIDv4 analyticsId.
11
+ *
12
+ * @param state - The analytics controller state to validate
13
+ * @throws Error if analyticsId is missing or not a valid UUIDv4
14
+ */
15
+ export declare function validateAnalyticsControllerState(state: AnalyticsControllerState): void;
16
+ //# sourceMappingURL=analyticsControllerStateValidator.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsControllerStateValidator.d.cts","sourceRoot":"","sources":["../src/analyticsControllerStateValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAA8B;AAYtE;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,wBAAwB,GAC9B,IAAI,CAMN"}
@@ -0,0 +1,16 @@
1
+ import type { AnalyticsControllerState } from "./AnalyticsController.mjs";
2
+ /**
3
+ * Validates that a string is a valid UUIDv4 format.
4
+ *
5
+ * @param value - The string to validate
6
+ * @returns True if the string matches UUIDv4 format
7
+ */
8
+ export declare function isValidUUIDv4(value: string): boolean;
9
+ /**
10
+ * Validates that the analytics state has a valid UUIDv4 analyticsId.
11
+ *
12
+ * @param state - The analytics controller state to validate
13
+ * @throws Error if analyticsId is missing or not a valid UUIDv4
14
+ */
15
+ export declare function validateAnalyticsControllerState(state: AnalyticsControllerState): void;
16
+ //# sourceMappingURL=analyticsControllerStateValidator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsControllerStateValidator.d.mts","sourceRoot":"","sources":["../src/analyticsControllerStateValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAA8B;AAYtE;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,wBAAwB,GAC9B,IAAI,CAMN"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * UUIDv4 format regex pattern.
3
+ * Format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
4
+ * - x is any hexadecimal digit [0-9a-f]
5
+ * - 4 indicates UUID version 4
6
+ * - y is the variant indicator [89ab]
7
+ */
8
+ const UUID_V4_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
9
+ /**
10
+ * Validates that a string is a valid UUIDv4 format.
11
+ *
12
+ * @param value - The string to validate
13
+ * @returns True if the string matches UUIDv4 format
14
+ */
15
+ export function isValidUUIDv4(value) {
16
+ return typeof value === 'string' && UUID_V4_REGEX.test(value);
17
+ }
18
+ /**
19
+ * Validates that the analytics state has a valid UUIDv4 analyticsId.
20
+ *
21
+ * @param state - The analytics controller state to validate
22
+ * @throws Error if analyticsId is missing or not a valid UUIDv4
23
+ */
24
+ export function validateAnalyticsControllerState(state) {
25
+ if (!state.analyticsId || !isValidUUIDv4(state.analyticsId)) {
26
+ throw new Error(`Invalid analyticsId: expected a valid UUIDv4, but got ${JSON.stringify(state.analyticsId)}`);
27
+ }
28
+ }
29
+ //# sourceMappingURL=analyticsControllerStateValidator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsControllerStateValidator.mjs","sourceRoot":"","sources":["../src/analyticsControllerStateValidator.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,aAAa,GACjB,yEAAyE,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAC9C,KAA+B;IAE/B,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CACb,yDAAyD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAC7F,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { AnalyticsControllerState } from './AnalyticsController';\n\n/**\n * UUIDv4 format regex pattern.\n * Format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\n * - x is any hexadecimal digit [0-9a-f]\n * - 4 indicates UUID version 4\n * - y is the variant indicator [89ab]\n */\nconst UUID_V4_REGEX =\n /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;\n\n/**\n * Validates that a string is a valid UUIDv4 format.\n *\n * @param value - The string to validate\n * @returns True if the string matches UUIDv4 format\n */\nexport function isValidUUIDv4(value: string): boolean {\n return typeof value === 'string' && UUID_V4_REGEX.test(value);\n}\n\n/**\n * Validates that the analytics state has a valid UUIDv4 analyticsId.\n *\n * @param state - The analytics controller state to validate\n * @throws Error if analyticsId is missing or not a valid UUIDv4\n */\nexport function validateAnalyticsControllerState(\n state: AnalyticsControllerState,\n): void {\n if (!state.analyticsId || !isValidUUIDv4(state.analyticsId)) {\n throw new Error(\n `Invalid analyticsId: expected a valid UUIDv4, but got ${JSON.stringify(state.analyticsId)}`,\n );\n }\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultAnalyticsControllerState = exports.AnalyticsController = void 0;
4
- // Export controller class
3
+ exports.analyticsControllerSelectors = exports.AnalyticsPlatformAdapterSetupError = exports.getDefaultAnalyticsControllerState = exports.AnalyticsController = void 0;
4
+ // Export controller class and state utilities
5
5
  var AnalyticsController_1 = require("./AnalyticsController.cjs");
6
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; } });
7
+ Object.defineProperty(exports, "getDefaultAnalyticsControllerState", { enumerable: true, get: function () { return AnalyticsController_1.getDefaultAnalyticsControllerState; } });
8
+ // Export errors
9
+ var AnalyticsPlatformAdapterSetupError_1 = require("./AnalyticsPlatformAdapterSetupError.cjs");
10
+ Object.defineProperty(exports, "AnalyticsPlatformAdapterSetupError", { enumerable: true, get: function () { return AnalyticsPlatformAdapterSetupError_1.AnalyticsPlatformAdapterSetupError; } });
11
+ // Export selectors
12
+ var selectors_1 = require("./selectors.cjs");
13
+ Object.defineProperty(exports, "analyticsControllerSelectors", { enumerable: true, get: function () { return selectors_1.analyticsControllerSelectors; } });
9
14
  //# sourceMappingURL=index.cjs.map
@@ -1 +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"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,8CAA8C;AAC9C,iEAG+B;AAF7B,0HAAA,mBAAmB,OAAA;AACnB,yIAAA,kCAAkC,OAAA;AAIpC,gBAAgB;AAChB,+FAA0F;AAAjF,wJAAA,kCAAkC,OAAA;AAa3C,mBAAmB;AACnB,6CAA2D;AAAlD,yHAAA,4BAA4B,OAAA","sourcesContent":["// Export controller class and state utilities\nexport {\n AnalyticsController,\n getDefaultAnalyticsControllerState,\n} from './AnalyticsController';\nexport type { AnalyticsControllerOptions } from './AnalyticsController';\n\n// Export errors\nexport { AnalyticsPlatformAdapterSetupError } from './AnalyticsPlatformAdapterSetupError';\n\n// Export types\nexport type {\n AnalyticsEventProperties,\n AnalyticsUserTraits,\n AnalyticsPlatformAdapter,\n AnalyticsTrackingEvent,\n} from './AnalyticsPlatformAdapter.types';\n\n// Export state types\nexport type { AnalyticsControllerState } from './AnalyticsController';\n\n// Export selectors\nexport { analyticsControllerSelectors } from './selectors';\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 AnalyticsControllerTrackViewAction,\n AnalyticsControllerOptInForRegularAccountAction,\n AnalyticsControllerOptOutForRegularAccountAction,\n AnalyticsControllerOptInForSocialAccountAction,\n AnalyticsControllerOptOutForSocialAccountAction,\n AnalyticsControllerMethodActions,\n} from './AnalyticsController-method-action-types';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,9 +1,10 @@
1
- export { AnalyticsController } from "./AnalyticsController.cjs";
1
+ export { AnalyticsController, getDefaultAnalyticsControllerState, } from "./AnalyticsController.cjs";
2
2
  export type { AnalyticsControllerOptions } from "./AnalyticsController.cjs";
3
- export type { AnalyticsEventProperties, AnalyticsPlatformAdapter, } from "./AnalyticsPlatformAdapter.types.cjs";
3
+ export { AnalyticsPlatformAdapterSetupError } from "./AnalyticsPlatformAdapterSetupError.cjs";
4
+ export type { AnalyticsEventProperties, AnalyticsUserTraits, AnalyticsPlatformAdapter, AnalyticsTrackingEvent, } from "./AnalyticsPlatformAdapter.types.cjs";
4
5
  export type { AnalyticsControllerState } from "./AnalyticsController.cjs";
5
- export { getDefaultAnalyticsControllerState } from "./AnalyticsController.cjs";
6
+ export { analyticsControllerSelectors } from "./selectors.cjs";
6
7
  export type { AnalyticsControllerMessenger } from "./AnalyticsController.cjs";
7
8
  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
+ export type { AnalyticsControllerTrackEventAction, AnalyticsControllerIdentifyAction, AnalyticsControllerTrackViewAction, AnalyticsControllerOptInForRegularAccountAction, AnalyticsControllerOptOutForRegularAccountAction, AnalyticsControllerOptInForSocialAccountAction, AnalyticsControllerOptOutForSocialAccountAction, AnalyticsControllerMethodActions, } from "./AnalyticsController-method-action-types.cjs";
9
10
  //# sourceMappingURL=index.d.cts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,kCAAkC,GACnC,kCAA8B;AAC/B,YAAY,EAAE,0BAA0B,EAAE,kCAA8B;AAGxE,OAAO,EAAE,kCAAkC,EAAE,iDAA6C;AAG1F,YAAY,EACV,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,GACvB,6CAAyC;AAG1C,YAAY,EAAE,wBAAwB,EAAE,kCAA8B;AAGtE,OAAO,EAAE,4BAA4B,EAAE,wBAAoB;AAG3D,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,+CAA+C,EAC/C,gDAAgD,EAChD,8CAA8C,EAC9C,+CAA+C,EAC/C,gCAAgC,GACjC,sDAAkD"}
package/dist/index.d.mts CHANGED
@@ -1,9 +1,10 @@
1
- export { AnalyticsController } from "./AnalyticsController.mjs";
1
+ export { AnalyticsController, getDefaultAnalyticsControllerState, } from "./AnalyticsController.mjs";
2
2
  export type { AnalyticsControllerOptions } from "./AnalyticsController.mjs";
3
- export type { AnalyticsEventProperties, AnalyticsPlatformAdapter, } from "./AnalyticsPlatformAdapter.types.mjs";
3
+ export { AnalyticsPlatformAdapterSetupError } from "./AnalyticsPlatformAdapterSetupError.mjs";
4
+ export type { AnalyticsEventProperties, AnalyticsUserTraits, AnalyticsPlatformAdapter, AnalyticsTrackingEvent, } from "./AnalyticsPlatformAdapter.types.mjs";
4
5
  export type { AnalyticsControllerState } from "./AnalyticsController.mjs";
5
- export { getDefaultAnalyticsControllerState } from "./AnalyticsController.mjs";
6
+ export { analyticsControllerSelectors } from "./selectors.mjs";
6
7
  export type { AnalyticsControllerMessenger } from "./AnalyticsController.mjs";
7
8
  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
+ export type { AnalyticsControllerTrackEventAction, AnalyticsControllerIdentifyAction, AnalyticsControllerTrackViewAction, AnalyticsControllerOptInForRegularAccountAction, AnalyticsControllerOptOutForRegularAccountAction, AnalyticsControllerOptInForSocialAccountAction, AnalyticsControllerOptOutForSocialAccountAction, AnalyticsControllerMethodActions, } from "./AnalyticsController-method-action-types.mjs";
9
10
  //# sourceMappingURL=index.d.mts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,kCAAkC,GACnC,kCAA8B;AAC/B,YAAY,EAAE,0BAA0B,EAAE,kCAA8B;AAGxE,OAAO,EAAE,kCAAkC,EAAE,iDAA6C;AAG1F,YAAY,EACV,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,GACvB,6CAAyC;AAG1C,YAAY,EAAE,wBAAwB,EAAE,kCAA8B;AAGtE,OAAO,EAAE,4BAA4B,EAAE,wBAAoB;AAG3D,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,+CAA+C,EAC/C,gDAAgD,EAChD,8CAA8C,EAC9C,+CAA+C,EAC/C,gCAAgC,GACjC,sDAAkD"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,7 @@
1
- // Export controller class
2
- export { AnalyticsController } from "./AnalyticsController.mjs";
3
- export { getDefaultAnalyticsControllerState } from "./AnalyticsController.mjs";
1
+ // Export controller class and state utilities
2
+ export { AnalyticsController, getDefaultAnalyticsControllerState } from "./AnalyticsController.mjs";
3
+ // Export errors
4
+ export { AnalyticsPlatformAdapterSetupError } from "./AnalyticsPlatformAdapterSetupError.mjs";
5
+ // Export selectors
6
+ export { analyticsControllerSelectors } from "./selectors.mjs";
4
7
  //# sourceMappingURL=index.mjs.map
@@ -1 +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"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,OAAO,EACL,mBAAmB,EACnB,kCAAkC,EACnC,kCAA8B;AAG/B,gBAAgB;AAChB,OAAO,EAAE,kCAAkC,EAAE,iDAA6C;AAa1F,mBAAmB;AACnB,OAAO,EAAE,4BAA4B,EAAE,wBAAoB","sourcesContent":["// Export controller class and state utilities\nexport {\n AnalyticsController,\n getDefaultAnalyticsControllerState,\n} from './AnalyticsController';\nexport type { AnalyticsControllerOptions } from './AnalyticsController';\n\n// Export errors\nexport { AnalyticsPlatformAdapterSetupError } from './AnalyticsPlatformAdapterSetupError';\n\n// Export types\nexport type {\n AnalyticsEventProperties,\n AnalyticsUserTraits,\n AnalyticsPlatformAdapter,\n AnalyticsTrackingEvent,\n} from './AnalyticsPlatformAdapter.types';\n\n// Export state types\nexport type { AnalyticsControllerState } from './AnalyticsController';\n\n// Export selectors\nexport { analyticsControllerSelectors } from './selectors';\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 AnalyticsControllerTrackViewAction,\n AnalyticsControllerOptInForRegularAccountAction,\n AnalyticsControllerOptOutForRegularAccountAction,\n AnalyticsControllerOptInForSocialAccountAction,\n AnalyticsControllerOptOutForSocialAccountAction,\n AnalyticsControllerMethodActions,\n} from './AnalyticsController-method-action-types';\n"]}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.analyticsControllerSelectors = void 0;
4
+ /**
5
+ * Selects the analytics ID from the controller state.
6
+ *
7
+ * @param state - The controller state
8
+ * @returns The analytics ID
9
+ */
10
+ const selectAnalyticsId = (state) => state.analyticsId;
11
+ /**
12
+ * Selects the opted-in status for regular account from the controller state.
13
+ *
14
+ * @param state - The controller state
15
+ * @returns Whether the user has opted in for regular account
16
+ */
17
+ const selectOptedInForRegularAccount = (state) => state.optedInForRegularAccount;
18
+ /**
19
+ * Selects the opted-in status for social account from the controller state.
20
+ *
21
+ * @param state - The controller state
22
+ * @returns Whether the user has opted in for social account
23
+ */
24
+ const selectOptedInForSocialAccount = (state) => state.optedInForSocialAccount;
25
+ /**
26
+ * Selects the enabled status from the controller state.
27
+ * Analytics is enabled if the user has opted in for regular account OR social account.
28
+ *
29
+ * @param state - The controller state
30
+ * @returns Whether analytics tracking is enabled
31
+ */
32
+ const selectEnabled = (state) => state.optedInForRegularAccount || state.optedInForSocialAccount;
33
+ /**
34
+ * Selectors for the AnalyticsController state.
35
+ * These can be used with Redux or directly with controller state.
36
+ */
37
+ exports.analyticsControllerSelectors = {
38
+ selectAnalyticsId,
39
+ selectOptedInForRegularAccount,
40
+ selectOptedInForSocialAccount,
41
+ selectEnabled,
42
+ };
43
+ //# sourceMappingURL=selectors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.cjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,CAAC,KAA+B,EAAU,EAAE,CACpE,KAAK,CAAC,WAAW,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,8BAA8B,GAAG,CACrC,KAA+B,EACtB,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,6BAA6B,GAAG,CACpC,KAA+B,EACtB,EAAE,CAAC,KAAK,CAAC,uBAAuB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,CAAC,KAA+B,EAAW,EAAE,CACjE,KAAK,CAAC,wBAAwB,IAAI,KAAK,CAAC,uBAAuB,CAAC;AAElE;;;GAGG;AACU,QAAA,4BAA4B,GAAG;IAC1C,iBAAiB;IACjB,8BAA8B;IAC9B,6BAA6B;IAC7B,aAAa;CACd,CAAC","sourcesContent":["import type { AnalyticsControllerState } from './AnalyticsController';\n\n/**\n * Selects the analytics ID from the controller state.\n *\n * @param state - The controller state\n * @returns The analytics ID\n */\nconst selectAnalyticsId = (state: AnalyticsControllerState): string =>\n state.analyticsId;\n\n/**\n * Selects the opted-in status for regular account from the controller state.\n *\n * @param state - The controller state\n * @returns Whether the user has opted in for regular account\n */\nconst selectOptedInForRegularAccount = (\n state: AnalyticsControllerState,\n): boolean => state.optedInForRegularAccount;\n\n/**\n * Selects the opted-in status for social account from the controller state.\n *\n * @param state - The controller state\n * @returns Whether the user has opted in for social account\n */\nconst selectOptedInForSocialAccount = (\n state: AnalyticsControllerState,\n): boolean => state.optedInForSocialAccount;\n\n/**\n * Selects the enabled status from the controller state.\n * Analytics is enabled if the user has opted in for regular account OR social account.\n *\n * @param state - The controller state\n * @returns Whether analytics tracking is enabled\n */\nconst selectEnabled = (state: AnalyticsControllerState): boolean =>\n state.optedInForRegularAccount || state.optedInForSocialAccount;\n\n/**\n * Selectors for the AnalyticsController state.\n * These can be used with Redux or directly with controller state.\n */\nexport const analyticsControllerSelectors = {\n selectAnalyticsId,\n selectOptedInForRegularAccount,\n selectOptedInForSocialAccount,\n selectEnabled,\n};\n"]}
@@ -0,0 +1,12 @@
1
+ import type { AnalyticsControllerState } from "./AnalyticsController.cjs";
2
+ /**
3
+ * Selectors for the AnalyticsController state.
4
+ * These can be used with Redux or directly with controller state.
5
+ */
6
+ export declare const analyticsControllerSelectors: {
7
+ selectAnalyticsId: (state: AnalyticsControllerState) => string;
8
+ selectOptedInForRegularAccount: (state: AnalyticsControllerState) => boolean;
9
+ selectOptedInForSocialAccount: (state: AnalyticsControllerState) => boolean;
10
+ selectEnabled: (state: AnalyticsControllerState) => boolean;
11
+ };
12
+ //# sourceMappingURL=selectors.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.d.cts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAA8B;AAyCtE;;;GAGG;AACH,eAAO,MAAM,4BAA4B;+BArCP,wBAAwB,KAAG,MAAM;4CAU1D,wBAAwB,KAC9B,OAAO;2CASD,wBAAwB,KAC9B,OAAO;2BASoB,wBAAwB,KAAG,OAAO;CAY/D,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { AnalyticsControllerState } from "./AnalyticsController.mjs";
2
+ /**
3
+ * Selectors for the AnalyticsController state.
4
+ * These can be used with Redux or directly with controller state.
5
+ */
6
+ export declare const analyticsControllerSelectors: {
7
+ selectAnalyticsId: (state: AnalyticsControllerState) => string;
8
+ selectOptedInForRegularAccount: (state: AnalyticsControllerState) => boolean;
9
+ selectOptedInForSocialAccount: (state: AnalyticsControllerState) => boolean;
10
+ selectEnabled: (state: AnalyticsControllerState) => boolean;
11
+ };
12
+ //# sourceMappingURL=selectors.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.d.mts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAA8B;AAyCtE;;;GAGG;AACH,eAAO,MAAM,4BAA4B;+BArCP,wBAAwB,KAAG,MAAM;4CAU1D,wBAAwB,KAC9B,OAAO;2CASD,wBAAwB,KAC9B,OAAO;2BASoB,wBAAwB,KAAG,OAAO;CAY/D,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Selects the analytics ID from the controller state.
3
+ *
4
+ * @param state - The controller state
5
+ * @returns The analytics ID
6
+ */
7
+ const selectAnalyticsId = (state) => state.analyticsId;
8
+ /**
9
+ * Selects the opted-in status for regular account from the controller state.
10
+ *
11
+ * @param state - The controller state
12
+ * @returns Whether the user has opted in for regular account
13
+ */
14
+ const selectOptedInForRegularAccount = (state) => state.optedInForRegularAccount;
15
+ /**
16
+ * Selects the opted-in status for social account from the controller state.
17
+ *
18
+ * @param state - The controller state
19
+ * @returns Whether the user has opted in for social account
20
+ */
21
+ const selectOptedInForSocialAccount = (state) => state.optedInForSocialAccount;
22
+ /**
23
+ * Selects the enabled status from the controller state.
24
+ * Analytics is enabled if the user has opted in for regular account OR social account.
25
+ *
26
+ * @param state - The controller state
27
+ * @returns Whether analytics tracking is enabled
28
+ */
29
+ const selectEnabled = (state) => state.optedInForRegularAccount || state.optedInForSocialAccount;
30
+ /**
31
+ * Selectors for the AnalyticsController state.
32
+ * These can be used with Redux or directly with controller state.
33
+ */
34
+ export const analyticsControllerSelectors = {
35
+ selectAnalyticsId,
36
+ selectOptedInForRegularAccount,
37
+ selectOptedInForSocialAccount,
38
+ selectEnabled,
39
+ };
40
+ //# sourceMappingURL=selectors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.mjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,CAAC,KAA+B,EAAU,EAAE,CACpE,KAAK,CAAC,WAAW,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,8BAA8B,GAAG,CACrC,KAA+B,EACtB,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,6BAA6B,GAAG,CACpC,KAA+B,EACtB,EAAE,CAAC,KAAK,CAAC,uBAAuB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,CAAC,KAA+B,EAAW,EAAE,CACjE,KAAK,CAAC,wBAAwB,IAAI,KAAK,CAAC,uBAAuB,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,iBAAiB;IACjB,8BAA8B;IAC9B,6BAA6B;IAC7B,aAAa;CACd,CAAC","sourcesContent":["import type { AnalyticsControllerState } from './AnalyticsController';\n\n/**\n * Selects the analytics ID from the controller state.\n *\n * @param state - The controller state\n * @returns The analytics ID\n */\nconst selectAnalyticsId = (state: AnalyticsControllerState): string =>\n state.analyticsId;\n\n/**\n * Selects the opted-in status for regular account from the controller state.\n *\n * @param state - The controller state\n * @returns Whether the user has opted in for regular account\n */\nconst selectOptedInForRegularAccount = (\n state: AnalyticsControllerState,\n): boolean => state.optedInForRegularAccount;\n\n/**\n * Selects the opted-in status for social account from the controller state.\n *\n * @param state - The controller state\n * @returns Whether the user has opted in for social account\n */\nconst selectOptedInForSocialAccount = (\n state: AnalyticsControllerState,\n): boolean => state.optedInForSocialAccount;\n\n/**\n * Selects the enabled status from the controller state.\n * Analytics is enabled if the user has opted in for regular account OR social account.\n *\n * @param state - The controller state\n * @returns Whether analytics tracking is enabled\n */\nconst selectEnabled = (state: AnalyticsControllerState): boolean =>\n state.optedInForRegularAccount || state.optedInForSocialAccount;\n\n/**\n * Selectors for the AnalyticsController state.\n * These can be used with Redux or directly with controller state.\n */\nexport const analyticsControllerSelectors = {\n selectAnalyticsId,\n selectOptedInForRegularAccount,\n selectOptedInForSocialAccount,\n selectEnabled,\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/analytics-controller",
3
- "version": "0.0.0-preview-d21b3dc",
3
+ "version": "0.0.0-preview-a5935709",
4
4
  "description": "Common Analytics controller for event tracking",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -50,8 +50,7 @@
50
50
  "dependencies": {
51
51
  "@metamask/base-controller": "^9.0.0",
52
52
  "@metamask/messenger": "^0.3.0",
53
- "@metamask/utils": "^11.8.1",
54
- "uuid": "^8.3.2"
53
+ "@metamask/utils": "^11.8.1"
55
54
  },
56
55
  "devDependencies": {
57
56
  "@metamask/auto-changelog": "^3.4.4",