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