humanbehavior-js 0.4.28 → 0.5.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.
Files changed (140) hide show
  1. package/README.md +151 -0
  2. package/package.json +114 -79
  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,79 +0,0 @@
1
- import { HumanBehaviorTracker } from '../index.js';
2
-
3
- // Angular NgModule for legacy Angular applications
4
- export class HumanBehaviorModule {
5
- static forRoot(config: {
6
- apiKey: string;
7
- ingestionUrl?: string;
8
- logLevel?: 'none' | 'error' | 'warn' | 'info' | 'debug';
9
- redactFields?: string[];
10
- suppressConsoleErrors?: boolean;
11
- recordCanvas?: boolean; // Enable canvas recording with protection
12
- }) {
13
- return {
14
- ngModule: HumanBehaviorModule,
15
- providers: [
16
- {
17
- provide: 'HUMANBEHAVIOR_API_KEY',
18
- useValue: config.apiKey
19
- },
20
- {
21
- provide: HumanBehaviorTracker,
22
- useFactory: (apiKey: string) => {
23
- return HumanBehaviorTracker.init(apiKey, {
24
- ingestionUrl: config.ingestionUrl,
25
- logLevel: config.logLevel,
26
- redactFields: config.redactFields,
27
- suppressConsoleErrors: config.suppressConsoleErrors,
28
- recordCanvas: config.recordCanvas, // Pass canvas recording option
29
- });
30
- },
31
- deps: ['HUMANBEHAVIOR_API_KEY']
32
- }
33
- ]
34
- };
35
- }
36
- }
37
-
38
- // Angular service for dependency injection
39
- export class HumanBehaviorService {
40
- private tracker: HumanBehaviorTracker;
41
-
42
- constructor(apiKey: string, options?: {
43
- ingestionUrl?: string;
44
- logLevel?: 'none' | 'error' | 'warn' | 'info' | 'debug';
45
- redactFields?: string[];
46
- suppressConsoleErrors?: boolean;
47
- recordCanvas?: boolean; // Enable canvas recording with protection
48
- }) {
49
- this.tracker = HumanBehaviorTracker.init(apiKey, options);
50
- }
51
-
52
- // Expose core tracker methods
53
- identifyUser(userProperties: Record<string, any>) {
54
- return this.tracker.identifyUser({ userProperties });
55
- }
56
-
57
- getSessionId() {
58
- return this.tracker.getSessionId();
59
- }
60
-
61
- setUnredactedFields(fields: string[]) {
62
- return this.tracker.setUnredactedFields(fields);
63
- }
64
-
65
- getUnredactedFields() {
66
- return this.tracker.getUnredactedFields();
67
- }
68
- }
69
-
70
- // Helper function for standalone Angular initialization
71
- export function initializeHumanBehavior(apiKey: string, options?: {
72
- ingestionUrl?: string;
73
- logLevel?: 'none' | 'error' | 'warn' | 'info' | 'debug';
74
- redactFields?: string[];
75
- suppressConsoleErrors?: boolean;
76
- recordCanvas?: boolean; // Enable canvas recording with protection
77
- }): HumanBehaviorTracker {
78
- return HumanBehaviorTracker.init(apiKey, options);
79
- }
package/src/api.ts DELETED
@@ -1,416 +0,0 @@
1
- import { logError, logInfo, logDebug, logWarn } from './utils/logger';
2
- import { getCachedIP, IPInfo } from './utils/ip-detector';
3
-
4
- export const MAX_CHUNK_SIZE_BYTES = 1024 * 1024; // 1MB chunk size - more conservative
5
-
6
- export function isChunkSizeExceeded(currentChunk: any[], newEvent: any, sessionId: string): boolean {
7
- const nextChunkSize = new TextEncoder().encode(JSON.stringify({
8
- sessionId,
9
- events: [...currentChunk, newEvent]
10
- })).length;
11
-
12
- return nextChunkSize > MAX_CHUNK_SIZE_BYTES;
13
- }
14
-
15
- export function validateSingleEventSize(event: any, sessionId: string): void {
16
- const singleEventSize = new TextEncoder().encode(JSON.stringify({
17
- sessionId,
18
- events: [event]
19
- })).length;
20
-
21
- if (singleEventSize > MAX_CHUNK_SIZE_BYTES) {
22
- // Instead of throwing, log a warning and suggest reducing event size
23
- logWarn(`Single event size (${singleEventSize} bytes) exceeds maximum chunk size (${MAX_CHUNK_SIZE_BYTES} bytes). Consider reducing event data size.`);
24
- }
25
- }
26
-
27
-
28
-
29
-
30
-
31
- export function splitLargeEvent(event: any, sessionId: string): any[] {
32
- // ✅ SIMPLE VALIDATION
33
- if (!event || typeof event !== 'object') {
34
- return [];
35
- }
36
-
37
- const eventSize = new TextEncoder().encode(JSON.stringify({
38
- sessionId,
39
- events: [event]
40
- })).length;
41
-
42
- if (eventSize <= MAX_CHUNK_SIZE_BYTES) {
43
- return [event];
44
- }
45
-
46
- // If event is too large, try to split it by removing large properties
47
- const simplifiedEvent = { ...event };
48
-
49
- // Remove potentially large properties
50
- const largeProperties = ['screenshot', 'html', 'dom', 'fullText', 'innerHTML', 'outerHTML'];
51
- largeProperties.forEach(prop => {
52
- if (simplifiedEvent[prop]) {
53
- delete simplifiedEvent[prop];
54
- }
55
- });
56
-
57
- // Check if simplified event is now small enough
58
- const simplifiedSize = new TextEncoder().encode(JSON.stringify({
59
- sessionId,
60
- events: [simplifiedEvent]
61
- })).length;
62
-
63
- if (simplifiedSize <= MAX_CHUNK_SIZE_BYTES) {
64
- return [simplifiedEvent];
65
- }
66
-
67
- // If still too large, create a minimal event
68
- const minimalEvent = {
69
- type: event.type,
70
- timestamp: event.timestamp,
71
- url: event.url,
72
- pathname: event.pathname,
73
- // Keep only essential properties
74
- ...Object.fromEntries(
75
- Object.entries(event).filter(([key, value]) =>
76
- !largeProperties.includes(key) &&
77
- typeof value !== 'object' &&
78
- typeof value !== 'string' ||
79
- (typeof value === 'string' && value.length < 1000)
80
- )
81
- )
82
- };
83
-
84
- return [minimalEvent];
85
- }
86
-
87
- export class HumanBehaviorAPI {
88
- private apiKey: string;
89
- private baseUrl: string;
90
-
91
- constructor({ apiKey, ingestionUrl }: { apiKey: string, ingestionUrl: string }) {
92
- this.apiKey = apiKey;
93
- this.baseUrl = ingestionUrl;
94
- }
95
-
96
- public async init(sessionId: string, userId: string | null) {
97
- // Get current page URL and referrer if in browser environment
98
- let entryURL = null;
99
- let referrer = null;
100
-
101
- if (typeof window !== 'undefined') {
102
- entryURL = window.location.href;
103
- referrer = document.referrer;
104
- }
105
-
106
- logInfo('API init called with:', { sessionId, userId, entryURL, referrer, baseUrl: this.baseUrl });
107
-
108
- try {
109
- const response = await fetch(`${this.baseUrl}/api/ingestion/init`, {
110
- method: 'POST',
111
- headers: {
112
- 'Content-Type': 'application/json',
113
- 'Authorization': `Bearer ${this.apiKey}`,
114
- 'Referer': referrer || ''
115
- },
116
- body: JSON.stringify({
117
- sessionId: sessionId,
118
- endUserId: userId,
119
- entryURL: entryURL,
120
- referrer: referrer
121
- })
122
- });
123
-
124
- logInfo('API init response status:', response.status);
125
-
126
- if (!response.ok) {
127
- const errorText = await response.text();
128
- logError('API init failed:', response.status, errorText);
129
- throw new Error(`Failed to initialize ingestion: ${response.statusText} - ${errorText}`);
130
- }
131
-
132
- const responseJson = await response.json();
133
- logInfo('API init success:', responseJson);
134
- return {
135
- sessionId: responseJson.sessionId,
136
- endUserId: responseJson.endUserId
137
- }
138
- } catch (error) {
139
- logError('API init error:', error);
140
- throw error;
141
- }
142
- }
143
-
144
- /**
145
- * Send IP address information to the server
146
- * This is called after successful initialization
147
- */
148
- public async sendIPInfo(sessionId: string): Promise<void> {
149
- try {
150
- const ipInfo = await getCachedIP();
151
- if (!ipInfo) {
152
- logWarn('No IP address available to send');
153
- return;
154
- }
155
-
156
- logDebug('Sending IP info:', ipInfo);
157
-
158
- const response = await fetch(`${this.baseUrl}/api/ingestion/ip-info`, {
159
- method: 'POST',
160
- headers: {
161
- 'Content-Type': 'application/json',
162
- 'Authorization': `Bearer ${this.apiKey}`
163
- },
164
- body: JSON.stringify({
165
- sessionId: sessionId,
166
- clientIP: ipInfo.ip,
167
- ipDetectionMethod: ipInfo.method,
168
- timestamp: ipInfo.timestamp
169
- })
170
- });
171
-
172
- if (!response.ok) {
173
- const errorText = await response.text();
174
- logWarn('Failed to send IP info:', response.status, errorText);
175
- } else {
176
- logDebug('IP info sent successfully');
177
- }
178
- } catch (error) {
179
- logWarn('Error sending IP info:', error);
180
- }
181
- }
182
-
183
- async sendEvents(events: any[], sessionId: string, userId: string) {
184
- // ✅ SIMPLE VALIDATION FOR ALL EVENTS
185
- const validEvents = events.filter(event => event && typeof event === 'object');
186
-
187
- const response = await fetch(`${this.baseUrl}/api/ingestion/events`, {
188
- method: 'POST',
189
- headers: {
190
- 'Content-Type': 'application/json',
191
- 'Authorization': `Bearer ${this.apiKey}`
192
- },
193
- body: JSON.stringify({
194
- sessionId,
195
- events: validEvents,
196
- endUserId: userId
197
- })
198
- });
199
-
200
- if (!response.ok) {
201
- throw new Error(`Failed to send events: ${response.statusText}`);
202
- }
203
- }
204
-
205
- async sendEventsChunked(events: any[], sessionId: string, userId?: string) {
206
- try {
207
- const results = [];
208
- let currentChunk: any[] = [];
209
-
210
- for (const event of events) {
211
- // ✅ SIMPLE VALIDATION FOR ALL EVENTS
212
- if (!event || typeof event !== 'object') {
213
- continue;
214
- }
215
-
216
- if (isChunkSizeExceeded(currentChunk, event, sessionId)) {
217
- // If current chunk is not empty, send it first
218
- if (currentChunk.length > 0) {
219
- const response = await fetch(`${this.baseUrl}/api/ingestion/events`, {
220
- method: 'POST',
221
- headers: {
222
- 'Content-Type': 'application/json',
223
- 'Authorization': `Bearer ${this.apiKey}`
224
- },
225
- body: JSON.stringify({
226
- sessionId,
227
- events: currentChunk,
228
- endUserId: userId
229
- })
230
- });
231
-
232
- if (!response.ok) {
233
- throw new Error(`Failed to send events: ${response.statusText}`);
234
- }
235
-
236
- results.push(await response.json());
237
- currentChunk = [];
238
- }
239
-
240
- // Handle large events by splitting them
241
- const splitEvents = splitLargeEvent(event, sessionId);
242
-
243
- // Start new chunk with the split events
244
- currentChunk = splitEvents;
245
- } else {
246
- // Add event to current chunk
247
- currentChunk.push(event);
248
- }
249
- }
250
-
251
- // Send any remaining events
252
- if (currentChunk.length > 0) {
253
- const response = await fetch(`${this.baseUrl}/api/ingestion/events`, {
254
- method: 'POST',
255
- headers: {
256
- 'Content-Type': 'application/json',
257
- 'Authorization': `Bearer ${this.apiKey}`
258
- },
259
- body: JSON.stringify({
260
- sessionId,
261
- events: currentChunk,
262
- endUserId: userId
263
- })
264
- });
265
-
266
- if (!response.ok) {
267
- throw new Error(`Failed to send events: ${response.statusText}`);
268
- }
269
-
270
- results.push(await response.json());
271
- }
272
-
273
- return results.flat();
274
- } catch (error) {
275
- logError('Error sending events:', error);
276
- throw error;
277
- }
278
- }
279
-
280
- async sendUserData(userId: string, userData: Record<string, any>, sessionId: string) {
281
- try {
282
- const payload = {
283
- userId: userId,
284
- userAttributes: userData,
285
- sessionId: sessionId,
286
- posthogName: userData.email || userData.name || null // Update user name with email
287
- };
288
-
289
- logDebug('Sending user data to server:', payload);
290
-
291
- const response = await fetch(`${this.baseUrl}/api/ingestion/user`, {
292
- method: 'POST',
293
- headers: {
294
- 'Content-Type': 'application/json',
295
- 'Authorization': `Bearer ${this.apiKey}`
296
- },
297
- body: JSON.stringify(payload)
298
- });
299
-
300
- if (!response.ok) {
301
- throw new Error(`Failed to send user data: ${response.statusText} with API key: ${this.apiKey}`);
302
- }
303
-
304
- const result = await response.json();
305
- logDebug('Server response:', result);
306
- return result;
307
- } catch (error) {
308
- logError('Error sending user data:', error);
309
- throw error;
310
- }
311
- }
312
-
313
- async sendUserAuth(userId: string, userData: Record<string, any>, sessionId: string, authFields: string[]) {
314
- try {
315
- const response = await fetch(`${this.baseUrl}/api/ingestion/user/auth`, {
316
- method: 'POST',
317
- headers: {
318
- 'Content-Type': 'application/json',
319
- 'Authorization': `Bearer ${this.apiKey}`
320
- },
321
- body: JSON.stringify({
322
- userId: userId,
323
- userAttributes: userData,
324
- sessionId: sessionId,
325
- authFields: authFields
326
- })
327
- });
328
-
329
- if (!response.ok) {
330
- throw new Error(`Failed to authenticate user: ${response.statusText} with API key: ${this.apiKey}`);
331
- }
332
- // Returns: { success: true, message: '...', userId: '...' }
333
- return await response.json();
334
- } catch (error) {
335
- logError('Error authenticating user:', error);
336
- throw error;
337
- }
338
- }
339
-
340
- public sendBeaconEvents(events: any[], sessionId: string) {
341
- // Create JSON payload that matches the server's expected format
342
- const payload = {
343
- sessionId: sessionId,
344
- events: events,
345
- endUserId: null, // Beacon doesn't have user context
346
- apiKey: this.apiKey // Include API key in body since beacon can't use headers
347
- };
348
-
349
- // Convert to Blob for sendBeacon
350
- const blob = new Blob([JSON.stringify(payload)], {
351
- type: 'application/json'
352
- });
353
-
354
- const success = navigator.sendBeacon(
355
- `${this.baseUrl}/api/ingestion/events`,
356
- blob
357
- );
358
-
359
- return success;
360
- }
361
-
362
- async sendCustomEvent(sessionId: string, eventName: string, eventProperties?: Record<string, any>) {
363
- logInfo('[SDK] Sending custom event', { sessionId, eventName, eventProperties });
364
- try {
365
- const response = await fetch(`${this.baseUrl}/api/ingestion/customEvent`, {
366
- method: 'POST',
367
- headers: {
368
- 'Content-Type': 'application/json',
369
- 'Authorization': `Bearer ${this.apiKey}`
370
- },
371
- body: JSON.stringify({
372
- sessionId: sessionId,
373
- eventName: eventName,
374
- eventProperties: eventProperties || {}
375
- })
376
- });
377
- logInfo('[SDK] Custom event response', { status: response.status, statusText: response.statusText });
378
- if (!response.ok) {
379
- const errorText = await response.text();
380
- logError('[SDK] Failed to send custom event', { status: response.status, statusText: response.statusText, errorText });
381
- throw new Error(`Failed to send custom event: ${response.status} ${response.statusText} - ${errorText}`);
382
- }
383
- const json = await response.json();
384
- logDebug('[SDK] Custom event success', json);
385
- return json;
386
- } catch (error) {
387
- logError('[SDK] Error sending custom event', error, { sessionId, eventName, eventProperties });
388
- throw error;
389
- }
390
- }
391
-
392
- async sendCustomEventBatch(sessionId: string, events: Array<{ eventName: string; eventProperties?: Record<string, any> }>) {
393
- try {
394
- const response = await fetch(`${this.baseUrl}/api/ingestion/customEvent/batch`, {
395
- method: 'POST',
396
- headers: {
397
- 'Content-Type': 'application/json',
398
- 'Authorization': `Bearer ${this.apiKey}`
399
- },
400
- body: JSON.stringify({
401
- sessionId: sessionId,
402
- events: events
403
- })
404
- });
405
-
406
- if (!response.ok) {
407
- throw new Error(`Failed to send custom event batch: ${response.statusText}`);
408
- }
409
-
410
- return await response.json();
411
- } catch (error) {
412
- logError('Error sending custom event batch:', error);
413
- throw error;
414
- }
415
- }
416
- }
package/src/index.ts DELETED
@@ -1,35 +0,0 @@
1
- /**
2
- * Main entry point for the HumanBehavior SDK
3
- */
4
-
5
- import { HumanBehaviorTracker } from './tracker';
6
-
7
- // Export everything from the tracker module
8
- export * from './tracker';
9
-
10
- // Export everything from the API module
11
- export * from './api';
12
-
13
- // Export redaction functionality
14
- export * from './redact';
15
-
16
- // Export property management functionality
17
- export * from './utils/property-detector';
18
- export * from './utils/property-manager';
19
-
20
- // Export IP detection functionality
21
- export * from './utils/ip-detector';
22
-
23
- // Export logger functionality
24
- export * from './utils/logger';
25
-
26
- // Installation wizard is exported separately to avoid Node.js dependencies in browser bundles
27
- // Import from 'humanbehavior-js/install-wizard' for Node.js usage
28
-
29
- // Note: Default export removed to avoid mixed export warnings
30
- // Use: import { HumanBehaviorTracker } from 'humanbehavior-js'
31
-
32
- // For UMD builds, expose the main class globally
33
- if (typeof window !== 'undefined') {
34
- (window as any).HumanBehaviorTracker = HumanBehaviorTracker;
35
- }