@jitsu/protocols 1.9.9 → 1.9.11
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 +21 -3
- package/package.json +1 -1
- package/profile.d.ts +16 -7
package/analytics.d.ts
CHANGED
|
@@ -189,7 +189,7 @@ interface AnalyticsContext {
|
|
|
189
189
|
|
|
190
190
|
locale?: string;
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
xlibrary?: {
|
|
193
193
|
name: string;
|
|
194
194
|
version: string;
|
|
195
195
|
//allow to add custom fields
|
|
@@ -316,6 +316,8 @@ export type RuntimeFacade = {
|
|
|
316
316
|
pageTitle(): string | undefined;
|
|
317
317
|
};
|
|
318
318
|
|
|
319
|
+
export type ErrorHandler = (message: string, ...args: any[]) => void;
|
|
320
|
+
|
|
319
321
|
export type JitsuOptions = {
|
|
320
322
|
/**
|
|
321
323
|
* API Key. Optional. If not set, Jitsu will send event to the server without auth, and server
|
|
@@ -372,6 +374,11 @@ export type JitsuOptions = {
|
|
|
372
374
|
*/
|
|
373
375
|
idEndpoint?: string;
|
|
374
376
|
|
|
377
|
+
/**
|
|
378
|
+
* What to do with errors. It can log it, rethrow or run a custom handler. Default value: "log"
|
|
379
|
+
*/
|
|
380
|
+
errorPolicy?: ErrorHandler | "rethrow" | "log";
|
|
381
|
+
|
|
375
382
|
privacy?: {
|
|
376
383
|
dontSend?: boolean;
|
|
377
384
|
disableUserIds?: boolean;
|
|
@@ -382,6 +389,17 @@ export type JitsuOptions = {
|
|
|
382
389
|
|
|
383
390
|
export type DynamicJitsuOptions = Pick<JitsuOptions, "privacy" | "debug" | "echoEvents">;
|
|
384
391
|
|
|
392
|
+
export type Traits = {
|
|
393
|
+
[key: string]: JSONValue;
|
|
394
|
+
//some traits, all starting with $, are reserved for signalling the behavior of the event
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Tells Jitsu to process event, but not send it to server. Used for .identify() and .group() calls
|
|
398
|
+
* that are intended to update user/group state, but not send events
|
|
399
|
+
*/
|
|
400
|
+
$doNotSend?: boolean;
|
|
401
|
+
};
|
|
402
|
+
|
|
385
403
|
export interface AnalyticsInterface {
|
|
386
404
|
track(
|
|
387
405
|
eventName: string | JSONObject,
|
|
@@ -400,12 +418,12 @@ export interface AnalyticsInterface {
|
|
|
400
418
|
|
|
401
419
|
group(
|
|
402
420
|
groupId?: ID | object,
|
|
403
|
-
traits?:
|
|
421
|
+
traits?: Traits | null,
|
|
404
422
|
options?: Options,
|
|
405
423
|
callback?: Callback
|
|
406
424
|
): Promise<DispatchedEvent>;
|
|
407
425
|
|
|
408
|
-
identify(id?: ID |
|
|
426
|
+
identify(id?: ID | Traits, traits?: Traits | Callback | null, callback?: Callback): Promise<DispatchedEvent>;
|
|
409
427
|
|
|
410
428
|
reset(callback?: (...params: any[]) => any): Promise<any>;
|
|
411
429
|
|
package/package.json
CHANGED
package/profile.d.ts
CHANGED
|
@@ -2,15 +2,24 @@ import { FunctionContext } from "./functions";
|
|
|
2
2
|
import { AnalyticsServerEvent } from "./analytics";
|
|
3
3
|
|
|
4
4
|
export type ProfileResult = {
|
|
5
|
-
|
|
5
|
+
traits: Record<string, any>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type ProfileUser = {
|
|
9
|
+
id?: string;
|
|
10
|
+
anonymousId?: string;
|
|
11
|
+
traits: Record<string, any>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type ProfileBuilderContext = {
|
|
15
|
+
profileBuilder: {
|
|
16
|
+
id: string;
|
|
17
|
+
version: number;
|
|
18
|
+
};
|
|
6
19
|
};
|
|
7
20
|
|
|
8
21
|
export type ProfileFunction = (
|
|
9
22
|
events: Iterable<AnalyticsServerEvent>,
|
|
10
|
-
user:
|
|
11
|
-
|
|
12
|
-
anonymousId?: string;
|
|
13
|
-
traits: Record<string, any>;
|
|
14
|
-
},
|
|
15
|
-
context: FunctionContext
|
|
23
|
+
user: ProfileUser,
|
|
24
|
+
context: FunctionContext & ProfileBuilderContext
|
|
16
25
|
) => Promise<ProfileResult | undefined>;
|