cryptique-sdk 1.2.23 → 1.2.24
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/lib/cjs/index.js +624 -614
- package/lib/esm/index.js +624 -614
- package/lib/types/index.d.ts +284 -250
- package/lib/umd/index.js +624 -614
- package/package.json +1 -1
package/lib/types/index.d.ts
CHANGED
|
@@ -1,250 +1,284 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cryptique Analytics SDK - TypeScript Definitions
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export interface CryptiqueOptions {
|
|
6
|
-
siteId: string;
|
|
7
|
-
autoEvents?: boolean;
|
|
8
|
-
disabledPaths?: string[];
|
|
9
|
-
disabledEvents?: string[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface AutoEventsConfig {
|
|
13
|
-
enabled: boolean;
|
|
14
|
-
disabledPaths: string[];
|
|
15
|
-
disabledEvents: string[];
|
|
16
|
-
availableEvents: string[];
|
|
17
|
-
currentPath: string;
|
|
18
|
-
shouldTrack: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface SessionData {
|
|
22
|
-
sessionId: string | null;
|
|
23
|
-
siteId: string;
|
|
24
|
-
userId: string | null;
|
|
25
|
-
startTime: string | null;
|
|
26
|
-
endTime: string | null;
|
|
27
|
-
lastActivity: number | null;
|
|
28
|
-
duration: number;
|
|
29
|
-
pagesViewed: number;
|
|
30
|
-
isBounce: boolean;
|
|
31
|
-
[key: string]: any;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface Interaction {
|
|
35
|
-
timestamp: string;
|
|
36
|
-
category: string;
|
|
37
|
-
originalCategory: string;
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface PeopleResult {
|
|
42
|
-
success: boolean;
|
|
43
|
-
error?: string;
|
|
44
|
-
[key: string]: any;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface PeopleManager {
|
|
48
|
-
/**
|
|
49
|
-
* Set custom properties (merge at top level)
|
|
50
|
-
*/
|
|
51
|
-
set(properties: Record<string, any>): Promise<PeopleResult>;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Set custom properties only if they don't exist
|
|
55
|
-
*/
|
|
56
|
-
setOnce(properties: Record<string, any>): Promise<PeopleResult>;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Remove custom properties
|
|
60
|
-
*/
|
|
61
|
-
unset(
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Increment numeric
|
|
65
|
-
*/
|
|
66
|
-
increment(
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Append values to
|
|
70
|
-
*/
|
|
71
|
-
append(
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Union values with
|
|
75
|
-
*/
|
|
76
|
-
union(
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Remove values from
|
|
80
|
-
*/
|
|
81
|
-
remove(
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Track a charge/revenue event
|
|
85
|
-
*/
|
|
86
|
-
trackCharge(amount: number, properties?: Record<string, any>): Promise<PeopleResult>;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Clear all charges
|
|
90
|
-
*/
|
|
91
|
-
clearCharges(): Promise<PeopleResult>;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Delete user and all associated data
|
|
95
|
-
*/
|
|
96
|
-
deleteUser(): Promise<PeopleResult>;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Cryptique Analytics SDK - TypeScript Definitions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export interface CryptiqueOptions {
|
|
6
|
+
siteId: string;
|
|
7
|
+
autoEvents?: boolean;
|
|
8
|
+
disabledPaths?: string[];
|
|
9
|
+
disabledEvents?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface AutoEventsConfig {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
disabledPaths: string[];
|
|
15
|
+
disabledEvents: string[];
|
|
16
|
+
availableEvents: string[];
|
|
17
|
+
currentPath: string;
|
|
18
|
+
shouldTrack: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SessionData {
|
|
22
|
+
sessionId: string | null;
|
|
23
|
+
siteId: string;
|
|
24
|
+
userId: string | null;
|
|
25
|
+
startTime: string | null;
|
|
26
|
+
endTime: string | null;
|
|
27
|
+
lastActivity: number | null;
|
|
28
|
+
duration: number;
|
|
29
|
+
pagesViewed: number;
|
|
30
|
+
isBounce: boolean;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Interaction {
|
|
35
|
+
timestamp: string;
|
|
36
|
+
category: string;
|
|
37
|
+
originalCategory: string;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface PeopleResult {
|
|
42
|
+
success: boolean;
|
|
43
|
+
error?: string;
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface PeopleManager {
|
|
48
|
+
/**
|
|
49
|
+
* Set custom properties (merge at top level)
|
|
50
|
+
*/
|
|
51
|
+
set(properties: Record<string, any>): Promise<PeopleResult>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Set custom properties only if they don't exist
|
|
55
|
+
*/
|
|
56
|
+
setOnce(properties: Record<string, any>): Promise<PeopleResult>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Remove custom properties
|
|
60
|
+
*/
|
|
61
|
+
unset(keys: string | string[]): Promise<PeopleResult>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Increment a numeric property by key
|
|
65
|
+
*/
|
|
66
|
+
increment(key: string, amount?: number): Promise<PeopleResult>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Append values to an array property
|
|
70
|
+
*/
|
|
71
|
+
append(key: string, values: any[]): Promise<PeopleResult>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Union values with an array property (deduplicate)
|
|
75
|
+
*/
|
|
76
|
+
union(key: string, values: any[]): Promise<PeopleResult>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Remove values from an array property
|
|
80
|
+
*/
|
|
81
|
+
remove(key: string, values: any[]): Promise<PeopleResult>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Track a charge/revenue event
|
|
85
|
+
*/
|
|
86
|
+
trackCharge(amount: number, properties?: Record<string, any>): Promise<PeopleResult>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Clear all charges
|
|
90
|
+
*/
|
|
91
|
+
clearCharges(): Promise<PeopleResult>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Delete user and all associated data
|
|
95
|
+
*/
|
|
96
|
+
deleteUser(): Promise<PeopleResult>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Returned by get_group(); profile calls hit the groups profile API.
|
|
101
|
+
*/
|
|
102
|
+
export interface GroupProfileRef {
|
|
103
|
+
set(properties: Record<string, any>): Promise<PeopleResult>;
|
|
104
|
+
set_once(properties: Record<string, any>): Promise<PeopleResult>;
|
|
105
|
+
union(listName: string, values: any[]): Promise<PeopleResult>;
|
|
106
|
+
remove(listName: string, value: any): Promise<PeopleResult>;
|
|
107
|
+
unset(property: string): Promise<PeopleResult>;
|
|
108
|
+
increment(property: string, value?: number): Promise<PeopleResult>;
|
|
109
|
+
append(property: string, value: any): Promise<PeopleResult>;
|
|
110
|
+
delete(): Promise<PeopleResult>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export default class CryptiqueSDK {
|
|
114
|
+
/**
|
|
115
|
+
* Initialize the SDK programmatically
|
|
116
|
+
* Returns a Promise that resolves when the SDK is fully initialized
|
|
117
|
+
*/
|
|
118
|
+
init(options: CryptiqueOptions): Promise<any>;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Get the SDK instance
|
|
122
|
+
*/
|
|
123
|
+
getInstance(): any | null;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Wait for SDK to be fully initialized
|
|
127
|
+
*/
|
|
128
|
+
ready(): Promise<void>;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Track a custom event
|
|
132
|
+
*/
|
|
133
|
+
track(eventName: string, properties?: object, options?: object): Promise<void>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Track a custom event (alias for track)
|
|
137
|
+
*/
|
|
138
|
+
trackEvent(eventName: string, properties?: object, options?: object): Promise<void>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Track an auto event
|
|
142
|
+
*/
|
|
143
|
+
trackAutoEvent(eventName: string, autoEventData?: object, elementData?: object): Promise<void>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Connect wallet
|
|
147
|
+
*/
|
|
148
|
+
connectWallet(): Promise<string | null>;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Check if wallet is connected
|
|
152
|
+
*/
|
|
153
|
+
isWalletConnected(): Promise<boolean>;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Update wallet info
|
|
157
|
+
*/
|
|
158
|
+
updateWalletInfo(): Promise<any>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Identify a user with a unique identifier
|
|
162
|
+
* Merges identities if the identifier already exists for another user
|
|
163
|
+
*/
|
|
164
|
+
identify(identifyId: string): Promise<{ success: boolean; merged?: boolean; newUserId?: string; error?: string }>;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Set wallet address for current user
|
|
168
|
+
* Merges identities if wallet address already exists for another user
|
|
169
|
+
*/
|
|
170
|
+
walletAddress(walletAddress: string): Promise<{ success: boolean; merged?: boolean; newUserId?: string; error?: string }>;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Reset user identity to anonymous
|
|
174
|
+
* Generates a new anonymous distinct_id and clears identification
|
|
175
|
+
*/
|
|
176
|
+
reset(): Promise<{ success: boolean; distinctId?: string; error?: string }>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Set tracking consent
|
|
180
|
+
*/
|
|
181
|
+
setTrackingConsent(consent: boolean): void;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Get tracking consent
|
|
185
|
+
*/
|
|
186
|
+
getTrackingConsent(): boolean;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Get session data
|
|
190
|
+
*/
|
|
191
|
+
getSessionData(): SessionData;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Get chronological interactions
|
|
195
|
+
*/
|
|
196
|
+
getChronologicalInteractions(): Interaction[];
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Sort interactions chronologically (alias)
|
|
200
|
+
*/
|
|
201
|
+
sortInteractionsChronologically(): Interaction[];
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Enable auto events
|
|
205
|
+
*/
|
|
206
|
+
enableAutoEvents(): void;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Disable auto events
|
|
210
|
+
*/
|
|
211
|
+
disableAutoEvents(): void;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Set auto events disabled paths
|
|
215
|
+
*/
|
|
216
|
+
setAutoEventsDisabledPaths(paths: string | string[]): void;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Disable specific auto events
|
|
220
|
+
*/
|
|
221
|
+
disableAutoEvent(events: string | string[]): void;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Enable specific auto events
|
|
225
|
+
*/
|
|
226
|
+
enableAutoEvent(events: string | string[]): void;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Set auto events disabled events
|
|
230
|
+
*/
|
|
231
|
+
setAutoEventsDisabledEvents(events: string[]): void;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Get available auto events
|
|
235
|
+
*/
|
|
236
|
+
getAvailableAutoEvents(): string[];
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Get auto events configuration
|
|
240
|
+
*/
|
|
241
|
+
getAutoEventsConfig(): AutoEventsConfig;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* People manager for custom user properties
|
|
245
|
+
*/
|
|
246
|
+
people: PeopleManager;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Set (overwrite) group membership for a key
|
|
250
|
+
*/
|
|
251
|
+
set_group(groupKey: string, groupId: string | string[]): Promise<PeopleResult>;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Add a group id to a key without removing existing memberships
|
|
255
|
+
*/
|
|
256
|
+
add_group(groupKey: string, groupId: string): Promise<PeopleResult>;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Remove a specific group id from a key
|
|
260
|
+
*/
|
|
261
|
+
remove_group(groupKey: string, groupId: string): Promise<PeopleResult>;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Group profile operations for a specific (groupKey, groupId)
|
|
265
|
+
*/
|
|
266
|
+
get_group(groupKey: string, groupId: string): GroupProfileRef;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* SDK version
|
|
270
|
+
*/
|
|
271
|
+
version: string;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Site ID
|
|
275
|
+
*/
|
|
276
|
+
siteId: string;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Session data
|
|
280
|
+
*/
|
|
281
|
+
sessionData: SessionData;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export { CryptiqueSDK };
|