@metamask-previews/analytics-controller 0.0.0-preview-2b2b3f4d → 0.0.0-preview-be27197a
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 +183 -102
- package/dist/AnalyticsController-method-action-types.cjs.map +1 -1
- package/dist/AnalyticsController-method-action-types.d.cts +10 -24
- package/dist/AnalyticsController-method-action-types.d.cts.map +1 -1
- package/dist/AnalyticsController-method-action-types.d.mts +10 -24
- 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 +86 -77
- package/dist/AnalyticsController.cjs.map +1 -1
- package/dist/AnalyticsController.d.cts +37 -33
- package/dist/AnalyticsController.d.cts.map +1 -1
- package/dist/AnalyticsController.d.mts +37 -33
- package/dist/AnalyticsController.d.mts.map +1 -1
- package/dist/AnalyticsController.mjs +85 -76
- package/dist/AnalyticsController.mjs.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.cjs.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.d.cts +63 -15
- package/dist/AnalyticsPlatformAdapter.types.d.cts.map +1 -1
- package/dist/AnalyticsPlatformAdapter.types.d.mts +63 -15
- 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/analyticsControllerStateValidator.cjs +34 -0
- package/dist/analyticsControllerStateValidator.cjs.map +1 -0
- package/dist/analyticsControllerStateValidator.d.cts +16 -0
- package/dist/analyticsControllerStateValidator.d.cts.map +1 -0
- package/dist/analyticsControllerStateValidator.d.mts +16 -0
- package/dist/analyticsControllerStateValidator.d.mts.map +1 -0
- package/dist/analyticsControllerStateValidator.mjs +29 -0
- package/dist/analyticsControllerStateValidator.mjs.map +1 -0
- package/dist/index.cjs +9 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -3
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.cjs +38 -0
- package/dist/selectors.cjs.map +1 -0
- package/dist/selectors.d.cts +11 -0
- package/dist/selectors.d.cts.map +1 -0
- package/dist/selectors.d.mts +11 -0
- package/dist/selectors.d.mts.map +1 -0
- package/dist/selectors.mjs +35 -0
- package/dist/selectors.mjs.map +1 -0
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -4,13 +4,10 @@ Common Analytics controller for event tracking.
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
- Tracking analytics events
|
|
9
|
-
- Identifying users
|
|
10
|
-
- Managing analytics preferences (enable/disable, opt-in/opt-out)
|
|
7
|
+
- Unified interface for tracking analytics events, identifying users, and managing preferences
|
|
11
8
|
- Delegates platform-specific implementation to `AnalyticsPlatformAdapter`
|
|
12
9
|
- Integrates with the MetaMask messenger system for inter-controller communication
|
|
13
|
-
-
|
|
10
|
+
- Platform-managed storage: controller doesn't persist state internally
|
|
14
11
|
|
|
15
12
|
## Installation
|
|
16
13
|
|
|
@@ -24,184 +21,268 @@ or
|
|
|
24
21
|
|
|
25
22
|
### 1. Create a Platform Adapter
|
|
26
23
|
|
|
27
|
-
The controller delegates platform-specific analytics implementation to
|
|
24
|
+
The controller delegates platform-specific analytics implementation to an `AnalyticsPlatformAdapter`:
|
|
28
25
|
|
|
29
26
|
```typescript
|
|
30
27
|
import type { AnalyticsPlatformAdapter } from '@metamask/analytics-controller';
|
|
31
28
|
|
|
32
29
|
const platformAdapter: AnalyticsPlatformAdapter = {
|
|
33
|
-
|
|
34
|
-
// Platform-specific implementation (e.g., Segment, Mixpanel, etc.)
|
|
30
|
+
track: (eventName: string, properties?: Record<string, unknown>) => {
|
|
35
31
|
segment.track(eventName, properties);
|
|
36
32
|
},
|
|
37
33
|
identify: (userId: string, traits?: Record<string, unknown>) => {
|
|
38
34
|
segment.identify(userId, traits);
|
|
39
35
|
},
|
|
40
|
-
|
|
41
|
-
segment.page(
|
|
36
|
+
view: (name: string, properties?: Record<string, unknown>) => {
|
|
37
|
+
segment.page(name, properties);
|
|
38
|
+
},
|
|
39
|
+
onSetupCompleted: async (analyticsId: string) => {
|
|
40
|
+
// Lifecycle hook called after controller initialization
|
|
41
|
+
// The analyticsId is guaranteed to be set when this method is called
|
|
42
|
+
// Use this for platform-specific setup that requires the analytics ID
|
|
43
|
+
// For example, adding plugins that need the analytics ID:
|
|
44
|
+
segment.add({
|
|
45
|
+
plugin: new PrivacyPlugin(analyticsId),
|
|
46
|
+
});
|
|
42
47
|
},
|
|
43
48
|
};
|
|
44
49
|
```
|
|
45
50
|
|
|
46
|
-
### 2.
|
|
51
|
+
### 2. Load Analytics Settings from Storage
|
|
52
|
+
|
|
53
|
+
The platform is responsible for loading and persisting analytics settings—the controller does not handle storage internally. This design allows:
|
|
47
54
|
|
|
48
|
-
|
|
55
|
+
- **Early access**: Platform can read the `analyticsId` before the controller is initialized (useful for other controllers or early startup code)
|
|
56
|
+
- **Resilience**: Storing analytics settings separately from main state protects them from state corruption, allowing analytics to continue working even when main state is corrupted
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
Load settings **before** initializing the controller:
|
|
51
59
|
|
|
52
60
|
```typescript
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
62
|
+
import {
|
|
63
|
+
getDefaultAnalyticsControllerState,
|
|
64
|
+
type AnalyticsControllerState,
|
|
65
|
+
} from '@metamask/analytics-controller';
|
|
66
|
+
|
|
67
|
+
async function loadAnalyticsSettings(): Promise<AnalyticsControllerState> {
|
|
68
|
+
// Load from platform storage (e.g., MMKV, AsyncStorage, localStorage)
|
|
69
|
+
const [savedAnalyticsId, savedOptedIn] = await Promise.all([
|
|
70
|
+
storage.getItem('analytics.id'),
|
|
71
|
+
storage.getItem('analytics.optedIn'),
|
|
72
|
+
]);
|
|
73
|
+
|
|
74
|
+
const defaults = getDefaultAnalyticsControllerState();
|
|
75
|
+
|
|
76
|
+
// Generate UUID on first run if not in storage
|
|
77
|
+
let analyticsId = savedAnalyticsId;
|
|
78
|
+
if (!analyticsId) {
|
|
79
|
+
analyticsId = uuidv4();
|
|
80
|
+
// Persist immediately - this ID must never change
|
|
81
|
+
await storage.setItem('analytics.id', analyticsId);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Parse boolean values (stored as strings)
|
|
85
|
+
const optedIn =
|
|
86
|
+
savedOptedIn !== null ? savedOptedIn === 'true' : defaults.optedIn;
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
analyticsId,
|
|
90
|
+
optedIn,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
66
93
|
```
|
|
67
94
|
|
|
68
|
-
|
|
95
|
+
### 3. Initialize the Controller
|
|
69
96
|
|
|
70
|
-
|
|
97
|
+
Create the controller with loaded state and subscribe to state changes for persistence:
|
|
71
98
|
|
|
72
99
|
```typescript
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
import {
|
|
101
|
+
AnalyticsController,
|
|
102
|
+
type AnalyticsControllerState,
|
|
103
|
+
} from '@metamask/analytics-controller';
|
|
104
|
+
|
|
105
|
+
// Persist state changes to storage (fire-and-forget)
|
|
106
|
+
function persistAnalyticsSettings(state: AnalyticsControllerState): void {
|
|
107
|
+
storage.setItem('analytics.id', state.analyticsId);
|
|
108
|
+
storage.setItem('analytics.optedIn', String(state.optedIn));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function initializeAnalyticsController(
|
|
112
|
+
messenger: AnalyticsControllerMessenger,
|
|
113
|
+
): Promise<AnalyticsController> {
|
|
114
|
+
// 1. Load settings from storage
|
|
115
|
+
const state = await loadAnalyticsSettings();
|
|
116
|
+
|
|
117
|
+
// 2. Create controller with loaded state
|
|
118
|
+
const controller = new AnalyticsController({
|
|
119
|
+
messenger,
|
|
120
|
+
platformAdapter,
|
|
121
|
+
state, // Must include valid UUIDv4 analyticsId
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// 3. Subscribe to state changes for persistence
|
|
125
|
+
messenger.subscribe('AnalyticsController:stateChange', (newState) => {
|
|
126
|
+
persistAnalyticsSettings(newState);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return controller;
|
|
130
|
+
}
|
|
82
131
|
```
|
|
83
132
|
|
|
84
|
-
|
|
133
|
+
### 4. Access Analytics ID Before Controller Init
|
|
134
|
+
|
|
135
|
+
One benefit of platform-managed storage is accessing the analytics ID before the controller is initialized:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
async function getAnalyticsId(): Promise<string | null> {
|
|
139
|
+
return storage.getItem('analytics.id');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Use in other controllers or early initialization
|
|
143
|
+
const analyticsId = await getAnalyticsId();
|
|
144
|
+
if (analyticsId) {
|
|
145
|
+
// Use analyticsId before AnalyticsController is ready
|
|
146
|
+
}
|
|
147
|
+
```
|
|
85
148
|
|
|
86
|
-
###
|
|
149
|
+
### 5. Track Events
|
|
87
150
|
|
|
88
151
|
```typescript
|
|
89
|
-
// Track
|
|
90
|
-
controller.trackEvent(
|
|
91
|
-
|
|
92
|
-
account_type: 'hd',
|
|
152
|
+
// Track event with properties
|
|
153
|
+
controller.trackEvent({
|
|
154
|
+
name: 'wallet_connected',
|
|
155
|
+
properties: { network: 'ethereum', account_type: 'hd' },
|
|
156
|
+
sensitiveProperties: {},
|
|
157
|
+
hasProperties: true,
|
|
158
|
+
saveDataRecording: true,
|
|
93
159
|
});
|
|
94
160
|
|
|
95
|
-
// Events are
|
|
96
|
-
controller.disable();
|
|
97
|
-
controller.trackEvent('some_event'); // This will not be tracked
|
|
161
|
+
// Events are filtered when analytics is disabled (optedIn is false)
|
|
98
162
|
```
|
|
99
163
|
|
|
100
|
-
###
|
|
164
|
+
### 6. Identify Users
|
|
101
165
|
|
|
102
166
|
```typescript
|
|
103
|
-
controller.identify(
|
|
104
|
-
|
|
105
|
-
|
|
167
|
+
controller.identify({
|
|
168
|
+
ENABLE_OPENSEA_API: 'ON',
|
|
169
|
+
NFT_AUTODETECTION: 'ON',
|
|
106
170
|
});
|
|
107
171
|
|
|
108
|
-
//
|
|
109
|
-
console.log(controller.state.analyticsId); // '550e8400-e29b-41d4-a716-446655440000'
|
|
172
|
+
// Uses the analyticsId from controller state
|
|
110
173
|
```
|
|
111
174
|
|
|
112
|
-
###
|
|
175
|
+
### 7. Track Page Views
|
|
113
176
|
|
|
114
177
|
```typescript
|
|
115
|
-
controller.
|
|
178
|
+
controller.trackView('home', {
|
|
116
179
|
referrer: 'google',
|
|
117
180
|
campaign: 'summer-2024',
|
|
118
181
|
});
|
|
119
182
|
```
|
|
120
183
|
|
|
121
|
-
###
|
|
184
|
+
### 8. Manage Analytics Preferences
|
|
122
185
|
|
|
123
186
|
```typescript
|
|
124
|
-
// Enable/disable analytics
|
|
125
|
-
controller.enable();
|
|
126
|
-
controller.disable();
|
|
127
|
-
|
|
128
187
|
// Opt in/out
|
|
129
188
|
controller.optIn();
|
|
130
189
|
controller.optOut();
|
|
131
|
-
```
|
|
132
190
|
|
|
133
|
-
|
|
191
|
+
// Changes trigger stateChange event → platform persists to storage
|
|
192
|
+
```
|
|
134
193
|
|
|
135
|
-
|
|
194
|
+
### 9. Use Messenger Actions
|
|
136
195
|
|
|
137
196
|
```typescript
|
|
138
197
|
// From another controller
|
|
139
|
-
messenger.call('AnalyticsController:trackEvent',
|
|
140
|
-
|
|
198
|
+
messenger.call('AnalyticsController:trackEvent', {
|
|
199
|
+
name: 'wallet_created',
|
|
200
|
+
properties: { wallet_type: 'hd' },
|
|
201
|
+
sensitiveProperties: {},
|
|
202
|
+
hasProperties: true,
|
|
203
|
+
saveDataRecording: true,
|
|
141
204
|
});
|
|
142
205
|
|
|
143
|
-
messenger.call(
|
|
144
|
-
'AnalyticsController:identify',
|
|
145
|
-
'550e8400-e29b-41d4-a716-446655440000',
|
|
146
|
-
{
|
|
147
|
-
email: 'newuser@example.com',
|
|
148
|
-
},
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
messenger.call('AnalyticsController:enable');
|
|
152
|
-
messenger.call('AnalyticsController:disable');
|
|
153
206
|
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
207
|
```
|
|
168
208
|
|
|
169
209
|
## State Management
|
|
170
210
|
|
|
171
211
|
### Default State
|
|
172
212
|
|
|
173
|
-
|
|
213
|
+
Use `getDefaultAnalyticsControllerState()` to get default values for opt-in preferences:
|
|
174
214
|
|
|
175
215
|
```typescript
|
|
176
216
|
import { getDefaultAnalyticsControllerState } from '@metamask/analytics-controller';
|
|
177
217
|
|
|
178
|
-
const
|
|
179
|
-
// {
|
|
180
|
-
//
|
|
181
|
-
// optedIn: false,
|
|
182
|
-
// analyticsId: auto-generated UUIDv4
|
|
183
|
-
// }
|
|
218
|
+
const defaults = getDefaultAnalyticsControllerState();
|
|
219
|
+
// Returns: { optedIn: false }
|
|
220
|
+
// Note: analyticsId is NOT included - platform must provide it
|
|
184
221
|
```
|
|
185
222
|
|
|
186
|
-
###
|
|
223
|
+
### State Structure
|
|
224
|
+
|
|
225
|
+
| Field | Type | Description |
|
|
226
|
+
| ------------- | --------- | -------------------------------------- |
|
|
227
|
+
| `analyticsId` | `string` | UUIDv4 identifier (platform-generated) |
|
|
228
|
+
| `optedIn` | `boolean` | User opt-in status |
|
|
229
|
+
|
|
230
|
+
### Why `analyticsId` Has No Default
|
|
231
|
+
|
|
232
|
+
The `analyticsId` is an **identity** (unique per user), not a **preference** (static default). A default should return the same value each call (deterministic), but a UUID must be unique each time (non-deterministic). These are mutually exclusive.
|
|
233
|
+
|
|
234
|
+
**Solution:** Platform generates the UUID once on first run, persists it, and provides it to the controller.
|
|
235
|
+
|
|
236
|
+
### Platform Responsibilities
|
|
237
|
+
|
|
238
|
+
1. **Generate UUID on first run**: Use `uuid` package or platform equivalent
|
|
239
|
+
2. **Load state before controller init**: Read from storage, provide to constructor
|
|
240
|
+
3. **Subscribe to state changes**: Persist changes to storage
|
|
241
|
+
4. **Persist to isolated storage**: Keep analytics settings separate from main state (protects against state corruption)
|
|
242
|
+
|
|
243
|
+
### Why Platform-Managed Storage?
|
|
244
|
+
|
|
245
|
+
- **Access before controller init**: Other code can read analytics ID early
|
|
246
|
+
- **Protection from state corruption**: Analytics settings in separate storage survive main state corruption
|
|
247
|
+
- **Analytics during corruption**: Can still report issues even when main state is corrupted
|
|
248
|
+
- **Platform flexibility**: Each platform uses its preferred storage mechanism
|
|
249
|
+
|
|
250
|
+
## Lifecycle Hooks
|
|
187
251
|
|
|
188
|
-
|
|
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
|
|
252
|
+
### `onSetupCompleted`
|
|
191
253
|
|
|
192
|
-
|
|
254
|
+
Called once after controller initialization with guaranteed valid `analyticsId`:
|
|
193
255
|
|
|
194
|
-
|
|
256
|
+
```typescript
|
|
257
|
+
onSetupCompleted: async (analyticsId: string) => {
|
|
258
|
+
// analyticsId is guaranteed to be a valid UUIDv4
|
|
259
|
+
client.add({ plugin: new PrivacyPlugin(analyticsId) });
|
|
260
|
+
},
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Errors in `onSetupCompleted` are caught and logged—they don't break the controller.
|
|
195
264
|
|
|
196
265
|
## Debugging
|
|
197
266
|
|
|
198
|
-
|
|
267
|
+
Enable debug logging:
|
|
199
268
|
|
|
200
269
|
```bash
|
|
201
270
|
export DEBUG="metamask:analytics-controller"
|
|
202
271
|
```
|
|
203
272
|
|
|
204
|
-
|
|
273
|
+
## Development
|
|
274
|
+
|
|
275
|
+
### Build
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
yarn install && yarn workspace @metamask/analytics-controller build
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Test
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
yarn install && yarn workspace @metamask/analytics-controller test
|
|
285
|
+
```
|
|
205
286
|
|
|
206
287
|
## Contributing
|
|
207
288
|
|
|
@@ -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 or screen view.\n *\n * @param name - The identifier/name of the page or screen being viewed (e.g., \"home\", \"settings\", \"wallet\")\n * @param properties - Optional properties associated with the view\n */\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 * Union of all AnalyticsController action types.\n */\nexport type AnalyticsControllerMethodActions =\n | AnalyticsControllerTrackEventAction\n | AnalyticsControllerIdentifyAction\n | AnalyticsControllerTrackViewAction\n | AnalyticsControllerOptInAction\n | AnalyticsControllerOptOutAction;\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 = {
|
|
@@ -26,31 +24,18 @@ export type AnalyticsControllerIdentifyAction = {
|
|
|
26
24
|
handler: AnalyticsController['identify'];
|
|
27
25
|
};
|
|
28
26
|
/**
|
|
29
|
-
* Track a page view.
|
|
27
|
+
* Track a page or screen view.
|
|
30
28
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @param properties -
|
|
29
|
+
* @param name - The identifier/name of the page or screen being viewed (e.g., "home", "settings", "wallet")
|
|
30
|
+
* @param properties - Optional properties associated with the view
|
|
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,6 +43,7 @@ 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`;
|
|
@@ -66,5 +52,5 @@ export type AnalyticsControllerOptOutAction = {
|
|
|
66
52
|
/**
|
|
67
53
|
* Union of all AnalyticsController action types.
|
|
68
54
|
*/
|
|
69
|
-
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction |
|
|
55
|
+
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackViewAction | AnalyticsControllerOptInAction | AnalyticsControllerOptOutAction;
|
|
70
56
|
//# 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;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,mCAAmC,GACnC,iCAAiC,GACjC,kCAAkC,GAClC,8BAA8B,GAC9B,+BAA+B,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 = {
|
|
@@ -26,31 +24,18 @@ export type AnalyticsControllerIdentifyAction = {
|
|
|
26
24
|
handler: AnalyticsController['identify'];
|
|
27
25
|
};
|
|
28
26
|
/**
|
|
29
|
-
* Track a page view.
|
|
27
|
+
* Track a page or screen view.
|
|
30
28
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @param properties -
|
|
29
|
+
* @param name - The identifier/name of the page or screen being viewed (e.g., "home", "settings", "wallet")
|
|
30
|
+
* @param properties - Optional properties associated with the view
|
|
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,6 +43,7 @@ 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`;
|
|
@@ -66,5 +52,5 @@ export type AnalyticsControllerOptOutAction = {
|
|
|
66
52
|
/**
|
|
67
53
|
* Union of all AnalyticsController action types.
|
|
68
54
|
*/
|
|
69
|
-
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction |
|
|
55
|
+
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackViewAction | AnalyticsControllerOptInAction | AnalyticsControllerOptOutAction;
|
|
70
56
|
//# 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;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,mCAAmC,GACnC,iCAAiC,GACjC,kCAAkC,GAClC,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 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 or screen view.\n *\n * @param name - The identifier/name of the page or screen being viewed (e.g., \"home\", \"settings\", \"wallet\")\n * @param properties - Optional properties associated with the view\n */\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 * Union of all AnalyticsController action types.\n */\nexport type AnalyticsControllerMethodActions =\n | AnalyticsControllerTrackEventAction\n | AnalyticsControllerIdentifyAction\n | AnalyticsControllerTrackViewAction\n | AnalyticsControllerOptInAction\n | AnalyticsControllerOptOutAction;\n"]}
|