rudder-sdk-js 2.45.1 → 2.46.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.
@@ -0,0 +1,472 @@
1
+ declare module 'rudder-sdk-js' {
2
+ /**
3
+ * Represents the integration options object
4
+ * Example usages:
5
+ * integrationOptions { All: false, "Google Analytics": true, "Braze": true}
6
+ * integrationOptions { All: true, "Chartbeat": false, "Customer.io": false}
7
+ */
8
+ interface integrationOptions {
9
+ // Defaults to true
10
+ // If set to false, specific integration should be set to true to send the event
11
+ All?: boolean;
12
+ // Destination name: true/false/integration specific information
13
+ [index: string]: boolean | undefined | apiObject;
14
+ }
15
+
16
+ /**
17
+ * Represents the queue options parameter in loadOptions type
18
+ */
19
+ interface queueOptions {
20
+ // Upper cap on maximum delay for an event
21
+ maxRetryDelay?: number;
22
+ // Minimum delay before sending an event
23
+ minRetryDelay?: number;
24
+ // Exponential base
25
+ backoffFactor?: number;
26
+ // Maximum number of attempts
27
+ maxAttempts?: number;
28
+ // Maximum number of events in storage
29
+ maxItems?: number;
30
+ }
31
+
32
+ /**
33
+ * Represents the beacon queue options parameter in loadOptions type
34
+ */
35
+ interface beaconQueueOptions {
36
+ // Maximum number of events in storage
37
+ maxItems?: number;
38
+ // Time in milliseconds to flush the queue autometically
39
+ flushQueueInterval?: number;
40
+ }
41
+
42
+ /**
43
+ * Represents the beacon queue options parameter in loadOptions type
44
+ */
45
+ interface cookieConsentManager {
46
+ // OneTrust
47
+ oneTrust?: {
48
+ enabled: boolean;
49
+ };
50
+ // Ketch
51
+ ketch?: {
52
+ enabled: boolean;
53
+ };
54
+ }
55
+
56
+ /**
57
+ * Represents the options parameter for anonymousId
58
+ */
59
+ interface anonymousIdOptions {
60
+ autoCapture?: {
61
+ enabled?: boolean;
62
+ source?: string;
63
+ };
64
+ }
65
+
66
+ /**
67
+ * Represents residency server input the options
68
+ */
69
+ enum RESIDENCY_SERVER {
70
+ US = 'US',
71
+ EU = 'EU',
72
+ }
73
+
74
+ /**
75
+ * Represents the options parameter in the load API
76
+ */
77
+ interface loadOptions {
78
+ integrations?: integrationOptions;
79
+ // defaults to https://api.rudderstack.com
80
+ configUrl?: string;
81
+ queueOptions?: queueOptions;
82
+ // Defaults to true
83
+ loadIntegration?: boolean;
84
+ lockIntegrationsVersion?: boolean;
85
+ // Defaults to false
86
+ secureCookie?: boolean;
87
+ // Defaults to "Lax" (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite)
88
+ sameSiteCookie?: string;
89
+ logLevel?: string;
90
+ getSourceConfig?: () => string | apiObject | Promise<apiObject> | Promise<string>;
91
+ setCookieDomain?: string;
92
+ sendAdblockPage?: boolean;
93
+ sendAdblockPageOptions?: apiOptions;
94
+ clientSuppliedCallbacks?: { string: () => void };
95
+ useBeacon?: boolean; // Defaults to false
96
+ beaconQueueOptions?: beaconQueueOptions;
97
+ cookieConsentManager?: cookieConsentManager;
98
+ anonymousIdOptions?: anonymousIdOptions;
99
+ // defaults to https://cdn.rudderlabs.com/v1.1/js-integrations
100
+ destSDKBaseURL?: string;
101
+ sessions?: {
102
+ autoTrack?: boolean; // Defaults to true
103
+ timeout?: number; // Defaults to 30 mins
104
+ };
105
+ residencyServer?: RESIDENCY_SERVER;
106
+ // Controls whether the SDK should polyfill unsupported browser API's if they are detected as missing
107
+ // Defaults to true
108
+ polyfillIfRequired?: boolean;
109
+ uaChTrackLevel?: 'none' | 'default' | 'full';
110
+ onLoaded?: (analytics: any) => void;
111
+ useGlobalIntegrationsConfigInEvents?: boolean; // Default is false
112
+ }
113
+
114
+ /**
115
+ * Represents the options parameter in the APIs
116
+ */
117
+ interface apiOptions {
118
+ integrations?: integrationOptions;
119
+ anonymousId?: string;
120
+ // ISO 8601 date string
121
+ originalTimestamp?: string;
122
+ // Merged with event's contextual information
123
+ [index: string]:
124
+ | string
125
+ | number
126
+ | boolean
127
+ | apiObject
128
+ | (string | number | boolean | apiObject)[]
129
+ | integrationOptions
130
+ | undefined;
131
+ }
132
+
133
+ /**
134
+ * Represents a generic object in the APIs
135
+ * Use for parameters like properties, traits etc.
136
+ */
137
+ interface apiObject {
138
+ [index: string]:
139
+ | string
140
+ | number
141
+ | boolean
142
+ | apiObject
143
+ | (string | number | boolean | apiObject)[]
144
+ | undefined;
145
+ }
146
+
147
+ /**
148
+ * Represents the callback in the APIs
149
+ */
150
+ type apiCallback = () => void;
151
+
152
+ /**
153
+ * Call control pane to get client configs
154
+ * @param writeKey
155
+ * @param dataPlaneUrl
156
+ * @param options
157
+ */
158
+ function load(writeKey: string, dataPlaneUrl: string, options?: loadOptions): void;
159
+
160
+ /**
161
+ * To register a callback for SDK ready state
162
+ * @param callback
163
+ */
164
+ function ready(callback: apiCallback): void;
165
+
166
+ /**
167
+ * To record a page view event
168
+ * @param category
169
+ * @param name
170
+ * @param properties
171
+ * @param options
172
+ * @param callback
173
+ */
174
+ function page(
175
+ category?: string,
176
+ name?: string,
177
+ properties?: apiObject,
178
+ options?: apiOptions,
179
+ callback?: apiCallback,
180
+ ): void;
181
+
182
+ /**
183
+ * To record a page view event
184
+ * @param category
185
+ * @param name
186
+ * @param properties
187
+ * @param callback
188
+ */
189
+ function page(category: string, name: string, properties: apiObject, callback: apiCallback): void;
190
+
191
+ /**
192
+ * To record a page view event
193
+ * @param category
194
+ * @param name
195
+ * @param callback
196
+ */
197
+ function page(category: string, name: string, callback: apiCallback): void;
198
+
199
+ /**
200
+ * To record a page view event
201
+ * @param name
202
+ * @param properties
203
+ * @param options
204
+ * @param callback
205
+ */
206
+ function page(
207
+ name: string,
208
+ properties?: apiObject,
209
+ options?: apiOptions,
210
+ callback?: apiCallback,
211
+ ): void;
212
+
213
+ /**
214
+ * To record a page view event
215
+ * @param name
216
+ * @param properties
217
+ * @param callback
218
+ */
219
+ function page(name: string, properties: apiObject, callback: apiCallback): void;
220
+
221
+ /**
222
+ *
223
+ * @param name
224
+ * @param callback
225
+ */
226
+ function page(name: string, callback: apiCallback): void;
227
+
228
+ /**
229
+ *
230
+ * @param properties
231
+ * @param options
232
+ * @param callback
233
+ */
234
+ function page(properties: apiObject, options: apiOptions, callback?: apiCallback): void;
235
+
236
+ /**
237
+ * To record a page view event
238
+ * @param properties
239
+ * @param callback
240
+ */
241
+ function page(properties: apiObject, callback?: apiCallback): void;
242
+
243
+ /**
244
+ * To record a user track event
245
+ * @param event
246
+ * @param properties
247
+ * @param options
248
+ * @param callback
249
+ */
250
+ function track(
251
+ event: string,
252
+ properties?: apiObject,
253
+ options?: apiOptions,
254
+ callback?: apiCallback,
255
+ ): void;
256
+
257
+ /**
258
+ * To record a user track event
259
+ * @param event
260
+ * @param properties
261
+ * @param callback
262
+ */
263
+ function track(event: string, properties: apiObject, callback: apiCallback): void;
264
+
265
+ /**
266
+ * To record a user track event
267
+ * @param event
268
+ * @param callback
269
+ */
270
+ function track(event: string, callback: apiCallback): void;
271
+
272
+ /**
273
+ * To record a user identification event
274
+ * @param userId
275
+ * @param traits
276
+ * @param options
277
+ * @param callback
278
+ */
279
+ function identify(
280
+ userId?: string,
281
+ traits?: apiObject,
282
+ options?: apiOptions,
283
+ callback?: apiCallback,
284
+ ): void;
285
+
286
+ /**
287
+ * To record a user identification event
288
+ * @param userId
289
+ * @param traits
290
+ * @param callback
291
+ */
292
+ function identify(userId: string, traits: apiObject, callback: apiCallback): void;
293
+
294
+ /**
295
+ * To record a user identification event
296
+ * @param userId
297
+ * @param callback
298
+ */
299
+ function identify(userId: string, callback: apiCallback): void;
300
+
301
+ /**
302
+ *
303
+ * @param traits
304
+ * @param options
305
+ * @param callback
306
+ */
307
+ function identify(traits: apiObject, options: apiOptions, callback?: apiCallback): void;
308
+
309
+ /**
310
+ *
311
+ * @param traits
312
+ * @param callback
313
+ */
314
+ function identify(traits: apiObject, callback?: apiCallback): void;
315
+
316
+ /**
317
+ * To record a user alias event
318
+ * @param to
319
+ * @param from
320
+ * @param options
321
+ * @param callback
322
+ */
323
+ function alias(to: string, from?: string, options?: apiOptions, callback?: apiCallback): void;
324
+
325
+ /**
326
+ * To record a user alias event
327
+ * @param to
328
+ * @param from
329
+ * @param callback
330
+ */
331
+ function alias(to: string, from: string, callback: apiCallback): void;
332
+
333
+ /**
334
+ * To record a user alias event
335
+ * @param to
336
+ * @param callback
337
+ */
338
+ function alias(to: string, callback: apiCallback): void;
339
+
340
+ /**
341
+ * To record a user alias event
342
+ * @param to
343
+ * @param options
344
+ * @param callback
345
+ */
346
+ function alias(to: string, options: apiOptions, callback?: apiCallback): void;
347
+
348
+ /**
349
+ * To record a user group event
350
+ * @param groupId
351
+ * @param traits
352
+ * @param options
353
+ * @param callback
354
+ */
355
+ function group(
356
+ groupId: string,
357
+ traits?: apiObject,
358
+ options?: apiOptions,
359
+ callback?: apiCallback,
360
+ ): void;
361
+
362
+ /**
363
+ * To record a user group event
364
+ * @param groupId
365
+ * @param traits
366
+ * @param callback
367
+ */
368
+ function group(groupId: string, traits: apiObject, callback: apiCallback): void;
369
+
370
+ /**
371
+ * To record a user group event
372
+ * @param groupId
373
+ * @param callback
374
+ */
375
+ function group(groupId: string, callback: apiCallback): void;
376
+
377
+ /**
378
+ * To record a user group event
379
+ * @param traits
380
+ * @param options
381
+ * @param callback
382
+ */
383
+ function group(traits: apiObject, options: apiOptions, callback?: apiCallback): void;
384
+
385
+ /**
386
+ * To record a user group event
387
+ * @param traits
388
+ * @param callback
389
+ */
390
+ function group(traits: apiObject, callback?: apiCallback): void;
391
+
392
+ /**
393
+ * To get anonymousId set in the SDK
394
+ */
395
+ function getAnonymousId(options?: anonymousIdOptions): string;
396
+
397
+ /**
398
+ * To set anonymousId
399
+ * @param anonymousId
400
+ * @param rudderAmpLinkerParm AMP Linker ID string
401
+ */
402
+ function setAnonymousId(anonymousId?: string, rudderAmpLinkerParm?: string): void;
403
+
404
+ /**
405
+ * Clear user information
406
+ * @param flag If true, clears anonymousId as well
407
+ */
408
+ function reset(flag?: boolean): void;
409
+
410
+ /**
411
+ * To get userId set in the SDK
412
+ */
413
+ function getUserId(): string;
414
+
415
+ /**
416
+ * To get user traits set in the SDK
417
+ */
418
+ function getUserTraits(): apiObject;
419
+
420
+ /**
421
+ * To get groupId set in the SDK
422
+ */
423
+ function getGroupId(): string;
424
+
425
+ /**
426
+ * To get group traits set in the SDK
427
+ */
428
+ function getGroupTraits(): apiObject;
429
+
430
+ /**
431
+ * To manually start user session in the SDK
432
+ */
433
+ function startSession(sessionId?: number): void;
434
+
435
+ /**
436
+ * To manually end user session in the SDK
437
+ */
438
+ function endSession(): void;
439
+
440
+ /**
441
+ * To fetch the current sessionId
442
+ */
443
+ function getSessionId(): number | null;
444
+
445
+ export {
446
+ integrationOptions,
447
+ loadOptions,
448
+ apiOptions,
449
+ queueOptions,
450
+ apiObject,
451
+ apiCallback,
452
+ anonymousIdOptions,
453
+ load,
454
+ ready,
455
+ reset,
456
+ page,
457
+ track,
458
+ identify,
459
+ alias,
460
+ group,
461
+ setAnonymousId,
462
+ getAnonymousId,
463
+ getUserId,
464
+ getUserTraits,
465
+ getGroupId,
466
+ getGroupTraits,
467
+ startSession,
468
+ endSession,
469
+ RESIDENCY_SERVER,
470
+ getSessionId,
471
+ };
472
+ }