@metamask-previews/analytics-controller 0.0.0-preview-704ae19a → 0.0.0-preview-b0cb618e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +4 -61
  2. package/dist/AnalyticsController-method-action-types.cjs.map +1 -1
  3. package/dist/AnalyticsController-method-action-types.d.cts +23 -62
  4. package/dist/AnalyticsController-method-action-types.d.cts.map +1 -1
  5. package/dist/AnalyticsController-method-action-types.d.mts +23 -62
  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 +52 -125
  9. package/dist/AnalyticsController.cjs.map +1 -1
  10. package/dist/AnalyticsController.d.cts +24 -52
  11. package/dist/AnalyticsController.d.cts.map +1 -1
  12. package/dist/AnalyticsController.d.mts +24 -52
  13. package/dist/AnalyticsController.d.mts.map +1 -1
  14. package/dist/AnalyticsController.mjs +53 -126
  15. package/dist/AnalyticsController.mjs.map +1 -1
  16. package/dist/AnalyticsPlatformAdapter.types.cjs.map +1 -1
  17. package/dist/AnalyticsPlatformAdapter.types.d.cts +13 -69
  18. package/dist/AnalyticsPlatformAdapter.types.d.cts.map +1 -1
  19. package/dist/AnalyticsPlatformAdapter.types.d.mts +13 -69
  20. package/dist/AnalyticsPlatformAdapter.types.d.mts.map +1 -1
  21. package/dist/AnalyticsPlatformAdapter.types.mjs.map +1 -1
  22. package/dist/index.cjs +1 -4
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +2 -3
  25. package/dist/index.d.cts.map +1 -1
  26. package/dist/index.d.mts +2 -3
  27. package/dist/index.d.mts.map +1 -1
  28. package/dist/index.mjs +0 -2
  29. package/dist/index.mjs.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/AnalyticsPlatformAdapterSetupError.cjs +0 -17
  32. package/dist/AnalyticsPlatformAdapterSetupError.cjs.map +0 -1
  33. package/dist/AnalyticsPlatformAdapterSetupError.d.cts +0 -8
  34. package/dist/AnalyticsPlatformAdapterSetupError.d.cts.map +0 -1
  35. package/dist/AnalyticsPlatformAdapterSetupError.d.mts +0 -8
  36. package/dist/AnalyticsPlatformAdapterSetupError.d.mts.map +0 -1
  37. package/dist/AnalyticsPlatformAdapterSetupError.mjs +0 -13
  38. package/dist/AnalyticsPlatformAdapterSetupError.mjs.map +0 -1
  39. package/dist/analyticsStateComputer.cjs +0 -46
  40. package/dist/analyticsStateComputer.cjs.map +0 -1
  41. package/dist/analyticsStateComputer.d.cts +0 -35
  42. package/dist/analyticsStateComputer.d.cts.map +0 -1
  43. package/dist/analyticsStateComputer.d.mts +0 -35
  44. package/dist/analyticsStateComputer.d.mts.map +0 -1
  45. package/dist/analyticsStateComputer.mjs +0 -42
  46. package/dist/analyticsStateComputer.mjs.map +0 -1
package/README.md CHANGED
@@ -30,24 +30,15 @@ The controller delegates platform-specific analytics implementation to a `Analyt
30
30
  import type { AnalyticsPlatformAdapter } from '@metamask/analytics-controller';
31
31
 
32
32
  const platformAdapter: AnalyticsPlatformAdapter = {
33
- track: (eventName: string, properties: Record<string, unknown>) => {
33
+ trackEvent: (eventName: string, properties: Record<string, unknown>) => {
34
34
  // Platform-specific implementation (e.g., Segment, Mixpanel, etc.)
35
35
  segment.track(eventName, properties);
36
36
  },
37
37
  identify: (userId: string, traits?: Record<string, unknown>) => {
38
38
  segment.identify(userId, traits);
39
39
  },
40
- view: (name: string, properties?: Record<string, unknown>) => {
41
- segment.page(name, properties);
42
- },
43
- onSetupCompleted: (analyticsId: string) => {
44
- // Lifecycle hook called after controller initialization
45
- // The analyticsId is guaranteed to be set when this method is called
46
- // Use this for platform-specific setup that requires the analytics ID
47
- // For example, adding plugins that need the analytics ID:
48
- segment.add({
49
- plugin: new PrivacyPlugin(analyticsId),
50
- });
40
+ trackPage: (pageName: string, properties?: Record<string, unknown>) => {
41
+ segment.page(pageName, properties);
51
42
  },
52
43
  };
53
44
  ```
@@ -121,7 +112,7 @@ console.log(controller.state.analyticsId); // '550e8400-e29b-41d4-a716-446655440
121
112
  ### 5. Track Page Views
122
113
 
123
114
  ```typescript
124
- controller.trackView('home', {
115
+ controller.trackPage('home', {
125
116
  referrer: 'google',
126
117
  campaign: 'summer-2024',
127
118
  });
@@ -202,54 +193,6 @@ const defaultState = getDefaultAnalyticsControllerState();
202
193
 
203
194
  **Analytics ID:** The `analyticsId` is a UUIDv4 string. If not provided in the `state` parameter, the controller automatically generates one on initialization. This ID is persisted in state and remains consistent across restarts. If you provide an `analyticsId` in the `state` parameter, it will be used instead (useful for migrations).
204
195
 
205
- ## Lifecycle Hooks
206
-
207
- ### `onSetupCompleted`
208
-
209
- The `onSetupCompleted` lifecycle hook is called once after the `AnalyticsController` is fully initialized. This hook allows platform-specific adapters to perform setup that requires access to the controller's state (e.g., `analyticsId`).
210
-
211
- **When it's called:**
212
-
213
- - After the controller is fully initialized
214
- - Only when `analyticsId` is set in controller state (the presence of `analyticsId` is the definition of "completed" setup)
215
- - The `analyticsId` parameter is guaranteed to be set and be a valid UUIDv4 when this method is called
216
-
217
- **What it's used for:**
218
-
219
- Platform-specific setup that requires access to adapter implementation like adding plugins or middleware that need the `analyticsId`
220
- Any initialization that depends on the controller being ready
221
-
222
- **Example usage:**
223
-
224
- ```typescript
225
- const platformAdapter: AnalyticsPlatformAdapter = {
226
- // ... other methods ...
227
- onSetupCompleted: (analyticsId: string) => {
228
- // Add platform-specific plugins that require analyticsId
229
- client.add({
230
- plugin: new PrivacyPlugin(analyticsId),
231
- });
232
- },
233
- };
234
- ```
235
-
236
- **Error handling:**
237
-
238
- - Errors thrown in `onSetupCompleted` are caught and logged
239
-
240
- **Best practices:**
241
-
242
- - Use `onSetupCompleted` for setup that requires controller state
243
- - Keep setup logic minimal and focused
244
- - Handle errors gracefully within the hook
245
- - If you don't need setup, provide a no-op implementation:
246
-
247
- ```typescript
248
- onSetupCompleted: (_analyticsId: string) => {
249
- // No-op: this adapter doesn't need setup
250
- },
251
- ```
252
-
253
196
  ## Debugging
254
197
 
255
198
  To display analytics-controller logs in the mobile app, you can add the following to your `.js.env` file:
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsController-method-action-types.cjs","sourceRoot":"","sources":["../src/AnalyticsController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { AnalyticsController } from './AnalyticsController';\n\n/**\n * Track an analytics event.\n *\n * Events are only tracked if analytics is enabled.\n *\n * @param event - Analytics event with properties and sensitive properties\n */\nexport type AnalyticsControllerTrackEventAction = {\n type: `AnalyticsController:trackEvent`;\n handler: AnalyticsController['trackEvent'];\n};\n\n/**\n * Identify a user for analytics.\n *\n * @param traits - User traits/properties\n */\nexport type AnalyticsControllerIdentifyAction = {\n type: `AnalyticsController:identify`;\n handler: AnalyticsController['identify'];\n};\n\n/**\n * Track a page view.\n *\n * @param name - The name of the UI item being viewed (pages for web, screen for mobile)\n * @param properties - UI item properties\n */\nexport type AnalyticsControllerTrackViewAction = {\n type: `AnalyticsController:trackView`;\n handler: AnalyticsController['trackView'];\n};\n\n/**\n * Opt in to analytics.\n * This updates the user's opt-in status.\n */\nexport type AnalyticsControllerOptInAction = {\n type: `AnalyticsController:optIn`;\n handler: AnalyticsController['optIn'];\n};\n\n/**\n * Opt out of analytics.\n * This updates the user's opt-in status.\n */\nexport type AnalyticsControllerOptOutAction = {\n type: `AnalyticsController:optOut`;\n handler: AnalyticsController['optOut'];\n};\n\n/**\n * Opt in to analytics through social account.\n * This updates the user's social opt-in status.\n */\nexport type AnalyticsControllerSocialOptInAction = {\n type: `AnalyticsController:socialOptIn`;\n handler: AnalyticsController['socialOptIn'];\n};\n\n/**\n * Opt out of analytics through social account.\n * This updates the user's social opt-in status.\n */\nexport type AnalyticsControllerSocialOptOutAction = {\n type: `AnalyticsController:socialOptOut`;\n handler: AnalyticsController['socialOptOut'];\n};\n\n/**\n * Get the analytics ID from the controller state.\n *\n * @returns The current analytics ID.\n */\nexport type AnalyticsControllerGetAnalyticsIdAction = {\n type: `AnalyticsController:getAnalyticsId`;\n handler: AnalyticsController['getAnalyticsId'];\n};\n\n/**\n * Get the enabled status from the controller state.\n * This is computed from user state via the state machine.\n *\n * @returns The current enabled status.\n */\nexport type AnalyticsControllerIsEnabledAction = {\n type: `AnalyticsController:isEnabled`;\n handler: AnalyticsController['isEnabled'];\n};\n\n/**\n * Get the opted in status from the controller state.\n *\n * @returns The current opted in status.\n */\nexport type AnalyticsControllerIsOptedInAction = {\n type: `AnalyticsController:isOptedIn`;\n handler: AnalyticsController['isOptedIn'];\n};\n\n/**\n * Get the social opted in status from the controller state.\n *\n * @returns The current social opted in status.\n */\nexport type AnalyticsControllerIsSocialOptedInAction = {\n type: `AnalyticsController:isSocialOptedIn`;\n handler: AnalyticsController['isSocialOptedIn'];\n};\n\n/**\n * Union of all AnalyticsController action types.\n */\nexport type AnalyticsControllerMethodActions =\n | AnalyticsControllerTrackEventAction\n | AnalyticsControllerIdentifyAction\n | AnalyticsControllerTrackViewAction\n | AnalyticsControllerOptInAction\n | AnalyticsControllerOptOutAction\n | AnalyticsControllerSocialOptInAction\n | AnalyticsControllerSocialOptOutAction\n | AnalyticsControllerGetAnalyticsIdAction\n | AnalyticsControllerIsEnabledAction\n | AnalyticsControllerIsOptedInAction\n | AnalyticsControllerIsSocialOptedInAction;\n"]}
1
+ {"version":3,"file":"AnalyticsController-method-action-types.cjs","sourceRoot":"","sources":["../src/AnalyticsController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { AnalyticsController } from './AnalyticsController';\n\n/**\n * Track an analytics event.\n *\n * Events are only tracked if analytics is enabled.\n *\n * @param eventName - The name of the event\n * @param properties - Event properties\n */\nexport type AnalyticsControllerTrackEventAction = {\n type: `AnalyticsController:trackEvent`;\n handler: AnalyticsController['trackEvent'];\n};\n\n/**\n * Identify a user for analytics.\n *\n * @param userId - The user identifier (e.g., metametrics ID)\n * @param traits - User traits/properties\n */\nexport type AnalyticsControllerIdentifyAction = {\n type: `AnalyticsController:identify`;\n handler: AnalyticsController['identify'];\n};\n\n/**\n * Track a page view.\n *\n * @param pageName - The name of the page\n * @param properties - Page properties\n */\nexport type AnalyticsControllerTrackPageAction = {\n type: `AnalyticsController:trackPage`;\n handler: AnalyticsController['trackPage'];\n};\n\n/**\n * Enable analytics tracking.\n */\nexport type AnalyticsControllerEnableAction = {\n type: `AnalyticsController:enable`;\n handler: AnalyticsController['enable'];\n};\n\n/**\n * Disable analytics tracking.\n */\nexport type AnalyticsControllerDisableAction = {\n type: `AnalyticsController:disable`;\n handler: AnalyticsController['disable'];\n};\n\n/**\n * Opt in to analytics.\n */\nexport type AnalyticsControllerOptInAction = {\n type: `AnalyticsController:optIn`;\n handler: AnalyticsController['optIn'];\n};\n\n/**\n * Opt out of analytics.\n */\nexport type AnalyticsControllerOptOutAction = {\n type: `AnalyticsController:optOut`;\n handler: AnalyticsController['optOut'];\n};\n\n/**\n * Union of all AnalyticsController action types.\n */\nexport type AnalyticsControllerMethodActions =\n | AnalyticsControllerTrackEventAction\n | AnalyticsControllerIdentifyAction\n | AnalyticsControllerTrackPageAction\n | AnalyticsControllerEnableAction\n | AnalyticsControllerDisableAction\n | AnalyticsControllerOptInAction\n | AnalyticsControllerOptOutAction;\n"]}
@@ -8,7 +8,8 @@ import type { AnalyticsController } from "./AnalyticsController.cjs";
8
8
  *
9
9
  * Events are only tracked if analytics is enabled.
10
10
  *
11
- * @param event - Analytics event with properties and sensitive properties
11
+ * @param eventName - The name of the event
12
+ * @param properties - Event properties
12
13
  */
13
14
  export type AnalyticsControllerTrackEventAction = {
14
15
  type: `AnalyticsController:trackEvent`;
@@ -17,6 +18,7 @@ export type AnalyticsControllerTrackEventAction = {
17
18
  /**
18
19
  * Identify a user for analytics.
19
20
  *
21
+ * @param userId - The user identifier (e.g., metametrics ID)
20
22
  * @param traits - User traits/properties
21
23
  */
22
24
  export type AnalyticsControllerIdentifyAction = {
@@ -26,16 +28,29 @@ export type AnalyticsControllerIdentifyAction = {
26
28
  /**
27
29
  * Track a page view.
28
30
  *
29
- * @param name - The name of the UI item being viewed (pages for web, screen for mobile)
30
- * @param properties - UI item properties
31
+ * @param pageName - The name of the page
32
+ * @param properties - Page properties
31
33
  */
32
- export type AnalyticsControllerTrackViewAction = {
33
- type: `AnalyticsController:trackView`;
34
- handler: AnalyticsController['trackView'];
34
+ export type AnalyticsControllerTrackPageAction = {
35
+ type: `AnalyticsController:trackPage`;
36
+ handler: AnalyticsController['trackPage'];
37
+ };
38
+ /**
39
+ * Enable analytics tracking.
40
+ */
41
+ export type AnalyticsControllerEnableAction = {
42
+ type: `AnalyticsController:enable`;
43
+ handler: AnalyticsController['enable'];
44
+ };
45
+ /**
46
+ * Disable analytics tracking.
47
+ */
48
+ export type AnalyticsControllerDisableAction = {
49
+ type: `AnalyticsController:disable`;
50
+ handler: AnalyticsController['disable'];
35
51
  };
36
52
  /**
37
53
  * Opt in to analytics.
38
- * This updates the user's opt-in status.
39
54
  */
40
55
  export type AnalyticsControllerOptInAction = {
41
56
  type: `AnalyticsController:optIn`;
@@ -43,67 +58,13 @@ export type AnalyticsControllerOptInAction = {
43
58
  };
44
59
  /**
45
60
  * Opt out of analytics.
46
- * This updates the user's opt-in status.
47
61
  */
48
62
  export type AnalyticsControllerOptOutAction = {
49
63
  type: `AnalyticsController:optOut`;
50
64
  handler: AnalyticsController['optOut'];
51
65
  };
52
- /**
53
- * Opt in to analytics through social account.
54
- * This updates the user's social opt-in status.
55
- */
56
- export type AnalyticsControllerSocialOptInAction = {
57
- type: `AnalyticsController:socialOptIn`;
58
- handler: AnalyticsController['socialOptIn'];
59
- };
60
- /**
61
- * Opt out of analytics through social account.
62
- * This updates the user's social opt-in status.
63
- */
64
- export type AnalyticsControllerSocialOptOutAction = {
65
- type: `AnalyticsController:socialOptOut`;
66
- handler: AnalyticsController['socialOptOut'];
67
- };
68
- /**
69
- * Get the analytics ID from the controller state.
70
- *
71
- * @returns The current analytics ID.
72
- */
73
- export type AnalyticsControllerGetAnalyticsIdAction = {
74
- type: `AnalyticsController:getAnalyticsId`;
75
- handler: AnalyticsController['getAnalyticsId'];
76
- };
77
- /**
78
- * Get the enabled status from the controller state.
79
- * This is computed from user state via the state machine.
80
- *
81
- * @returns The current enabled status.
82
- */
83
- export type AnalyticsControllerIsEnabledAction = {
84
- type: `AnalyticsController:isEnabled`;
85
- handler: AnalyticsController['isEnabled'];
86
- };
87
- /**
88
- * Get the opted in status from the controller state.
89
- *
90
- * @returns The current opted in status.
91
- */
92
- export type AnalyticsControllerIsOptedInAction = {
93
- type: `AnalyticsController:isOptedIn`;
94
- handler: AnalyticsController['isOptedIn'];
95
- };
96
- /**
97
- * Get the social opted in status from the controller state.
98
- *
99
- * @returns The current social opted in status.
100
- */
101
- export type AnalyticsControllerIsSocialOptedInAction = {
102
- type: `AnalyticsController:isSocialOptedIn`;
103
- handler: AnalyticsController['isSocialOptedIn'];
104
- };
105
66
  /**
106
67
  * Union of all AnalyticsController action types.
107
68
  */
108
- export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackViewAction | AnalyticsControllerOptInAction | AnalyticsControllerOptOutAction | AnalyticsControllerSocialOptInAction | AnalyticsControllerSocialOptOutAction | AnalyticsControllerGetAnalyticsIdAction | AnalyticsControllerIsEnabledAction | AnalyticsControllerIsOptedInAction | AnalyticsControllerIsSocialOptedInAction;
69
+ export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackPageAction | AnalyticsControllerEnableAction | AnalyticsControllerDisableAction | AnalyticsControllerOptInAction | AnalyticsControllerOptOutAction;
109
70
  //# sourceMappingURL=AnalyticsController-method-action-types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsController-method-action-types.d.cts","sourceRoot":"","sources":["../src/AnalyticsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAA8B;AAEjE;;;;;;GAMG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CAC3C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;CACvC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACxC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;CAC7C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,mCAAmC,GACnC,iCAAiC,GACjC,kCAAkC,GAClC,8BAA8B,GAC9B,+BAA+B,GAC/B,oCAAoC,GACpC,qCAAqC,GACrC,uCAAuC,GACvC,kCAAkC,GAClC,kCAAkC,GAClC,wCAAwC,CAAC"}
1
+ {"version":3,"file":"AnalyticsController-method-action-types.d.cts","sourceRoot":"","sources":["../src/AnalyticsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAA8B;AAEjE;;;;;;;GAOG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,mCAAmC,GACnC,iCAAiC,GACjC,kCAAkC,GAClC,+BAA+B,GAC/B,gCAAgC,GAChC,8BAA8B,GAC9B,+BAA+B,CAAC"}
@@ -8,7 +8,8 @@ import type { AnalyticsController } from "./AnalyticsController.mjs";
8
8
  *
9
9
  * Events are only tracked if analytics is enabled.
10
10
  *
11
- * @param event - Analytics event with properties and sensitive properties
11
+ * @param eventName - The name of the event
12
+ * @param properties - Event properties
12
13
  */
13
14
  export type AnalyticsControllerTrackEventAction = {
14
15
  type: `AnalyticsController:trackEvent`;
@@ -17,6 +18,7 @@ export type AnalyticsControllerTrackEventAction = {
17
18
  /**
18
19
  * Identify a user for analytics.
19
20
  *
21
+ * @param userId - The user identifier (e.g., metametrics ID)
20
22
  * @param traits - User traits/properties
21
23
  */
22
24
  export type AnalyticsControllerIdentifyAction = {
@@ -26,16 +28,29 @@ export type AnalyticsControllerIdentifyAction = {
26
28
  /**
27
29
  * Track a page view.
28
30
  *
29
- * @param name - The name of the UI item being viewed (pages for web, screen for mobile)
30
- * @param properties - UI item properties
31
+ * @param pageName - The name of the page
32
+ * @param properties - Page properties
31
33
  */
32
- export type AnalyticsControllerTrackViewAction = {
33
- type: `AnalyticsController:trackView`;
34
- handler: AnalyticsController['trackView'];
34
+ export type AnalyticsControllerTrackPageAction = {
35
+ type: `AnalyticsController:trackPage`;
36
+ handler: AnalyticsController['trackPage'];
37
+ };
38
+ /**
39
+ * Enable analytics tracking.
40
+ */
41
+ export type AnalyticsControllerEnableAction = {
42
+ type: `AnalyticsController:enable`;
43
+ handler: AnalyticsController['enable'];
44
+ };
45
+ /**
46
+ * Disable analytics tracking.
47
+ */
48
+ export type AnalyticsControllerDisableAction = {
49
+ type: `AnalyticsController:disable`;
50
+ handler: AnalyticsController['disable'];
35
51
  };
36
52
  /**
37
53
  * Opt in to analytics.
38
- * This updates the user's opt-in status.
39
54
  */
40
55
  export type AnalyticsControllerOptInAction = {
41
56
  type: `AnalyticsController:optIn`;
@@ -43,67 +58,13 @@ export type AnalyticsControllerOptInAction = {
43
58
  };
44
59
  /**
45
60
  * Opt out of analytics.
46
- * This updates the user's opt-in status.
47
61
  */
48
62
  export type AnalyticsControllerOptOutAction = {
49
63
  type: `AnalyticsController:optOut`;
50
64
  handler: AnalyticsController['optOut'];
51
65
  };
52
- /**
53
- * Opt in to analytics through social account.
54
- * This updates the user's social opt-in status.
55
- */
56
- export type AnalyticsControllerSocialOptInAction = {
57
- type: `AnalyticsController:socialOptIn`;
58
- handler: AnalyticsController['socialOptIn'];
59
- };
60
- /**
61
- * Opt out of analytics through social account.
62
- * This updates the user's social opt-in status.
63
- */
64
- export type AnalyticsControllerSocialOptOutAction = {
65
- type: `AnalyticsController:socialOptOut`;
66
- handler: AnalyticsController['socialOptOut'];
67
- };
68
- /**
69
- * Get the analytics ID from the controller state.
70
- *
71
- * @returns The current analytics ID.
72
- */
73
- export type AnalyticsControllerGetAnalyticsIdAction = {
74
- type: `AnalyticsController:getAnalyticsId`;
75
- handler: AnalyticsController['getAnalyticsId'];
76
- };
77
- /**
78
- * Get the enabled status from the controller state.
79
- * This is computed from user state via the state machine.
80
- *
81
- * @returns The current enabled status.
82
- */
83
- export type AnalyticsControllerIsEnabledAction = {
84
- type: `AnalyticsController:isEnabled`;
85
- handler: AnalyticsController['isEnabled'];
86
- };
87
- /**
88
- * Get the opted in status from the controller state.
89
- *
90
- * @returns The current opted in status.
91
- */
92
- export type AnalyticsControllerIsOptedInAction = {
93
- type: `AnalyticsController:isOptedIn`;
94
- handler: AnalyticsController['isOptedIn'];
95
- };
96
- /**
97
- * Get the social opted in status from the controller state.
98
- *
99
- * @returns The current social opted in status.
100
- */
101
- export type AnalyticsControllerIsSocialOptedInAction = {
102
- type: `AnalyticsController:isSocialOptedIn`;
103
- handler: AnalyticsController['isSocialOptedIn'];
104
- };
105
66
  /**
106
67
  * Union of all AnalyticsController action types.
107
68
  */
108
- export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackViewAction | AnalyticsControllerOptInAction | AnalyticsControllerOptOutAction | AnalyticsControllerSocialOptInAction | AnalyticsControllerSocialOptOutAction | AnalyticsControllerGetAnalyticsIdAction | AnalyticsControllerIsEnabledAction | AnalyticsControllerIsOptedInAction | AnalyticsControllerIsSocialOptedInAction;
69
+ export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackPageAction | AnalyticsControllerEnableAction | AnalyticsControllerDisableAction | AnalyticsControllerOptInAction | AnalyticsControllerOptOutAction;
109
70
  //# sourceMappingURL=AnalyticsController-method-action-types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsController-method-action-types.d.mts","sourceRoot":"","sources":["../src/AnalyticsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAA8B;AAEjE;;;;;;GAMG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CAC3C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;CACvC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACxC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;CAC7C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,mCAAmC,GACnC,iCAAiC,GACjC,kCAAkC,GAClC,8BAA8B,GAC9B,+BAA+B,GAC/B,oCAAoC,GACpC,qCAAqC,GACrC,uCAAuC,GACvC,kCAAkC,GAClC,kCAAkC,GAClC,wCAAwC,CAAC"}
1
+ {"version":3,"file":"AnalyticsController-method-action-types.d.mts","sourceRoot":"","sources":["../src/AnalyticsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAA8B;AAEjE;;;;;;;GAOG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,mCAAmC,GACnC,iCAAiC,GACjC,kCAAkC,GAClC,+BAA+B,GAC/B,gCAAgC,GAChC,8BAA8B,GAC9B,+BAA+B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsController-method-action-types.mjs","sourceRoot":"","sources":["../src/AnalyticsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { AnalyticsController } from './AnalyticsController';\n\n/**\n * Track an analytics event.\n *\n * Events are only tracked if analytics is enabled.\n *\n * @param event - Analytics event with properties and sensitive properties\n */\nexport type AnalyticsControllerTrackEventAction = {\n type: `AnalyticsController:trackEvent`;\n handler: AnalyticsController['trackEvent'];\n};\n\n/**\n * Identify a user for analytics.\n *\n * @param traits - User traits/properties\n */\nexport type AnalyticsControllerIdentifyAction = {\n type: `AnalyticsController:identify`;\n handler: AnalyticsController['identify'];\n};\n\n/**\n * Track a page view.\n *\n * @param name - The name of the UI item being viewed (pages for web, screen for mobile)\n * @param properties - UI item properties\n */\nexport type AnalyticsControllerTrackViewAction = {\n type: `AnalyticsController:trackView`;\n handler: AnalyticsController['trackView'];\n};\n\n/**\n * Opt in to analytics.\n * This updates the user's opt-in status.\n */\nexport type AnalyticsControllerOptInAction = {\n type: `AnalyticsController:optIn`;\n handler: AnalyticsController['optIn'];\n};\n\n/**\n * Opt out of analytics.\n * This updates the user's opt-in status.\n */\nexport type AnalyticsControllerOptOutAction = {\n type: `AnalyticsController:optOut`;\n handler: AnalyticsController['optOut'];\n};\n\n/**\n * Opt in to analytics through social account.\n * This updates the user's social opt-in status.\n */\nexport type AnalyticsControllerSocialOptInAction = {\n type: `AnalyticsController:socialOptIn`;\n handler: AnalyticsController['socialOptIn'];\n};\n\n/**\n * Opt out of analytics through social account.\n * This updates the user's social opt-in status.\n */\nexport type AnalyticsControllerSocialOptOutAction = {\n type: `AnalyticsController:socialOptOut`;\n handler: AnalyticsController['socialOptOut'];\n};\n\n/**\n * Get the analytics ID from the controller state.\n *\n * @returns The current analytics ID.\n */\nexport type AnalyticsControllerGetAnalyticsIdAction = {\n type: `AnalyticsController:getAnalyticsId`;\n handler: AnalyticsController['getAnalyticsId'];\n};\n\n/**\n * Get the enabled status from the controller state.\n * This is computed from user state via the state machine.\n *\n * @returns The current enabled status.\n */\nexport type AnalyticsControllerIsEnabledAction = {\n type: `AnalyticsController:isEnabled`;\n handler: AnalyticsController['isEnabled'];\n};\n\n/**\n * Get the opted in status from the controller state.\n *\n * @returns The current opted in status.\n */\nexport type AnalyticsControllerIsOptedInAction = {\n type: `AnalyticsController:isOptedIn`;\n handler: AnalyticsController['isOptedIn'];\n};\n\n/**\n * Get the social opted in status from the controller state.\n *\n * @returns The current social opted in status.\n */\nexport type AnalyticsControllerIsSocialOptedInAction = {\n type: `AnalyticsController:isSocialOptedIn`;\n handler: AnalyticsController['isSocialOptedIn'];\n};\n\n/**\n * Union of all AnalyticsController action types.\n */\nexport type AnalyticsControllerMethodActions =\n | AnalyticsControllerTrackEventAction\n | AnalyticsControllerIdentifyAction\n | AnalyticsControllerTrackViewAction\n | AnalyticsControllerOptInAction\n | AnalyticsControllerOptOutAction\n | AnalyticsControllerSocialOptInAction\n | AnalyticsControllerSocialOptOutAction\n | AnalyticsControllerGetAnalyticsIdAction\n | AnalyticsControllerIsEnabledAction\n | AnalyticsControllerIsOptedInAction\n | AnalyticsControllerIsSocialOptedInAction;\n"]}
1
+ {"version":3,"file":"AnalyticsController-method-action-types.mjs","sourceRoot":"","sources":["../src/AnalyticsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { AnalyticsController } from './AnalyticsController';\n\n/**\n * Track an analytics event.\n *\n * Events are only tracked if analytics is enabled.\n *\n * @param eventName - The name of the event\n * @param properties - Event properties\n */\nexport type AnalyticsControllerTrackEventAction = {\n type: `AnalyticsController:trackEvent`;\n handler: AnalyticsController['trackEvent'];\n};\n\n/**\n * Identify a user for analytics.\n *\n * @param userId - The user identifier (e.g., metametrics ID)\n * @param traits - User traits/properties\n */\nexport type AnalyticsControllerIdentifyAction = {\n type: `AnalyticsController:identify`;\n handler: AnalyticsController['identify'];\n};\n\n/**\n * Track a page view.\n *\n * @param pageName - The name of the page\n * @param properties - Page properties\n */\nexport type AnalyticsControllerTrackPageAction = {\n type: `AnalyticsController:trackPage`;\n handler: AnalyticsController['trackPage'];\n};\n\n/**\n * Enable analytics tracking.\n */\nexport type AnalyticsControllerEnableAction = {\n type: `AnalyticsController:enable`;\n handler: AnalyticsController['enable'];\n};\n\n/**\n * Disable analytics tracking.\n */\nexport type AnalyticsControllerDisableAction = {\n type: `AnalyticsController:disable`;\n handler: AnalyticsController['disable'];\n};\n\n/**\n * Opt in to analytics.\n */\nexport type AnalyticsControllerOptInAction = {\n type: `AnalyticsController:optIn`;\n handler: AnalyticsController['optIn'];\n};\n\n/**\n * Opt out of analytics.\n */\nexport type AnalyticsControllerOptOutAction = {\n type: `AnalyticsController:optOut`;\n handler: AnalyticsController['optOut'];\n};\n\n/**\n * Union of all AnalyticsController action types.\n */\nexport type AnalyticsControllerMethodActions =\n | AnalyticsControllerTrackEventAction\n | AnalyticsControllerIdentifyAction\n | AnalyticsControllerTrackPageAction\n | AnalyticsControllerEnableAction\n | AnalyticsControllerDisableAction\n | AnalyticsControllerOptInAction\n | AnalyticsControllerOptOutAction;\n"]}