@jasolar/tracker-sdk 1.0.11 → 1.0.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.
@@ -0,0 +1,63 @@
1
+ export interface TrackerOptions {
2
+ endPoint: string;
3
+ appId?: string;
4
+ token?: string;
5
+ delay?: number;
6
+ maxBatchSize?: number;
7
+ sessionTimeout?: number;
8
+ debug?: boolean;
9
+ headers?: Record<string, string>;
10
+ batch?: boolean;
11
+ beaconAuth?: "none" | "query";
12
+ maxKeepaliveBytes?: number;
13
+ credentials?: RequestCredentials;
14
+ visibilityBehavior?: "emit" | "silent" | "ignore";
15
+ enableActivityTimeout?: boolean;
16
+ persistDeviceId?: boolean;
17
+ deviceId?: string;
18
+ beforeSend?: (event: TrackerEvent) => boolean | void;
19
+ }
20
+
21
+ export interface TrackerContext {
22
+ device_id: string;
23
+ session_id: string;
24
+ user_id: string | number | null;
25
+ }
26
+
27
+ export interface TrackerEvent {
28
+ app_id: string;
29
+ event_id: string;
30
+ schema_version: number;
31
+ occurred_at: string;
32
+ system: string;
33
+ module: string;
34
+ sub_module: string;
35
+ duration: number;
36
+ event: string;
37
+ timestamp: string;
38
+ context: TrackerContext;
39
+ ext: Record<string, unknown>;
40
+ }
41
+
42
+ export interface Tracker {
43
+ track(event: string, params?: Record<string, unknown>): void;
44
+ enter(module: Record<string, unknown>): void;
45
+ leave(force?: boolean, isTimeout?: boolean, reason?: string): void;
46
+ setUser(userId: string | number | null): void;
47
+ setExt(ext: Record<string, unknown>): void;
48
+ use(plugin: Function, options?: unknown): void;
49
+ flush(): void;
50
+ destroy(): void;
51
+ }
52
+
53
+ export function initTracker(options: TrackerOptions): Tracker;
54
+ export function getTracker(): Tracker;
55
+ export function flushTracker(): void;
56
+ export function destroyTracker(): void;
57
+ export const TRACKER_VERSION: string;
58
+
59
+ export function performancePlugin(tracker: Tracker, options?: unknown): void;
60
+ export function errorPlugin(tracker: Tracker, options?: unknown): void;
61
+ export function routerPlugin(tracker: Tracker, options?: unknown): void;
62
+ export function autoTracker(tracker: Tracker, options?: unknown): void;
63
+ export function safeErrorPlugin(tracker: Tracker, options?: unknown): void;