@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.
- package/README.md +4 -61
- package/dist/AnalyticsController-method-action-types.cjs.map +1 -1
- package/dist/AnalyticsController-method-action-types.d.cts +23 -62
- package/dist/AnalyticsController-method-action-types.d.cts.map +1 -1
- package/dist/AnalyticsController-method-action-types.d.mts +23 -62
- 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 +52 -125
- package/dist/AnalyticsController.cjs.map +1 -1
- package/dist/AnalyticsController.d.cts +24 -52
- package/dist/AnalyticsController.d.cts.map +1 -1
- package/dist/AnalyticsController.d.mts +24 -52
- package/dist/AnalyticsController.d.mts.map +1 -1
- package/dist/AnalyticsController.mjs +53 -126
- package/dist/AnalyticsController.mjs.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.cjs.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.d.cts +13 -69
- package/dist/AnalyticsPlatformAdapter.types.d.cts.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.d.mts +13 -69
- package/dist/AnalyticsPlatformAdapter.types.d.mts.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.mjs.map +1 -1
- package/dist/index.cjs +1 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/AnalyticsPlatformAdapterSetupError.cjs +0 -17
- package/dist/AnalyticsPlatformAdapterSetupError.cjs.map +0 -1
- package/dist/AnalyticsPlatformAdapterSetupError.d.cts +0 -8
- 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 +0 -13
- package/dist/AnalyticsPlatformAdapterSetupError.mjs.map +0 -1
- package/dist/analyticsStateComputer.cjs +0 -46
- package/dist/analyticsStateComputer.cjs.map +0 -1
- package/dist/analyticsStateComputer.d.cts +0 -35
- package/dist/analyticsStateComputer.d.cts.map +0 -1
- package/dist/analyticsStateComputer.d.mts +0 -35
- package/dist/analyticsStateComputer.d.mts.map +0 -1
- package/dist/analyticsStateComputer.mjs +0 -42
- 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
|
-
|
|
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
|
-
|
|
41
|
-
segment.page(
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
30
|
-
* @param properties -
|
|
31
|
+
* @param pageName - The name of the page
|
|
32
|
+
* @param properties - Page properties
|
|
31
33
|
*/
|
|
32
|
-
export type
|
|
33
|
-
type: `AnalyticsController:
|
|
34
|
-
handler: AnalyticsController['
|
|
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 |
|
|
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
|
|
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
|
|
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
|
|
30
|
-
* @param properties -
|
|
31
|
+
* @param pageName - The name of the page
|
|
32
|
+
* @param properties - Page properties
|
|
31
33
|
*/
|
|
32
|
-
export type
|
|
33
|
-
type: `AnalyticsController:
|
|
34
|
-
handler: AnalyticsController['
|
|
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 |
|
|
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
|
|
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
|
|
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"]}
|