@jitsu/protocols 1.9.10 → 1.9.12
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/analytics.d.ts +52 -3
- package/package.json +1 -1
package/analytics.d.ts
CHANGED
|
@@ -12,12 +12,19 @@ export type WithConfidence<T> = T & {
|
|
|
12
12
|
export type Geo = {
|
|
13
13
|
continent?: {
|
|
14
14
|
code: "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
|
|
15
|
+
/**
|
|
16
|
+
* Localized name of the continent
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
15
19
|
};
|
|
16
20
|
country?: {
|
|
17
21
|
/**
|
|
18
22
|
* Two-letter country code (ISO 3166-1 alpha-2): https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
|
19
23
|
*/
|
|
20
24
|
code: string;
|
|
25
|
+
/**
|
|
26
|
+
* Localized name of the country
|
|
27
|
+
*/
|
|
21
28
|
name: string;
|
|
22
29
|
isEU: boolean;
|
|
23
30
|
};
|
|
@@ -27,8 +34,15 @@ export type Geo = {
|
|
|
27
34
|
* For USA it's two-letter capitaluzed state code (such as NY)
|
|
28
35
|
*/
|
|
29
36
|
code: string;
|
|
37
|
+
/**
|
|
38
|
+
* Localized name of the region
|
|
39
|
+
*/
|
|
40
|
+
name: string;
|
|
30
41
|
}>;
|
|
31
42
|
city?: WithConfidence<{
|
|
43
|
+
/**
|
|
44
|
+
* Localized name of the city
|
|
45
|
+
*/
|
|
32
46
|
name: string;
|
|
33
47
|
}>;
|
|
34
48
|
|
|
@@ -189,7 +203,7 @@ interface AnalyticsContext {
|
|
|
189
203
|
|
|
190
204
|
locale?: string;
|
|
191
205
|
|
|
192
|
-
|
|
206
|
+
xlibrary?: {
|
|
193
207
|
name: string;
|
|
194
208
|
version: string;
|
|
195
209
|
//allow to add custom fields
|
|
@@ -316,6 +330,8 @@ export type RuntimeFacade = {
|
|
|
316
330
|
pageTitle(): string | undefined;
|
|
317
331
|
};
|
|
318
332
|
|
|
333
|
+
export type ErrorHandler = (message: string, ...args: any[]) => void;
|
|
334
|
+
|
|
319
335
|
export type JitsuOptions = {
|
|
320
336
|
/**
|
|
321
337
|
* API Key. Optional. If not set, Jitsu will send event to the server without auth, and server
|
|
@@ -330,12 +346,29 @@ export type JitsuOptions = {
|
|
|
330
346
|
* To enable debug logging
|
|
331
347
|
*/
|
|
332
348
|
debug?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Default payload context to be included in all requests.
|
|
351
|
+
* These attributes are merged with the request-specific payload context,
|
|
352
|
+
* allowing common or global data (e.g., browser timezone, some extra user identifier)
|
|
353
|
+
* to be automatically included to every request.
|
|
354
|
+
*
|
|
355
|
+
* The context can be a nested structure.
|
|
356
|
+
*/
|
|
357
|
+
defaultPayloadContext?: Record<string, JSONValue>;
|
|
333
358
|
/**
|
|
334
359
|
* Explicitly specify cookie domain. If not set, cookie domain will be set to top level
|
|
335
360
|
* of the current domain. Example: if JS lives on "app.example.com", cookie domain will be
|
|
336
361
|
* set to ".example.com". If it lives on "example.com", cookie domain will be set to ".example.com" too
|
|
337
362
|
*/
|
|
338
363
|
cookieDomain?: string;
|
|
364
|
+
/**
|
|
365
|
+
* Additional cookies to capture, where the keys are cookie names and
|
|
366
|
+
* the values are the corresponding cookie values. By default, the following cookies are captured:
|
|
367
|
+
* - Facebook: `_fbc`, `_fbp`
|
|
368
|
+
* - Google Analytics 4: GA4 client ID
|
|
369
|
+
* This property allows you to capture additional cookies beyond the defaults.
|
|
370
|
+
*/
|
|
371
|
+
cookieCapture?: Record<string, string>;
|
|
339
372
|
/**
|
|
340
373
|
* Provide fetch implementation. It is required if you want to use Jitsu in NodeJS
|
|
341
374
|
*/
|
|
@@ -372,6 +405,11 @@ export type JitsuOptions = {
|
|
|
372
405
|
*/
|
|
373
406
|
idEndpoint?: string;
|
|
374
407
|
|
|
408
|
+
/**
|
|
409
|
+
* What to do with errors. It can log it, rethrow or run a custom handler. Default value: "log"
|
|
410
|
+
*/
|
|
411
|
+
errorPolicy?: ErrorHandler | "rethrow" | "log";
|
|
412
|
+
|
|
375
413
|
privacy?: {
|
|
376
414
|
dontSend?: boolean;
|
|
377
415
|
disableUserIds?: boolean;
|
|
@@ -382,6 +420,17 @@ export type JitsuOptions = {
|
|
|
382
420
|
|
|
383
421
|
export type DynamicJitsuOptions = Pick<JitsuOptions, "privacy" | "debug" | "echoEvents">;
|
|
384
422
|
|
|
423
|
+
export type Traits = {
|
|
424
|
+
[key: string]: JSONValue;
|
|
425
|
+
//some traits, all starting with $, are reserved for signalling the behavior of the event
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Tells Jitsu to process event, but not send it to server. Used for .identify() and .group() calls
|
|
429
|
+
* that are intended to update user/group state, but not send events
|
|
430
|
+
*/
|
|
431
|
+
$doNotSend?: boolean;
|
|
432
|
+
};
|
|
433
|
+
|
|
385
434
|
export interface AnalyticsInterface {
|
|
386
435
|
track(
|
|
387
436
|
eventName: string | JSONObject,
|
|
@@ -400,12 +449,12 @@ export interface AnalyticsInterface {
|
|
|
400
449
|
|
|
401
450
|
group(
|
|
402
451
|
groupId?: ID | object,
|
|
403
|
-
traits?:
|
|
452
|
+
traits?: Traits | null,
|
|
404
453
|
options?: Options,
|
|
405
454
|
callback?: Callback
|
|
406
455
|
): Promise<DispatchedEvent>;
|
|
407
456
|
|
|
408
|
-
identify(id?: ID |
|
|
457
|
+
identify(id?: ID | Traits, traits?: Traits | Callback | null, callback?: Callback): Promise<DispatchedEvent>;
|
|
409
458
|
|
|
410
459
|
reset(callback?: (...params: any[]) => any): Promise<any>;
|
|
411
460
|
|