@incodetech/tri-sdk 0.1.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,128 @@
1
+ type CollectorKey = 'fingerprint' | 'pointer' | 'pointermove' | 'focus' | 'input' | 'keystroke' | 'clipboard' | 'form' | 'change' | 'selection' | 'visibility' | 'navigation' | 'viewportresize' | 'viewport' | 'scroll' | 'devicemotion' | 'networkrequest' | 'networkconnection' | 'permissionchange' | 'environmental';
2
+ type CollectorEventMap = {
3
+ pointer: 'pointerdown' | 'pointerup' | 'click' | 'dblclick' | 'contextmenu' | 'dragend';
4
+ focus: 'focusin' | 'focusout';
5
+ input: 'input';
6
+ keystroke: 'keydown' | 'keyup';
7
+ clipboard: 'paste' | 'cut' | 'copy';
8
+ form: 'submit' | 'invalid';
9
+ change: 'change';
10
+ selection: 'selectionchange';
11
+ visibility: 'visibilitychange';
12
+ pointermove: never;
13
+ fingerprint: never;
14
+ navigation: never;
15
+ viewport: never;
16
+ viewportresize: never;
17
+ scroll: never;
18
+ devicemotion: never;
19
+ networkrequest: never;
20
+ networkconnection: never;
21
+ permissionchange: never;
22
+ environmental: never;
23
+ };
24
+ type Layer = 'session' | 'behavioral' | 'device-fingerprinting' | 'environmental-integrity' | 'network-intelligence' | 'persistent-identity';
25
+
26
+ /**
27
+ * Global PII capture level for the SDK.
28
+ *
29
+ * - `'all'` — all fields emitted; PII identifiers and labels included.
30
+ * Consumers should annotate sensitive elements with `data-tri-redact`.
31
+ * - `'redact'` — PII identifiers (`id`, `name`, label, classes) set to `null`.
32
+ * Default. Per-element overrides via `data-tri-redact` / `data-tri-ignore`.
33
+ * - `'off'` — Element Context Processor is skipped entirely; `element` is always `null`.
34
+ */
35
+ type CaptureElementLevel = 'all' | 'redact' | 'off';
36
+ type CaptureContentLevel = 'on' | 'off';
37
+ /**
38
+ * Public SDK configuration. Both `layers` and `collectors` are optional; pass at
39
+ * most one. When neither is provided, every collector defaults to enabled (same
40
+ * behaviour as calling `start()` with no config).
41
+ */
42
+ type TriSDKConfig = TriSDKConfigBase & (LayerBasedConfig | CollectorBasedConfig | NoCollectorSelectionConfig);
43
+ type TriSDKConfigBase = {
44
+ capture?: {
45
+ element?: CaptureElementLevel;
46
+ content?: CaptureContentLevel;
47
+ };
48
+ profileId?: string;
49
+ api: {
50
+ key: string;
51
+ version: string;
52
+ url: string;
53
+ };
54
+ };
55
+ type EventConfig = {
56
+ enabled?: boolean;
57
+ exclude?: string[];
58
+ };
59
+ type CollectorEventsConfig<C extends CollectorKey> = {
60
+ /** Applied to every event emitted by this collector. */
61
+ exclude?: string[];
62
+ } & {
63
+ [E in CollectorEventMap[C]]?: EventConfig;
64
+ };
65
+ type CollectorConfig<C extends CollectorKey> = [CollectorEventMap[C]] extends [
66
+ never
67
+ ] ? {
68
+ enabled?: boolean;
69
+ } : {
70
+ enabled?: boolean;
71
+ events?: CollectorEventsConfig<C>;
72
+ };
73
+ type CollectorsConfig = {
74
+ [C in CollectorKey]?: CollectorConfig<C>;
75
+ };
76
+ type LayerBasedConfig = {
77
+ layers: Partial<Record<Layer, boolean>>;
78
+ collectors?: never;
79
+ };
80
+ type CollectorBasedConfig = {
81
+ layers?: never;
82
+ collectors: CollectorsConfig;
83
+ };
84
+ type NoCollectorSelectionConfig = {
85
+ layers?: never;
86
+ collectors?: never;
87
+ };
88
+ interface TriSDKInterface {
89
+ start(config?: TriSDKConfig): void;
90
+ reportEvent(name: string, metadata: Record<string, unknown>): void;
91
+ }
92
+
93
+ declare class TriSDK$1 implements TriSDKInterface {
94
+ private static _instance;
95
+ private initialized;
96
+ private activityManager;
97
+ private transportManager;
98
+ private tabManager;
99
+ private collectorManager;
100
+ private falconServiceManager;
101
+ constructor();
102
+ static get instance(): TriSDK$1;
103
+ /**
104
+ * Initialises the TRI SDK. Synchronous and idempotent — a second call is a
105
+ * no-op. Safe to call in SSR environments; if `document` is unavailable the
106
+ * function logs an error and returns without throwing.
107
+ */
108
+ start(config?: TriSDKConfig): void;
109
+ private _start;
110
+ /**
111
+ * Reports a host-defined event to the TRI backend. Fire-and-forget — never
112
+ * throws and never returns a promise the host must handle. Drops the event
113
+ * silently (with a dev warning) if called before `init`.
114
+ */
115
+ reportEvent(name: string, metadata: Record<string, unknown>): void;
116
+ private _shouldEarlyEscapeInit;
117
+ private _shouldEarlyEscapeReportEvent;
118
+ private _createFalconServiceManagerContext;
119
+ private _createActivityManagerContext;
120
+ private _createTransportManagerContext;
121
+ private _createTabManagerContext;
122
+ private _createLifecycleManagerContext;
123
+ private _createCollectorsManagerContext;
124
+ }
125
+
126
+ declare const TriSDK: TriSDK$1;
127
+
128
+ export { TriSDK as default };