@metamask-previews/analytics-controller 2.0.0-preview-b13d916 → 2.0.0-preview-4f4c98e
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.
- package/CHANGELOG.md +4 -0
- package/dist/{AnalyticsController-method-action-types.d.mts → AnalyticsController-method-action-types.d.ts} +2 -2
- package/dist/AnalyticsController-method-action-types.d.ts.map +1 -0
- package/dist/{AnalyticsController-method-action-types.mjs → AnalyticsController-method-action-types.js} +1 -1
- package/dist/AnalyticsController-method-action-types.js.map +1 -0
- package/dist/{AnalyticsController.d.cts → AnalyticsController.d.ts} +8 -8
- package/dist/AnalyticsController.d.ts.map +1 -0
- package/dist/{AnalyticsController.mjs → AnalyticsController.js} +7 -8
- package/dist/AnalyticsController.js.map +1 -0
- package/dist/AnalyticsLogger.d.ts +4 -0
- package/dist/AnalyticsLogger.d.ts.map +1 -0
- package/dist/{AnalyticsLogger.mjs → AnalyticsLogger.js} +2 -2
- package/dist/AnalyticsLogger.js.map +1 -0
- package/dist/{AnalyticsPlatformAdapter.types.d.cts → AnalyticsPlatformAdapter.types.d.ts} +2 -2
- package/dist/AnalyticsPlatformAdapter.types.d.ts.map +1 -0
- package/dist/AnalyticsPlatformAdapter.types.js +2 -0
- package/dist/AnalyticsPlatformAdapter.types.js.map +1 -0
- package/dist/{AnalyticsPlatformAdapterSetupError.d.cts → AnalyticsPlatformAdapterSetupError.d.ts} +1 -1
- package/dist/AnalyticsPlatformAdapterSetupError.d.ts.map +1 -0
- package/dist/{AnalyticsPlatformAdapterSetupError.mjs → AnalyticsPlatformAdapterSetupError.js} +1 -1
- package/dist/AnalyticsPlatformAdapterSetupError.js.map +1 -0
- package/dist/{analyticsControllerStateValidator.d.mts → analyticsControllerStateValidator.d.ts} +2 -2
- package/dist/analyticsControllerStateValidator.d.ts.map +1 -0
- package/dist/{analyticsControllerStateValidator.mjs → analyticsControllerStateValidator.js} +1 -1
- package/dist/analyticsControllerStateValidator.js.map +1 -0
- package/dist/{index.d.cts → index.d.ts} +10 -10
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/{selectors.cjs → selectors.d.ts} +12 -13
- package/dist/selectors.d.ts.map +1 -0
- package/dist/{selectors.mjs → selectors.js} +1 -1
- package/dist/selectors.js.map +1 -0
- package/package.json +13 -17
- package/dist/AnalyticsController-method-action-types.cjs +0 -7
- package/dist/AnalyticsController-method-action-types.cjs.map +0 -1
- package/dist/AnalyticsController-method-action-types.d.cts +0 -81
- package/dist/AnalyticsController-method-action-types.d.cts.map +0 -1
- package/dist/AnalyticsController-method-action-types.d.mts.map +0 -1
- package/dist/AnalyticsController-method-action-types.mjs.map +0 -1
- package/dist/AnalyticsController.cjs +0 -641
- package/dist/AnalyticsController.cjs.map +0 -1
- package/dist/AnalyticsController.d.cts.map +0 -1
- package/dist/AnalyticsController.d.mts +0 -312
- package/dist/AnalyticsController.d.mts.map +0 -1
- package/dist/AnalyticsController.mjs.map +0 -1
- package/dist/AnalyticsLogger.cjs +0 -8
- package/dist/AnalyticsLogger.cjs.map +0 -1
- package/dist/AnalyticsLogger.d.cts +0 -5
- package/dist/AnalyticsLogger.d.cts.map +0 -1
- package/dist/AnalyticsLogger.d.mts +0 -5
- package/dist/AnalyticsLogger.d.mts.map +0 -1
- package/dist/AnalyticsLogger.mjs.map +0 -1
- package/dist/AnalyticsPlatformAdapter.types.cjs +0 -3
- package/dist/AnalyticsPlatformAdapter.types.cjs.map +0 -1
- package/dist/AnalyticsPlatformAdapter.types.d.cts.map +0 -1
- package/dist/AnalyticsPlatformAdapter.types.d.mts +0 -144
- package/dist/AnalyticsPlatformAdapter.types.d.mts.map +0 -1
- package/dist/AnalyticsPlatformAdapter.types.mjs +0 -2
- package/dist/AnalyticsPlatformAdapter.types.mjs.map +0 -1
- package/dist/AnalyticsPlatformAdapterSetupError.cjs +0 -17
- package/dist/AnalyticsPlatformAdapterSetupError.cjs.map +0 -1
- package/dist/AnalyticsPlatformAdapterSetupError.d.cts.map +0 -1
- package/dist/AnalyticsPlatformAdapterSetupError.d.mts +0 -8
- package/dist/AnalyticsPlatformAdapterSetupError.d.mts.map +0 -1
- package/dist/AnalyticsPlatformAdapterSetupError.mjs.map +0 -1
- package/dist/analyticsControllerStateValidator.cjs +0 -36
- package/dist/analyticsControllerStateValidator.cjs.map +0 -1
- package/dist/analyticsControllerStateValidator.d.cts +0 -17
- package/dist/analyticsControllerStateValidator.d.cts.map +0 -1
- package/dist/analyticsControllerStateValidator.d.mts.map +0 -1
- package/dist/analyticsControllerStateValidator.mjs.map +0 -1
- package/dist/index.cjs +0 -14
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -10
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -7
- package/dist/index.mjs.map +0 -1
- package/dist/selectors.cjs.map +0 -1
- package/dist/selectors.d.cts +0 -12
- package/dist/selectors.d.cts.map +0 -1
- package/dist/selectors.d.mts +0 -12
- package/dist/selectors.d.mts.map +0 -1
- package/dist/selectors.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsPlatformAdapter.types.cjs","sourceRoot":"","sources":["../src/AnalyticsPlatformAdapter.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Json } from '@metamask/utils';\n\n/**\n * Analytics event properties\n */\nexport type AnalyticsEventProperties = Record<string, Json>;\n\n/**\n * User traits/properties for analytics identification\n */\nexport type AnalyticsUserTraits = Record<string, Json>;\n\n/**\n * Callback invoked by the platform adapter after an analytics payload is\n * delivered or fails.\n */\nexport type AnalyticsInvocationCallback = (error?: unknown) => void;\n\n/**\n * Internal delivery metadata used by AnalyticsController when event queue\n * persistence is enabled.\n */\nexport type AnalyticsDeliveryOptions = {\n /**\n * Stable identifier for the analytics payload.\n */\n messageId?: string;\n\n /**\n * Original timestamp for the analytics payload.\n */\n timestamp?: Date;\n\n /**\n * Callback for delivery acknowledgement.\n */\n callback?: AnalyticsInvocationCallback;\n};\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 * Optional analytics context payload (for example Segment-style context).\n */\nexport type AnalyticsContext = Record<string, Json>;\n\n/**\n * Names of the geolocation fields attached to an analytics event.\n *\n * These follow the schema that downstream analytics destinations expect, which\n * is why they are snake_case rather than camelCase:\n *\n * - `country_code` is an ISO 3166-1 alpha-2 country code (e.g. `US`).\n * - `region` is an ISO 3166-2 subdivision code without the country prefix\n * (e.g. `WA`).\n * - `timezone` is an IANA time zone name (e.g. `America/Los_Angeles`).\n */\nexport type AnalyticsLocationField = 'country_code' | 'region' | 'timezone';\n\n/**\n * Geolocation fields attached to the `location` key of {@link AnalyticsContext}.\n *\n * Each field is only present when the geolocation API returned a valid value\n * for it.\n */\nexport type AnalyticsLocationContext = Partial<\n Record<AnalyticsLocationField, string>\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 * When `true`, the controller accepts any non-empty `analyticsId` string\n * instead of requiring UUIDv4 format. Defaults to validation against UUIDv4 when omitted or `false`.\n */\n skipUUIDv4Check?: boolean;\n\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 * @param context - Optional platform-specific context attached to the invocation.\n * @param options - Optional delivery metadata for platform adapters.\n */\n track(\n eventName: string,\n properties?: AnalyticsEventProperties,\n context?: AnalyticsContext,\n options?: AnalyticsDeliveryOptions,\n ): 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 * @param context - Optional platform-specific context attached to the invocation.\n * @param options - Optional delivery metadata for platform adapters.\n */\n identify(\n userId: string,\n traits?: AnalyticsUserTraits,\n context?: AnalyticsContext,\n options?: AnalyticsDeliveryOptions,\n ): 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 * @param context - Optional platform-specific context attached to the invocation.\n * @param options - Optional delivery metadata for platform adapters.\n */\n view(\n name: string,\n properties?: AnalyticsEventProperties,\n context?: AnalyticsContext,\n options?: AnalyticsDeliveryOptions,\n ): 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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,2BAA2B,CAAC;CACxC,CAAC;AAEF;;;;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;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC,CACvC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;;;;;;;OAUG;IACH,KAAK,CACH,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,wBAAwB,EACrC,OAAO,CAAC,EAAE,gBAAgB,EAC1B,OAAO,CAAC,EAAE,wBAAwB,GACjC,IAAI,CAAC;IAER;;;;;;;OAOG;IACH,QAAQ,CACN,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,gBAAgB,EAC1B,OAAO,CAAC,EAAE,wBAAwB,GACjC,IAAI,CAAC;IAER;;;;;;;;;;;OAWG;IACH,IAAI,CACF,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,wBAAwB,EACrC,OAAO,CAAC,EAAE,gBAAgB,EAC1B,OAAO,CAAC,EAAE,wBAAwB,GACjC,IAAI,CAAC;IAER;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C,CAAC"}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import type { Json } from "@metamask/utils";
|
|
2
|
-
/**
|
|
3
|
-
* Analytics event properties
|
|
4
|
-
*/
|
|
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
|
-
* Callback invoked by the platform adapter after an analytics payload is
|
|
12
|
-
* delivered or fails.
|
|
13
|
-
*/
|
|
14
|
-
export type AnalyticsInvocationCallback = (error?: unknown) => void;
|
|
15
|
-
/**
|
|
16
|
-
* Internal delivery metadata used by AnalyticsController when event queue
|
|
17
|
-
* persistence is enabled.
|
|
18
|
-
*/
|
|
19
|
-
export type AnalyticsDeliveryOptions = {
|
|
20
|
-
/**
|
|
21
|
-
* Stable identifier for the analytics payload.
|
|
22
|
-
*/
|
|
23
|
-
messageId?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Original timestamp for the analytics payload.
|
|
26
|
-
*/
|
|
27
|
-
timestamp?: Date;
|
|
28
|
-
/**
|
|
29
|
-
* Callback for delivery acknowledgement.
|
|
30
|
-
*/
|
|
31
|
-
callback?: AnalyticsInvocationCallback;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Event properties structure with two distinct properties lists for regular and sensitive data.
|
|
35
|
-
* Similar to ITrackingEvent from legacy analytics but decoupled for platform agnosticism.
|
|
36
|
-
* Sensitivity is derived from the presence of sensitiveProperties (if sensitiveProperties has keys, the event is sensitive).
|
|
37
|
-
*/
|
|
38
|
-
export type AnalyticsTrackingEvent = {
|
|
39
|
-
readonly name: string;
|
|
40
|
-
properties: AnalyticsEventProperties;
|
|
41
|
-
sensitiveProperties: AnalyticsEventProperties;
|
|
42
|
-
/**
|
|
43
|
-
* Legacy property handled by the mobile app.
|
|
44
|
-
* This property is ignored by the analytics controller and will be removed from the type in the future.
|
|
45
|
-
* The mobile app will use the future analytics privacy controller to handle this functionality.
|
|
46
|
-
*/
|
|
47
|
-
saveDataRecording: boolean;
|
|
48
|
-
readonly hasProperties: boolean;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Optional analytics context payload (for example Segment-style context).
|
|
52
|
-
*/
|
|
53
|
-
export type AnalyticsContext = Record<string, Json>;
|
|
54
|
-
/**
|
|
55
|
-
* Names of the geolocation fields attached to an analytics event.
|
|
56
|
-
*
|
|
57
|
-
* These follow the schema that downstream analytics destinations expect, which
|
|
58
|
-
* is why they are snake_case rather than camelCase:
|
|
59
|
-
*
|
|
60
|
-
* - `country_code` is an ISO 3166-1 alpha-2 country code (e.g. `US`).
|
|
61
|
-
* - `region` is an ISO 3166-2 subdivision code without the country prefix
|
|
62
|
-
* (e.g. `WA`).
|
|
63
|
-
* - `timezone` is an IANA time zone name (e.g. `America/Los_Angeles`).
|
|
64
|
-
*/
|
|
65
|
-
export type AnalyticsLocationField = 'country_code' | 'region' | 'timezone';
|
|
66
|
-
/**
|
|
67
|
-
* Geolocation fields attached to the `location` key of {@link AnalyticsContext}.
|
|
68
|
-
*
|
|
69
|
-
* Each field is only present when the geolocation API returned a valid value
|
|
70
|
-
* for it.
|
|
71
|
-
*/
|
|
72
|
-
export type AnalyticsLocationContext = Partial<Record<AnalyticsLocationField, string>>;
|
|
73
|
-
/**
|
|
74
|
-
* Platform adapter interface for analytics tracking
|
|
75
|
-
* Implementations should handle platform-specific details (Segment SDK, etc.)
|
|
76
|
-
*/
|
|
77
|
-
export type AnalyticsPlatformAdapter = {
|
|
78
|
-
/**
|
|
79
|
-
* When `true`, the controller accepts any non-empty `analyticsId` string
|
|
80
|
-
* instead of requiring UUIDv4 format. Defaults to validation against UUIDv4 when omitted or `false`.
|
|
81
|
-
*/
|
|
82
|
-
skipUUIDv4Check?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Track an analytics event.
|
|
85
|
-
*
|
|
86
|
-
* This is the same as trackEvent in the old analytics system
|
|
87
|
-
*
|
|
88
|
-
* @param eventName - The name of the event
|
|
89
|
-
* @param properties - Event properties. If not provided, the event has no properties.
|
|
90
|
-
* The privacy plugin should check for `isSensitive === true` to determine if an event contains sensitive data.
|
|
91
|
-
* @param context - Optional platform-specific context attached to the invocation.
|
|
92
|
-
* @param options - Optional delivery metadata for platform adapters.
|
|
93
|
-
*/
|
|
94
|
-
track(eventName: string, properties?: AnalyticsEventProperties, context?: AnalyticsContext, options?: AnalyticsDeliveryOptions): void;
|
|
95
|
-
/**
|
|
96
|
-
* Identify a user with traits.
|
|
97
|
-
*
|
|
98
|
-
* @param userId - The user identifier (e.g., metametrics ID)
|
|
99
|
-
* @param traits - User traits/properties
|
|
100
|
-
* @param context - Optional platform-specific context attached to the invocation.
|
|
101
|
-
* @param options - Optional delivery metadata for platform adapters.
|
|
102
|
-
*/
|
|
103
|
-
identify(userId: string, traits?: AnalyticsUserTraits, context?: AnalyticsContext, options?: AnalyticsDeliveryOptions): void;
|
|
104
|
-
/**
|
|
105
|
-
* Track a UI unit (page or screen) view depending on the platform
|
|
106
|
-
*
|
|
107
|
-
* This method delegates to platform-specific Segment SDK methods:
|
|
108
|
-
* - Web adapters should call `analytics.page(name, properties)`
|
|
109
|
-
* - Mobile adapters should call `analytics.screen(name, properties)`
|
|
110
|
-
*
|
|
111
|
-
* @param name - The identifier/name of the page or screen being viewed (e.g., "home", "settings", "wallet")
|
|
112
|
-
* @param properties - Optional properties associated with the view
|
|
113
|
-
* @param context - Optional platform-specific context attached to the invocation.
|
|
114
|
-
* @param options - Optional delivery metadata for platform adapters.
|
|
115
|
-
*/
|
|
116
|
-
view(name: string, properties?: AnalyticsEventProperties, context?: AnalyticsContext, options?: AnalyticsDeliveryOptions): void;
|
|
117
|
-
/**
|
|
118
|
-
* Lifecycle hook called after the AnalyticsController is fully initialized.
|
|
119
|
-
*
|
|
120
|
-
* This hook allows platform-specific adapters to perform setup that requires
|
|
121
|
-
* access to the controller's state (e.g., analyticsId).
|
|
122
|
-
*
|
|
123
|
-
* The controller calls this method once after initialization, passing the
|
|
124
|
-
* analyticsId from controller state. The analyticsId is guaranteed to be set
|
|
125
|
-
* when this method is called - this is the definition of "completed" setup.
|
|
126
|
-
*
|
|
127
|
-
* @param analyticsId - The analytics ID from controller state. Always set (never empty).
|
|
128
|
-
* @throws {AnalyticsPlatformAdapterSetupError} May throw errors during setup (e.g., configuration errors, network failures).
|
|
129
|
-
* Errors thrown by this method are caught and logged by the controller, but do not prevent
|
|
130
|
-
* controller initialization from completing successfully.
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* ```typescript
|
|
134
|
-
* onSetupCompleted(analyticsId: string): void {
|
|
135
|
-
* // Add platform-specific plugins that require analyticsId
|
|
136
|
-
* client.add({
|
|
137
|
-
* plugin: new PrivacyPlugin(analyticsId),
|
|
138
|
-
* });
|
|
139
|
-
* }
|
|
140
|
-
* ```
|
|
141
|
-
*/
|
|
142
|
-
onSetupCompleted(analyticsId: string): void;
|
|
143
|
-
};
|
|
144
|
-
//# sourceMappingURL=AnalyticsPlatformAdapter.types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,2BAA2B,CAAC;CACxC,CAAC;AAEF;;;;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;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC,CACvC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;;;;;;;OAUG;IACH,KAAK,CACH,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,wBAAwB,EACrC,OAAO,CAAC,EAAE,gBAAgB,EAC1B,OAAO,CAAC,EAAE,wBAAwB,GACjC,IAAI,CAAC;IAER;;;;;;;OAOG;IACH,QAAQ,CACN,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,gBAAgB,EAC1B,OAAO,CAAC,EAAE,wBAAwB,GACjC,IAAI,CAAC;IAER;;;;;;;;;;;OAWG;IACH,IAAI,CACF,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,wBAAwB,EACrC,OAAO,CAAC,EAAE,gBAAgB,EAC1B,OAAO,CAAC,EAAE,wBAAwB,GACjC,IAAI,CAAC;IAER;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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 * Callback invoked by the platform adapter after an analytics payload is\n * delivered or fails.\n */\nexport type AnalyticsInvocationCallback = (error?: unknown) => void;\n\n/**\n * Internal delivery metadata used by AnalyticsController when event queue\n * persistence is enabled.\n */\nexport type AnalyticsDeliveryOptions = {\n /**\n * Stable identifier for the analytics payload.\n */\n messageId?: string;\n\n /**\n * Original timestamp for the analytics payload.\n */\n timestamp?: Date;\n\n /**\n * Callback for delivery acknowledgement.\n */\n callback?: AnalyticsInvocationCallback;\n};\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 * Optional analytics context payload (for example Segment-style context).\n */\nexport type AnalyticsContext = Record<string, Json>;\n\n/**\n * Names of the geolocation fields attached to an analytics event.\n *\n * These follow the schema that downstream analytics destinations expect, which\n * is why they are snake_case rather than camelCase:\n *\n * - `country_code` is an ISO 3166-1 alpha-2 country code (e.g. `US`).\n * - `region` is an ISO 3166-2 subdivision code without the country prefix\n * (e.g. `WA`).\n * - `timezone` is an IANA time zone name (e.g. `America/Los_Angeles`).\n */\nexport type AnalyticsLocationField = 'country_code' | 'region' | 'timezone';\n\n/**\n * Geolocation fields attached to the `location` key of {@link AnalyticsContext}.\n *\n * Each field is only present when the geolocation API returned a valid value\n * for it.\n */\nexport type AnalyticsLocationContext = Partial<\n Record<AnalyticsLocationField, string>\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 * When `true`, the controller accepts any non-empty `analyticsId` string\n * instead of requiring UUIDv4 format. Defaults to validation against UUIDv4 when omitted or `false`.\n */\n skipUUIDv4Check?: boolean;\n\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 * @param context - Optional platform-specific context attached to the invocation.\n * @param options - Optional delivery metadata for platform adapters.\n */\n track(\n eventName: string,\n properties?: AnalyticsEventProperties,\n context?: AnalyticsContext,\n options?: AnalyticsDeliveryOptions,\n ): 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 * @param context - Optional platform-specific context attached to the invocation.\n * @param options - Optional delivery metadata for platform adapters.\n */\n identify(\n userId: string,\n traits?: AnalyticsUserTraits,\n context?: AnalyticsContext,\n options?: AnalyticsDeliveryOptions,\n ): 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 * @param context - Optional platform-specific context attached to the invocation.\n * @param options - Optional delivery metadata for platform adapters.\n */\n view(\n name: string,\n properties?: AnalyticsEventProperties,\n context?: AnalyticsContext,\n options?: AnalyticsDeliveryOptions,\n ): 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"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
* @param skipUUIDv4Check - When `true`, skips UUIDv4 format validation
|
|
27
|
-
* @throws Error if analyticsId is missing or not a valid UUIDv4
|
|
28
|
-
*/
|
|
29
|
-
function validateAnalyticsControllerState(state, skipUUIDv4Check) {
|
|
30
|
-
if (!state.analyticsId ||
|
|
31
|
-
(skipUUIDv4Check !== true && !isValidUUIDv4(state.analyticsId))) {
|
|
32
|
-
throw new Error('Invalid analyticsId');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.validateAnalyticsControllerState = validateAnalyticsControllerState;
|
|
36
|
-
//# sourceMappingURL=analyticsControllerStateValidator.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;GAMG;AACH,SAAgB,gCAAgC,CAC9C,KAA+B,EAC/B,eAAyB;IAEzB,IACE,CAAC,KAAK,CAAC,WAAW;QAClB,CAAC,eAAe,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAC/D,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAVD,4EAUC","sourcesContent":["import type { AnalyticsControllerState } from './AnalyticsController.js';\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 * @param skipUUIDv4Check - When `true`, skips UUIDv4 format validation\n * @throws Error if analyticsId is missing or not a valid UUIDv4\n */\nexport function validateAnalyticsControllerState(\n state: AnalyticsControllerState,\n skipUUIDv4Check?: boolean,\n): void {\n if (\n !state.analyticsId ||\n (skipUUIDv4Check !== true && !isValidUUIDv4(state.analyticsId))\n ) {\n throw new Error('Invalid analyticsId');\n }\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
* @param skipUUIDv4Check - When `true`, skips UUIDv4 format validation
|
|
14
|
-
* @throws Error if analyticsId is missing or not a valid UUIDv4
|
|
15
|
-
*/
|
|
16
|
-
export declare function validateAnalyticsControllerState(state: AnalyticsControllerState, skipUUIDv4Check?: boolean): void;
|
|
17
|
-
//# sourceMappingURL=analyticsControllerStateValidator.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analyticsControllerStateValidator.d.cts","sourceRoot":"","sources":["../src/analyticsControllerStateValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAiC;AAYzE;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,wBAAwB,EAC/B,eAAe,CAAC,EAAE,OAAO,GACxB,IAAI,CAON"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analyticsControllerStateValidator.d.mts","sourceRoot":"","sources":["../src/analyticsControllerStateValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAiC;AAYzE;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,wBAAwB,EAC/B,eAAe,CAAC,EAAE,OAAO,GACxB,IAAI,CAON"}
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAC9C,KAA+B,EAC/B,eAAyB;IAEzB,IACE,CAAC,KAAK,CAAC,WAAW;QAClB,CAAC,eAAe,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAC/D,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;AACH,CAAC","sourcesContent":["import type { AnalyticsControllerState } from './AnalyticsController.js';\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 * @param skipUUIDv4Check - When `true`, skips UUIDv4 format validation\n * @throws Error if analyticsId is missing or not a valid UUIDv4\n */\nexport function validateAnalyticsControllerState(\n state: AnalyticsControllerState,\n skipUUIDv4Check?: boolean,\n): void {\n if (\n !state.analyticsId ||\n (skipUUIDv4Check !== true && !isValidUUIDv4(state.analyticsId))\n ) {\n throw new Error('Invalid analyticsId');\n }\n}\n"]}
|
package/dist/index.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.analyticsControllerSelectors = exports.AnalyticsPlatformAdapterSetupError = exports.getDefaultAnalyticsControllerState = exports.AnalyticsController = void 0;
|
|
4
|
-
// Export controller class and state utilities
|
|
5
|
-
var AnalyticsController_js_1 = require("./AnalyticsController.cjs");
|
|
6
|
-
Object.defineProperty(exports, "AnalyticsController", { enumerable: true, get: function () { return AnalyticsController_js_1.AnalyticsController; } });
|
|
7
|
-
Object.defineProperty(exports, "getDefaultAnalyticsControllerState", { enumerable: true, get: function () { return AnalyticsController_js_1.getDefaultAnalyticsControllerState; } });
|
|
8
|
-
// Export errors
|
|
9
|
-
var AnalyticsPlatformAdapterSetupError_js_1 = require("./AnalyticsPlatformAdapterSetupError.cjs");
|
|
10
|
-
Object.defineProperty(exports, "AnalyticsPlatformAdapterSetupError", { enumerable: true, get: function () { return AnalyticsPlatformAdapterSetupError_js_1.AnalyticsPlatformAdapterSetupError; } });
|
|
11
|
-
// Export selectors
|
|
12
|
-
var selectors_js_1 = require("./selectors.cjs");
|
|
13
|
-
Object.defineProperty(exports, "analyticsControllerSelectors", { enumerable: true, get: function () { return selectors_js_1.analyticsControllerSelectors; } });
|
|
14
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,8CAA8C;AAC9C,oEAGkC;AAFhC,6HAAA,mBAAmB,OAAA;AACnB,4IAAA,kCAAkC,OAAA;AAIpC,gBAAgB;AAChB,kGAA6F;AAApF,2JAAA,kCAAkC,OAAA;AA0B3C,mBAAmB;AACnB,gDAA8D;AAArD,4HAAA,4BAA4B,OAAA","sourcesContent":["// Export controller class and state utilities\nexport {\n AnalyticsController,\n getDefaultAnalyticsControllerState,\n} from './AnalyticsController.js';\nexport type { AnalyticsControllerOptions } from './AnalyticsController.js';\n\n// Export errors\nexport { AnalyticsPlatformAdapterSetupError } from './AnalyticsPlatformAdapterSetupError.js';\n\n// Export types\nexport type {\n AnalyticsContext,\n AnalyticsEventProperties,\n AnalyticsDeliveryOptions,\n AnalyticsInvocationCallback,\n AnalyticsLocationContext,\n AnalyticsLocationField,\n AnalyticsUserTraits,\n AnalyticsPlatformAdapter,\n AnalyticsTrackingEvent,\n} from './AnalyticsPlatformAdapter.types';\n\n// Export state types\nexport type {\n AnalyticsControllerState,\n AnalyticsEventQueue,\n AnalyticsQueuedEvent,\n AnalyticsQueuedEventType,\n AnalyticsQueuedTrackEvent,\n AnalyticsQueuedIdentifyEvent,\n AnalyticsQueuedViewEvent,\n} from './AnalyticsController.js';\n\n// Export selectors\nexport { analyticsControllerSelectors } from './selectors.js';\n\n// Export messenger types\nexport type { AnalyticsControllerMessenger } from './AnalyticsController.js';\n\n// Export action and event types\nexport type {\n AnalyticsControllerActions,\n AnalyticsControllerEvents,\n AnalyticsControllerGetStateAction,\n AnalyticsControllerStateChangeEvent,\n} from './AnalyticsController.js';\nexport type {\n AnalyticsControllerTrackEventAction,\n AnalyticsControllerIdentifyAction,\n AnalyticsControllerTrackViewAction,\n AnalyticsControllerOptInAction,\n AnalyticsControllerOptOutAction,\n AnalyticsControllerResetConsentDecisionAction,\n AnalyticsControllerMethodActions,\n} from './AnalyticsController-method-action-types.js';\n"]}
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,kCAAkC,GACnC,kCAAiC;AAClC,YAAY,EAAE,0BAA0B,EAAE,kCAAiC;AAG3E,OAAO,EAAE,kCAAkC,EAAE,iDAAgD;AAG7F,YAAY,EACV,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,2BAA2B,EAC3B,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,GACvB,6CAAyC;AAG1C,YAAY,EACV,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,4BAA4B,EAC5B,wBAAwB,GACzB,kCAAiC;AAGlC,OAAO,EAAE,4BAA4B,EAAE,wBAAuB;AAG9D,YAAY,EAAE,4BAA4B,EAAE,kCAAiC;AAG7E,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,iCAAiC,EACjC,mCAAmC,GACpC,kCAAiC;AAClC,YAAY,EACV,mCAAmC,EACnC,iCAAiC,EACjC,kCAAkC,EAClC,8BAA8B,EAC9B,+BAA+B,EAC/B,6CAA6C,EAC7C,gCAAgC,GACjC,sDAAqD"}
|
package/dist/index.d.mts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { AnalyticsController, getDefaultAnalyticsControllerState, } from "./AnalyticsController.mjs";
|
|
2
|
-
export type { AnalyticsControllerOptions } from "./AnalyticsController.mjs";
|
|
3
|
-
export { AnalyticsPlatformAdapterSetupError } from "./AnalyticsPlatformAdapterSetupError.mjs";
|
|
4
|
-
export type { AnalyticsContext, AnalyticsEventProperties, AnalyticsDeliveryOptions, AnalyticsInvocationCallback, AnalyticsLocationContext, AnalyticsLocationField, AnalyticsUserTraits, AnalyticsPlatformAdapter, AnalyticsTrackingEvent, } from "./AnalyticsPlatformAdapter.types.mjs";
|
|
5
|
-
export type { AnalyticsControllerState, AnalyticsEventQueue, AnalyticsQueuedEvent, AnalyticsQueuedEventType, AnalyticsQueuedTrackEvent, AnalyticsQueuedIdentifyEvent, AnalyticsQueuedViewEvent, } from "./AnalyticsController.mjs";
|
|
6
|
-
export { analyticsControllerSelectors } from "./selectors.mjs";
|
|
7
|
-
export type { AnalyticsControllerMessenger } from "./AnalyticsController.mjs";
|
|
8
|
-
export type { AnalyticsControllerActions, AnalyticsControllerEvents, AnalyticsControllerGetStateAction, AnalyticsControllerStateChangeEvent, } from "./AnalyticsController.mjs";
|
|
9
|
-
export type { AnalyticsControllerTrackEventAction, AnalyticsControllerIdentifyAction, AnalyticsControllerTrackViewAction, AnalyticsControllerOptInAction, AnalyticsControllerOptOutAction, AnalyticsControllerResetConsentDecisionAction, AnalyticsControllerMethodActions, } from "./AnalyticsController-method-action-types.mjs";
|
|
10
|
-
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,kCAAkC,GACnC,kCAAiC;AAClC,YAAY,EAAE,0BAA0B,EAAE,kCAAiC;AAG3E,OAAO,EAAE,kCAAkC,EAAE,iDAAgD;AAG7F,YAAY,EACV,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,2BAA2B,EAC3B,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,GACvB,6CAAyC;AAG1C,YAAY,EACV,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,4BAA4B,EAC5B,wBAAwB,GACzB,kCAAiC;AAGlC,OAAO,EAAE,4BAA4B,EAAE,wBAAuB;AAG9D,YAAY,EAAE,4BAA4B,EAAE,kCAAiC;AAG7E,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,iCAAiC,EACjC,mCAAmC,GACpC,kCAAiC;AAClC,YAAY,EACV,mCAAmC,EACnC,iCAAiC,EACjC,kCAAkC,EAClC,8BAA8B,EAC9B,+BAA+B,EAC/B,6CAA6C,EAC7C,gCAAgC,GACjC,sDAAqD"}
|
package/dist/index.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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";
|
|
7
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,OAAO,EACL,mBAAmB,EACnB,kCAAkC,EACnC,kCAAiC;AAGlC,gBAAgB;AAChB,OAAO,EAAE,kCAAkC,EAAE,iDAAgD;AA0B7F,mBAAmB;AACnB,OAAO,EAAE,4BAA4B,EAAE,wBAAuB","sourcesContent":["// Export controller class and state utilities\nexport {\n AnalyticsController,\n getDefaultAnalyticsControllerState,\n} from './AnalyticsController.js';\nexport type { AnalyticsControllerOptions } from './AnalyticsController.js';\n\n// Export errors\nexport { AnalyticsPlatformAdapterSetupError } from './AnalyticsPlatformAdapterSetupError.js';\n\n// Export types\nexport type {\n AnalyticsContext,\n AnalyticsEventProperties,\n AnalyticsDeliveryOptions,\n AnalyticsInvocationCallback,\n AnalyticsLocationContext,\n AnalyticsLocationField,\n AnalyticsUserTraits,\n AnalyticsPlatformAdapter,\n AnalyticsTrackingEvent,\n} from './AnalyticsPlatformAdapter.types';\n\n// Export state types\nexport type {\n AnalyticsControllerState,\n AnalyticsEventQueue,\n AnalyticsQueuedEvent,\n AnalyticsQueuedEventType,\n AnalyticsQueuedTrackEvent,\n AnalyticsQueuedIdentifyEvent,\n AnalyticsQueuedViewEvent,\n} from './AnalyticsController.js';\n\n// Export selectors\nexport { analyticsControllerSelectors } from './selectors.js';\n\n// Export messenger types\nexport type { AnalyticsControllerMessenger } from './AnalyticsController.js';\n\n// Export action and event types\nexport type {\n AnalyticsControllerActions,\n AnalyticsControllerEvents,\n AnalyticsControllerGetStateAction,\n AnalyticsControllerStateChangeEvent,\n} from './AnalyticsController.js';\nexport type {\n AnalyticsControllerTrackEventAction,\n AnalyticsControllerIdentifyAction,\n AnalyticsControllerTrackViewAction,\n AnalyticsControllerOptInAction,\n AnalyticsControllerOptOutAction,\n AnalyticsControllerResetConsentDecisionAction,\n AnalyticsControllerMethodActions,\n} from './AnalyticsController-method-action-types.js';\n"]}
|
package/dist/selectors.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,CAAC,KAA+B,EAAW,EAAE,CACjE,KAAK,CAAC,OAAO,CAAC;AAEhB;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,CAAC,KAA+B,EAAW,EAAE,CACjE,KAAK,CAAC,OAAO,CAAC;AAEhB;;;;;;;GAOG;AACH,MAAM,yBAAyB,GAAG,CAAC,KAA+B,EAAW,EAAE,CAC7E,KAAK,CAAC,mBAAmB,IAAI,KAAK,CAAC;AAErC;;;GAGG;AACU,QAAA,4BAA4B,GAAG;IAC1C,iBAAiB;IACjB,aAAa;IACb,aAAa;IACb,yBAAyB;CAC1B,CAAC","sourcesContent":["import type { AnalyticsControllerState } from './AnalyticsController.js';\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 user status from the controller state.\n * Use this selector to read the user's opt-in preference (e.g., for UI display).\n *\n * @param state - The controller state\n * @returns Whether the user has opted in to analytics\n */\nconst selectOptedIn = (state: AnalyticsControllerState): boolean =>\n state.optedIn;\n\n/**\n * Selects whether analytics tracking is enabled.\n * Use this selector to determine if tracking should occur (e.g., in controller methods).\n *\n * @param state - The controller state\n * @returns Whether analytics tracking is enabled\n */\nconst selectEnabled = (state: AnalyticsControllerState): boolean =>\n state.optedIn;\n\n/**\n * Selects whether the user has made a consent decision (opted in or opted out).\n * Use this selector to distinguish the \"undecided\" state (e.g. during\n * onboarding) from an explicit opt-out.\n *\n * @param state - The controller state\n * @returns Whether the user has made a consent decision\n */\nconst selectConsentDecisionMade = (state: AnalyticsControllerState): boolean =>\n state.consentDecisionMade ?? false;\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 selectOptedIn,\n selectEnabled,\n selectConsentDecisionMade,\n};\n"]}
|
package/dist/selectors.d.cts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
selectOptedIn: (state: AnalyticsControllerState) => boolean;
|
|
9
|
-
selectEnabled: (state: AnalyticsControllerState) => boolean;
|
|
10
|
-
selectConsentDecisionMade: (state: AnalyticsControllerState) => boolean;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=selectors.d.cts.map
|
package/dist/selectors.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.cts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAiC;AA0CzE;;;GAGG;AACH,eAAO,MAAM,4BAA4B;+BAtCP,wBAAwB,KAAG,MAAM;2BAUrC,wBAAwB,KAAG,OAAO;2BAUlC,wBAAwB,KAAG,OAAO;uCAWtB,wBAAwB,KAAG,OAAO;CAY3E,CAAC"}
|
package/dist/selectors.d.mts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
selectOptedIn: (state: AnalyticsControllerState) => boolean;
|
|
9
|
-
selectEnabled: (state: AnalyticsControllerState) => boolean;
|
|
10
|
-
selectConsentDecisionMade: (state: AnalyticsControllerState) => boolean;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=selectors.d.mts.map
|
package/dist/selectors.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.mts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAiC;AA0CzE;;;GAGG;AACH,eAAO,MAAM,4BAA4B;+BAtCP,wBAAwB,KAAG,MAAM;2BAUrC,wBAAwB,KAAG,OAAO;2BAUlC,wBAAwB,KAAG,OAAO;uCAWtB,wBAAwB,KAAG,OAAO;CAY3E,CAAC"}
|
package/dist/selectors.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,CAAC,KAA+B,EAAW,EAAE,CACjE,KAAK,CAAC,OAAO,CAAC;AAEhB;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,CAAC,KAA+B,EAAW,EAAE,CACjE,KAAK,CAAC,OAAO,CAAC;AAEhB;;;;;;;GAOG;AACH,MAAM,yBAAyB,GAAG,CAAC,KAA+B,EAAW,EAAE,CAC7E,KAAK,CAAC,mBAAmB,IAAI,KAAK,CAAC;AAErC;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,iBAAiB;IACjB,aAAa;IACb,aAAa;IACb,yBAAyB;CAC1B,CAAC","sourcesContent":["import type { AnalyticsControllerState } from './AnalyticsController.js';\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 user status from the controller state.\n * Use this selector to read the user's opt-in preference (e.g., for UI display).\n *\n * @param state - The controller state\n * @returns Whether the user has opted in to analytics\n */\nconst selectOptedIn = (state: AnalyticsControllerState): boolean =>\n state.optedIn;\n\n/**\n * Selects whether analytics tracking is enabled.\n * Use this selector to determine if tracking should occur (e.g., in controller methods).\n *\n * @param state - The controller state\n * @returns Whether analytics tracking is enabled\n */\nconst selectEnabled = (state: AnalyticsControllerState): boolean =>\n state.optedIn;\n\n/**\n * Selects whether the user has made a consent decision (opted in or opted out).\n * Use this selector to distinguish the \"undecided\" state (e.g. during\n * onboarding) from an explicit opt-out.\n *\n * @param state - The controller state\n * @returns Whether the user has made a consent decision\n */\nconst selectConsentDecisionMade = (state: AnalyticsControllerState): boolean =>\n state.consentDecisionMade ?? false;\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 selectOptedIn,\n selectEnabled,\n selectConsentDecisionMade,\n};\n"]}
|