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.
Files changed (140) hide show
  1. package/README.md +151 -0
  2. package/package.json +116 -78
  3. package/packages/angular/dist/index.d.ts +46 -0
  4. package/packages/angular/dist/index.d.ts.map +1 -0
  5. package/packages/angular/dist/index.js +2 -0
  6. package/packages/angular/dist/index.js.map +1 -0
  7. package/packages/angular/dist/index.mjs +2 -0
  8. package/packages/angular/dist/index.mjs.map +1 -0
  9. package/packages/browser/dist/index.d.ts +5 -0
  10. package/packages/browser/dist/index.d.ts.map +1 -0
  11. package/packages/browser/dist/index.iife.js +12095 -0
  12. package/packages/browser/dist/index.iife.js.map +1 -0
  13. package/packages/browser/dist/index.js +2 -0
  14. package/packages/browser/dist/index.js.map +1 -0
  15. package/packages/browser/dist/index.min.js +2 -0
  16. package/packages/browser/dist/index.min.js.map +1 -0
  17. package/packages/browser/dist/index.mjs +2 -0
  18. package/packages/browser/dist/index.mjs.map +1 -0
  19. package/packages/react/dist/browser.d.ts +2 -0
  20. package/packages/react/dist/browser.d.ts.map +1 -0
  21. package/packages/react/dist/index.d.ts +48 -0
  22. package/packages/react/dist/index.d.ts.map +1 -0
  23. package/packages/react/dist/index.js +2 -0
  24. package/packages/react/dist/index.js.map +1 -0
  25. package/packages/react/dist/index.mjs +2 -0
  26. package/packages/react/dist/index.mjs.map +1 -0
  27. package/packages/remix/dist/index.d.ts +8 -0
  28. package/packages/remix/dist/index.d.ts.map +1 -0
  29. package/packages/remix/dist/index.js +2 -0
  30. package/packages/remix/dist/index.js.map +1 -0
  31. package/packages/remix/dist/index.mjs +2 -0
  32. package/packages/remix/dist/index.mjs.map +1 -0
  33. package/packages/svelte/dist/index.d.ts +11 -0
  34. package/packages/svelte/dist/index.d.ts.map +1 -0
  35. package/packages/svelte/dist/index.js +2 -0
  36. package/packages/svelte/dist/index.js.map +1 -0
  37. package/packages/svelte/dist/index.mjs +2 -0
  38. package/packages/svelte/dist/index.mjs.map +1 -0
  39. package/{dist/types/vue → packages/vue/dist}/index.d.ts +4 -5
  40. package/packages/vue/dist/index.d.ts.map +1 -0
  41. package/packages/vue/dist/index.js +2 -0
  42. package/packages/vue/dist/index.js.map +1 -0
  43. package/packages/vue/dist/index.mjs +2 -0
  44. package/packages/vue/dist/index.mjs.map +1 -0
  45. package/packages/wizard/dist/ai/ai-install-wizard.d.ts +145 -0
  46. package/packages/wizard/dist/ai/ai-install-wizard.d.ts.map +1 -0
  47. package/packages/wizard/dist/ai/manual-framework-wizard.d.ts +52 -0
  48. package/packages/wizard/dist/ai/manual-framework-wizard.d.ts.map +1 -0
  49. package/packages/wizard/dist/cli/ai-auto-install.d.ts +27 -0
  50. package/packages/wizard/dist/cli/ai-auto-install.d.ts.map +1 -0
  51. package/{dist → packages/wizard/dist}/cli/ai-auto-install.js +821 -905
  52. package/packages/wizard/dist/cli/ai-auto-install.js.map +1 -0
  53. package/packages/wizard/dist/cli/auto-install.d.ts +26 -0
  54. package/packages/wizard/dist/cli/auto-install.d.ts.map +1 -0
  55. package/{dist → packages/wizard/dist}/cli/auto-install.js +821 -905
  56. package/packages/wizard/dist/cli/auto-install.js.map +1 -0
  57. package/{dist/types → packages/wizard/dist/core}/install-wizard.d.ts +6 -8
  58. package/packages/wizard/dist/core/install-wizard.d.ts.map +1 -0
  59. package/packages/wizard/dist/index.d.ts +18 -0
  60. package/packages/wizard/dist/index.d.ts.map +1 -0
  61. package/packages/wizard/dist/index.js +2 -0
  62. package/packages/wizard/dist/index.js.map +1 -0
  63. package/packages/wizard/dist/index.mjs +2 -0
  64. package/packages/wizard/dist/index.mjs.map +1 -0
  65. package/packages/wizard/dist/services/centralized-ai-service.d.ts +159 -0
  66. package/packages/wizard/dist/services/centralized-ai-service.d.ts.map +1 -0
  67. package/packages/wizard/dist/services/remote-ai-service.d.ts +58 -0
  68. package/packages/wizard/dist/services/remote-ai-service.d.ts.map +1 -0
  69. package/WIZARD_USAGE_GUIDE.md +0 -381
  70. package/dist/cjs/angular/index.cjs +0 -14979
  71. package/dist/cjs/angular/index.cjs.map +0 -1
  72. package/dist/cjs/index.cjs +0 -14964
  73. package/dist/cjs/index.cjs.map +0 -1
  74. package/dist/cjs/install-wizard.cjs +0 -1576
  75. package/dist/cjs/install-wizard.cjs.map +0 -1
  76. package/dist/cjs/react/index.cjs +0 -15103
  77. package/dist/cjs/react/index.cjs.map +0 -1
  78. package/dist/cjs/remix/index.cjs +0 -15077
  79. package/dist/cjs/remix/index.cjs.map +0 -1
  80. package/dist/cjs/svelte/index.cjs +0 -14933
  81. package/dist/cjs/svelte/index.cjs.map +0 -1
  82. package/dist/cjs/vue/index.cjs +0 -14942
  83. package/dist/cjs/vue/index.cjs.map +0 -1
  84. package/dist/cjs/wizard/index.cjs +0 -3490
  85. package/dist/cjs/wizard/index.cjs.map +0 -1
  86. package/dist/cli/ai-auto-install.js.map +0 -1
  87. package/dist/cli/auto-install.js.map +0 -1
  88. package/dist/esm/angular/index.js +0 -14975
  89. package/dist/esm/angular/index.js.map +0 -1
  90. package/dist/esm/index.js +0 -14941
  91. package/dist/esm/index.js.map +0 -1
  92. package/dist/esm/install-wizard.js +0 -1553
  93. package/dist/esm/install-wizard.js.map +0 -1
  94. package/dist/esm/react/index.js +0 -15097
  95. package/dist/esm/react/index.js.map +0 -1
  96. package/dist/esm/remix/index.js +0 -15073
  97. package/dist/esm/remix/index.js.map +0 -1
  98. package/dist/esm/svelte/index.js +0 -14931
  99. package/dist/esm/svelte/index.js.map +0 -1
  100. package/dist/esm/vue/index.js +0 -14940
  101. package/dist/esm/vue/index.js.map +0 -1
  102. package/dist/esm/wizard/index.js +0 -3459
  103. package/dist/esm/wizard/index.js.map +0 -1
  104. package/dist/index.min.js +0 -2
  105. package/dist/index.min.js.map +0 -1
  106. package/dist/types/angular/index.d.ts +0 -357
  107. package/dist/types/index.d.ts +0 -644
  108. package/dist/types/react/index.d.ts +0 -345
  109. package/dist/types/remix/index.d.ts +0 -336
  110. package/dist/types/svelte/index.d.ts +0 -322
  111. package/dist/types/wizard/index.d.ts +0 -523
  112. package/readme.md +0 -335
  113. package/rollup.config.js +0 -422
  114. package/simple-spa.html +0 -1000
  115. package/src/angular/index.ts +0 -79
  116. package/src/api.ts +0 -416
  117. package/src/index.ts +0 -35
  118. package/src/react/AutoInstallWizard.tsx +0 -557
  119. package/src/react/browser.ts +0 -8
  120. package/src/react/index.tsx +0 -308
  121. package/src/redact.ts +0 -327
  122. package/src/remix/index.ts +0 -16
  123. package/src/svelte/index.ts +0 -14
  124. package/src/tracker.ts +0 -1587
  125. package/src/types/clack.d.ts +0 -31
  126. package/src/utils/ip-detector.ts +0 -158
  127. package/src/utils/logger.ts +0 -144
  128. package/src/utils/property-detector.ts +0 -345
  129. package/src/utils/property-manager.ts +0 -274
  130. package/src/vue/index.ts +0 -29
  131. package/src/wizard/README.md +0 -114
  132. package/src/wizard/ai/ai-install-wizard.ts +0 -897
  133. package/src/wizard/ai/manual-framework-wizard.ts +0 -238
  134. package/src/wizard/cli/ai-auto-install.ts +0 -241
  135. package/src/wizard/cli/auto-install.ts +0 -224
  136. package/src/wizard/core/install-wizard.ts +0 -1794
  137. package/src/wizard/index.ts +0 -23
  138. package/src/wizard/services/centralized-ai-service.ts +0 -668
  139. package/src/wizard/services/remote-ai-service.ts +0 -240
  140. package/tsconfig.json +0 -24
@@ -1,345 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
-
3
- interface RedactionOptions {
4
- redactedText?: string;
5
- excludeSelectors?: string[];
6
- userFields?: string[];
7
- redactionStrategy?: {
8
- mode: 'privacy-first' | 'visibility-first';
9
- unredactFields?: string[];
10
- redactFields?: string[];
11
- };
12
- legacyRedactFields?: string[];
13
- }
14
-
15
- declare global {
16
- interface Window {
17
- HumanBehaviorTracker: typeof HumanBehaviorTracker;
18
- __humanBehaviorGlobalTracker?: HumanBehaviorTracker;
19
- }
20
- }
21
- declare class HumanBehaviorTracker {
22
- private eventIngestionQueue;
23
- private sessionId;
24
- private userProperties;
25
- private isProcessing;
26
- private flushInterval;
27
- private readonly FLUSH_INTERVAL_MS;
28
- private readonly MAX_QUEUE_SIZE;
29
- private api;
30
- private endUserId;
31
- private apiKey;
32
- private initialized;
33
- initializationPromise: Promise<void> | null;
34
- private redactionManager;
35
- private propertyManager;
36
- private originalConsole;
37
- private consoleTrackingEnabled;
38
- navigationTrackingEnabled: boolean;
39
- private currentUrl;
40
- private previousUrl;
41
- private originalPushState;
42
- private originalReplaceState;
43
- private navigationListeners;
44
- private _connectionBlocked;
45
- private recordInstance;
46
- private sessionStartTime;
47
- private rrwebRecord;
48
- private fullSnapshotTimeout;
49
- private recordCanvas;
50
- /**
51
- * Initialize the HumanBehavior tracker
52
- * This is the main entry point - call this once per page
53
- */
54
- static init(apiKey: string, options?: {
55
- ingestionUrl?: string;
56
- logLevel?: 'none' | 'error' | 'warn' | 'info' | 'debug';
57
- redactFields?: string[];
58
- redactionStrategy?: {
59
- mode: 'privacy-first' | 'visibility-first';
60
- unredactFields?: string[];
61
- redactFields?: string[];
62
- };
63
- enableAutomaticTracking?: boolean;
64
- suppressConsoleErrors?: boolean;
65
- recordCanvas?: boolean;
66
- enableAutomaticProperties?: boolean;
67
- propertyDenylist?: string[];
68
- automaticTrackingOptions?: {
69
- trackButtons?: boolean;
70
- trackLinks?: boolean;
71
- trackForms?: boolean;
72
- includeText?: boolean;
73
- includeClasses?: boolean;
74
- };
75
- }): HumanBehaviorTracker;
76
- constructor(apiKey: string | undefined, ingestionUrl?: string, options?: {
77
- enableAutomaticProperties?: boolean;
78
- propertyDenylist?: string[];
79
- redactionStrategy?: {
80
- mode: 'privacy-first' | 'visibility-first';
81
- unredactFields?: string[];
82
- redactFields?: string[];
83
- };
84
- redactFields?: string[];
85
- });
86
- private init;
87
- private ensureInitialized;
88
- /**
89
- * Setup navigation event tracking for SPA navigation
90
- */
91
- private setupNavigationTracking;
92
- /**
93
- * Track navigation events and send custom events
94
- */
95
- trackNavigationEvent(type: string, fromUrl: string, toUrl: string): Promise<void>;
96
- trackPageView(url?: string): Promise<void>;
97
- customEvent(eventName: string, properties?: Record<string, any>): Promise<void>;
98
- /**
99
- * Setup automatic tracking for buttons, links, and forms
100
- */
101
- private setupAutomaticTracking;
102
- /**
103
- * Setup automatic button tracking
104
- */
105
- private setupAutomaticButtonTracking;
106
- /**
107
- * Setup automatic link tracking
108
- */
109
- private setupAutomaticLinkTracking;
110
- /**
111
- * Setup automatic form tracking
112
- */
113
- private setupAutomaticFormTracking;
114
- /**
115
- * Cleanup navigation tracking
116
- */
117
- private cleanupNavigationTracking;
118
- static logToStorage(message: string): void;
119
- /**
120
- * Configure logging behavior for the SDK
121
- * @param config Logger configuration options
122
- */
123
- static configureLogging(config: {
124
- level?: 'none' | 'error' | 'warn' | 'info' | 'debug';
125
- enableConsole?: boolean;
126
- enableStorage?: boolean;
127
- }): void;
128
- /**
129
- * Enable console event tracking
130
- */
131
- enableConsoleTracking(): void;
132
- /**
133
- * Disable console event tracking
134
- */
135
- disableConsoleTracking(): void;
136
- private trackConsoleEvent;
137
- private setupPageUnloadHandler;
138
- viewLogs(): void;
139
- /**
140
- * Add user identification information to the tracker
141
- * If userId is not provided, will use userProperties.email as the userId (if present)
142
- */
143
- identifyUser({ userProperties }: {
144
- userProperties: Record<string, any>;
145
- }): Promise<string>;
146
- /**
147
- * Get current user attributes
148
- */
149
- getUserAttributes(): Record<string, any>;
150
- start(): Promise<void>;
151
- /**
152
- * Manually trigger a FullSnapshot (for navigation events)
153
- * Delays snapshot to avoid capturing mid-animation states
154
- */
155
- private takeFullSnapshot;
156
- stop(): Promise<void>;
157
- /**
158
- * Add an event to the ingestion queue
159
- * Events are sent directly without processing to avoid corruption
160
- */
161
- addEvent(event: any): Promise<void>;
162
- /**
163
- * Flush events to the ingestion server
164
- * Events are sent in chunks to handle large payloads efficiently
165
- */
166
- private flush;
167
- private setCookie;
168
- getCookie(name: string): string | null;
169
- /**
170
- * Delete a cookie by setting its expiration date to the past
171
- * @param name The name of the cookie to delete
172
- */
173
- private deleteCookie;
174
- /**
175
- * Clear user data and reset session when user signs out of the site
176
- * This should be called when a user logs out of your application to prevent
177
- * data contamination between different users
178
- */
179
- logout(): void;
180
- /**
181
- * Start redaction functionality for sensitive input fields
182
- * @param options Optional configuration for redaction behavior
183
- */
184
- redact(options?: RedactionOptions): Promise<void>;
185
- /**
186
- * Set specific fields to be redacted (for visibility-first mode)
187
- * @param fields Array of CSS selectors for fields to redact
188
- */
189
- setRedactedFields(fields: string[]): void;
190
- /**
191
- * Set specific fields to be unredacted (everything else stays redacted by rrweb)
192
- * @param fields Array of CSS selectors for fields to unredact (e.g., ['#username', '#comment'])
193
- */
194
- setUnredactedFields(fields: string[]): void;
195
- private restartWithNewRedaction;
196
- /**
197
- * Check if any fields are currently unredacted
198
- */
199
- hasUnredactedFields(): boolean;
200
- /**
201
- * Get the currently unredacted fields
202
- */
203
- getUnredactedFields(): string[];
204
- /**
205
- * Remove specific fields from unredaction (they become redacted again)
206
- * @param fields Array of CSS selectors for fields to redact
207
- */
208
- redactFields(fields: string[]): void;
209
- /**
210
- * Clear all unredacted fields (everything becomes redacted again)
211
- */
212
- clearUnredactedFields(): void;
213
- /**
214
- * Get the current session ID
215
- */
216
- getSessionId(): string;
217
- /**
218
- * Get the current URL being tracked
219
- */
220
- getCurrentUrl(): string;
221
- /**
222
- * Get current snapshot frequency info
223
- * Uses configured values (5 minutes, 1000 events)
224
- */
225
- getSnapshotFrequencyInfo(): {
226
- sessionDuration: number;
227
- currentInterval: number;
228
- currentThreshold: number;
229
- phase: string;
230
- };
231
- /**
232
- * Test if the tracker can reach the ingestion server
233
- */
234
- testConnection(): Promise<{
235
- success: boolean;
236
- error?: string;
237
- }>;
238
- /**
239
- * Get connection status and recommendations
240
- */
241
- getConnectionStatus(): {
242
- blocked: boolean;
243
- recommendations: string[];
244
- };
245
- /**
246
- * Check if the current user is a preexisting user
247
- * Returns true if the user has an existing endUserId cookie from a previous session
248
- */
249
- isPreexistingUser(): boolean;
250
- /**
251
- * Get user information including whether they are preexisting
252
- */
253
- getUserInfo(): {
254
- endUserId: string | null;
255
- sessionId: string;
256
- isPreexistingUser: boolean;
257
- initialized: boolean;
258
- };
259
- /**
260
- * Set a session property that will be included in all events for this session
261
- */
262
- setSessionProperty(key: string, value: any): void;
263
- /**
264
- * Set multiple session properties
265
- */
266
- setSessionProperties(properties: Record<string, any>): void;
267
- /**
268
- * Get a session property
269
- */
270
- getSessionProperty(key: string): any;
271
- /**
272
- * Remove a session property
273
- */
274
- removeSessionProperty(key: string): void;
275
- /**
276
- * Set a user property that will be included in all events
277
- */
278
- setUserProperty(key: string, value: any): void;
279
- /**
280
- * Set multiple user properties
281
- */
282
- setUserProperties(properties: Record<string, any>): void;
283
- /**
284
- * Get a user property
285
- */
286
- getUserProperty(key: string): any;
287
- /**
288
- * Remove a user property
289
- */
290
- removeUserProperty(key: string): void;
291
- /**
292
- * Set a property only if it hasn't been set before
293
- */
294
- setOnce(key: string, value: any, scope?: 'session' | 'user'): void;
295
- /**
296
- * Clear all session properties
297
- */
298
- clearSessionProperties(): void;
299
- /**
300
- * Clear all user properties
301
- */
302
- clearUserProperties(): void;
303
- /**
304
- * Get all properties for debugging
305
- */
306
- getAllProperties(): {
307
- automatic: Record<string, any>;
308
- session: Record<string, any>;
309
- user: Record<string, any>;
310
- initial: Record<string, any>;
311
- };
312
- }
313
-
314
- interface HumanBehaviorProviderProps {
315
- apiKey?: string;
316
- client?: HumanBehaviorTracker;
317
- children: ReactNode;
318
- options?: {
319
- ingestionUrl?: string;
320
- logLevel?: 'none' | 'error' | 'warn' | 'info' | 'debug';
321
- redactFields?: string[];
322
- suppressConsoleErrors?: boolean;
323
- recordCanvas?: boolean;
324
- };
325
- }
326
- declare const HumanBehaviorProvider: ({ apiKey, client, children, options }: HumanBehaviorProviderProps) => React.JSX.Element;
327
- declare const useHumanBehavior: () => HumanBehaviorTracker;
328
- declare const useRedaction: () => {
329
- setUnredactedFields: (fields: string[]) => void;
330
- hasUnredactedFields: () => boolean;
331
- getUnredactedFields: () => string[];
332
- };
333
- declare const useUserTracking: () => {
334
- identifyUser: ({ userProperties }: {
335
- userProperties: Record<string, any>;
336
- }) => Promise<{
337
- success: boolean;
338
- error?: undefined;
339
- } | {
340
- success: boolean;
341
- error: unknown;
342
- }>;
343
- };
344
-
345
- export { HumanBehaviorProvider, HumanBehaviorTracker, useHumanBehavior, useRedaction, useUserTracking };
@@ -1,336 +0,0 @@
1
- import { LoaderFunctionArgs } from '@remix-run/node';
2
- import React, { ReactNode } from 'react';
3
-
4
- interface RedactionOptions {
5
- redactedText?: string;
6
- excludeSelectors?: string[];
7
- userFields?: string[];
8
- redactionStrategy?: {
9
- mode: 'privacy-first' | 'visibility-first';
10
- unredactFields?: string[];
11
- redactFields?: string[];
12
- };
13
- legacyRedactFields?: string[];
14
- }
15
-
16
- declare global {
17
- interface Window {
18
- HumanBehaviorTracker: typeof HumanBehaviorTracker;
19
- __humanBehaviorGlobalTracker?: HumanBehaviorTracker;
20
- }
21
- }
22
- declare class HumanBehaviorTracker {
23
- private eventIngestionQueue;
24
- private sessionId;
25
- private userProperties;
26
- private isProcessing;
27
- private flushInterval;
28
- private readonly FLUSH_INTERVAL_MS;
29
- private readonly MAX_QUEUE_SIZE;
30
- private api;
31
- private endUserId;
32
- private apiKey;
33
- private initialized;
34
- initializationPromise: Promise<void> | null;
35
- private redactionManager;
36
- private propertyManager;
37
- private originalConsole;
38
- private consoleTrackingEnabled;
39
- navigationTrackingEnabled: boolean;
40
- private currentUrl;
41
- private previousUrl;
42
- private originalPushState;
43
- private originalReplaceState;
44
- private navigationListeners;
45
- private _connectionBlocked;
46
- private recordInstance;
47
- private sessionStartTime;
48
- private rrwebRecord;
49
- private fullSnapshotTimeout;
50
- private recordCanvas;
51
- /**
52
- * Initialize the HumanBehavior tracker
53
- * This is the main entry point - call this once per page
54
- */
55
- static init(apiKey: string, options?: {
56
- ingestionUrl?: string;
57
- logLevel?: 'none' | 'error' | 'warn' | 'info' | 'debug';
58
- redactFields?: string[];
59
- redactionStrategy?: {
60
- mode: 'privacy-first' | 'visibility-first';
61
- unredactFields?: string[];
62
- redactFields?: string[];
63
- };
64
- enableAutomaticTracking?: boolean;
65
- suppressConsoleErrors?: boolean;
66
- recordCanvas?: boolean;
67
- enableAutomaticProperties?: boolean;
68
- propertyDenylist?: string[];
69
- automaticTrackingOptions?: {
70
- trackButtons?: boolean;
71
- trackLinks?: boolean;
72
- trackForms?: boolean;
73
- includeText?: boolean;
74
- includeClasses?: boolean;
75
- };
76
- }): HumanBehaviorTracker;
77
- constructor(apiKey: string | undefined, ingestionUrl?: string, options?: {
78
- enableAutomaticProperties?: boolean;
79
- propertyDenylist?: string[];
80
- redactionStrategy?: {
81
- mode: 'privacy-first' | 'visibility-first';
82
- unredactFields?: string[];
83
- redactFields?: string[];
84
- };
85
- redactFields?: string[];
86
- });
87
- private init;
88
- private ensureInitialized;
89
- /**
90
- * Setup navigation event tracking for SPA navigation
91
- */
92
- private setupNavigationTracking;
93
- /**
94
- * Track navigation events and send custom events
95
- */
96
- trackNavigationEvent(type: string, fromUrl: string, toUrl: string): Promise<void>;
97
- trackPageView(url?: string): Promise<void>;
98
- customEvent(eventName: string, properties?: Record<string, any>): Promise<void>;
99
- /**
100
- * Setup automatic tracking for buttons, links, and forms
101
- */
102
- private setupAutomaticTracking;
103
- /**
104
- * Setup automatic button tracking
105
- */
106
- private setupAutomaticButtonTracking;
107
- /**
108
- * Setup automatic link tracking
109
- */
110
- private setupAutomaticLinkTracking;
111
- /**
112
- * Setup automatic form tracking
113
- */
114
- private setupAutomaticFormTracking;
115
- /**
116
- * Cleanup navigation tracking
117
- */
118
- private cleanupNavigationTracking;
119
- static logToStorage(message: string): void;
120
- /**
121
- * Configure logging behavior for the SDK
122
- * @param config Logger configuration options
123
- */
124
- static configureLogging(config: {
125
- level?: 'none' | 'error' | 'warn' | 'info' | 'debug';
126
- enableConsole?: boolean;
127
- enableStorage?: boolean;
128
- }): void;
129
- /**
130
- * Enable console event tracking
131
- */
132
- enableConsoleTracking(): void;
133
- /**
134
- * Disable console event tracking
135
- */
136
- disableConsoleTracking(): void;
137
- private trackConsoleEvent;
138
- private setupPageUnloadHandler;
139
- viewLogs(): void;
140
- /**
141
- * Add user identification information to the tracker
142
- * If userId is not provided, will use userProperties.email as the userId (if present)
143
- */
144
- identifyUser({ userProperties }: {
145
- userProperties: Record<string, any>;
146
- }): Promise<string>;
147
- /**
148
- * Get current user attributes
149
- */
150
- getUserAttributes(): Record<string, any>;
151
- start(): Promise<void>;
152
- /**
153
- * Manually trigger a FullSnapshot (for navigation events)
154
- * Delays snapshot to avoid capturing mid-animation states
155
- */
156
- private takeFullSnapshot;
157
- stop(): Promise<void>;
158
- /**
159
- * Add an event to the ingestion queue
160
- * Events are sent directly without processing to avoid corruption
161
- */
162
- addEvent(event: any): Promise<void>;
163
- /**
164
- * Flush events to the ingestion server
165
- * Events are sent in chunks to handle large payloads efficiently
166
- */
167
- private flush;
168
- private setCookie;
169
- getCookie(name: string): string | null;
170
- /**
171
- * Delete a cookie by setting its expiration date to the past
172
- * @param name The name of the cookie to delete
173
- */
174
- private deleteCookie;
175
- /**
176
- * Clear user data and reset session when user signs out of the site
177
- * This should be called when a user logs out of your application to prevent
178
- * data contamination between different users
179
- */
180
- logout(): void;
181
- /**
182
- * Start redaction functionality for sensitive input fields
183
- * @param options Optional configuration for redaction behavior
184
- */
185
- redact(options?: RedactionOptions): Promise<void>;
186
- /**
187
- * Set specific fields to be redacted (for visibility-first mode)
188
- * @param fields Array of CSS selectors for fields to redact
189
- */
190
- setRedactedFields(fields: string[]): void;
191
- /**
192
- * Set specific fields to be unredacted (everything else stays redacted by rrweb)
193
- * @param fields Array of CSS selectors for fields to unredact (e.g., ['#username', '#comment'])
194
- */
195
- setUnredactedFields(fields: string[]): void;
196
- private restartWithNewRedaction;
197
- /**
198
- * Check if any fields are currently unredacted
199
- */
200
- hasUnredactedFields(): boolean;
201
- /**
202
- * Get the currently unredacted fields
203
- */
204
- getUnredactedFields(): string[];
205
- /**
206
- * Remove specific fields from unredaction (they become redacted again)
207
- * @param fields Array of CSS selectors for fields to redact
208
- */
209
- redactFields(fields: string[]): void;
210
- /**
211
- * Clear all unredacted fields (everything becomes redacted again)
212
- */
213
- clearUnredactedFields(): void;
214
- /**
215
- * Get the current session ID
216
- */
217
- getSessionId(): string;
218
- /**
219
- * Get the current URL being tracked
220
- */
221
- getCurrentUrl(): string;
222
- /**
223
- * Get current snapshot frequency info
224
- * Uses configured values (5 minutes, 1000 events)
225
- */
226
- getSnapshotFrequencyInfo(): {
227
- sessionDuration: number;
228
- currentInterval: number;
229
- currentThreshold: number;
230
- phase: string;
231
- };
232
- /**
233
- * Test if the tracker can reach the ingestion server
234
- */
235
- testConnection(): Promise<{
236
- success: boolean;
237
- error?: string;
238
- }>;
239
- /**
240
- * Get connection status and recommendations
241
- */
242
- getConnectionStatus(): {
243
- blocked: boolean;
244
- recommendations: string[];
245
- };
246
- /**
247
- * Check if the current user is a preexisting user
248
- * Returns true if the user has an existing endUserId cookie from a previous session
249
- */
250
- isPreexistingUser(): boolean;
251
- /**
252
- * Get user information including whether they are preexisting
253
- */
254
- getUserInfo(): {
255
- endUserId: string | null;
256
- sessionId: string;
257
- isPreexistingUser: boolean;
258
- initialized: boolean;
259
- };
260
- /**
261
- * Set a session property that will be included in all events for this session
262
- */
263
- setSessionProperty(key: string, value: any): void;
264
- /**
265
- * Set multiple session properties
266
- */
267
- setSessionProperties(properties: Record<string, any>): void;
268
- /**
269
- * Get a session property
270
- */
271
- getSessionProperty(key: string): any;
272
- /**
273
- * Remove a session property
274
- */
275
- removeSessionProperty(key: string): void;
276
- /**
277
- * Set a user property that will be included in all events
278
- */
279
- setUserProperty(key: string, value: any): void;
280
- /**
281
- * Set multiple user properties
282
- */
283
- setUserProperties(properties: Record<string, any>): void;
284
- /**
285
- * Get a user property
286
- */
287
- getUserProperty(key: string): any;
288
- /**
289
- * Remove a user property
290
- */
291
- removeUserProperty(key: string): void;
292
- /**
293
- * Set a property only if it hasn't been set before
294
- */
295
- setOnce(key: string, value: any, scope?: 'session' | 'user'): void;
296
- /**
297
- * Clear all session properties
298
- */
299
- clearSessionProperties(): void;
300
- /**
301
- * Clear all user properties
302
- */
303
- clearUserProperties(): void;
304
- /**
305
- * Get all properties for debugging
306
- */
307
- getAllProperties(): {
308
- automatic: Record<string, any>;
309
- session: Record<string, any>;
310
- user: Record<string, any>;
311
- initial: Record<string, any>;
312
- };
313
- }
314
-
315
- interface HumanBehaviorProviderProps {
316
- apiKey?: string;
317
- client?: HumanBehaviorTracker;
318
- children: ReactNode;
319
- options?: {
320
- ingestionUrl?: string;
321
- logLevel?: 'none' | 'error' | 'warn' | 'info' | 'debug';
322
- redactFields?: string[];
323
- suppressConsoleErrors?: boolean;
324
- recordCanvas?: boolean;
325
- };
326
- }
327
- declare const HumanBehaviorProvider: ({ apiKey, client, children, options }: HumanBehaviorProviderProps) => React.JSX.Element;
328
- declare const useHumanBehavior: () => HumanBehaviorTracker;
329
-
330
- declare function createHumanBehaviorLoader(): ({ request }: LoaderFunctionArgs) => Promise<{
331
- ENV: {
332
- HUMANBEHAVIOR_API_KEY: string | undefined;
333
- };
334
- }>;
335
-
336
- export { HumanBehaviorProvider, createHumanBehaviorLoader, useHumanBehavior };