@bentolabs/sdk 1.2.2 → 2.0.0
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/dist/index.d.ts +188 -27
- package/dist/index.js +1516 -169
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import { generateSelector } from 'rrweb';
|
|
2
|
-
export { generateSelector };
|
|
1
|
+
import { generateSelector, generateSelectorFromElement, generateSelectorFromHTML } from 'rrweb';
|
|
2
|
+
export { generateSelector, generateSelectorFromElement, generateSelectorFromHTML };
|
|
3
|
+
interface NetworkOptions {
|
|
4
|
+
skipUrls?: string[];
|
|
5
|
+
captureHeaders?: boolean;
|
|
6
|
+
captureBody?: boolean;
|
|
7
|
+
maxBodySize?: number;
|
|
8
|
+
sampleRate?: number;
|
|
9
|
+
}
|
|
10
|
+
interface StorageOptions {
|
|
11
|
+
localStorage?: boolean;
|
|
12
|
+
sessionStorage?: boolean;
|
|
13
|
+
cookies?: boolean;
|
|
14
|
+
sensitiveKeys?: string[];
|
|
15
|
+
}
|
|
16
|
+
interface ConsoleOptions {
|
|
17
|
+
levels?: ('log' | 'warn' | 'error' | 'info' | 'debug')[];
|
|
18
|
+
maxLogs?: number;
|
|
19
|
+
maxPayloadSize?: number;
|
|
20
|
+
captureStackTrace?: boolean;
|
|
21
|
+
}
|
|
3
22
|
interface SDKConfig {
|
|
4
23
|
apiKey: string;
|
|
5
24
|
endpoint: string;
|
|
@@ -9,6 +28,22 @@ interface SDKConfig {
|
|
|
9
28
|
enableRecording: boolean;
|
|
10
29
|
maxRetries: number;
|
|
11
30
|
baseRetryDelay: number;
|
|
31
|
+
enableCompression: boolean;
|
|
32
|
+
persistence: 'localStorage' | 'cookie' | 'localStorage+cookie' | 'memory' | 'none';
|
|
33
|
+
respect_dnt: boolean;
|
|
34
|
+
autocapture: boolean;
|
|
35
|
+
capture_pageview: boolean;
|
|
36
|
+
capture_pageleave: boolean;
|
|
37
|
+
capture_network: boolean;
|
|
38
|
+
networkOptions: NetworkOptions;
|
|
39
|
+
capture_storage: boolean;
|
|
40
|
+
storageOptions: StorageOptions;
|
|
41
|
+
capture_console: boolean;
|
|
42
|
+
consoleOptions: ConsoleOptions;
|
|
43
|
+
bootstrap?: {
|
|
44
|
+
distinctID?: string;
|
|
45
|
+
isIdentifiedID?: boolean;
|
|
46
|
+
};
|
|
12
47
|
}
|
|
13
48
|
interface SDKOptions {
|
|
14
49
|
endpoint?: string;
|
|
@@ -18,6 +53,64 @@ interface SDKOptions {
|
|
|
18
53
|
enableRecording?: boolean;
|
|
19
54
|
maxRetries?: number;
|
|
20
55
|
baseRetryDelay?: number;
|
|
56
|
+
enableCompression?: boolean;
|
|
57
|
+
persistence?: 'localStorage' | 'cookie' | 'localStorage+cookie' | 'memory' | 'none';
|
|
58
|
+
respect_dnt?: boolean;
|
|
59
|
+
autocapture?: boolean;
|
|
60
|
+
capture_pageview?: boolean;
|
|
61
|
+
capture_pageleave?: boolean;
|
|
62
|
+
capture_network?: boolean;
|
|
63
|
+
networkOptions?: NetworkOptions;
|
|
64
|
+
capture_storage?: boolean;
|
|
65
|
+
storageOptions?: StorageOptions;
|
|
66
|
+
capture_console?: boolean;
|
|
67
|
+
consoleOptions?: ConsoleOptions;
|
|
68
|
+
bootstrap?: {
|
|
69
|
+
distinctID?: string;
|
|
70
|
+
isIdentifiedID?: boolean;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
interface UserProperties {
|
|
74
|
+
[key: string]: string | number | boolean | null | undefined;
|
|
75
|
+
}
|
|
76
|
+
interface NetworkLog {
|
|
77
|
+
url: string;
|
|
78
|
+
method: string;
|
|
79
|
+
status: number;
|
|
80
|
+
duration: number;
|
|
81
|
+
responseSize: number;
|
|
82
|
+
initiator: 'fetch' | 'xhr';
|
|
83
|
+
error?: string;
|
|
84
|
+
timestamp: number;
|
|
85
|
+
}
|
|
86
|
+
interface StorageLog {
|
|
87
|
+
storageType: 'localStorage' | 'sessionStorage' | 'cookie';
|
|
88
|
+
operation: 'get' | 'set' | 'remove' | 'clear';
|
|
89
|
+
key: string;
|
|
90
|
+
valueType?: string;
|
|
91
|
+
timestamp: number;
|
|
92
|
+
}
|
|
93
|
+
interface ConsoleLog {
|
|
94
|
+
level: 'log' | 'warn' | 'error' | 'info' | 'debug';
|
|
95
|
+
payload: string[];
|
|
96
|
+
trace: string[];
|
|
97
|
+
timestamp: number;
|
|
98
|
+
}
|
|
99
|
+
declare class PeopleAPI {
|
|
100
|
+
private sdk;
|
|
101
|
+
constructor(sdk: BentoLabsSDK);
|
|
102
|
+
/**
|
|
103
|
+
* Set properties on the current user
|
|
104
|
+
*/
|
|
105
|
+
set(properties: UserProperties): void;
|
|
106
|
+
/**
|
|
107
|
+
* Set properties on the current user only if they haven't been set already
|
|
108
|
+
*/
|
|
109
|
+
setOnce(properties: UserProperties): void;
|
|
110
|
+
/**
|
|
111
|
+
* Remove properties from the current user
|
|
112
|
+
*/
|
|
113
|
+
unset(propertyNames: string[]): void;
|
|
21
114
|
}
|
|
22
115
|
export declare class BentoLabsSDK {
|
|
23
116
|
private config;
|
|
@@ -26,46 +119,107 @@ export declare class BentoLabsSDK {
|
|
|
26
119
|
private isRecording;
|
|
27
120
|
private batchTimer;
|
|
28
121
|
private retryTimer;
|
|
29
|
-
private
|
|
122
|
+
private stopRecordingFn;
|
|
123
|
+
private distinctId;
|
|
124
|
+
private identity;
|
|
125
|
+
private superProperties;
|
|
126
|
+
private persistence;
|
|
127
|
+
private initialized;
|
|
128
|
+
private optedOut;
|
|
129
|
+
private networkMonitor;
|
|
130
|
+
private storageMonitor;
|
|
131
|
+
private consoleMonitor;
|
|
132
|
+
people: PeopleAPI;
|
|
133
|
+
private autocaptureCleanup;
|
|
30
134
|
constructor();
|
|
31
135
|
/**
|
|
32
136
|
* Initialize the BentoLabs SDK
|
|
33
|
-
* @param apiKey - Your API key for authentication
|
|
34
|
-
* @param options - Optional configuration options
|
|
35
137
|
*/
|
|
36
138
|
init(apiKey: string, options?: SDKOptions): void;
|
|
37
139
|
/**
|
|
38
|
-
*
|
|
140
|
+
* Identify a user with a distinct ID and optional properties
|
|
39
141
|
*/
|
|
40
|
-
|
|
142
|
+
identify(distinctId: string, properties?: UserProperties): void;
|
|
41
143
|
/**
|
|
42
|
-
*
|
|
144
|
+
* Reset the user to an anonymous state
|
|
43
145
|
*/
|
|
44
|
-
|
|
146
|
+
reset(): void;
|
|
45
147
|
/**
|
|
46
|
-
*
|
|
148
|
+
* Get the current distinct ID
|
|
47
149
|
*/
|
|
48
|
-
|
|
150
|
+
getDistinctId(): string;
|
|
49
151
|
/**
|
|
50
|
-
*
|
|
152
|
+
* Register super properties to be sent with every event
|
|
51
153
|
*/
|
|
52
|
-
|
|
154
|
+
register(properties: Record<string, unknown>): void;
|
|
53
155
|
/**
|
|
54
|
-
*
|
|
156
|
+
* Register super properties only if they haven't been set
|
|
55
157
|
*/
|
|
56
|
-
|
|
158
|
+
registerOnce(properties: Record<string, unknown>): void;
|
|
57
159
|
/**
|
|
58
|
-
*
|
|
160
|
+
* Remove a super property
|
|
59
161
|
*/
|
|
60
|
-
|
|
162
|
+
unregister(propertyName: string): void;
|
|
61
163
|
/**
|
|
62
|
-
*
|
|
164
|
+
* Capture an event
|
|
63
165
|
*/
|
|
64
|
-
|
|
166
|
+
capture(eventName: string, properties?: Record<string, unknown>): void;
|
|
65
167
|
/**
|
|
66
|
-
*
|
|
168
|
+
* Track a custom event (legacy method, delegates to capture)
|
|
67
169
|
*/
|
|
68
|
-
|
|
170
|
+
trackCustomEvent(eventName: string, data?: Record<string, unknown>): void;
|
|
171
|
+
/**
|
|
172
|
+
* Opt out of tracking
|
|
173
|
+
*/
|
|
174
|
+
opt_out_capturing(): void;
|
|
175
|
+
/**
|
|
176
|
+
* Opt back into tracking
|
|
177
|
+
*/
|
|
178
|
+
opt_in_capturing(): void;
|
|
179
|
+
/**
|
|
180
|
+
* Check if user has opted out
|
|
181
|
+
*/
|
|
182
|
+
has_opted_out_capturing(): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Check if user has opted in (not opted out)
|
|
185
|
+
*/
|
|
186
|
+
has_opted_in_capturing(): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Start network request monitoring
|
|
189
|
+
*/
|
|
190
|
+
startNetworkCapture(): void;
|
|
191
|
+
/**
|
|
192
|
+
* Stop network request monitoring
|
|
193
|
+
*/
|
|
194
|
+
stopNetworkCapture(): void;
|
|
195
|
+
/**
|
|
196
|
+
* Start storage monitoring
|
|
197
|
+
*/
|
|
198
|
+
startStorageCapture(): void;
|
|
199
|
+
/**
|
|
200
|
+
* Stop storage monitoring
|
|
201
|
+
*/
|
|
202
|
+
stopStorageCapture(): void;
|
|
203
|
+
/**
|
|
204
|
+
* Start console monitoring
|
|
205
|
+
*/
|
|
206
|
+
startConsoleCapture(): void;
|
|
207
|
+
/**
|
|
208
|
+
* Stop console monitoring
|
|
209
|
+
*/
|
|
210
|
+
stopConsoleCapture(): void;
|
|
211
|
+
/**
|
|
212
|
+
* Get network logs
|
|
213
|
+
*/
|
|
214
|
+
getNetworkLogs(): NetworkLog[];
|
|
215
|
+
/**
|
|
216
|
+
* Get storage logs
|
|
217
|
+
*/
|
|
218
|
+
getStorageLogs(): StorageLog[];
|
|
219
|
+
/**
|
|
220
|
+
* Get console logs
|
|
221
|
+
*/
|
|
222
|
+
getConsoleLogs(): ConsoleLog[];
|
|
69
223
|
/**
|
|
70
224
|
* Stop recording and clean up resources
|
|
71
225
|
*/
|
|
@@ -92,12 +246,19 @@ export declare class BentoLabsSDK {
|
|
|
92
246
|
* Manually trigger a batch send
|
|
93
247
|
*/
|
|
94
248
|
flushEvents(): Promise<void>;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
249
|
+
private generateSessionId;
|
|
250
|
+
private generateAnonymousId;
|
|
251
|
+
private generateUUID;
|
|
252
|
+
private isDNTEnabled;
|
|
253
|
+
private loadPersistedState;
|
|
254
|
+
private startRecording;
|
|
255
|
+
private startBatching;
|
|
256
|
+
private addEvent;
|
|
257
|
+
private sendBatch;
|
|
258
|
+
private scheduleRetry;
|
|
259
|
+
private stopRecordingInternal;
|
|
260
|
+
private setupAutocapture;
|
|
261
|
+
private handlePageLeave;
|
|
101
262
|
}
|
|
102
263
|
declare const sdk: BentoLabsSDK;
|
|
103
264
|
export default sdk;
|