humanbehavior-js 0.4.28 → 0.5.1
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/README.md +151 -0
- package/package.json +116 -78
- package/packages/angular/dist/index.d.ts +46 -0
- package/packages/angular/dist/index.d.ts.map +1 -0
- package/packages/angular/dist/index.js +2 -0
- package/packages/angular/dist/index.js.map +1 -0
- package/packages/angular/dist/index.mjs +2 -0
- package/packages/angular/dist/index.mjs.map +1 -0
- package/packages/browser/dist/index.d.ts +5 -0
- package/packages/browser/dist/index.d.ts.map +1 -0
- package/packages/browser/dist/index.iife.js +12095 -0
- package/packages/browser/dist/index.iife.js.map +1 -0
- package/packages/browser/dist/index.js +2 -0
- package/packages/browser/dist/index.js.map +1 -0
- package/packages/browser/dist/index.min.js +2 -0
- package/packages/browser/dist/index.min.js.map +1 -0
- package/packages/browser/dist/index.mjs +2 -0
- package/packages/browser/dist/index.mjs.map +1 -0
- package/packages/react/dist/browser.d.ts +2 -0
- package/packages/react/dist/browser.d.ts.map +1 -0
- package/packages/react/dist/index.d.ts +48 -0
- package/packages/react/dist/index.d.ts.map +1 -0
- package/packages/react/dist/index.js +2 -0
- package/packages/react/dist/index.js.map +1 -0
- package/packages/react/dist/index.mjs +2 -0
- package/packages/react/dist/index.mjs.map +1 -0
- package/packages/remix/dist/index.d.ts +8 -0
- package/packages/remix/dist/index.d.ts.map +1 -0
- package/packages/remix/dist/index.js +2 -0
- package/packages/remix/dist/index.js.map +1 -0
- package/packages/remix/dist/index.mjs +2 -0
- package/packages/remix/dist/index.mjs.map +1 -0
- package/packages/svelte/dist/index.d.ts +11 -0
- package/packages/svelte/dist/index.d.ts.map +1 -0
- package/packages/svelte/dist/index.js +2 -0
- package/packages/svelte/dist/index.js.map +1 -0
- package/packages/svelte/dist/index.mjs +2 -0
- package/packages/svelte/dist/index.mjs.map +1 -0
- package/{dist/types/vue → packages/vue/dist}/index.d.ts +4 -5
- package/packages/vue/dist/index.d.ts.map +1 -0
- package/packages/vue/dist/index.js +2 -0
- package/packages/vue/dist/index.js.map +1 -0
- package/packages/vue/dist/index.mjs +2 -0
- package/packages/vue/dist/index.mjs.map +1 -0
- package/packages/wizard/dist/ai/ai-install-wizard.d.ts +145 -0
- package/packages/wizard/dist/ai/ai-install-wizard.d.ts.map +1 -0
- package/packages/wizard/dist/ai/manual-framework-wizard.d.ts +52 -0
- package/packages/wizard/dist/ai/manual-framework-wizard.d.ts.map +1 -0
- package/packages/wizard/dist/cli/ai-auto-install.d.ts +27 -0
- package/packages/wizard/dist/cli/ai-auto-install.d.ts.map +1 -0
- package/{dist → packages/wizard/dist}/cli/ai-auto-install.js +821 -905
- package/packages/wizard/dist/cli/ai-auto-install.js.map +1 -0
- package/packages/wizard/dist/cli/auto-install.d.ts +26 -0
- package/packages/wizard/dist/cli/auto-install.d.ts.map +1 -0
- package/{dist → packages/wizard/dist}/cli/auto-install.js +821 -905
- package/packages/wizard/dist/cli/auto-install.js.map +1 -0
- package/{dist/types → packages/wizard/dist/core}/install-wizard.d.ts +6 -8
- package/packages/wizard/dist/core/install-wizard.d.ts.map +1 -0
- package/packages/wizard/dist/index.d.ts +18 -0
- package/packages/wizard/dist/index.d.ts.map +1 -0
- package/packages/wizard/dist/index.js +2 -0
- package/packages/wizard/dist/index.js.map +1 -0
- package/packages/wizard/dist/index.mjs +2 -0
- package/packages/wizard/dist/index.mjs.map +1 -0
- package/packages/wizard/dist/services/centralized-ai-service.d.ts +159 -0
- package/packages/wizard/dist/services/centralized-ai-service.d.ts.map +1 -0
- package/packages/wizard/dist/services/remote-ai-service.d.ts +58 -0
- package/packages/wizard/dist/services/remote-ai-service.d.ts.map +1 -0
- package/WIZARD_USAGE_GUIDE.md +0 -381
- package/dist/cjs/angular/index.cjs +0 -14979
- package/dist/cjs/angular/index.cjs.map +0 -1
- package/dist/cjs/index.cjs +0 -14964
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/install-wizard.cjs +0 -1576
- package/dist/cjs/install-wizard.cjs.map +0 -1
- package/dist/cjs/react/index.cjs +0 -15103
- package/dist/cjs/react/index.cjs.map +0 -1
- package/dist/cjs/remix/index.cjs +0 -15077
- package/dist/cjs/remix/index.cjs.map +0 -1
- package/dist/cjs/svelte/index.cjs +0 -14933
- package/dist/cjs/svelte/index.cjs.map +0 -1
- package/dist/cjs/vue/index.cjs +0 -14942
- package/dist/cjs/vue/index.cjs.map +0 -1
- package/dist/cjs/wizard/index.cjs +0 -3490
- package/dist/cjs/wizard/index.cjs.map +0 -1
- package/dist/cli/ai-auto-install.js.map +0 -1
- package/dist/cli/auto-install.js.map +0 -1
- package/dist/esm/angular/index.js +0 -14975
- package/dist/esm/angular/index.js.map +0 -1
- package/dist/esm/index.js +0 -14941
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/install-wizard.js +0 -1553
- package/dist/esm/install-wizard.js.map +0 -1
- package/dist/esm/react/index.js +0 -15097
- package/dist/esm/react/index.js.map +0 -1
- package/dist/esm/remix/index.js +0 -15073
- package/dist/esm/remix/index.js.map +0 -1
- package/dist/esm/svelte/index.js +0 -14931
- package/dist/esm/svelte/index.js.map +0 -1
- package/dist/esm/vue/index.js +0 -14940
- package/dist/esm/vue/index.js.map +0 -1
- package/dist/esm/wizard/index.js +0 -3459
- package/dist/esm/wizard/index.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/dist/types/angular/index.d.ts +0 -357
- package/dist/types/index.d.ts +0 -644
- package/dist/types/react/index.d.ts +0 -345
- package/dist/types/remix/index.d.ts +0 -336
- package/dist/types/svelte/index.d.ts +0 -322
- package/dist/types/wizard/index.d.ts +0 -523
- package/readme.md +0 -335
- package/rollup.config.js +0 -422
- package/simple-spa.html +0 -1000
- package/src/angular/index.ts +0 -79
- package/src/api.ts +0 -416
- package/src/index.ts +0 -35
- package/src/react/AutoInstallWizard.tsx +0 -557
- package/src/react/browser.ts +0 -8
- package/src/react/index.tsx +0 -308
- package/src/redact.ts +0 -327
- package/src/remix/index.ts +0 -16
- package/src/svelte/index.ts +0 -14
- package/src/tracker.ts +0 -1587
- package/src/types/clack.d.ts +0 -31
- package/src/utils/ip-detector.ts +0 -158
- package/src/utils/logger.ts +0 -144
- package/src/utils/property-detector.ts +0 -345
- package/src/utils/property-manager.ts +0 -274
- package/src/vue/index.ts +0 -29
- package/src/wizard/README.md +0 -114
- package/src/wizard/ai/ai-install-wizard.ts +0 -897
- package/src/wizard/ai/manual-framework-wizard.ts +0 -238
- package/src/wizard/cli/ai-auto-install.ts +0 -241
- package/src/wizard/cli/auto-install.ts +0 -224
- package/src/wizard/core/install-wizard.ts +0 -1794
- package/src/wizard/index.ts +0 -23
- package/src/wizard/services/centralized-ai-service.ts +0 -668
- package/src/wizard/services/remote-ai-service.ts +0 -240
- package/tsconfig.json +0 -24
package/dist/types/index.d.ts
DELETED
|
@@ -1,644 +0,0 @@
|
|
|
1
|
-
interface RedactionOptions {
|
|
2
|
-
redactedText?: string;
|
|
3
|
-
excludeSelectors?: string[];
|
|
4
|
-
userFields?: string[];
|
|
5
|
-
redactionStrategy?: {
|
|
6
|
-
mode: 'privacy-first' | 'visibility-first';
|
|
7
|
-
unredactFields?: string[];
|
|
8
|
-
redactFields?: string[];
|
|
9
|
-
};
|
|
10
|
-
legacyRedactFields?: string[];
|
|
11
|
-
}
|
|
12
|
-
declare class RedactionManager {
|
|
13
|
-
private redactedText;
|
|
14
|
-
private unredactedFields;
|
|
15
|
-
private redactedFields;
|
|
16
|
-
private redactionMode;
|
|
17
|
-
private excludeSelectors;
|
|
18
|
-
constructor(options?: RedactionOptions);
|
|
19
|
-
/**
|
|
20
|
-
* Set specific fields to be redacted (for visibility-first mode)
|
|
21
|
-
* @param fields Array of CSS selectors for fields to redact
|
|
22
|
-
*/
|
|
23
|
-
setFieldsToRedact(fields: string[]): void;
|
|
24
|
-
/**
|
|
25
|
-
* Set specific fields to be unredacted (everything else stays redacted by rrweb)
|
|
26
|
-
* @param fields Array of CSS selectors for fields to unredact
|
|
27
|
-
*/
|
|
28
|
-
setFieldsToUnredact(fields: string[]): void;
|
|
29
|
-
/**
|
|
30
|
-
* Remove specific fields from unredaction (they become redacted again)
|
|
31
|
-
* @param fields Array of CSS selectors for fields to redact
|
|
32
|
-
*/
|
|
33
|
-
redactFields(fields: string[]): void;
|
|
34
|
-
/**
|
|
35
|
-
* Clear all unredacted fields (everything becomes redacted again)
|
|
36
|
-
*/
|
|
37
|
-
clearUnredactedFields(): void;
|
|
38
|
-
/**
|
|
39
|
-
* Check if any fields are currently unredacted
|
|
40
|
-
*/
|
|
41
|
-
hasUnredactedFields(): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Get the current redaction mode
|
|
44
|
-
*/
|
|
45
|
-
getRedactionMode(): 'privacy-first' | 'visibility-first';
|
|
46
|
-
/**
|
|
47
|
-
* Get the currently unredacted fields
|
|
48
|
-
*/
|
|
49
|
-
getUnredactedFields(): string[];
|
|
50
|
-
/**
|
|
51
|
-
* Get CSS selectors for rrweb masking configuration
|
|
52
|
-
* Returns null if no fields are unredacted (everything stays redacted)
|
|
53
|
-
*/
|
|
54
|
-
getMaskTextSelector(): string | null;
|
|
55
|
-
/**
|
|
56
|
-
* Apply redaction classes to DOM elements (for visibility-first mode)
|
|
57
|
-
* Adds 'rr-mask' class to elements that should be redacted
|
|
58
|
-
*/
|
|
59
|
-
applyRedactionClasses(): void;
|
|
60
|
-
/**
|
|
61
|
-
* Apply unredaction classes to DOM elements
|
|
62
|
-
* Removes 'rr-mask' class from elements that should be unredacted
|
|
63
|
-
*/
|
|
64
|
-
applyUnredactionClasses(): void;
|
|
65
|
-
/**
|
|
66
|
-
* Remove all unredaction classes from DOM elements
|
|
67
|
-
*/
|
|
68
|
-
removeUnredactionClasses(): void;
|
|
69
|
-
/**
|
|
70
|
-
* Check if a selector represents a password field
|
|
71
|
-
*/
|
|
72
|
-
private isPasswordSelector;
|
|
73
|
-
/**
|
|
74
|
-
* Get the original value of an element (for debugging)
|
|
75
|
-
*/
|
|
76
|
-
getOriginalValue(element: HTMLElement): string | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Check if an element is currently unredacted
|
|
79
|
-
*/
|
|
80
|
-
isElementUnredacted(element: HTMLElement): boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Check if an element should be unredacted
|
|
83
|
-
*/
|
|
84
|
-
shouldUnredactElement(element: HTMLElement): boolean;
|
|
85
|
-
}
|
|
86
|
-
declare const redactionManager: RedactionManager;
|
|
87
|
-
|
|
88
|
-
declare global {
|
|
89
|
-
interface Window {
|
|
90
|
-
HumanBehaviorTracker: typeof HumanBehaviorTracker;
|
|
91
|
-
__humanBehaviorGlobalTracker?: HumanBehaviorTracker;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
declare class HumanBehaviorTracker {
|
|
95
|
-
private eventIngestionQueue;
|
|
96
|
-
private sessionId;
|
|
97
|
-
private userProperties;
|
|
98
|
-
private isProcessing;
|
|
99
|
-
private flushInterval;
|
|
100
|
-
private readonly FLUSH_INTERVAL_MS;
|
|
101
|
-
private readonly MAX_QUEUE_SIZE;
|
|
102
|
-
private api;
|
|
103
|
-
private endUserId;
|
|
104
|
-
private apiKey;
|
|
105
|
-
private initialized;
|
|
106
|
-
initializationPromise: Promise<void> | null;
|
|
107
|
-
private redactionManager;
|
|
108
|
-
private propertyManager;
|
|
109
|
-
private originalConsole;
|
|
110
|
-
private consoleTrackingEnabled;
|
|
111
|
-
navigationTrackingEnabled: boolean;
|
|
112
|
-
private currentUrl;
|
|
113
|
-
private previousUrl;
|
|
114
|
-
private originalPushState;
|
|
115
|
-
private originalReplaceState;
|
|
116
|
-
private navigationListeners;
|
|
117
|
-
private _connectionBlocked;
|
|
118
|
-
private recordInstance;
|
|
119
|
-
private sessionStartTime;
|
|
120
|
-
private rrwebRecord;
|
|
121
|
-
private fullSnapshotTimeout;
|
|
122
|
-
private recordCanvas;
|
|
123
|
-
/**
|
|
124
|
-
* Initialize the HumanBehavior tracker
|
|
125
|
-
* This is the main entry point - call this once per page
|
|
126
|
-
*/
|
|
127
|
-
static init(apiKey: string, options?: {
|
|
128
|
-
ingestionUrl?: string;
|
|
129
|
-
logLevel?: 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
130
|
-
redactFields?: string[];
|
|
131
|
-
redactionStrategy?: {
|
|
132
|
-
mode: 'privacy-first' | 'visibility-first';
|
|
133
|
-
unredactFields?: string[];
|
|
134
|
-
redactFields?: string[];
|
|
135
|
-
};
|
|
136
|
-
enableAutomaticTracking?: boolean;
|
|
137
|
-
suppressConsoleErrors?: boolean;
|
|
138
|
-
recordCanvas?: boolean;
|
|
139
|
-
enableAutomaticProperties?: boolean;
|
|
140
|
-
propertyDenylist?: string[];
|
|
141
|
-
automaticTrackingOptions?: {
|
|
142
|
-
trackButtons?: boolean;
|
|
143
|
-
trackLinks?: boolean;
|
|
144
|
-
trackForms?: boolean;
|
|
145
|
-
includeText?: boolean;
|
|
146
|
-
includeClasses?: boolean;
|
|
147
|
-
};
|
|
148
|
-
}): HumanBehaviorTracker;
|
|
149
|
-
constructor(apiKey: string | undefined, ingestionUrl?: string, options?: {
|
|
150
|
-
enableAutomaticProperties?: boolean;
|
|
151
|
-
propertyDenylist?: string[];
|
|
152
|
-
redactionStrategy?: {
|
|
153
|
-
mode: 'privacy-first' | 'visibility-first';
|
|
154
|
-
unredactFields?: string[];
|
|
155
|
-
redactFields?: string[];
|
|
156
|
-
};
|
|
157
|
-
redactFields?: string[];
|
|
158
|
-
});
|
|
159
|
-
private init;
|
|
160
|
-
private ensureInitialized;
|
|
161
|
-
/**
|
|
162
|
-
* Setup navigation event tracking for SPA navigation
|
|
163
|
-
*/
|
|
164
|
-
private setupNavigationTracking;
|
|
165
|
-
/**
|
|
166
|
-
* Track navigation events and send custom events
|
|
167
|
-
*/
|
|
168
|
-
trackNavigationEvent(type: string, fromUrl: string, toUrl: string): Promise<void>;
|
|
169
|
-
trackPageView(url?: string): Promise<void>;
|
|
170
|
-
customEvent(eventName: string, properties?: Record<string, any>): Promise<void>;
|
|
171
|
-
/**
|
|
172
|
-
* Setup automatic tracking for buttons, links, and forms
|
|
173
|
-
*/
|
|
174
|
-
private setupAutomaticTracking;
|
|
175
|
-
/**
|
|
176
|
-
* Setup automatic button tracking
|
|
177
|
-
*/
|
|
178
|
-
private setupAutomaticButtonTracking;
|
|
179
|
-
/**
|
|
180
|
-
* Setup automatic link tracking
|
|
181
|
-
*/
|
|
182
|
-
private setupAutomaticLinkTracking;
|
|
183
|
-
/**
|
|
184
|
-
* Setup automatic form tracking
|
|
185
|
-
*/
|
|
186
|
-
private setupAutomaticFormTracking;
|
|
187
|
-
/**
|
|
188
|
-
* Cleanup navigation tracking
|
|
189
|
-
*/
|
|
190
|
-
private cleanupNavigationTracking;
|
|
191
|
-
static logToStorage(message: string): void;
|
|
192
|
-
/**
|
|
193
|
-
* Configure logging behavior for the SDK
|
|
194
|
-
* @param config Logger configuration options
|
|
195
|
-
*/
|
|
196
|
-
static configureLogging(config: {
|
|
197
|
-
level?: 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
198
|
-
enableConsole?: boolean;
|
|
199
|
-
enableStorage?: boolean;
|
|
200
|
-
}): void;
|
|
201
|
-
/**
|
|
202
|
-
* Enable console event tracking
|
|
203
|
-
*/
|
|
204
|
-
enableConsoleTracking(): void;
|
|
205
|
-
/**
|
|
206
|
-
* Disable console event tracking
|
|
207
|
-
*/
|
|
208
|
-
disableConsoleTracking(): void;
|
|
209
|
-
private trackConsoleEvent;
|
|
210
|
-
private setupPageUnloadHandler;
|
|
211
|
-
viewLogs(): void;
|
|
212
|
-
/**
|
|
213
|
-
* Add user identification information to the tracker
|
|
214
|
-
* If userId is not provided, will use userProperties.email as the userId (if present)
|
|
215
|
-
*/
|
|
216
|
-
identifyUser({ userProperties }: {
|
|
217
|
-
userProperties: Record<string, any>;
|
|
218
|
-
}): Promise<string>;
|
|
219
|
-
/**
|
|
220
|
-
* Get current user attributes
|
|
221
|
-
*/
|
|
222
|
-
getUserAttributes(): Record<string, any>;
|
|
223
|
-
start(): Promise<void>;
|
|
224
|
-
/**
|
|
225
|
-
* Manually trigger a FullSnapshot (for navigation events)
|
|
226
|
-
* Delays snapshot to avoid capturing mid-animation states
|
|
227
|
-
*/
|
|
228
|
-
private takeFullSnapshot;
|
|
229
|
-
stop(): Promise<void>;
|
|
230
|
-
/**
|
|
231
|
-
* Add an event to the ingestion queue
|
|
232
|
-
* Events are sent directly without processing to avoid corruption
|
|
233
|
-
*/
|
|
234
|
-
addEvent(event: any): Promise<void>;
|
|
235
|
-
/**
|
|
236
|
-
* Flush events to the ingestion server
|
|
237
|
-
* Events are sent in chunks to handle large payloads efficiently
|
|
238
|
-
*/
|
|
239
|
-
private flush;
|
|
240
|
-
private setCookie;
|
|
241
|
-
getCookie(name: string): string | null;
|
|
242
|
-
/**
|
|
243
|
-
* Delete a cookie by setting its expiration date to the past
|
|
244
|
-
* @param name The name of the cookie to delete
|
|
245
|
-
*/
|
|
246
|
-
private deleteCookie;
|
|
247
|
-
/**
|
|
248
|
-
* Clear user data and reset session when user signs out of the site
|
|
249
|
-
* This should be called when a user logs out of your application to prevent
|
|
250
|
-
* data contamination between different users
|
|
251
|
-
*/
|
|
252
|
-
logout(): void;
|
|
253
|
-
/**
|
|
254
|
-
* Start redaction functionality for sensitive input fields
|
|
255
|
-
* @param options Optional configuration for redaction behavior
|
|
256
|
-
*/
|
|
257
|
-
redact(options?: RedactionOptions): Promise<void>;
|
|
258
|
-
/**
|
|
259
|
-
* Set specific fields to be redacted (for visibility-first mode)
|
|
260
|
-
* @param fields Array of CSS selectors for fields to redact
|
|
261
|
-
*/
|
|
262
|
-
setRedactedFields(fields: string[]): void;
|
|
263
|
-
/**
|
|
264
|
-
* Set specific fields to be unredacted (everything else stays redacted by rrweb)
|
|
265
|
-
* @param fields Array of CSS selectors for fields to unredact (e.g., ['#username', '#comment'])
|
|
266
|
-
*/
|
|
267
|
-
setUnredactedFields(fields: string[]): void;
|
|
268
|
-
private restartWithNewRedaction;
|
|
269
|
-
/**
|
|
270
|
-
* Check if any fields are currently unredacted
|
|
271
|
-
*/
|
|
272
|
-
hasUnredactedFields(): boolean;
|
|
273
|
-
/**
|
|
274
|
-
* Get the currently unredacted fields
|
|
275
|
-
*/
|
|
276
|
-
getUnredactedFields(): string[];
|
|
277
|
-
/**
|
|
278
|
-
* Remove specific fields from unredaction (they become redacted again)
|
|
279
|
-
* @param fields Array of CSS selectors for fields to redact
|
|
280
|
-
*/
|
|
281
|
-
redactFields(fields: string[]): void;
|
|
282
|
-
/**
|
|
283
|
-
* Clear all unredacted fields (everything becomes redacted again)
|
|
284
|
-
*/
|
|
285
|
-
clearUnredactedFields(): void;
|
|
286
|
-
/**
|
|
287
|
-
* Get the current session ID
|
|
288
|
-
*/
|
|
289
|
-
getSessionId(): string;
|
|
290
|
-
/**
|
|
291
|
-
* Get the current URL being tracked
|
|
292
|
-
*/
|
|
293
|
-
getCurrentUrl(): string;
|
|
294
|
-
/**
|
|
295
|
-
* Get current snapshot frequency info
|
|
296
|
-
* Uses configured values (5 minutes, 1000 events)
|
|
297
|
-
*/
|
|
298
|
-
getSnapshotFrequencyInfo(): {
|
|
299
|
-
sessionDuration: number;
|
|
300
|
-
currentInterval: number;
|
|
301
|
-
currentThreshold: number;
|
|
302
|
-
phase: string;
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* Test if the tracker can reach the ingestion server
|
|
306
|
-
*/
|
|
307
|
-
testConnection(): Promise<{
|
|
308
|
-
success: boolean;
|
|
309
|
-
error?: string;
|
|
310
|
-
}>;
|
|
311
|
-
/**
|
|
312
|
-
* Get connection status and recommendations
|
|
313
|
-
*/
|
|
314
|
-
getConnectionStatus(): {
|
|
315
|
-
blocked: boolean;
|
|
316
|
-
recommendations: string[];
|
|
317
|
-
};
|
|
318
|
-
/**
|
|
319
|
-
* Check if the current user is a preexisting user
|
|
320
|
-
* Returns true if the user has an existing endUserId cookie from a previous session
|
|
321
|
-
*/
|
|
322
|
-
isPreexistingUser(): boolean;
|
|
323
|
-
/**
|
|
324
|
-
* Get user information including whether they are preexisting
|
|
325
|
-
*/
|
|
326
|
-
getUserInfo(): {
|
|
327
|
-
endUserId: string | null;
|
|
328
|
-
sessionId: string;
|
|
329
|
-
isPreexistingUser: boolean;
|
|
330
|
-
initialized: boolean;
|
|
331
|
-
};
|
|
332
|
-
/**
|
|
333
|
-
* Set a session property that will be included in all events for this session
|
|
334
|
-
*/
|
|
335
|
-
setSessionProperty(key: string, value: any): void;
|
|
336
|
-
/**
|
|
337
|
-
* Set multiple session properties
|
|
338
|
-
*/
|
|
339
|
-
setSessionProperties(properties: Record<string, any>): void;
|
|
340
|
-
/**
|
|
341
|
-
* Get a session property
|
|
342
|
-
*/
|
|
343
|
-
getSessionProperty(key: string): any;
|
|
344
|
-
/**
|
|
345
|
-
* Remove a session property
|
|
346
|
-
*/
|
|
347
|
-
removeSessionProperty(key: string): void;
|
|
348
|
-
/**
|
|
349
|
-
* Set a user property that will be included in all events
|
|
350
|
-
*/
|
|
351
|
-
setUserProperty(key: string, value: any): void;
|
|
352
|
-
/**
|
|
353
|
-
* Set multiple user properties
|
|
354
|
-
*/
|
|
355
|
-
setUserProperties(properties: Record<string, any>): void;
|
|
356
|
-
/**
|
|
357
|
-
* Get a user property
|
|
358
|
-
*/
|
|
359
|
-
getUserProperty(key: string): any;
|
|
360
|
-
/**
|
|
361
|
-
* Remove a user property
|
|
362
|
-
*/
|
|
363
|
-
removeUserProperty(key: string): void;
|
|
364
|
-
/**
|
|
365
|
-
* Set a property only if it hasn't been set before
|
|
366
|
-
*/
|
|
367
|
-
setOnce(key: string, value: any, scope?: 'session' | 'user'): void;
|
|
368
|
-
/**
|
|
369
|
-
* Clear all session properties
|
|
370
|
-
*/
|
|
371
|
-
clearSessionProperties(): void;
|
|
372
|
-
/**
|
|
373
|
-
* Clear all user properties
|
|
374
|
-
*/
|
|
375
|
-
clearUserProperties(): void;
|
|
376
|
-
/**
|
|
377
|
-
* Get all properties for debugging
|
|
378
|
-
*/
|
|
379
|
-
getAllProperties(): {
|
|
380
|
-
automatic: Record<string, any>;
|
|
381
|
-
session: Record<string, any>;
|
|
382
|
-
user: Record<string, any>;
|
|
383
|
-
initial: Record<string, any>;
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
declare const MAX_CHUNK_SIZE_BYTES: number;
|
|
388
|
-
declare function isChunkSizeExceeded(currentChunk: any[], newEvent: any, sessionId: string): boolean;
|
|
389
|
-
declare function validateSingleEventSize(event: any, sessionId: string): void;
|
|
390
|
-
declare function splitLargeEvent(event: any, sessionId: string): any[];
|
|
391
|
-
declare class HumanBehaviorAPI {
|
|
392
|
-
private apiKey;
|
|
393
|
-
private baseUrl;
|
|
394
|
-
constructor({ apiKey, ingestionUrl }: {
|
|
395
|
-
apiKey: string;
|
|
396
|
-
ingestionUrl: string;
|
|
397
|
-
});
|
|
398
|
-
init(sessionId: string, userId: string | null): Promise<{
|
|
399
|
-
sessionId: any;
|
|
400
|
-
endUserId: any;
|
|
401
|
-
}>;
|
|
402
|
-
/**
|
|
403
|
-
* Send IP address information to the server
|
|
404
|
-
* This is called after successful initialization
|
|
405
|
-
*/
|
|
406
|
-
sendIPInfo(sessionId: string): Promise<void>;
|
|
407
|
-
sendEvents(events: any[], sessionId: string, userId: string): Promise<void>;
|
|
408
|
-
sendEventsChunked(events: any[], sessionId: string, userId?: string): Promise<any[]>;
|
|
409
|
-
sendUserData(userId: string, userData: Record<string, any>, sessionId: string): Promise<any>;
|
|
410
|
-
sendUserAuth(userId: string, userData: Record<string, any>, sessionId: string, authFields: string[]): Promise<any>;
|
|
411
|
-
sendBeaconEvents(events: any[], sessionId: string): boolean;
|
|
412
|
-
sendCustomEvent(sessionId: string, eventName: string, eventProperties?: Record<string, any>): Promise<any>;
|
|
413
|
-
sendCustomEventBatch(sessionId: string, events: Array<{
|
|
414
|
-
eventName: string;
|
|
415
|
-
eventProperties?: Record<string, any>;
|
|
416
|
-
}>): Promise<any>;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Automatic Property Detection for HumanBehavior SDK
|
|
421
|
-
* Captures device type, location, and initial referrer information
|
|
422
|
-
*/
|
|
423
|
-
interface DeviceInfo {
|
|
424
|
-
device_type: string;
|
|
425
|
-
browser: string;
|
|
426
|
-
browser_version: string;
|
|
427
|
-
os: string;
|
|
428
|
-
os_version: string;
|
|
429
|
-
device_model?: string;
|
|
430
|
-
screen_resolution: string;
|
|
431
|
-
viewport_size: string;
|
|
432
|
-
color_depth: number;
|
|
433
|
-
timezone: string;
|
|
434
|
-
language: string;
|
|
435
|
-
languages: string[];
|
|
436
|
-
raw_user_agent?: string;
|
|
437
|
-
}
|
|
438
|
-
interface LocationInfo {
|
|
439
|
-
current_url: string;
|
|
440
|
-
pathname: string;
|
|
441
|
-
search: string;
|
|
442
|
-
hash: string;
|
|
443
|
-
title: string;
|
|
444
|
-
referrer: string;
|
|
445
|
-
referrer_domain: string;
|
|
446
|
-
initial_referrer: string;
|
|
447
|
-
initial_referrer_domain: string;
|
|
448
|
-
initial_host?: string;
|
|
449
|
-
utm_source?: string;
|
|
450
|
-
utm_medium?: string;
|
|
451
|
-
utm_campaign?: string;
|
|
452
|
-
utm_term?: string;
|
|
453
|
-
utm_content?: string;
|
|
454
|
-
}
|
|
455
|
-
interface AutomaticProperties extends DeviceInfo, LocationInfo {
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* Get device information
|
|
459
|
-
*/
|
|
460
|
-
declare function getDeviceInfo(): DeviceInfo;
|
|
461
|
-
/**
|
|
462
|
-
* Get location information
|
|
463
|
-
*/
|
|
464
|
-
declare function getLocationInfo(): LocationInfo;
|
|
465
|
-
/**
|
|
466
|
-
* Get all automatic properties
|
|
467
|
-
*/
|
|
468
|
-
declare function getAutomaticProperties(): AutomaticProperties;
|
|
469
|
-
/**
|
|
470
|
-
* Get initial properties that should be captured once per session
|
|
471
|
-
*/
|
|
472
|
-
declare function getInitialProperties(): Record<string, any>;
|
|
473
|
-
/**
|
|
474
|
-
* Get current page properties (changes with navigation)
|
|
475
|
-
*/
|
|
476
|
-
declare function getCurrentPageProperties(): Record<string, any>;
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* Property Manager for HumanBehavior SDK
|
|
480
|
-
* Handles automatic properties, session properties, and user properties
|
|
481
|
-
*/
|
|
482
|
-
interface Properties {
|
|
483
|
-
[key: string]: any;
|
|
484
|
-
}
|
|
485
|
-
interface PropertyManagerConfig {
|
|
486
|
-
enableAutomaticProperties?: boolean;
|
|
487
|
-
enableSessionProperties?: boolean;
|
|
488
|
-
enableUserProperties?: boolean;
|
|
489
|
-
propertyDenylist?: string[];
|
|
490
|
-
}
|
|
491
|
-
declare class PropertyManager {
|
|
492
|
-
private config;
|
|
493
|
-
private automaticProperties;
|
|
494
|
-
private sessionProperties;
|
|
495
|
-
private userProperties;
|
|
496
|
-
private initialProperties;
|
|
497
|
-
private isInitialized;
|
|
498
|
-
constructor(config?: PropertyManagerConfig);
|
|
499
|
-
/**
|
|
500
|
-
* Initialize the property manager
|
|
501
|
-
*/
|
|
502
|
-
private initialize;
|
|
503
|
-
/**
|
|
504
|
-
* Get all properties for an event
|
|
505
|
-
*/
|
|
506
|
-
getEventProperties(eventProperties?: Properties): Properties;
|
|
507
|
-
/**
|
|
508
|
-
* Get automatic properties
|
|
509
|
-
*/
|
|
510
|
-
getAutomaticProperties(): Properties;
|
|
511
|
-
/**
|
|
512
|
-
* Get automatic properties with GeoIP data merged in
|
|
513
|
-
*/
|
|
514
|
-
getAutomaticPropertiesWithGeoIP(geoIPProperties?: Record<string, any>): Properties;
|
|
515
|
-
/**
|
|
516
|
-
* Set a session property
|
|
517
|
-
*/
|
|
518
|
-
setSessionProperty(key: string, value: any): void;
|
|
519
|
-
/**
|
|
520
|
-
* Set multiple session properties
|
|
521
|
-
*/
|
|
522
|
-
setSessionProperties(properties: Properties): void;
|
|
523
|
-
/**
|
|
524
|
-
* Get a session property
|
|
525
|
-
*/
|
|
526
|
-
getSessionProperty(key: string): any;
|
|
527
|
-
/**
|
|
528
|
-
* Remove a session property
|
|
529
|
-
*/
|
|
530
|
-
removeSessionProperty(key: string): void;
|
|
531
|
-
/**
|
|
532
|
-
* Set a user property
|
|
533
|
-
*/
|
|
534
|
-
setUserProperty(key: string, value: any): void;
|
|
535
|
-
/**
|
|
536
|
-
* Set multiple user properties
|
|
537
|
-
*/
|
|
538
|
-
setUserProperties(properties: Properties): void;
|
|
539
|
-
/**
|
|
540
|
-
* Get a user property
|
|
541
|
-
*/
|
|
542
|
-
getUserProperty(key: string): any;
|
|
543
|
-
/**
|
|
544
|
-
* Remove a user property
|
|
545
|
-
*/
|
|
546
|
-
removeUserProperty(key: string): void;
|
|
547
|
-
/**
|
|
548
|
-
* Set a property only if it hasn't been set before
|
|
549
|
-
*/
|
|
550
|
-
setOnce(key: string, value: any, scope?: 'session' | 'user'): void;
|
|
551
|
-
/**
|
|
552
|
-
* Clear all session properties
|
|
553
|
-
*/
|
|
554
|
-
clearSessionProperties(): void;
|
|
555
|
-
/**
|
|
556
|
-
* Clear all user properties
|
|
557
|
-
*/
|
|
558
|
-
clearUserProperties(): void;
|
|
559
|
-
/**
|
|
560
|
-
* Reset all properties
|
|
561
|
-
*/
|
|
562
|
-
reset(): void;
|
|
563
|
-
/**
|
|
564
|
-
* Load session properties from sessionStorage
|
|
565
|
-
*/
|
|
566
|
-
private loadSessionProperties;
|
|
567
|
-
/**
|
|
568
|
-
* Save session properties to sessionStorage
|
|
569
|
-
*/
|
|
570
|
-
private saveSessionProperties;
|
|
571
|
-
/**
|
|
572
|
-
* Apply property denylist
|
|
573
|
-
*/
|
|
574
|
-
private applyDenylist;
|
|
575
|
-
/**
|
|
576
|
-
* Update automatic properties (call when page changes)
|
|
577
|
-
*/
|
|
578
|
-
updateAutomaticProperties(): void;
|
|
579
|
-
/**
|
|
580
|
-
* Get all properties for debugging
|
|
581
|
-
*/
|
|
582
|
-
getAllProperties(): {
|
|
583
|
-
automatic: Properties;
|
|
584
|
-
session: Properties;
|
|
585
|
-
user: Properties;
|
|
586
|
-
initial: Properties;
|
|
587
|
-
};
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
/**
|
|
591
|
-
* IP Address Detection Utility
|
|
592
|
-
* Attempts to get the client's public IP address using multiple methods
|
|
593
|
-
*/
|
|
594
|
-
interface IPInfo {
|
|
595
|
-
ip: string;
|
|
596
|
-
method: 'stun' | 'public-service' | 'fallback';
|
|
597
|
-
timestamp: number;
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* Get client's public IP address
|
|
601
|
-
* Tries STUN first (most reliable), then falls back to public services
|
|
602
|
-
*/
|
|
603
|
-
declare function getClientIP(): Promise<IPInfo | null>;
|
|
604
|
-
declare function getCachedIP(): Promise<IPInfo | null>;
|
|
605
|
-
/**
|
|
606
|
-
* Clear IP cache (useful for testing or when network changes)
|
|
607
|
-
*/
|
|
608
|
-
declare function clearIPCache(): void;
|
|
609
|
-
|
|
610
|
-
declare enum LogLevel {
|
|
611
|
-
NONE = 0,
|
|
612
|
-
ERROR = 1,
|
|
613
|
-
WARN = 2,
|
|
614
|
-
INFO = 3,
|
|
615
|
-
DEBUG = 4
|
|
616
|
-
}
|
|
617
|
-
interface LoggerConfig {
|
|
618
|
-
level: LogLevel;
|
|
619
|
-
enableConsole: boolean;
|
|
620
|
-
enableStorage: boolean;
|
|
621
|
-
}
|
|
622
|
-
declare class Logger {
|
|
623
|
-
private config;
|
|
624
|
-
private isBrowser;
|
|
625
|
-
constructor(config?: Partial<LoggerConfig>);
|
|
626
|
-
setConfig(config: Partial<LoggerConfig>): void;
|
|
627
|
-
private shouldLog;
|
|
628
|
-
private formatMessage;
|
|
629
|
-
error(message: string, ...args: any[]): void;
|
|
630
|
-
warn(message: string, ...args: any[]): void;
|
|
631
|
-
info(message: string, ...args: any[]): void;
|
|
632
|
-
debug(message: string, ...args: any[]): void;
|
|
633
|
-
private logToStorage;
|
|
634
|
-
getLogs(): any[];
|
|
635
|
-
clearLogs(): void;
|
|
636
|
-
}
|
|
637
|
-
declare const logger: Logger;
|
|
638
|
-
declare const logError: (message: string, ...args: any[]) => void;
|
|
639
|
-
declare const logWarn: (message: string, ...args: any[]) => void;
|
|
640
|
-
declare const logInfo: (message: string, ...args: any[]) => void;
|
|
641
|
-
declare const logDebug: (message: string, ...args: any[]) => void;
|
|
642
|
-
|
|
643
|
-
export { HumanBehaviorAPI, HumanBehaviorTracker, LogLevel, MAX_CHUNK_SIZE_BYTES, PropertyManager, RedactionManager, clearIPCache, getAutomaticProperties, getCachedIP, getClientIP, getCurrentPageProperties, getDeviceInfo, getInitialProperties, getLocationInfo, isChunkSizeExceeded, logDebug, logError, logInfo, logWarn, logger, redactionManager, splitLargeEvent, validateSingleEventSize };
|
|
644
|
-
export type { AutomaticProperties, DeviceInfo, IPInfo, LocationInfo, LoggerConfig, Properties, PropertyManagerConfig, RedactionOptions };
|