@metamask-previews/analytics-controller 0.0.0-preview-8647bc1c → 0.0.0-preview-704ae19a
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/README.md +61 -4
- package/dist/AnalyticsController-method-action-types.cjs.map +1 -1
- package/dist/AnalyticsController-method-action-types.d.cts +62 -23
- package/dist/AnalyticsController-method-action-types.d.cts.map +1 -1
- package/dist/AnalyticsController-method-action-types.d.mts +62 -23
- package/dist/AnalyticsController-method-action-types.d.mts.map +1 -1
- package/dist/AnalyticsController-method-action-types.mjs.map +1 -1
- package/dist/AnalyticsController.cjs +125 -52
- package/dist/AnalyticsController.cjs.map +1 -1
- package/dist/AnalyticsController.d.cts +52 -24
- package/dist/AnalyticsController.d.cts.map +1 -1
- package/dist/AnalyticsController.d.mts +52 -24
- package/dist/AnalyticsController.d.mts.map +1 -1
- package/dist/AnalyticsController.mjs +126 -53
- package/dist/AnalyticsController.mjs.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.cjs.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.d.cts +69 -13
- package/dist/AnalyticsPlatformAdapter.types.d.cts.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.d.mts +69 -13
- package/dist/AnalyticsPlatformAdapter.types.d.mts.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.mjs.map +1 -1
- package/dist/AnalyticsPlatformAdapterSetupError.cjs +17 -0
- package/dist/AnalyticsPlatformAdapterSetupError.cjs.map +1 -0
- package/dist/AnalyticsPlatformAdapterSetupError.d.cts +8 -0
- package/dist/AnalyticsPlatformAdapterSetupError.d.cts.map +1 -0
- package/dist/AnalyticsPlatformAdapterSetupError.d.mts +8 -0
- package/dist/AnalyticsPlatformAdapterSetupError.d.mts.map +1 -0
- package/dist/AnalyticsPlatformAdapterSetupError.mjs +13 -0
- package/dist/AnalyticsPlatformAdapterSetupError.mjs.map +1 -0
- package/dist/analyticsStateComputer.cjs +46 -0
- package/dist/analyticsStateComputer.cjs.map +1 -0
- package/dist/analyticsStateComputer.d.cts +35 -0
- package/dist/analyticsStateComputer.d.cts.map +1 -0
- package/dist/analyticsStateComputer.d.mts +35 -0
- package/dist/analyticsStateComputer.d.mts.map +1 -0
- package/dist/analyticsStateComputer.mjs +42 -0
- package/dist/analyticsStateComputer.mjs.map +1 -0
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,15 +30,24 @@ 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
|
-
|
|
33
|
+
track: (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
|
-
|
|
41
|
-
segment.page(
|
|
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
|
+
});
|
|
42
51
|
},
|
|
43
52
|
};
|
|
44
53
|
```
|
|
@@ -112,7 +121,7 @@ console.log(controller.state.analyticsId); // '550e8400-e29b-41d4-a716-446655440
|
|
|
112
121
|
### 5. Track Page Views
|
|
113
122
|
|
|
114
123
|
```typescript
|
|
115
|
-
controller.
|
|
124
|
+
controller.trackView('home', {
|
|
116
125
|
referrer: 'google',
|
|
117
126
|
campaign: 'summer-2024',
|
|
118
127
|
});
|
|
@@ -193,6 +202,54 @@ const defaultState = getDefaultAnalyticsControllerState();
|
|
|
193
202
|
|
|
194
203
|
**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).
|
|
195
204
|
|
|
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
|
+
|
|
196
253
|
## Debugging
|
|
197
254
|
|
|
198
255
|
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
|
|
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"]}
|
|
@@ -8,8 +8,7 @@ import type { AnalyticsController } from "./AnalyticsController.cjs";
|
|
|
8
8
|
*
|
|
9
9
|
* Events are only tracked if analytics is enabled.
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
12
|
-
* @param properties - Event properties
|
|
11
|
+
* @param event - Analytics event with properties and sensitive properties
|
|
13
12
|
*/
|
|
14
13
|
export type AnalyticsControllerTrackEventAction = {
|
|
15
14
|
type: `AnalyticsController:trackEvent`;
|
|
@@ -18,7 +17,6 @@ export type AnalyticsControllerTrackEventAction = {
|
|
|
18
17
|
/**
|
|
19
18
|
* Identify a user for analytics.
|
|
20
19
|
*
|
|
21
|
-
* @param userId - The user identifier (e.g., metametrics ID)
|
|
22
20
|
* @param traits - User traits/properties
|
|
23
21
|
*/
|
|
24
22
|
export type AnalyticsControllerIdentifyAction = {
|
|
@@ -28,29 +26,16 @@ export type AnalyticsControllerIdentifyAction = {
|
|
|
28
26
|
/**
|
|
29
27
|
* Track a page view.
|
|
30
28
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @param properties -
|
|
29
|
+
* @param name - The name of the UI item being viewed (pages for web, screen for mobile)
|
|
30
|
+
* @param properties - UI item properties
|
|
33
31
|
*/
|
|
34
|
-
export type
|
|
35
|
-
type: `AnalyticsController:
|
|
36
|
-
handler: AnalyticsController['
|
|
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'];
|
|
32
|
+
export type AnalyticsControllerTrackViewAction = {
|
|
33
|
+
type: `AnalyticsController:trackView`;
|
|
34
|
+
handler: AnalyticsController['trackView'];
|
|
51
35
|
};
|
|
52
36
|
/**
|
|
53
37
|
* Opt in to analytics.
|
|
38
|
+
* This updates the user's opt-in status.
|
|
54
39
|
*/
|
|
55
40
|
export type AnalyticsControllerOptInAction = {
|
|
56
41
|
type: `AnalyticsController:optIn`;
|
|
@@ -58,13 +43,67 @@ export type AnalyticsControllerOptInAction = {
|
|
|
58
43
|
};
|
|
59
44
|
/**
|
|
60
45
|
* Opt out of analytics.
|
|
46
|
+
* This updates the user's opt-in status.
|
|
61
47
|
*/
|
|
62
48
|
export type AnalyticsControllerOptOutAction = {
|
|
63
49
|
type: `AnalyticsController:optOut`;
|
|
64
50
|
handler: AnalyticsController['optOut'];
|
|
65
51
|
};
|
|
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
|
+
};
|
|
66
105
|
/**
|
|
67
106
|
* Union of all AnalyticsController action types.
|
|
68
107
|
*/
|
|
69
|
-
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction |
|
|
108
|
+
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackViewAction | AnalyticsControllerOptInAction | AnalyticsControllerOptOutAction | AnalyticsControllerSocialOptInAction | AnalyticsControllerSocialOptOutAction | AnalyticsControllerGetAnalyticsIdAction | AnalyticsControllerIsEnabledAction | AnalyticsControllerIsOptedInAction | AnalyticsControllerIsSocialOptedInAction;
|
|
70
109
|
//# 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
|
|
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"}
|
|
@@ -8,8 +8,7 @@ import type { AnalyticsController } from "./AnalyticsController.mjs";
|
|
|
8
8
|
*
|
|
9
9
|
* Events are only tracked if analytics is enabled.
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
12
|
-
* @param properties - Event properties
|
|
11
|
+
* @param event - Analytics event with properties and sensitive properties
|
|
13
12
|
*/
|
|
14
13
|
export type AnalyticsControllerTrackEventAction = {
|
|
15
14
|
type: `AnalyticsController:trackEvent`;
|
|
@@ -18,7 +17,6 @@ export type AnalyticsControllerTrackEventAction = {
|
|
|
18
17
|
/**
|
|
19
18
|
* Identify a user for analytics.
|
|
20
19
|
*
|
|
21
|
-
* @param userId - The user identifier (e.g., metametrics ID)
|
|
22
20
|
* @param traits - User traits/properties
|
|
23
21
|
*/
|
|
24
22
|
export type AnalyticsControllerIdentifyAction = {
|
|
@@ -28,29 +26,16 @@ export type AnalyticsControllerIdentifyAction = {
|
|
|
28
26
|
/**
|
|
29
27
|
* Track a page view.
|
|
30
28
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @param properties -
|
|
29
|
+
* @param name - The name of the UI item being viewed (pages for web, screen for mobile)
|
|
30
|
+
* @param properties - UI item properties
|
|
33
31
|
*/
|
|
34
|
-
export type
|
|
35
|
-
type: `AnalyticsController:
|
|
36
|
-
handler: AnalyticsController['
|
|
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'];
|
|
32
|
+
export type AnalyticsControllerTrackViewAction = {
|
|
33
|
+
type: `AnalyticsController:trackView`;
|
|
34
|
+
handler: AnalyticsController['trackView'];
|
|
51
35
|
};
|
|
52
36
|
/**
|
|
53
37
|
* Opt in to analytics.
|
|
38
|
+
* This updates the user's opt-in status.
|
|
54
39
|
*/
|
|
55
40
|
export type AnalyticsControllerOptInAction = {
|
|
56
41
|
type: `AnalyticsController:optIn`;
|
|
@@ -58,13 +43,67 @@ export type AnalyticsControllerOptInAction = {
|
|
|
58
43
|
};
|
|
59
44
|
/**
|
|
60
45
|
* Opt out of analytics.
|
|
46
|
+
* This updates the user's opt-in status.
|
|
61
47
|
*/
|
|
62
48
|
export type AnalyticsControllerOptOutAction = {
|
|
63
49
|
type: `AnalyticsController:optOut`;
|
|
64
50
|
handler: AnalyticsController['optOut'];
|
|
65
51
|
};
|
|
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
|
+
};
|
|
66
105
|
/**
|
|
67
106
|
* Union of all AnalyticsController action types.
|
|
68
107
|
*/
|
|
69
|
-
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction |
|
|
108
|
+
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackViewAction | AnalyticsControllerOptInAction | AnalyticsControllerOptOutAction | AnalyticsControllerSocialOptInAction | AnalyticsControllerSocialOptOutAction | AnalyticsControllerGetAnalyticsIdAction | AnalyticsControllerIsEnabledAction | AnalyticsControllerIsOptedInAction | AnalyticsControllerIsSocialOptedInAction;
|
|
70
109
|
//# 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
|
|
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 +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
|
|
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"]}
|