humanbehavior-js 0.4.9 → 0.4.11

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.
@@ -12584,7 +12584,7 @@ class HumanBehaviorAPI {
12584
12584
  sessionId: sessionId,
12585
12585
  posthogName: userData.email || userData.name || null // Update user name with email
12586
12586
  };
12587
- logInfo('Sending user data to server:', payload);
12587
+ logDebug('Sending user data to server:', payload);
12588
12588
  const response = yield fetch(`${this.baseUrl}/api/ingestion/user`, {
12589
12589
  method: 'POST',
12590
12590
  headers: {
@@ -12597,7 +12597,7 @@ class HumanBehaviorAPI {
12597
12597
  throw new Error(`Failed to send user data: ${response.statusText} with API key: ${this.apiKey}`);
12598
12598
  }
12599
12599
  const result = yield response.json();
12600
- logInfo('Server response:', result);
12600
+ logDebug('Server response:', result);
12601
12601
  return result;
12602
12602
  }
12603
12603
  catch (error) {
@@ -13173,6 +13173,53 @@ class HumanBehaviorTracker {
13173
13173
  * This is the main entry point - call this once per page
13174
13174
  */
13175
13175
  static init(apiKey, options) {
13176
+ // ✅ SUPPRESS COMMON RRWEB ERRORS FOR CLEAN CONSOLE
13177
+ if (isBrowser$1 && (options === null || options === void 0 ? void 0 : options.suppressConsoleErrors) !== false) {
13178
+ // Suppress canvas security errors
13179
+ const originalConsoleError = console.error;
13180
+ console.error = (...args) => {
13181
+ const message = args.join(' ');
13182
+ if (message.includes('SecurityError: Failed to execute \'toDataURL\'') ||
13183
+ message.includes('Tainted canvases may not be exported') ||
13184
+ message.includes('Cannot inline img src=') ||
13185
+ message.includes('Cross-Origin') ||
13186
+ message.includes('CORS') ||
13187
+ message.includes('Access-Control-Allow-Origin') ||
13188
+ message.includes('Failed to load resource') ||
13189
+ message.includes('net::ERR_BLOCKED_BY_CLIENT')) {
13190
+ // Silently suppress these common rrweb errors
13191
+ return;
13192
+ }
13193
+ originalConsoleError.apply(console, args);
13194
+ };
13195
+ // Suppress console.warn for similar issues
13196
+ const originalConsoleWarn = console.warn;
13197
+ console.warn = (...args) => {
13198
+ const message = args.join(' ');
13199
+ if (message.includes('Cannot inline img src=') ||
13200
+ message.includes('Cross-Origin') ||
13201
+ message.includes('CORS') ||
13202
+ message.includes('Access-Control-Allow-Origin') ||
13203
+ message.includes('Failed to load resource') ||
13204
+ message.includes('net::ERR_BLOCKED_BY_CLIENT')) {
13205
+ // Silently suppress these common rrweb warnings
13206
+ return;
13207
+ }
13208
+ originalConsoleWarn.apply(console, args);
13209
+ };
13210
+ // Add global error handler for any remaining rrweb errors
13211
+ window.addEventListener('error', (event) => {
13212
+ const message = event.message || '';
13213
+ if (message.includes('SecurityError') ||
13214
+ message.includes('Tainted canvases') ||
13215
+ message.includes('toDataURL') ||
13216
+ message.includes('Cross-Origin') ||
13217
+ message.includes('CORS')) {
13218
+ event.preventDefault();
13219
+ return false;
13220
+ }
13221
+ });
13222
+ }
13176
13223
  // Return existing instance if already initialized
13177
13224
  if (isBrowser$1 && window.__humanBehaviorGlobalTracker) {
13178
13225
  logDebug('Tracker already initialized, returning existing instance');
@@ -13194,16 +13241,6 @@ class HumanBehaviorTracker {
13194
13241
  if ((options === null || options === void 0 ? void 0 : options.enableAutomaticTracking) !== false) {
13195
13242
  tracker.setupAutomaticTracking(options === null || options === void 0 ? void 0 : options.automaticTrackingOptions);
13196
13243
  }
13197
- // Test connection (non-blocking)
13198
- if (isBrowser$1) {
13199
- const testUrl = tracker.api['baseUrl'] + '/api/health';
13200
- fetch(testUrl, { method: 'HEAD' })
13201
- .then(() => logDebug('Connection test successful'))
13202
- .catch((error) => {
13203
- logWarn('Connection test failed - ad blocker may be active:', error.message);
13204
- tracker._connectionBlocked = true;
13205
- });
13206
- }
13207
13244
  // Start tracking
13208
13245
  tracker.start();
13209
13246
  return tracker;
@@ -13766,6 +13803,7 @@ class HumanBehaviorTracker {
13766
13803
  const originalEndUserId = this.endUserId;
13767
13804
  // Store user properties
13768
13805
  this.userProperties = userProperties;
13806
+ logDebug('Identifying user:', { userProperties, originalEndUserId, sessionId: this.sessionId });
13769
13807
  // Send user data with the original endUserId
13770
13808
  yield this.api.sendUserData(originalEndUserId, userProperties, this.sessionId);
13771
13809
  // Don't update endUserId - keep it as the original UUID
@@ -13811,11 +13849,11 @@ class HumanBehaviorTracker {
13811
13849
  maskInputOptions: { password: true }, // HumanBehavior default
13812
13850
  maskInputFn: undefined,
13813
13851
  slimDOMOptions: {},
13814
- collectFonts: false, // HumanBehavior default
13815
- inlineStylesheet: true, // HumanBehavior default
13816
- recordCrossOriginIframes: false, // HumanBehavior default
13817
- // CANVAS RECORDING - Disabled to prevent large data URIs
13818
- recordCanvas: false, // Disabled to prevent large data URIs
13852
+ // ERROR SUPPRESSION SETTINGS - Disabled to prevent console noise
13853
+ collectFonts: false, // Disable font collection to reduce errors
13854
+ inlineStylesheet: false, // Disable inline stylesheet to reduce errors
13855
+ recordCrossOriginIframes: false, // Prevent cross-origin iframe errors
13856
+ recordCanvas: false, // Disabled to prevent large data URIs and canvas errors
13819
13857
  // ✅ FULLSNAPSHOT GENERATION - No periodic snapshots to avoid animation issues
13820
13858
  // Rely on initial FullSnapshot + navigation-triggered ones only
13821
13859
  });