humanbehavior-js 0.4.15 → 0.4.17

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 (89) hide show
  1. package/dist/cjs/wizard/index.cjs +6 -8
  2. package/dist/cjs/wizard/index.cjs.map +1 -1
  3. package/dist/cli/ai-auto-install.js +6 -8
  4. package/dist/cli/ai-auto-install.js.map +1 -1
  5. package/dist/esm/wizard/index.js +6 -8
  6. package/dist/esm/wizard/index.js.map +1 -1
  7. package/package/WIZARD_USAGE_GUIDE.md +381 -0
  8. package/package/canvas-recording-demo.html +143 -0
  9. package/package/clean-console-demo.html +39 -0
  10. package/package/dist/cjs/angular/index.cjs +14354 -0
  11. package/package/dist/cjs/angular/index.cjs.map +1 -0
  12. package/package/dist/cjs/index.cjs +14323 -0
  13. package/package/dist/cjs/index.cjs.map +1 -0
  14. package/package/dist/cjs/install-wizard.cjs +1530 -0
  15. package/package/dist/cjs/install-wizard.cjs.map +1 -0
  16. package/package/dist/cjs/react/index.cjs +14478 -0
  17. package/package/dist/cjs/react/index.cjs.map +1 -0
  18. package/package/dist/cjs/remix/index.cjs +14452 -0
  19. package/package/dist/cjs/remix/index.cjs.map +1 -0
  20. package/package/dist/cjs/svelte/index.cjs +14308 -0
  21. package/package/dist/cjs/svelte/index.cjs.map +1 -0
  22. package/package/dist/cjs/vue/index.cjs +14317 -0
  23. package/package/dist/cjs/vue/index.cjs.map +1 -0
  24. package/package/dist/cjs/wizard/index.cjs +3446 -0
  25. package/package/dist/cjs/wizard/index.cjs.map +1 -0
  26. package/package/dist/cli/ai-auto-install.cjs +57161 -0
  27. package/package/dist/cli/ai-auto-install.cjs.map +1 -0
  28. package/package/dist/cli/ai-auto-install.js +1969 -0
  29. package/package/dist/cli/ai-auto-install.js.map +1 -0
  30. package/package/dist/cli/auto-install.cjs +56352 -0
  31. package/package/dist/cli/auto-install.cjs.map +1 -0
  32. package/package/dist/cli/auto-install.js +1957 -0
  33. package/package/dist/cli/auto-install.js.map +1 -0
  34. package/package/dist/esm/angular/index.js +14350 -0
  35. package/package/dist/esm/angular/index.js.map +1 -0
  36. package/package/dist/esm/index.js +14309 -0
  37. package/package/dist/esm/index.js.map +1 -0
  38. package/package/dist/esm/install-wizard.js +1507 -0
  39. package/package/dist/esm/install-wizard.js.map +1 -0
  40. package/package/dist/esm/react/index.js +14472 -0
  41. package/package/dist/esm/react/index.js.map +1 -0
  42. package/package/dist/esm/remix/index.js +14448 -0
  43. package/package/dist/esm/remix/index.js.map +1 -0
  44. package/package/dist/esm/svelte/index.js +14306 -0
  45. package/package/dist/esm/svelte/index.js.map +1 -0
  46. package/package/dist/esm/vue/index.js +14315 -0
  47. package/package/dist/esm/vue/index.js.map +1 -0
  48. package/package/dist/esm/wizard/index.js +3415 -0
  49. package/package/dist/esm/wizard/index.js.map +1 -0
  50. package/package/dist/index.min.js +2 -0
  51. package/package/dist/index.min.js.map +1 -0
  52. package/package/dist/types/angular/index.d.ts +267 -0
  53. package/package/dist/types/index.d.ts +373 -0
  54. package/package/dist/types/install-wizard.d.ts +156 -0
  55. package/package/dist/types/react/index.d.ts +255 -0
  56. package/package/dist/types/remix/index.d.ts +246 -0
  57. package/package/dist/types/svelte/index.d.ts +232 -0
  58. package/package/dist/types/vue/index.d.ts +15 -0
  59. package/package/dist/types/wizard/index.d.ts +523 -0
  60. package/package/package.json +105 -0
  61. package/package/readme.md +281 -0
  62. package/package/rollup.config.js +422 -0
  63. package/package/simple-demo.html +26 -0
  64. package/package/simple-spa.html +838 -0
  65. package/package/src/angular/index.ts +79 -0
  66. package/package/src/api.ts +376 -0
  67. package/package/src/index.ts +28 -0
  68. package/package/src/react/AutoInstallWizard.tsx +557 -0
  69. package/package/src/react/browser.ts +8 -0
  70. package/package/src/react/index.tsx +308 -0
  71. package/package/src/redact.ts +521 -0
  72. package/package/src/remix/index.ts +16 -0
  73. package/package/src/svelte/index.ts +14 -0
  74. package/package/src/tracker.ts +1319 -0
  75. package/package/src/types/clack.d.ts +31 -0
  76. package/package/src/utils/logger.ts +144 -0
  77. package/package/src/vue/index.ts +29 -0
  78. package/package/src/wizard/README.md +114 -0
  79. package/package/src/wizard/ai/ai-install-wizard.ts +897 -0
  80. package/package/src/wizard/ai/manual-framework-wizard.ts +238 -0
  81. package/package/src/wizard/cli/ai-auto-install.ts +243 -0
  82. package/package/src/wizard/cli/auto-install.ts +224 -0
  83. package/package/src/wizard/core/install-wizard.ts +1744 -0
  84. package/package/src/wizard/index.ts +23 -0
  85. package/package/src/wizard/services/centralized-ai-service.ts +668 -0
  86. package/package/src/wizard/services/remote-ai-service.ts +240 -0
  87. package/package/tsconfig.json +24 -0
  88. package/package.json +1 -1
  89. package/src/wizard/cli/ai-auto-install.ts +4 -6
@@ -0,0 +1,232 @@
1
+ interface RedactionOptions {
2
+ redactedText?: string;
3
+ excludeSelectors?: string[];
4
+ userFields?: string[];
5
+ }
6
+
7
+ declare global {
8
+ interface Window {
9
+ HumanBehaviorTracker: typeof HumanBehaviorTracker;
10
+ __humanBehaviorGlobalTracker?: HumanBehaviorTracker;
11
+ }
12
+ }
13
+ declare class HumanBehaviorTracker {
14
+ private eventIngestionQueue;
15
+ private sessionId;
16
+ private userProperties;
17
+ private isProcessing;
18
+ private flushInterval;
19
+ private readonly FLUSH_INTERVAL_MS;
20
+ private api;
21
+ private endUserId;
22
+ private apiKey;
23
+ private initialized;
24
+ initializationPromise: Promise<void> | null;
25
+ private redactionManager;
26
+ private originalConsole;
27
+ private consoleTrackingEnabled;
28
+ navigationTrackingEnabled: boolean;
29
+ private currentUrl;
30
+ private previousUrl;
31
+ private originalPushState;
32
+ private originalReplaceState;
33
+ private navigationListeners;
34
+ private _connectionBlocked;
35
+ private recordInstance;
36
+ private sessionStartTime;
37
+ private rrwebRecord;
38
+ private fullSnapshotTimeout;
39
+ private recordCanvas;
40
+ /**
41
+ * Initialize the HumanBehavior tracker
42
+ * This is the main entry point - call this once per page
43
+ */
44
+ static init(apiKey: string, options?: {
45
+ ingestionUrl?: string;
46
+ logLevel?: 'none' | 'error' | 'warn' | 'info' | 'debug';
47
+ redactFields?: string[];
48
+ enableAutomaticTracking?: boolean;
49
+ suppressConsoleErrors?: boolean;
50
+ recordCanvas?: boolean;
51
+ automaticTrackingOptions?: {
52
+ trackButtons?: boolean;
53
+ trackLinks?: boolean;
54
+ trackForms?: boolean;
55
+ includeText?: boolean;
56
+ includeClasses?: boolean;
57
+ };
58
+ }): HumanBehaviorTracker;
59
+ constructor(apiKey: string | undefined, ingestionUrl?: string);
60
+ private init;
61
+ private ensureInitialized;
62
+ /**
63
+ * Setup navigation event tracking for SPA navigation
64
+ */
65
+ private setupNavigationTracking;
66
+ /**
67
+ * Track navigation events and send custom events
68
+ */
69
+ trackNavigationEvent(type: string, fromUrl: string, toUrl: string): Promise<void>;
70
+ trackPageView(url?: string): Promise<void>;
71
+ customEvent(eventName: string, properties?: Record<string, any>): Promise<void>;
72
+ /**
73
+ * Setup automatic tracking for buttons, links, and forms
74
+ */
75
+ private setupAutomaticTracking;
76
+ /**
77
+ * Setup automatic button tracking
78
+ */
79
+ private setupAutomaticButtonTracking;
80
+ /**
81
+ * Setup automatic link tracking
82
+ */
83
+ private setupAutomaticLinkTracking;
84
+ /**
85
+ * Setup automatic form tracking
86
+ */
87
+ private setupAutomaticFormTracking;
88
+ /**
89
+ * Cleanup navigation tracking
90
+ */
91
+ private cleanupNavigationTracking;
92
+ static logToStorage(message: string): void;
93
+ /**
94
+ * Configure logging behavior for the SDK
95
+ * @param config Logger configuration options
96
+ */
97
+ static configureLogging(config: {
98
+ level?: 'none' | 'error' | 'warn' | 'info' | 'debug';
99
+ enableConsole?: boolean;
100
+ enableStorage?: boolean;
101
+ }): void;
102
+ /**
103
+ * Enable console event tracking
104
+ */
105
+ enableConsoleTracking(): void;
106
+ /**
107
+ * Disable console event tracking
108
+ */
109
+ disableConsoleTracking(): void;
110
+ private trackConsoleEvent;
111
+ private setupPageUnloadHandler;
112
+ viewLogs(): void;
113
+ /**
114
+ * Add user identification information to the tracker
115
+ * If userId is not provided, will use userProperties.email as the userId (if present)
116
+ */
117
+ identifyUser({ userProperties }: {
118
+ userProperties: Record<string, any>;
119
+ }): Promise<string>;
120
+ /**
121
+ * Get current user attributes
122
+ */
123
+ getUserAttributes(): Record<string, any>;
124
+ start(): Promise<void>;
125
+ /**
126
+ * Manually trigger a FullSnapshot (for navigation events)
127
+ * Delays snapshot to avoid capturing mid-animation states
128
+ */
129
+ private takeFullSnapshot;
130
+ stop(): Promise<void>;
131
+ /**
132
+ * Add an event to the ingestion queue
133
+ * Events are sent directly without processing to avoid corruption
134
+ */
135
+ addEvent(event: any): Promise<void>;
136
+ /**
137
+ * Flush events to the ingestion server
138
+ * Events are sent in chunks to handle large payloads efficiently
139
+ */
140
+ private flush;
141
+ private setCookie;
142
+ getCookie(name: string): string | null;
143
+ /**
144
+ * Delete a cookie by setting its expiration date to the past
145
+ * @param name The name of the cookie to delete
146
+ */
147
+ private deleteCookie;
148
+ /**
149
+ * Clear user data and reset session when user signs out of the site
150
+ * This should be called when a user logs out of your application to prevent
151
+ * data contamination between different users
152
+ */
153
+ logout(): void;
154
+ /**
155
+ * Start redaction functionality for sensitive input fields
156
+ * @param options Optional configuration for redaction behavior
157
+ */
158
+ redact(options?: RedactionOptions): Promise<void>;
159
+ /**
160
+ * Set specific fields to be redacted during session recording
161
+ * Uses rrweb's built-in masking instead of custom redaction processing
162
+ * @param fields Array of CSS selectors for fields to redact (e.g., ['input[type="password"]', '#email-field'])
163
+ */
164
+ setRedactedFields(fields: string[]): void;
165
+ private restartWithNewRedaction;
166
+ /**
167
+ * Check if redaction is currently active
168
+ */
169
+ isRedactionActive(): boolean;
170
+ /**
171
+ * Get the currently selected fields for redaction
172
+ */
173
+ getRedactedFields(): string[];
174
+ /**
175
+ * Get the current session ID
176
+ */
177
+ getSessionId(): string;
178
+ /**
179
+ * Get the current URL being tracked
180
+ */
181
+ getCurrentUrl(): string;
182
+ /**
183
+ * Get current snapshot frequency info
184
+ * Uses configured values (5 minutes, 1000 events)
185
+ */
186
+ getSnapshotFrequencyInfo(): {
187
+ sessionDuration: number;
188
+ currentInterval: number;
189
+ currentThreshold: number;
190
+ phase: string;
191
+ };
192
+ /**
193
+ * Test if the tracker can reach the ingestion server
194
+ */
195
+ testConnection(): Promise<{
196
+ success: boolean;
197
+ error?: string;
198
+ }>;
199
+ /**
200
+ * Get connection status and recommendations
201
+ */
202
+ getConnectionStatus(): {
203
+ blocked: boolean;
204
+ recommendations: string[];
205
+ };
206
+ /**
207
+ * Check if the current user is a preexisting user
208
+ * Returns true if the user has an existing endUserId cookie from a previous session
209
+ */
210
+ isPreexistingUser(): boolean;
211
+ /**
212
+ * Get user information including whether they are preexisting
213
+ */
214
+ getUserInfo(): {
215
+ endUserId: string | null;
216
+ sessionId: string;
217
+ isPreexistingUser: boolean;
218
+ initialized: boolean;
219
+ };
220
+ }
221
+
222
+ declare const humanBehaviorStore: {
223
+ init: (apiKey: string, options?: {
224
+ ingestionUrl?: string;
225
+ logLevel?: "none" | "error" | "warn" | "info" | "debug";
226
+ redactFields?: string[];
227
+ suppressConsoleErrors?: boolean;
228
+ recordCanvas?: boolean;
229
+ }) => HumanBehaviorTracker;
230
+ };
231
+
232
+ export { humanBehaviorStore };
@@ -0,0 +1,15 @@
1
+ import { App } from 'vue';
2
+
3
+ interface HumanBehaviorPluginOptions {
4
+ apiKey: string;
5
+ ingestionUrl?: string;
6
+ logLevel?: 'none' | 'error' | 'warn' | 'info' | 'debug';
7
+ redactFields?: string[];
8
+ suppressConsoleErrors?: boolean;
9
+ recordCanvas?: boolean;
10
+ }
11
+ declare const HumanBehaviorPlugin: {
12
+ install: (app: App, options: HumanBehaviorPluginOptions) => void;
13
+ };
14
+
15
+ export { HumanBehaviorPlugin };