@metamask-previews/analytics-controller 0.0.0-preview-cb4a07d5 → 0.0.0-preview-565dfca2
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 +174 -30
- package/dist/AnalyticsController-method-action-types.cjs.map +1 -1
- package/dist/AnalyticsController-method-action-types.d.cts +24 -8
- package/dist/AnalyticsController-method-action-types.d.cts.map +1 -1
- package/dist/AnalyticsController-method-action-types.d.mts +24 -8
- 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 +78 -102
- package/dist/AnalyticsController.cjs.map +1 -1
- package/dist/AnalyticsController.d.cts +34 -48
- package/dist/AnalyticsController.d.cts.map +1 -1
- package/dist/AnalyticsController.d.mts +34 -48
- package/dist/AnalyticsController.d.mts.map +1 -1
- package/dist/AnalyticsController.mjs +79 -103
- package/dist/AnalyticsController.mjs.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.cjs.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.d.cts +15 -63
- package/dist/AnalyticsPlatformAdapter.types.d.cts.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.d.mts +15 -63
- package/dist/AnalyticsPlatformAdapter.types.d.mts.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.mjs.map +1 -1
- package/dist/index.cjs +4 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +5 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- 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/analyticsControllerStateValidator.cjs +0 -34
- package/dist/analyticsControllerStateValidator.cjs.map +0 -1
- package/dist/analyticsControllerStateValidator.d.cts +0 -16
- package/dist/analyticsControllerStateValidator.d.cts.map +0 -1
- package/dist/analyticsControllerStateValidator.d.mts +0 -16
- package/dist/analyticsControllerStateValidator.d.mts.map +0 -1
- package/dist/analyticsControllerStateValidator.mjs +0 -29
- package/dist/analyticsControllerStateValidator.mjs.map +0 -1
- package/dist/selectors.cjs +0 -36
- package/dist/selectors.cjs.map +0 -1
- package/dist/selectors.d.cts +0 -11
- package/dist/selectors.d.cts.map +0 -1
- package/dist/selectors.d.mts +0 -11
- package/dist/selectors.d.mts.map +0 -1
- package/dist/selectors.mjs +0 -33
- package/dist/selectors.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# `@metamask/analytics-controller`
|
|
2
2
|
|
|
3
|
-
Common Analytics controller for event tracking
|
|
3
|
+
Common Analytics controller for event tracking.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Provides a unified interface for:
|
|
8
|
+
- Tracking analytics events
|
|
9
|
+
- Identifying users
|
|
10
|
+
- Managing analytics preferences (enable/disable, opt-in/opt-out)
|
|
11
|
+
- Delegates platform-specific implementation to `AnalyticsPlatformAdapter`
|
|
12
|
+
- Integrates with the MetaMask messenger system for inter-controller communication
|
|
13
|
+
- Supports state persistence and migrations
|
|
4
14
|
|
|
5
15
|
## Installation
|
|
6
16
|
|
|
@@ -10,54 +20,188 @@ or
|
|
|
10
20
|
|
|
11
21
|
`npm install @metamask/analytics-controller`
|
|
12
22
|
|
|
13
|
-
##
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### 1. Create a Platform Adapter
|
|
26
|
+
|
|
27
|
+
The controller delegates platform-specific analytics implementation to a `AnalyticsPlatformAdapter`. You must provide an adapter that implements the required methods:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import type { AnalyticsPlatformAdapter } from '@metamask/analytics-controller';
|
|
31
|
+
|
|
32
|
+
const platformAdapter: AnalyticsPlatformAdapter = {
|
|
33
|
+
trackEvent: (eventName: string, properties: Record<string, unknown>) => {
|
|
34
|
+
// Platform-specific implementation (e.g., Segment, Mixpanel, etc.)
|
|
35
|
+
segment.track(eventName, properties);
|
|
36
|
+
},
|
|
37
|
+
identify: (userId: string, traits?: Record<string, unknown>) => {
|
|
38
|
+
segment.identify(userId, traits);
|
|
39
|
+
},
|
|
40
|
+
trackPage: (pageName: string, properties?: Record<string, unknown>) => {
|
|
41
|
+
segment.page(pageName, properties);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Initialize the Controller
|
|
47
|
+
|
|
48
|
+
#### Basic Initialization (Uses Defaults)
|
|
49
|
+
|
|
50
|
+
The controller uses default state values when no `state` parameter is provided:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { AnalyticsController } from '@metamask/analytics-controller';
|
|
54
|
+
import { Messenger } from '@metamask/messenger';
|
|
55
|
+
|
|
56
|
+
const messenger = new Messenger({ namespace: 'AnalyticsController' });
|
|
57
|
+
|
|
58
|
+
const controller = new AnalyticsController({
|
|
59
|
+
messenger,
|
|
60
|
+
platformAdapter,
|
|
61
|
+
// State defaults to:
|
|
62
|
+
// - enabled: true
|
|
63
|
+
// - optedIn: false
|
|
64
|
+
// - analyticsId: auto-generated UUIDv4 (if not provided)
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### Custom Initial State
|
|
69
|
+
|
|
70
|
+
You can provide partial state to override defaults:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
const controller = new AnalyticsController({
|
|
74
|
+
messenger,
|
|
75
|
+
platformAdapter,
|
|
76
|
+
state: {
|
|
77
|
+
enabled: false, // Override default (true)
|
|
78
|
+
optedIn: true, // Override default (false)
|
|
79
|
+
analyticsId: '550e8400-e29b-41d4-a716-446655440000', // Override default
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Important:** The `state` parameter is the single source of truth for initial values. Any properties you provide will override the defaults from `getDefaultAnalyticsControllerState()`.
|
|
85
|
+
|
|
86
|
+
### 3. Track Events
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// Track a simple event
|
|
90
|
+
controller.trackEvent('wallet_connected', {
|
|
91
|
+
network: 'ethereum',
|
|
92
|
+
account_type: 'hd',
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Events are automatically filtered when analytics is disabled
|
|
96
|
+
controller.disable();
|
|
97
|
+
controller.trackEvent('some_event'); // This will not be tracked
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 4. Identify Users
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
controller.identify('550e8400-e29b-41d4-a716-446655440000', {
|
|
104
|
+
email: 'user@example.com',
|
|
105
|
+
plan: 'premium',
|
|
106
|
+
});
|
|
14
107
|
|
|
15
|
-
The
|
|
108
|
+
// The analytics ID is automatically stored in controller state
|
|
109
|
+
console.log(controller.state.analyticsId); // '550e8400-e29b-41d4-a716-446655440000'
|
|
110
|
+
```
|
|
16
111
|
|
|
17
|
-
|
|
112
|
+
### 5. Track Page Views
|
|
18
113
|
|
|
19
|
-
|
|
20
|
-
|
|
114
|
+
```typescript
|
|
115
|
+
controller.trackPage('home', {
|
|
116
|
+
referrer: 'google',
|
|
117
|
+
campaign: 'summer-2024',
|
|
118
|
+
});
|
|
119
|
+
```
|
|
21
120
|
|
|
22
|
-
|
|
121
|
+
### 6. Manage Analytics State
|
|
23
122
|
|
|
24
|
-
|
|
25
|
-
|
|
123
|
+
```typescript
|
|
124
|
+
// Enable/disable analytics
|
|
125
|
+
controller.enable();
|
|
126
|
+
controller.disable();
|
|
127
|
+
|
|
128
|
+
// Opt in/out
|
|
129
|
+
controller.optIn();
|
|
130
|
+
controller.optOut();
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 7. Use Messenger Actions
|
|
134
|
+
|
|
135
|
+
The controller exposes methods as messenger actions for inter-controller communication:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
// From another controller
|
|
139
|
+
messenger.call('AnalyticsController:trackEvent', 'wallet_created', {
|
|
140
|
+
wallet_type: 'hd',
|
|
141
|
+
});
|
|
26
142
|
|
|
27
|
-
|
|
143
|
+
messenger.call(
|
|
144
|
+
'AnalyticsController:identify',
|
|
145
|
+
'550e8400-e29b-41d4-a716-446655440000',
|
|
146
|
+
{
|
|
147
|
+
email: 'newuser@example.com',
|
|
148
|
+
},
|
|
149
|
+
);
|
|
28
150
|
|
|
29
|
-
|
|
151
|
+
messenger.call('AnalyticsController:enable');
|
|
152
|
+
messenger.call('AnalyticsController:disable');
|
|
153
|
+
messenger.call('AnalyticsController:optIn');
|
|
154
|
+
messenger.call('AnalyticsController:optOut');
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 8. Subscribe to State Changes
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
messenger.subscribe('AnalyticsController:stateChange', (state, prevState) => {
|
|
161
|
+
console.log('Analytics state changed:', {
|
|
162
|
+
enabled: state.enabled,
|
|
163
|
+
optedIn: state.optedIn,
|
|
164
|
+
analyticsId: state.analyticsId,
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
```
|
|
30
168
|
|
|
31
|
-
|
|
32
|
-
| ------------- | --------- | --------------------------------------------- | --------- |
|
|
33
|
-
| `analyticsId` | `string` | UUIDv4 identifier (client platform-generated) | No |
|
|
34
|
-
| `optedIn` | `boolean` | User opt-in status | Yes |
|
|
169
|
+
## State Management
|
|
35
170
|
|
|
36
|
-
###
|
|
171
|
+
### Default State
|
|
172
|
+
|
|
173
|
+
The default state is provided by `getDefaultAnalyticsControllerState()`:
|
|
37
174
|
|
|
38
|
-
|
|
175
|
+
```typescript
|
|
176
|
+
import { getDefaultAnalyticsControllerState } from '@metamask/analytics-controller';
|
|
39
177
|
|
|
40
|
-
|
|
178
|
+
const defaultState = getDefaultAnalyticsControllerState();
|
|
179
|
+
// {
|
|
180
|
+
// enabled: true,
|
|
181
|
+
// optedIn: false,
|
|
182
|
+
// analyticsId: auto-generated UUIDv4
|
|
183
|
+
// }
|
|
184
|
+
```
|
|
41
185
|
|
|
42
|
-
|
|
43
|
-
2. **Load state before controller init**: Read from storage, provide to constructor
|
|
44
|
-
3. **Subscribe to state changes**: Persist changes to isolated storage
|
|
45
|
-
4. **Persist to isolated storage**: Keep analytics settings separate from main state (protects against state corruption)
|
|
186
|
+
### Initialization Strategy
|
|
46
187
|
|
|
47
|
-
|
|
188
|
+
- **No `state` parameter**: Uses defaults from `getDefaultAnalyticsControllerState()` and auto-generates `analyticsId` as UUIDv4
|
|
189
|
+
- **Partial `state`**: Merges with defaults (user-provided values override defaults); `analyticsId` is auto-generated if not provided
|
|
190
|
+
- **Complete `state`**: Full control for migrations and advanced use cases
|
|
48
191
|
|
|
49
|
-
|
|
192
|
+
**Best Practice:** Use `state` as the single source of truth for initial values. Do not use convenience parameters—they have been removed to ensure consistency.
|
|
50
193
|
|
|
51
|
-
|
|
52
|
-
- **Sensitive properties event**: Tracked separately with both `properties` and `sensitiveProperties` (uses anonymous ID)
|
|
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).
|
|
53
195
|
|
|
54
|
-
|
|
196
|
+
## Debugging
|
|
55
197
|
|
|
56
|
-
|
|
198
|
+
To display analytics-controller logs in the mobile app, you can add the following to your `.js.env` file:
|
|
57
199
|
|
|
58
|
-
|
|
200
|
+
```bash
|
|
201
|
+
export DEBUG="metamask:analytics-controller"
|
|
202
|
+
```
|
|
59
203
|
|
|
60
|
-
|
|
204
|
+
This will enable debug logging for the analytics-controller, allowing you to see detailed logs of analytics events, state changes, and controller operations.
|
|
61
205
|
|
|
62
206
|
## Contributing
|
|
63
207
|
|
|
@@ -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 = {
|
|
@@ -24,14 +26,28 @@ export type AnalyticsControllerIdentifyAction = {
|
|
|
24
26
|
handler: AnalyticsController['identify'];
|
|
25
27
|
};
|
|
26
28
|
/**
|
|
27
|
-
* Track a page
|
|
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.
|
|
@@ -50,5 +66,5 @@ export type AnalyticsControllerOptOutAction = {
|
|
|
50
66
|
/**
|
|
51
67
|
* Union of all AnalyticsController action types.
|
|
52
68
|
*/
|
|
53
|
-
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction |
|
|
69
|
+
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackPageAction | AnalyticsControllerEnableAction | AnalyticsControllerDisableAction | AnalyticsControllerOptInAction | AnalyticsControllerOptOutAction;
|
|
54
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 = {
|
|
@@ -24,14 +26,28 @@ export type AnalyticsControllerIdentifyAction = {
|
|
|
24
26
|
handler: AnalyticsController['identify'];
|
|
25
27
|
};
|
|
26
28
|
/**
|
|
27
|
-
* Track a page
|
|
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.
|
|
@@ -50,5 +66,5 @@ export type AnalyticsControllerOptOutAction = {
|
|
|
50
66
|
/**
|
|
51
67
|
* Union of all AnalyticsController action types.
|
|
52
68
|
*/
|
|
53
|
-
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction |
|
|
69
|
+
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackPageAction | AnalyticsControllerEnableAction | AnalyticsControllerDisableAction | AnalyticsControllerOptInAction | AnalyticsControllerOptOutAction;
|
|
54
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"]}
|