@metamask-previews/analytics-controller 0.0.0-preview-152da47f → 0.0.0-preview-21a5ddac

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 (62) hide show
  1. package/README.md +72 -11
  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 +81 -52
  9. package/dist/AnalyticsController.cjs.map +1 -1
  10. package/dist/AnalyticsController.d.cts +27 -24
  11. package/dist/AnalyticsController.d.cts.map +1 -1
  12. package/dist/AnalyticsController.d.mts +27 -24
  13. package/dist/AnalyticsController.d.mts.map +1 -1
  14. package/dist/AnalyticsController.mjs +81 -52
  15. package/dist/AnalyticsController.mjs.map +1 -1
  16. package/dist/AnalyticsPlatformAdapter.types.cjs.map +1 -1
  17. package/dist/AnalyticsPlatformAdapter.types.d.cts +58 -15
  18. package/dist/AnalyticsPlatformAdapter.types.d.cts.map +1 -1
  19. package/dist/AnalyticsPlatformAdapter.types.d.mts +58 -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/analyticsStateComputer.cjs +46 -0
  31. package/dist/analyticsStateComputer.cjs.map +1 -0
  32. package/dist/analyticsStateComputer.d.cts +35 -0
  33. package/dist/analyticsStateComputer.d.cts.map +1 -0
  34. package/dist/analyticsStateComputer.d.mts +35 -0
  35. package/dist/analyticsStateComputer.d.mts.map +1 -0
  36. package/dist/analyticsStateComputer.mjs +42 -0
  37. package/dist/analyticsStateComputer.mjs.map +1 -0
  38. package/dist/analyticsStateValidator.cjs +19 -0
  39. package/dist/analyticsStateValidator.cjs.map +1 -0
  40. package/dist/analyticsStateValidator.d.cts +9 -0
  41. package/dist/analyticsStateValidator.d.cts.map +1 -0
  42. package/dist/analyticsStateValidator.d.mts +9 -0
  43. package/dist/analyticsStateValidator.d.mts.map +1 -0
  44. package/dist/analyticsStateValidator.mjs +15 -0
  45. package/dist/analyticsStateValidator.mjs.map +1 -0
  46. package/dist/index.cjs +7 -1
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +4 -2
  49. package/dist/index.d.cts.map +1 -1
  50. package/dist/index.d.mts +4 -2
  51. package/dist/index.d.mts.map +1 -1
  52. package/dist/index.mjs +4 -0
  53. package/dist/index.mjs.map +1 -1
  54. package/dist/selectors.cjs +44 -0
  55. package/dist/selectors.cjs.map +1 -0
  56. package/dist/selectors.d.cts +12 -0
  57. package/dist/selectors.d.cts.map +1 -0
  58. package/dist/selectors.d.mts +12 -0
  59. package/dist/selectors.d.mts.map +1 -0
  60. package/dist/selectors.mjs +41 -0
  61. package/dist/selectors.mjs.map +1 -0
  62. package/package.json +1 -1
@@ -3,37 +3,80 @@ 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
+ saveDataRecording: boolean;
20
+ readonly hasProperties: boolean;
21
+ };
6
22
  /**
7
23
  * Platform adapter interface for analytics tracking
8
24
  * 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
25
  */
16
26
  export type AnalyticsPlatformAdapter = {
17
27
  /**
18
- * Track an analytics event
28
+ * Track an analytics event.
29
+ *
30
+ * This is the same as trackEvent in the old analytics system
19
31
  *
20
32
  * @param eventName - The name of the event
21
- * @param properties - Event properties
33
+ * @param properties - Event properties. If not provided, the event has no properties.
34
+ * The privacy plugin should check for `isSensitive === true` to determine if an event contains sensitive data.
22
35
  */
23
- trackEvent(eventName: string, properties: AnalyticsEventProperties): void;
36
+ track(eventName: string, properties?: AnalyticsEventProperties): void;
24
37
  /**
25
- * Identify a user
38
+ * Identify a user with traits.
26
39
  *
27
40
  * @param userId - The user identifier (e.g., metametrics ID)
28
41
  * @param traits - User traits/properties
29
42
  */
30
- identify?(userId: string, traits?: AnalyticsEventProperties): void;
43
+ identify(userId: string, traits?: AnalyticsUserTraits): void;
31
44
  /**
32
- * Track a page view
45
+ * Track a UI unit (page or screen) view depending on the platform
46
+ *
47
+ * This method delegates to platform-specific Segment SDK methods:
48
+ * - Web adapters should call `analytics.page(name, properties)`
49
+ * - Mobile adapters should call `analytics.screen(name, properties)`
50
+ *
51
+ * @param name - The identifier/name of the page or screen being viewed (e.g., "home", "settings", "wallet")
52
+ * @param properties - Optional properties associated with the view
53
+ */
54
+ view(name: string, properties?: AnalyticsEventProperties): void;
55
+ /**
56
+ * Lifecycle hook called after the AnalyticsController is fully initialized.
57
+ *
58
+ * This hook allows platform-specific adapters to perform setup that requires
59
+ * access to the controller's state (e.g., analyticsId).
60
+ *
61
+ * The controller calls this method once after initialization, passing the
62
+ * analyticsId from controller state. The analyticsId is guaranteed to be set
63
+ * when this method is called - this is the definition of "completed" setup.
64
+ *
65
+ * @param analyticsId - The analytics ID from controller state. Always set (never empty).
66
+ * @throws {AnalyticsPlatformAdapterSetupError} May throw errors during setup (e.g., configuration errors, network failures).
67
+ * Errors thrown by this method are caught and logged by the controller, but do not prevent
68
+ * controller initialization from completing successfully.
33
69
  *
34
- * @param pageName - The name of the page
35
- * @param properties - Page properties
70
+ * @example
71
+ * ```typescript
72
+ * onSetupCompleted(analyticsId: string): void {
73
+ * // Add platform-specific plugins that require analyticsId
74
+ * client.add({
75
+ * plugin: new PrivacyPlugin(analyticsId),
76
+ * });
77
+ * }
78
+ * ```
36
79
  */
37
- trackPage?(pageName: string, properties?: AnalyticsEventProperties): void;
80
+ onSetupCompleted(analyticsId: string): void;
38
81
  };
39
82
  //# sourceMappingURL=AnalyticsPlatformAdapter.types.d.cts.map
@@ -1 +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;;;;;;;;;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.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;;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,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,IAAI,CAAC;CAC7C,CAAC"}
@@ -3,37 +3,80 @@ 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
+ saveDataRecording: boolean;
20
+ readonly hasProperties: boolean;
21
+ };
6
22
  /**
7
23
  * Platform adapter interface for analytics tracking
8
24
  * 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
25
  */
16
26
  export type AnalyticsPlatformAdapter = {
17
27
  /**
18
- * Track an analytics event
28
+ * Track an analytics event.
29
+ *
30
+ * This is the same as trackEvent in the old analytics system
19
31
  *
20
32
  * @param eventName - The name of the event
21
- * @param properties - Event properties
33
+ * @param properties - Event properties. If not provided, the event has no properties.
34
+ * The privacy plugin should check for `isSensitive === true` to determine if an event contains sensitive data.
22
35
  */
23
- trackEvent(eventName: string, properties: AnalyticsEventProperties): void;
36
+ track(eventName: string, properties?: AnalyticsEventProperties): void;
24
37
  /**
25
- * Identify a user
38
+ * Identify a user with traits.
26
39
  *
27
40
  * @param userId - The user identifier (e.g., metametrics ID)
28
41
  * @param traits - User traits/properties
29
42
  */
30
- identify?(userId: string, traits?: AnalyticsEventProperties): void;
43
+ identify(userId: string, traits?: AnalyticsUserTraits): void;
31
44
  /**
32
- * Track a page view
45
+ * Track a UI unit (page or screen) view depending on the platform
46
+ *
47
+ * This method delegates to platform-specific Segment SDK methods:
48
+ * - Web adapters should call `analytics.page(name, properties)`
49
+ * - Mobile adapters should call `analytics.screen(name, properties)`
50
+ *
51
+ * @param name - The identifier/name of the page or screen being viewed (e.g., "home", "settings", "wallet")
52
+ * @param properties - Optional properties associated with the view
53
+ */
54
+ view(name: string, properties?: AnalyticsEventProperties): void;
55
+ /**
56
+ * Lifecycle hook called after the AnalyticsController is fully initialized.
57
+ *
58
+ * This hook allows platform-specific adapters to perform setup that requires
59
+ * access to the controller's state (e.g., analyticsId).
60
+ *
61
+ * The controller calls this method once after initialization, passing the
62
+ * analyticsId from controller state. The analyticsId is guaranteed to be set
63
+ * when this method is called - this is the definition of "completed" setup.
64
+ *
65
+ * @param analyticsId - The analytics ID from controller state. Always set (never empty).
66
+ * @throws {AnalyticsPlatformAdapterSetupError} May throw errors during setup (e.g., configuration errors, network failures).
67
+ * Errors thrown by this method are caught and logged by the controller, but do not prevent
68
+ * controller initialization from completing successfully.
33
69
  *
34
- * @param pageName - The name of the page
35
- * @param properties - Page properties
70
+ * @example
71
+ * ```typescript
72
+ * onSetupCompleted(analyticsId: string): void {
73
+ * // Add platform-specific plugins that require analyticsId
74
+ * client.add({
75
+ * plugin: new PrivacyPlugin(analyticsId),
76
+ * });
77
+ * }
78
+ * ```
36
79
  */
37
- trackPage?(pageName: string, properties?: AnalyticsEventProperties): void;
80
+ onSetupCompleted(analyticsId: string): void;
38
81
  };
39
82
  //# 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,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,IAAI,CAAC;CAC7C,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 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 * onSetupCompleted(analyticsId: string): 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): 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,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeEnabledState = void 0;
4
+ /**
5
+ * State computer that computes controller values from controller state.
6
+ *
7
+ * This module provides functions that compute derived controller values from the
8
+ * controller's state. Currently, it computes the `controller_enabled` state, but
9
+ * can be extended to compute other values in the future.
10
+ *
11
+ * **State Computer Computations:**
12
+ *
13
+ * 1. **Enabled State** (`computeEnabledState`):
14
+ * - Determines whether analytics tracking is active
15
+ * - Rules: `controller_enabled = optedInForRegularAccount || optedInForSocialAccount`
16
+ * - Analytics is enabled if the user has opted in for regular account OR social account
17
+ *
18
+ * 2. **Future computations** (e.g., feature flags, permissions, etc.)
19
+ *
20
+ * **Usage:**
21
+ * These functions are called:
22
+ * - During controller initialization to set initial values
23
+ * - Whenever user state changes (e.g., in `optInForRegularAccount()`, `optOutForRegularAccount()`, `optInForSocialAccount()`, `optOutForSocialAccount()`)
24
+ *
25
+ * **Extensibility:**
26
+ * To add new computations, add new functions that take `AnalyticsControllerState` as input.
27
+ * To add new user state properties, update the `AnalyticsControllerState` type with `user_` prefix
28
+ * and all computation functions that need to consider them.
29
+ */
30
+ /**
31
+ * Computes the `controller_enabled` state from controller state.
32
+ *
33
+ * @param state - The current controller state
34
+ * @returns `true` if analytics tracking should be enabled, `false` otherwise
35
+ */
36
+ function computeEnabledState(state) {
37
+ // Analytics is enabled if user has opted in for regular account OR social account
38
+ // Rules:
39
+ // - optedInForRegularAccount==true && optedInForSocialAccount==true -> enabled=true
40
+ // - optedInForRegularAccount==false && optedInForSocialAccount==true -> enabled=true
41
+ // - optedInForRegularAccount==true && optedInForSocialAccount==false -> enabled=true
42
+ // - optedInForRegularAccount==false && optedInForSocialAccount==false -> enabled=false
43
+ return state.optedInForRegularAccount || state.optedInForSocialAccount;
44
+ }
45
+ exports.computeEnabledState = computeEnabledState;
46
+ //# sourceMappingURL=analyticsStateComputer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsStateComputer.cjs","sourceRoot":"","sources":["../src/analyticsStateComputer.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,kFAAkF;IAClF,SAAS;IACT,oFAAoF;IACpF,qFAAqF;IACrF,qFAAqF;IACrF,uFAAuF;IACvF,OAAO,KAAK,CAAC,wBAAwB,IAAI,KAAK,CAAC,uBAAuB,CAAC;AACzE,CAAC;AARD,kDAQC","sourcesContent":["import type { AnalyticsControllerState } from './AnalyticsController';\n\n/**\n * State computer that computes controller values from controller state.\n *\n * This module provides functions that compute derived controller values from the\n * controller's state. Currently, it computes the `controller_enabled` state, but\n * can be extended to compute other values in the future.\n *\n * **State Computer Computations:**\n *\n * 1. **Enabled State** (`computeEnabledState`):\n * - Determines whether analytics tracking is active\n * - Rules: `controller_enabled = optedInForRegularAccount || optedInForSocialAccount`\n * - Analytics is enabled if the user has opted in for regular account OR social account\n *\n * 2. **Future computations** (e.g., feature flags, permissions, etc.)\n *\n * **Usage:**\n * These functions are called:\n * - During controller initialization to set initial values\n * - Whenever user state changes (e.g., in `optInForRegularAccount()`, `optOutForRegularAccount()`, `optInForSocialAccount()`, `optOutForSocialAccount()`)\n *\n * **Extensibility:**\n * To add new computations, add new functions that take `AnalyticsControllerState` as input.\n * To add new user state properties, update the `AnalyticsControllerState` type with `user_` prefix\n * and all computation functions that need to consider them.\n */\n\n/**\n * Computes the `controller_enabled` state from controller state.\n *\n * @param state - The current controller state\n * @returns `true` if analytics tracking should be enabled, `false` otherwise\n */\nexport function computeEnabledState(state: AnalyticsControllerState): boolean {\n // Analytics is enabled if user has opted in for regular account OR social account\n // Rules:\n // - optedInForRegularAccount==true && optedInForSocialAccount==true -> enabled=true\n // - optedInForRegularAccount==false && optedInForSocialAccount==true -> enabled=true\n // - optedInForRegularAccount==true && optedInForSocialAccount==false -> enabled=true\n // - optedInForRegularAccount==false && optedInForSocialAccount==false -> enabled=false\n return state.optedInForRegularAccount || state.optedInForSocialAccount;\n}\n"]}
@@ -0,0 +1,35 @@
1
+ import type { AnalyticsControllerState } from "./AnalyticsController.cjs";
2
+ /**
3
+ * State computer that computes controller values from controller state.
4
+ *
5
+ * This module provides functions that compute derived controller values from the
6
+ * controller's state. Currently, it computes the `controller_enabled` state, but
7
+ * can be extended to compute other values in the future.
8
+ *
9
+ * **State Computer Computations:**
10
+ *
11
+ * 1. **Enabled State** (`computeEnabledState`):
12
+ * - Determines whether analytics tracking is active
13
+ * - Rules: `controller_enabled = optedInForRegularAccount || optedInForSocialAccount`
14
+ * - Analytics is enabled if the user has opted in for regular account OR social account
15
+ *
16
+ * 2. **Future computations** (e.g., feature flags, permissions, etc.)
17
+ *
18
+ * **Usage:**
19
+ * These functions are called:
20
+ * - During controller initialization to set initial values
21
+ * - Whenever user state changes (e.g., in `optInForRegularAccount()`, `optOutForRegularAccount()`, `optInForSocialAccount()`, `optOutForSocialAccount()`)
22
+ *
23
+ * **Extensibility:**
24
+ * To add new computations, add new functions that take `AnalyticsControllerState` as input.
25
+ * To add new user state properties, update the `AnalyticsControllerState` type with `user_` prefix
26
+ * and all computation functions that need to consider them.
27
+ */
28
+ /**
29
+ * Computes the `controller_enabled` state from controller state.
30
+ *
31
+ * @param state - The current controller state
32
+ * @returns `true` if analytics tracking should be enabled, `false` otherwise
33
+ */
34
+ export declare function computeEnabledState(state: AnalyticsControllerState): boolean;
35
+ //# sourceMappingURL=analyticsStateComputer.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsStateComputer.d.cts","sourceRoot":"","sources":["../src/analyticsStateComputer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAA8B;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAQ5E"}
@@ -0,0 +1,35 @@
1
+ import type { AnalyticsControllerState } from "./AnalyticsController.mjs";
2
+ /**
3
+ * State computer that computes controller values from controller state.
4
+ *
5
+ * This module provides functions that compute derived controller values from the
6
+ * controller's state. Currently, it computes the `controller_enabled` state, but
7
+ * can be extended to compute other values in the future.
8
+ *
9
+ * **State Computer Computations:**
10
+ *
11
+ * 1. **Enabled State** (`computeEnabledState`):
12
+ * - Determines whether analytics tracking is active
13
+ * - Rules: `controller_enabled = optedInForRegularAccount || optedInForSocialAccount`
14
+ * - Analytics is enabled if the user has opted in for regular account OR social account
15
+ *
16
+ * 2. **Future computations** (e.g., feature flags, permissions, etc.)
17
+ *
18
+ * **Usage:**
19
+ * These functions are called:
20
+ * - During controller initialization to set initial values
21
+ * - Whenever user state changes (e.g., in `optInForRegularAccount()`, `optOutForRegularAccount()`, `optInForSocialAccount()`, `optOutForSocialAccount()`)
22
+ *
23
+ * **Extensibility:**
24
+ * To add new computations, add new functions that take `AnalyticsControllerState` as input.
25
+ * To add new user state properties, update the `AnalyticsControllerState` type with `user_` prefix
26
+ * and all computation functions that need to consider them.
27
+ */
28
+ /**
29
+ * Computes the `controller_enabled` state from controller state.
30
+ *
31
+ * @param state - The current controller state
32
+ * @returns `true` if analytics tracking should be enabled, `false` otherwise
33
+ */
34
+ export declare function computeEnabledState(state: AnalyticsControllerState): boolean;
35
+ //# sourceMappingURL=analyticsStateComputer.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsStateComputer.d.mts","sourceRoot":"","sources":["../src/analyticsStateComputer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAA8B;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAQ5E"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * State computer that computes controller values from controller state.
3
+ *
4
+ * This module provides functions that compute derived controller values from the
5
+ * controller's state. Currently, it computes the `controller_enabled` state, but
6
+ * can be extended to compute other values in the future.
7
+ *
8
+ * **State Computer Computations:**
9
+ *
10
+ * 1. **Enabled State** (`computeEnabledState`):
11
+ * - Determines whether analytics tracking is active
12
+ * - Rules: `controller_enabled = optedInForRegularAccount || optedInForSocialAccount`
13
+ * - Analytics is enabled if the user has opted in for regular account OR social account
14
+ *
15
+ * 2. **Future computations** (e.g., feature flags, permissions, etc.)
16
+ *
17
+ * **Usage:**
18
+ * These functions are called:
19
+ * - During controller initialization to set initial values
20
+ * - Whenever user state changes (e.g., in `optInForRegularAccount()`, `optOutForRegularAccount()`, `optInForSocialAccount()`, `optOutForSocialAccount()`)
21
+ *
22
+ * **Extensibility:**
23
+ * To add new computations, add new functions that take `AnalyticsControllerState` as input.
24
+ * To add new user state properties, update the `AnalyticsControllerState` type with `user_` prefix
25
+ * and all computation functions that need to consider them.
26
+ */
27
+ /**
28
+ * Computes the `controller_enabled` state from controller state.
29
+ *
30
+ * @param state - The current controller state
31
+ * @returns `true` if analytics tracking should be enabled, `false` otherwise
32
+ */
33
+ export function computeEnabledState(state) {
34
+ // Analytics is enabled if user has opted in for regular account OR social account
35
+ // Rules:
36
+ // - optedInForRegularAccount==true && optedInForSocialAccount==true -> enabled=true
37
+ // - optedInForRegularAccount==false && optedInForSocialAccount==true -> enabled=true
38
+ // - optedInForRegularAccount==true && optedInForSocialAccount==false -> enabled=true
39
+ // - optedInForRegularAccount==false && optedInForSocialAccount==false -> enabled=false
40
+ return state.optedInForRegularAccount || state.optedInForSocialAccount;
41
+ }
42
+ //# sourceMappingURL=analyticsStateComputer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsStateComputer.mjs","sourceRoot":"","sources":["../src/analyticsStateComputer.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,kFAAkF;IAClF,SAAS;IACT,oFAAoF;IACpF,qFAAqF;IACrF,qFAAqF;IACrF,uFAAuF;IACvF,OAAO,KAAK,CAAC,wBAAwB,IAAI,KAAK,CAAC,uBAAuB,CAAC;AACzE,CAAC","sourcesContent":["import type { AnalyticsControllerState } from './AnalyticsController';\n\n/**\n * State computer that computes controller values from controller state.\n *\n * This module provides functions that compute derived controller values from the\n * controller's state. Currently, it computes the `controller_enabled` state, but\n * can be extended to compute other values in the future.\n *\n * **State Computer Computations:**\n *\n * 1. **Enabled State** (`computeEnabledState`):\n * - Determines whether analytics tracking is active\n * - Rules: `controller_enabled = optedInForRegularAccount || optedInForSocialAccount`\n * - Analytics is enabled if the user has opted in for regular account OR social account\n *\n * 2. **Future computations** (e.g., feature flags, permissions, etc.)\n *\n * **Usage:**\n * These functions are called:\n * - During controller initialization to set initial values\n * - Whenever user state changes (e.g., in `optInForRegularAccount()`, `optOutForRegularAccount()`, `optInForSocialAccount()`, `optOutForSocialAccount()`)\n *\n * **Extensibility:**\n * To add new computations, add new functions that take `AnalyticsControllerState` as input.\n * To add new user state properties, update the `AnalyticsControllerState` type with `user_` prefix\n * and all computation functions that need to consider them.\n */\n\n/**\n * Computes the `controller_enabled` state from controller state.\n *\n * @param state - The current controller state\n * @returns `true` if analytics tracking should be enabled, `false` otherwise\n */\nexport function computeEnabledState(state: AnalyticsControllerState): boolean {\n // Analytics is enabled if user has opted in for regular account OR social account\n // Rules:\n // - optedInForRegularAccount==true && optedInForSocialAccount==true -> enabled=true\n // - optedInForRegularAccount==false && optedInForSocialAccount==true -> enabled=true\n // - optedInForRegularAccount==true && optedInForSocialAccount==false -> enabled=true\n // - optedInForRegularAccount==false && optedInForSocialAccount==false -> enabled=false\n return state.optedInForRegularAccount || state.optedInForSocialAccount;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateAnalyticsState = void 0;
4
+ const uuid_1 = require("uuid");
5
+ /**
6
+ * Validates that the analytics state has a valid UUIDv4 analyticsId.
7
+ *
8
+ * @param state - The analytics controller state to validate
9
+ * @throws {Error} If analyticsId is missing, invalid, or not a UUIDv4
10
+ */
11
+ function validateAnalyticsState(state) {
12
+ if (!state.analyticsId ||
13
+ !(0, uuid_1.validate)(state.analyticsId) ||
14
+ (0, uuid_1.version)(state.analyticsId) !== 4) {
15
+ throw new Error(`Invalid analyticsId: expected a valid UUIDv4, but got ${JSON.stringify(state.analyticsId)}`);
16
+ }
17
+ }
18
+ exports.validateAnalyticsState = validateAnalyticsState;
19
+ //# sourceMappingURL=analyticsStateValidator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsStateValidator.cjs","sourceRoot":"","sources":["../src/analyticsStateValidator.ts"],"names":[],"mappings":";;;AAAA,+BAA2E;AAI3E;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,KAA+B;IACpE,IACE,CAAC,KAAK,CAAC,WAAW;QAClB,CAAC,IAAA,eAAY,EAAC,KAAK,CAAC,WAAW,CAAC;QAChC,IAAA,cAAc,EAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,EACvC,CAAC;QACD,MAAM,IAAI,KAAK,CACb,yDAAyD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAC7F,CAAC;IACJ,CAAC;AACH,CAAC;AAVD,wDAUC","sourcesContent":["import { validate as validateUuid, version as getUuidVersion } from 'uuid';\n\nimport type { AnalyticsControllerState } from './AnalyticsController';\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, invalid, or not a UUIDv4\n */\nexport function validateAnalyticsState(state: AnalyticsControllerState): void {\n if (\n !state.analyticsId ||\n !validateUuid(state.analyticsId) ||\n getUuidVersion(state.analyticsId) !== 4\n ) {\n throw new Error(\n `Invalid analyticsId: expected a valid UUIDv4, but got ${JSON.stringify(state.analyticsId)}`,\n );\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { AnalyticsControllerState } from "./AnalyticsController.cjs";
2
+ /**
3
+ * Validates that the analytics state has a valid UUIDv4 analyticsId.
4
+ *
5
+ * @param state - The analytics controller state to validate
6
+ * @throws {Error} If analyticsId is missing, invalid, or not a UUIDv4
7
+ */
8
+ export declare function validateAnalyticsState(state: AnalyticsControllerState): void;
9
+ //# sourceMappingURL=analyticsStateValidator.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsStateValidator.d.cts","sourceRoot":"","sources":["../src/analyticsStateValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAA8B;AAEtE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,wBAAwB,GAAG,IAAI,CAU5E"}
@@ -0,0 +1,9 @@
1
+ import type { AnalyticsControllerState } from "./AnalyticsController.mjs";
2
+ /**
3
+ * Validates that the analytics state has a valid UUIDv4 analyticsId.
4
+ *
5
+ * @param state - The analytics controller state to validate
6
+ * @throws {Error} If analyticsId is missing, invalid, or not a UUIDv4
7
+ */
8
+ export declare function validateAnalyticsState(state: AnalyticsControllerState): void;
9
+ //# sourceMappingURL=analyticsStateValidator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsStateValidator.d.mts","sourceRoot":"","sources":["../src/analyticsStateValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAA8B;AAEtE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,wBAAwB,GAAG,IAAI,CAU5E"}
@@ -0,0 +1,15 @@
1
+ import { validate as validateUuid, version as getUuidVersion } from "uuid";
2
+ /**
3
+ * Validates that the analytics state has a valid UUIDv4 analyticsId.
4
+ *
5
+ * @param state - The analytics controller state to validate
6
+ * @throws {Error} If analyticsId is missing, invalid, or not a UUIDv4
7
+ */
8
+ export function validateAnalyticsState(state) {
9
+ if (!state.analyticsId ||
10
+ !validateUuid(state.analyticsId) ||
11
+ getUuidVersion(state.analyticsId) !== 4) {
12
+ throw new Error(`Invalid analyticsId: expected a valid UUIDv4, but got ${JSON.stringify(state.analyticsId)}`);
13
+ }
14
+ }
15
+ //# sourceMappingURL=analyticsStateValidator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsStateValidator.mjs","sourceRoot":"","sources":["../src/analyticsStateValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,OAAO,IAAI,cAAc,EAAE,aAAa;AAI3E;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAA+B;IACpE,IACE,CAAC,KAAK,CAAC,WAAW;QAClB,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC;QAChC,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,EACvC,CAAC;QACD,MAAM,IAAI,KAAK,CACb,yDAAyD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAC7F,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { validate as validateUuid, version as getUuidVersion } from 'uuid';\n\nimport type { AnalyticsControllerState } from './AnalyticsController';\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, invalid, or not a UUIDv4\n */\nexport function validateAnalyticsState(state: AnalyticsControllerState): void {\n if (\n !state.analyticsId ||\n !validateUuid(state.analyticsId) ||\n getUuidVersion(state.analyticsId) !== 4\n ) {\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,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultAnalyticsControllerState = exports.AnalyticsController = void 0;
3
+ exports.analyticsControllerSelectors = exports.getDefaultAnalyticsControllerState = exports.AnalyticsPlatformAdapterSetupError = exports.AnalyticsController = void 0;
4
4
  // Export controller class
5
5
  var AnalyticsController_1 = require("./AnalyticsController.cjs");
6
6
  Object.defineProperty(exports, "AnalyticsController", { enumerable: true, get: function () { return AnalyticsController_1.AnalyticsController; } });
7
+ // Export errors
8
+ var AnalyticsPlatformAdapterSetupError_1 = require("./AnalyticsPlatformAdapterSetupError.cjs");
9
+ Object.defineProperty(exports, "AnalyticsPlatformAdapterSetupError", { enumerable: true, get: function () { return AnalyticsPlatformAdapterSetupError_1.AnalyticsPlatformAdapterSetupError; } });
7
10
  var AnalyticsController_2 = require("./AnalyticsController.cjs");
8
11
  Object.defineProperty(exports, "getDefaultAnalyticsControllerState", { enumerable: true, get: function () { return AnalyticsController_2.getDefaultAnalyticsControllerState; } });
12
+ // Export selectors
13
+ var selectors_1 = require("./selectors.cjs");
14
+ Object.defineProperty(exports, "analyticsControllerSelectors", { enumerable: true, get: function () { return selectors_1.analyticsControllerSelectors; } });
9
15
  //# 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,0BAA0B;AAC1B,iEAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAG5B,gBAAgB;AAChB,+FAA0F;AAAjF,wJAAA,kCAAkC,OAAA;AAY3C,iEAA2E;AAAlE,yIAAA,kCAAkC,OAAA;AAE3C,mBAAmB;AACnB,6CAA2D;AAAlD,yHAAA,4BAA4B,OAAA","sourcesContent":["// Export controller class\nexport { AnalyticsController } 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 and utilities\nexport type { AnalyticsControllerState } from './AnalyticsController';\nexport { getDefaultAnalyticsControllerState } 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,11 @@
1
1
  export { AnalyticsController } 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
6
  export { getDefaultAnalyticsControllerState } from "./AnalyticsController.cjs";
7
+ export { analyticsControllerSelectors } from "./selectors.cjs";
6
8
  export type { AnalyticsControllerMessenger } from "./AnalyticsController.cjs";
7
9
  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";
10
+ export type { AnalyticsControllerTrackEventAction, AnalyticsControllerIdentifyAction, AnalyticsControllerTrackViewAction, AnalyticsControllerOptInForRegularAccountAction, AnalyticsControllerOptOutForRegularAccountAction, AnalyticsControllerOptInForSocialAccountAction, AnalyticsControllerOptOutForSocialAccountAction, AnalyticsControllerMethodActions, } from "./AnalyticsController-method-action-types.cjs";
9
11
  //# 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,EAAE,mBAAmB,EAAE,kCAA8B;AAC5D,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;AACtE,OAAO,EAAE,kCAAkC,EAAE,kCAA8B;AAG3E,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"}