@metamask-previews/analytics-controller 0.0.0-preview-de995bed → 0.0.0-preview-cb4a07d5
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 +30 -174
- package/dist/AnalyticsController-method-action-types.cjs.map +1 -1
- package/dist/AnalyticsController-method-action-types.d.cts +8 -24
- package/dist/AnalyticsController-method-action-types.d.cts.map +1 -1
- package/dist/AnalyticsController-method-action-types.d.mts +8 -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 +102 -78
- package/dist/AnalyticsController.cjs.map +1 -1
- package/dist/AnalyticsController.d.cts +48 -34
- package/dist/AnalyticsController.d.cts.map +1 -1
- package/dist/AnalyticsController.d.mts +48 -34
- package/dist/AnalyticsController.d.mts.map +1 -1
- package/dist/AnalyticsController.mjs +103 -79
- 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 +6 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +6 -5
- 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 +36 -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 +33 -0
- package/dist/selectors.mjs.map +1 -0
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
# `@metamask/analytics-controller`
|
|
2
2
|
|
|
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
|
|
3
|
+
Common Analytics controller for event tracking across MetaMask client platforms.
|
|
14
4
|
|
|
15
5
|
## Installation
|
|
16
6
|
|
|
@@ -20,188 +10,54 @@ or
|
|
|
20
10
|
|
|
21
11
|
`npm install @metamask/analytics-controller`
|
|
22
12
|
|
|
23
|
-
##
|
|
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
|
-
});
|
|
13
|
+
## Overview
|
|
107
14
|
|
|
108
|
-
|
|
109
|
-
console.log(controller.state.analyticsId); // '550e8400-e29b-41d4-a716-446655440000'
|
|
110
|
-
```
|
|
15
|
+
The AnalyticsController provides a unified interface for tracking analytics events, identifying users, and managing analytics preferences. It delegates client platform-specific implementation to an `AnalyticsPlatformAdapter` and integrates with the MetaMask messenger system for inter-controller communication.
|
|
111
16
|
|
|
112
|
-
|
|
17
|
+
## Client Platform-Managed Storage
|
|
113
18
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
referrer: 'google',
|
|
117
|
-
campaign: 'summer-2024',
|
|
118
|
-
});
|
|
119
|
-
```
|
|
19
|
+
> [!NOTE]
|
|
20
|
+
> "Client platform" means mobile or extension
|
|
120
21
|
|
|
121
|
-
|
|
22
|
+
The controller does not persist state internally. The client platform is responsible for loading and persisting analytics settings. This design enables:
|
|
122
23
|
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
});
|
|
24
|
+
- **Early access**: The client platform can read the `analyticsId` before the controller is initialized, useful for other controllers or early startup code
|
|
25
|
+
- **Resilience**: Storing analytics settings separately from main state protects them from state corruption, allowing analytics to continue working even when main state is corrupted
|
|
142
26
|
|
|
143
|
-
|
|
144
|
-
'AnalyticsController:identify',
|
|
145
|
-
'550e8400-e29b-41d4-a716-446655440000',
|
|
146
|
-
{
|
|
147
|
-
email: 'newuser@example.com',
|
|
148
|
-
},
|
|
149
|
-
);
|
|
27
|
+
Load settings from storage **before** initializing the controller, then subscribe to `AnalyticsController:stateChange` events to persist any state changes.
|
|
150
28
|
|
|
151
|
-
|
|
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
|
-
```
|
|
29
|
+
## State
|
|
168
30
|
|
|
169
|
-
|
|
31
|
+
| Field | Type | Description | Persisted |
|
|
32
|
+
| ------------- | --------- | --------------------------------------------- | --------- |
|
|
33
|
+
| `analyticsId` | `string` | UUIDv4 identifier (client platform-generated) | No |
|
|
34
|
+
| `optedIn` | `boolean` | User opt-in status | Yes |
|
|
170
35
|
|
|
171
|
-
### Default
|
|
172
|
-
|
|
173
|
-
The default state is provided by `getDefaultAnalyticsControllerState()`:
|
|
36
|
+
### Why `analyticsId` Has No Default
|
|
174
37
|
|
|
175
|
-
|
|
176
|
-
import { getDefaultAnalyticsControllerState } from '@metamask/analytics-controller';
|
|
38
|
+
The `analyticsId` uniquely identifies the user. If the controller generated a new ID on each boot, the ID would be ineffective. The client platform must generate a UUID on first run, persist it, and provide it to the controller constructor.
|
|
177
39
|
|
|
178
|
-
|
|
179
|
-
// {
|
|
180
|
-
// enabled: true,
|
|
181
|
-
// optedIn: false,
|
|
182
|
-
// analyticsId: auto-generated UUIDv4
|
|
183
|
-
// }
|
|
184
|
-
```
|
|
40
|
+
### Client Platform Responsibilities
|
|
185
41
|
|
|
186
|
-
|
|
42
|
+
1. **Generate UUID on first run**: Use `uuid` package or client platform equivalent
|
|
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)
|
|
187
46
|
|
|
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
|
|
47
|
+
## Anonymous Events Feature
|
|
191
48
|
|
|
192
|
-
|
|
49
|
+
When `isAnonymousEventsFeatureEnabled` is enabled in the constructor, events with sensitive properties are split into separate events:
|
|
193
50
|
|
|
194
|
-
**
|
|
51
|
+
- **Regular properties event**: Tracked first with only `properties` (uses user ID)
|
|
52
|
+
- **Sensitive properties event**: Tracked separately with both `properties` and `sensitiveProperties` (uses anonymous ID)
|
|
195
53
|
|
|
196
|
-
|
|
54
|
+
This allows sensitive data to be tracked anonymously while maintaining user identification for regular properties. When disabled (default), all properties are tracked in a single event.
|
|
197
55
|
|
|
198
|
-
|
|
56
|
+
## Lifecycle Hooks
|
|
199
57
|
|
|
200
|
-
|
|
201
|
-
export DEBUG="metamask:analytics-controller"
|
|
202
|
-
```
|
|
58
|
+
### `onSetupCompleted`
|
|
203
59
|
|
|
204
|
-
|
|
60
|
+
Called once after controller initialization with a guaranteed valid `analyticsId`. Use this for client platform-specific setup that requires the analytics ID (e.g., adding plugins). Errors in `onSetupCompleted` are caught and logged—they don't break the controller.
|
|
205
61
|
|
|
206
62
|
## Contributing
|
|
207
63
|
|
|
@@ -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 */\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 | 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,28 +24,14 @@ 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.
|
|
@@ -66,5 +50,5 @@ export type AnalyticsControllerOptOutAction = {
|
|
|
66
50
|
/**
|
|
67
51
|
* Union of all AnalyticsController action types.
|
|
68
52
|
*/
|
|
69
|
-
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction |
|
|
53
|
+
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackViewAction | AnalyticsControllerOptInAction | AnalyticsControllerOptOutAction;
|
|
70
54
|
//# 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;;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,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,28 +24,14 @@ 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.
|
|
@@ -66,5 +50,5 @@ export type AnalyticsControllerOptOutAction = {
|
|
|
66
50
|
/**
|
|
67
51
|
* Union of all AnalyticsController action types.
|
|
68
52
|
*/
|
|
69
|
-
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction |
|
|
53
|
+
export type AnalyticsControllerMethodActions = AnalyticsControllerTrackEventAction | AnalyticsControllerIdentifyAction | AnalyticsControllerTrackViewAction | AnalyticsControllerOptInAction | AnalyticsControllerOptOutAction;
|
|
70
54
|
//# 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;;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,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 */\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 | AnalyticsControllerTrackViewAction\n | AnalyticsControllerOptInAction\n | AnalyticsControllerOptOutAction;\n"]}
|