@metamask-previews/analytics-controller 0.0.0-preview-d21b3dc → 0.0.0-preview-a5935709
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 +208 -105
- package/dist/AnalyticsController-method-action-types.cjs.map +1 -1
- package/dist/AnalyticsController-method-action-types.d.cts +28 -26
- package/dist/AnalyticsController-method-action-types.d.cts.map +1 -1
- package/dist/AnalyticsController-method-action-types.d.mts +28 -26
- 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 +110 -73
- package/dist/AnalyticsController.cjs.map +1 -1
- package/dist/AnalyticsController.d.cts +50 -32
- package/dist/AnalyticsController.d.cts.map +1 -1
- package/dist/AnalyticsController.d.mts +50 -32
- package/dist/AnalyticsController.d.mts.map +1 -1
- package/dist/AnalyticsController.mjs +109 -72
- 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 +43 -0
- package/dist/selectors.cjs.map +1 -0
- package/dist/selectors.d.cts +12 -0
- package/dist/selectors.d.cts.map +1 -0
- package/dist/selectors.d.mts +12 -0
- package/dist/selectors.d.mts.map +1 -0
- package/dist/selectors.mjs +40 -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,290 @@ 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, savedOptedInRegular, savedOptedInSocial] =
|
|
70
|
+
await Promise.all([
|
|
71
|
+
storage.getItem('analytics.id'),
|
|
72
|
+
storage.getItem('analytics.optedInForRegularAccount'),
|
|
73
|
+
storage.getItem('analytics.optedInForSocialAccount'),
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
const defaults = getDefaultAnalyticsControllerState();
|
|
77
|
+
|
|
78
|
+
// Generate UUID on first run if not in storage
|
|
79
|
+
let analyticsId = savedAnalyticsId;
|
|
80
|
+
if (!analyticsId) {
|
|
81
|
+
analyticsId = uuidv4();
|
|
82
|
+
// Persist immediately - this ID must never change
|
|
83
|
+
await storage.setItem('analytics.id', analyticsId);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Parse boolean values (stored as strings)
|
|
87
|
+
const optedInForRegularAccount =
|
|
88
|
+
savedOptedInRegular !== null
|
|
89
|
+
? savedOptedInRegular === 'true'
|
|
90
|
+
: defaults.optedInForRegularAccount;
|
|
91
|
+
|
|
92
|
+
const optedInForSocialAccount =
|
|
93
|
+
savedOptedInSocial !== null
|
|
94
|
+
? savedOptedInSocial === 'true'
|
|
95
|
+
: defaults.optedInForSocialAccount;
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
analyticsId,
|
|
99
|
+
optedInForRegularAccount,
|
|
100
|
+
optedInForSocialAccount,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
66
103
|
```
|
|
67
104
|
|
|
68
|
-
|
|
105
|
+
### 3. Initialize the Controller
|
|
69
106
|
|
|
70
|
-
|
|
107
|
+
Create the controller with loaded state and subscribe to state changes for persistence:
|
|
71
108
|
|
|
72
109
|
```typescript
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
110
|
+
import {
|
|
111
|
+
AnalyticsController,
|
|
112
|
+
type AnalyticsControllerState,
|
|
113
|
+
} from '@metamask/analytics-controller';
|
|
114
|
+
|
|
115
|
+
// Persist state changes to storage (fire-and-forget)
|
|
116
|
+
function persistAnalyticsSettings(state: AnalyticsControllerState): void {
|
|
117
|
+
storage.setItem('analytics.id', state.analyticsId);
|
|
118
|
+
storage.setItem(
|
|
119
|
+
'analytics.optedInForRegularAccount',
|
|
120
|
+
String(state.optedInForRegularAccount),
|
|
121
|
+
);
|
|
122
|
+
storage.setItem(
|
|
123
|
+
'analytics.optedInForSocialAccount',
|
|
124
|
+
String(state.optedInForSocialAccount),
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function initializeAnalyticsController(
|
|
129
|
+
messenger: AnalyticsControllerMessenger,
|
|
130
|
+
): Promise<AnalyticsController> {
|
|
131
|
+
// 1. Load settings from storage
|
|
132
|
+
const state = await loadAnalyticsSettings();
|
|
133
|
+
|
|
134
|
+
// 2. Create controller with loaded state
|
|
135
|
+
const controller = new AnalyticsController({
|
|
136
|
+
messenger,
|
|
137
|
+
platformAdapter,
|
|
138
|
+
state, // Must include valid UUIDv4 analyticsId
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// 3. Subscribe to state changes for persistence
|
|
142
|
+
messenger.subscribe('AnalyticsController:stateChange', (newState) => {
|
|
143
|
+
persistAnalyticsSettings(newState);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
return controller;
|
|
147
|
+
}
|
|
82
148
|
```
|
|
83
149
|
|
|
84
|
-
|
|
150
|
+
### 4. Access Analytics ID Before Controller Init
|
|
151
|
+
|
|
152
|
+
One benefit of platform-managed storage is accessing the analytics ID before the controller is initialized:
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
async function getAnalyticsId(): Promise<string | null> {
|
|
156
|
+
return storage.getItem('analytics.id');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Use in other controllers or early initialization
|
|
160
|
+
const analyticsId = await getAnalyticsId();
|
|
161
|
+
if (analyticsId) {
|
|
162
|
+
// Use analyticsId before AnalyticsController is ready
|
|
163
|
+
}
|
|
164
|
+
```
|
|
85
165
|
|
|
86
|
-
###
|
|
166
|
+
### 5. Track Events
|
|
87
167
|
|
|
88
168
|
```typescript
|
|
89
|
-
// Track
|
|
90
|
-
controller.trackEvent(
|
|
91
|
-
|
|
92
|
-
account_type: 'hd',
|
|
169
|
+
// Track event with properties
|
|
170
|
+
controller.trackEvent({
|
|
171
|
+
name: 'wallet_connected',
|
|
172
|
+
properties: { network: 'ethereum', account_type: 'hd' },
|
|
173
|
+
sensitiveProperties: {},
|
|
174
|
+
hasProperties: true,
|
|
175
|
+
saveDataRecording: true,
|
|
93
176
|
});
|
|
94
177
|
|
|
95
|
-
// Events are
|
|
96
|
-
controller.disable();
|
|
97
|
-
controller.trackEvent('some_event'); // This will not be tracked
|
|
178
|
+
// Events are filtered when analytics is disabled (both opt-ins are false)
|
|
98
179
|
```
|
|
99
180
|
|
|
100
|
-
###
|
|
181
|
+
### 6. Identify Users
|
|
101
182
|
|
|
102
183
|
```typescript
|
|
103
|
-
controller.identify(
|
|
104
|
-
|
|
105
|
-
|
|
184
|
+
controller.identify({
|
|
185
|
+
ENABLE_OPENSEA_API: 'ON',
|
|
186
|
+
NFT_AUTODETECTION: 'ON',
|
|
106
187
|
});
|
|
107
188
|
|
|
108
|
-
//
|
|
109
|
-
console.log(controller.state.analyticsId); // '550e8400-e29b-41d4-a716-446655440000'
|
|
189
|
+
// Uses the analyticsId from controller state
|
|
110
190
|
```
|
|
111
191
|
|
|
112
|
-
###
|
|
192
|
+
### 7. Track Page Views
|
|
113
193
|
|
|
114
194
|
```typescript
|
|
115
|
-
controller.
|
|
195
|
+
controller.trackView('home', {
|
|
116
196
|
referrer: 'google',
|
|
117
197
|
campaign: 'summer-2024',
|
|
118
198
|
});
|
|
119
199
|
```
|
|
120
200
|
|
|
121
|
-
###
|
|
201
|
+
### 8. Manage Analytics Preferences
|
|
122
202
|
|
|
123
203
|
```typescript
|
|
124
|
-
//
|
|
125
|
-
controller.
|
|
126
|
-
controller.
|
|
204
|
+
// Opt in/out for regular account
|
|
205
|
+
controller.optInForRegularAccount();
|
|
206
|
+
controller.optOutForRegularAccount();
|
|
127
207
|
|
|
128
|
-
// Opt in/out
|
|
129
|
-
controller.
|
|
130
|
-
controller.
|
|
131
|
-
```
|
|
208
|
+
// Opt in/out for social account
|
|
209
|
+
controller.optInForSocialAccount();
|
|
210
|
+
controller.optOutForSocialAccount();
|
|
132
211
|
|
|
133
|
-
|
|
212
|
+
// Changes trigger stateChange event → platform persists to storage
|
|
213
|
+
```
|
|
134
214
|
|
|
135
|
-
|
|
215
|
+
### 9. Use Messenger Actions
|
|
136
216
|
|
|
137
217
|
```typescript
|
|
138
218
|
// From another controller
|
|
139
|
-
messenger.call('AnalyticsController:trackEvent',
|
|
140
|
-
|
|
219
|
+
messenger.call('AnalyticsController:trackEvent', {
|
|
220
|
+
name: 'wallet_created',
|
|
221
|
+
properties: { wallet_type: 'hd' },
|
|
222
|
+
sensitiveProperties: {},
|
|
223
|
+
hasProperties: true,
|
|
224
|
+
saveDataRecording: true,
|
|
141
225
|
});
|
|
142
226
|
|
|
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
|
-
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
|
-
});
|
|
227
|
+
messenger.call('AnalyticsController:optInForRegularAccount');
|
|
167
228
|
```
|
|
168
229
|
|
|
169
230
|
## State Management
|
|
170
231
|
|
|
171
232
|
### Default State
|
|
172
233
|
|
|
173
|
-
|
|
234
|
+
Use `getDefaultAnalyticsControllerState()` to get default values for opt-in preferences:
|
|
174
235
|
|
|
175
236
|
```typescript
|
|
176
237
|
import { getDefaultAnalyticsControllerState } from '@metamask/analytics-controller';
|
|
177
238
|
|
|
178
|
-
const
|
|
179
|
-
// {
|
|
180
|
-
//
|
|
181
|
-
// optedIn: false,
|
|
182
|
-
// analyticsId: auto-generated UUIDv4
|
|
183
|
-
// }
|
|
239
|
+
const defaults = getDefaultAnalyticsControllerState();
|
|
240
|
+
// Returns: { optedInForRegularAccount: false, optedInForSocialAccount: false }
|
|
241
|
+
// Note: analyticsId is NOT included - platform must provide it
|
|
184
242
|
```
|
|
185
243
|
|
|
186
|
-
###
|
|
244
|
+
### State Structure
|
|
245
|
+
|
|
246
|
+
| Field | Type | Description |
|
|
247
|
+
| -------------------------- | --------- | -------------------------------------- |
|
|
248
|
+
| `analyticsId` | `string` | UUIDv4 identifier (platform-generated) |
|
|
249
|
+
| `optedInForRegularAccount` | `boolean` | User opt-in status for regular account |
|
|
250
|
+
| `optedInForSocialAccount` | `boolean` | User opt-in status for social account |
|
|
251
|
+
|
|
252
|
+
### Why `analyticsId` Has No Default
|
|
253
|
+
|
|
254
|
+
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.
|
|
255
|
+
|
|
256
|
+
**Solution:** Platform generates the UUID once on first run, persists it, and provides it to the controller.
|
|
257
|
+
|
|
258
|
+
### Platform Responsibilities
|
|
187
259
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
260
|
+
1. **Generate UUID on first run**: Use `uuid` package or platform equivalent
|
|
261
|
+
2. **Load state before controller init**: Read from storage, provide to constructor
|
|
262
|
+
3. **Subscribe to state changes**: Persist changes to storage
|
|
263
|
+
4. **Persist to isolated storage**: Keep analytics settings separate from main state (protects against state corruption)
|
|
191
264
|
|
|
192
|
-
|
|
265
|
+
### Why Platform-Managed Storage?
|
|
193
266
|
|
|
194
|
-
**
|
|
267
|
+
- **Access before controller init**: Other code can read analytics ID early
|
|
268
|
+
- **Protection from state corruption**: Analytics settings in separate storage survive main state corruption
|
|
269
|
+
- **Analytics during corruption**: Can still report issues even when main state is corrupted
|
|
270
|
+
- **Platform flexibility**: Each platform uses its preferred storage mechanism
|
|
271
|
+
|
|
272
|
+
## Lifecycle Hooks
|
|
273
|
+
|
|
274
|
+
### `onSetupCompleted`
|
|
275
|
+
|
|
276
|
+
Called once after controller initialization with guaranteed valid `analyticsId`:
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
onSetupCompleted: async (analyticsId: string) => {
|
|
280
|
+
// analyticsId is guaranteed to be a valid UUIDv4
|
|
281
|
+
client.add({ plugin: new PrivacyPlugin(analyticsId) });
|
|
282
|
+
},
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Errors in `onSetupCompleted` are caught and logged—they don't break the controller.
|
|
195
286
|
|
|
196
287
|
## Debugging
|
|
197
288
|
|
|
198
|
-
|
|
289
|
+
Enable debug logging:
|
|
199
290
|
|
|
200
291
|
```bash
|
|
201
292
|
export DEBUG="metamask:analytics-controller"
|
|
202
293
|
```
|
|
203
294
|
|
|
204
|
-
|
|
295
|
+
## Development
|
|
296
|
+
|
|
297
|
+
### Build
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
yarn install && yarn workspace @metamask/analytics-controller build
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Test
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
yarn install && yarn workspace @metamask/analytics-controller test
|
|
307
|
+
```
|
|
205
308
|
|
|
206
309
|
## Contributing
|
|
207
310
|
|
|
@@ -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 for regular account.\n * This updates the user's opt-in status for regular account.\n */\nexport type AnalyticsControllerOptInForRegularAccountAction = {\n type: `AnalyticsController:optInForRegularAccount`;\n handler: AnalyticsController['optInForRegularAccount'];\n};\n\n/**\n * Opt out of analytics for regular account.\n * This updates the user's opt-in status for regular account.\n */\nexport type AnalyticsControllerOptOutForRegularAccountAction = {\n type: `AnalyticsController:optOutForRegularAccount`;\n handler: AnalyticsController['optOutForRegularAccount'];\n};\n\n/**\n * Opt in to analytics for social account.\n * This updates the user's opt-in status for social account.\n */\nexport type AnalyticsControllerOptInForSocialAccountAction = {\n type: `AnalyticsController:optInForSocialAccount`;\n handler: AnalyticsController['optInForSocialAccount'];\n};\n\n/**\n * Opt out of analytics for social account.\n * This updates the user's opt-in status for social account.\n */\nexport type AnalyticsControllerOptOutForSocialAccountAction = {\n type: `AnalyticsController:optOutForSocialAccount`;\n handler: AnalyticsController['optOutForSocialAccount'];\n};\n\n/**\n * Union of all AnalyticsController action types.\n */\nexport type AnalyticsControllerMethodActions =\n | AnalyticsControllerTrackEventAction\n | AnalyticsControllerIdentifyAction\n | AnalyticsControllerTrackViewAction\n | AnalyticsControllerOptInForRegularAccountAction\n | AnalyticsControllerOptOutForRegularAccountAction\n | AnalyticsControllerOptInForSocialAccountAction\n | AnalyticsControllerOptOutForSocialAccountAction;\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,45 +24,49 @@ 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['
|
|
32
|
+
export type AnalyticsControllerTrackViewAction = {
|
|
33
|
+
type: `AnalyticsController:trackView`;
|
|
34
|
+
handler: AnalyticsController['trackView'];
|
|
37
35
|
};
|
|
38
36
|
/**
|
|
39
|
-
*
|
|
37
|
+
* Opt in to analytics for regular account.
|
|
38
|
+
* This updates the user's opt-in status for regular account.
|
|
40
39
|
*/
|
|
41
|
-
export type
|
|
42
|
-
type: `AnalyticsController:
|
|
43
|
-
handler: AnalyticsController['
|
|
40
|
+
export type AnalyticsControllerOptInForRegularAccountAction = {
|
|
41
|
+
type: `AnalyticsController:optInForRegularAccount`;
|
|
42
|
+
handler: AnalyticsController['optInForRegularAccount'];
|
|
44
43
|
};
|
|
45
44
|
/**
|
|
46
|
-
*
|
|
45
|
+
* Opt out of analytics for regular account.
|
|
46
|
+
* This updates the user's opt-in status for regular account.
|
|
47
47
|
*/
|
|
48
|
-
export type
|
|
49
|
-
type: `AnalyticsController:
|
|
50
|
-
handler: AnalyticsController['
|
|
48
|
+
export type AnalyticsControllerOptOutForRegularAccountAction = {
|
|
49
|
+
type: `AnalyticsController:optOutForRegularAccount`;
|
|
50
|
+
handler: AnalyticsController['optOutForRegularAccount'];
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
|
-
* Opt in to analytics.
|
|
53
|
+
* Opt in to analytics for social account.
|
|
54
|
+
* This updates the user's opt-in status for social account.
|
|
54
55
|
*/
|
|
55
|
-
export type
|
|
56
|
-
type: `AnalyticsController:
|
|
57
|
-
handler: AnalyticsController['
|
|
56
|
+
export type AnalyticsControllerOptInForSocialAccountAction = {
|
|
57
|
+
type: `AnalyticsController:optInForSocialAccount`;
|
|
58
|
+
handler: AnalyticsController['optInForSocialAccount'];
|
|
58
59
|
};
|
|
59
60
|
/**
|
|
60
|
-
* Opt out of analytics.
|
|
61
|
+
* Opt out of analytics for social account.
|
|
62
|
+
* This updates the user's opt-in status for social account.
|
|
61
63
|
*/
|
|
62
|
-
export type
|
|
63
|
-
type: `AnalyticsController:
|
|
64
|
-
handler: AnalyticsController['
|
|
64
|
+
export type AnalyticsControllerOptOutForSocialAccountAction = {
|
|
65
|
+
type: `AnalyticsController:optOutForSocialAccount`;
|
|
66
|
+
handler: AnalyticsController['optOutForSocialAccount'];
|
|
65
67
|
};
|
|
66
68
|
/**
|
|
67
69
|
* Union of all AnalyticsController action types.
|
|
68
70
|
*/
|
|
69
|
-
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction |
|
|
71
|
+
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackViewAction | AnalyticsControllerOptInForRegularAccountAction | AnalyticsControllerOptOutForRegularAccountAction | AnalyticsControllerOptInForSocialAccountAction | AnalyticsControllerOptOutForSocialAccountAction;
|
|
70
72
|
//# 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,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,mBAAmB,CAAC,wBAAwB,CAAC,CAAC;CACxD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,mBAAmB,CAAC,yBAAyB,CAAC,CAAC;CACzD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;CACvD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,mBAAmB,CAAC,wBAAwB,CAAC,CAAC;CACxD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,mCAAmC,GACnC,iCAAiC,GACjC,kCAAkC,GAClC,+CAA+C,GAC/C,gDAAgD,GAChD,8CAA8C,GAC9C,+CAA+C,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,45 +24,49 @@ 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['
|
|
32
|
+
export type AnalyticsControllerTrackViewAction = {
|
|
33
|
+
type: `AnalyticsController:trackView`;
|
|
34
|
+
handler: AnalyticsController['trackView'];
|
|
37
35
|
};
|
|
38
36
|
/**
|
|
39
|
-
*
|
|
37
|
+
* Opt in to analytics for regular account.
|
|
38
|
+
* This updates the user's opt-in status for regular account.
|
|
40
39
|
*/
|
|
41
|
-
export type
|
|
42
|
-
type: `AnalyticsController:
|
|
43
|
-
handler: AnalyticsController['
|
|
40
|
+
export type AnalyticsControllerOptInForRegularAccountAction = {
|
|
41
|
+
type: `AnalyticsController:optInForRegularAccount`;
|
|
42
|
+
handler: AnalyticsController['optInForRegularAccount'];
|
|
44
43
|
};
|
|
45
44
|
/**
|
|
46
|
-
*
|
|
45
|
+
* Opt out of analytics for regular account.
|
|
46
|
+
* This updates the user's opt-in status for regular account.
|
|
47
47
|
*/
|
|
48
|
-
export type
|
|
49
|
-
type: `AnalyticsController:
|
|
50
|
-
handler: AnalyticsController['
|
|
48
|
+
export type AnalyticsControllerOptOutForRegularAccountAction = {
|
|
49
|
+
type: `AnalyticsController:optOutForRegularAccount`;
|
|
50
|
+
handler: AnalyticsController['optOutForRegularAccount'];
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
|
-
* Opt in to analytics.
|
|
53
|
+
* Opt in to analytics for social account.
|
|
54
|
+
* This updates the user's opt-in status for social account.
|
|
54
55
|
*/
|
|
55
|
-
export type
|
|
56
|
-
type: `AnalyticsController:
|
|
57
|
-
handler: AnalyticsController['
|
|
56
|
+
export type AnalyticsControllerOptInForSocialAccountAction = {
|
|
57
|
+
type: `AnalyticsController:optInForSocialAccount`;
|
|
58
|
+
handler: AnalyticsController['optInForSocialAccount'];
|
|
58
59
|
};
|
|
59
60
|
/**
|
|
60
|
-
* Opt out of analytics.
|
|
61
|
+
* Opt out of analytics for social account.
|
|
62
|
+
* This updates the user's opt-in status for social account.
|
|
61
63
|
*/
|
|
62
|
-
export type
|
|
63
|
-
type: `AnalyticsController:
|
|
64
|
-
handler: AnalyticsController['
|
|
64
|
+
export type AnalyticsControllerOptOutForSocialAccountAction = {
|
|
65
|
+
type: `AnalyticsController:optOutForSocialAccount`;
|
|
66
|
+
handler: AnalyticsController['optOutForSocialAccount'];
|
|
65
67
|
};
|
|
66
68
|
/**
|
|
67
69
|
* Union of all AnalyticsController action types.
|
|
68
70
|
*/
|
|
69
|
-
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction |
|
|
71
|
+
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackViewAction | AnalyticsControllerOptInForRegularAccountAction | AnalyticsControllerOptOutForRegularAccountAction | AnalyticsControllerOptInForSocialAccountAction | AnalyticsControllerOptOutForSocialAccountAction;
|
|
70
72
|
//# 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,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,mBAAmB,CAAC,wBAAwB,CAAC,CAAC;CACxD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,mBAAmB,CAAC,yBAAyB,CAAC,CAAC;CACzD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;CACvD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,mBAAmB,CAAC,wBAAwB,CAAC,CAAC;CACxD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GACxC,mCAAmC,GACnC,iCAAiC,GACjC,kCAAkC,GAClC,+CAA+C,GAC/C,gDAAgD,GAChD,8CAA8C,GAC9C,+CAA+C,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 for regular account.\n * This updates the user's opt-in status for regular account.\n */\nexport type AnalyticsControllerOptInForRegularAccountAction = {\n type: `AnalyticsController:optInForRegularAccount`;\n handler: AnalyticsController['optInForRegularAccount'];\n};\n\n/**\n * Opt out of analytics for regular account.\n * This updates the user's opt-in status for regular account.\n */\nexport type AnalyticsControllerOptOutForRegularAccountAction = {\n type: `AnalyticsController:optOutForRegularAccount`;\n handler: AnalyticsController['optOutForRegularAccount'];\n};\n\n/**\n * Opt in to analytics for social account.\n * This updates the user's opt-in status for social account.\n */\nexport type AnalyticsControllerOptInForSocialAccountAction = {\n type: `AnalyticsController:optInForSocialAccount`;\n handler: AnalyticsController['optInForSocialAccount'];\n};\n\n/**\n * Opt out of analytics for social account.\n * This updates the user's opt-in status for social account.\n */\nexport type AnalyticsControllerOptOutForSocialAccountAction = {\n type: `AnalyticsController:optOutForSocialAccount`;\n handler: AnalyticsController['optOutForSocialAccount'];\n};\n\n/**\n * Union of all AnalyticsController action types.\n */\nexport type AnalyticsControllerMethodActions =\n | AnalyticsControllerTrackEventAction\n | AnalyticsControllerIdentifyAction\n | AnalyticsControllerTrackViewAction\n | AnalyticsControllerOptInForRegularAccountAction\n | AnalyticsControllerOptOutForRegularAccountAction\n | AnalyticsControllerOptInForSocialAccountAction\n | AnalyticsControllerOptOutForSocialAccountAction;\n"]}
|