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.
@@ -12592,7 +12592,7 @@ class HumanBehaviorAPI {
12592
12592
  sessionId: sessionId,
12593
12593
  posthogName: userData.email || userData.name || null // Update user name with email
12594
12594
  };
12595
- logInfo('Sending user data to server:', payload);
12595
+ logDebug('Sending user data to server:', payload);
12596
12596
  const response = yield fetch(`${this.baseUrl}/api/ingestion/user`, {
12597
12597
  method: 'POST',
12598
12598
  headers: {
@@ -12605,7 +12605,7 @@ class HumanBehaviorAPI {
12605
12605
  throw new Error(`Failed to send user data: ${response.statusText} with API key: ${this.apiKey}`);
12606
12606
  }
12607
12607
  const result = yield response.json();
12608
- logInfo('Server response:', result);
12608
+ logDebug('Server response:', result);
12609
12609
  return result;
12610
12610
  }
12611
12611
  catch (error) {
@@ -13181,6 +13181,53 @@ class HumanBehaviorTracker {
13181
13181
  * This is the main entry point - call this once per page
13182
13182
  */
13183
13183
  static init(apiKey, options) {
13184
+ // ✅ SUPPRESS COMMON RRWEB ERRORS FOR CLEAN CONSOLE
13185
+ if (isBrowser && (options === null || options === void 0 ? void 0 : options.suppressConsoleErrors) !== false) {
13186
+ // Suppress canvas security errors
13187
+ const originalConsoleError = console.error;
13188
+ console.error = (...args) => {
13189
+ const message = args.join(' ');
13190
+ if (message.includes('SecurityError: Failed to execute \'toDataURL\'') ||
13191
+ message.includes('Tainted canvases may not be exported') ||
13192
+ message.includes('Cannot inline img src=') ||
13193
+ message.includes('Cross-Origin') ||
13194
+ message.includes('CORS') ||
13195
+ message.includes('Access-Control-Allow-Origin') ||
13196
+ message.includes('Failed to load resource') ||
13197
+ message.includes('net::ERR_BLOCKED_BY_CLIENT')) {
13198
+ // Silently suppress these common rrweb errors
13199
+ return;
13200
+ }
13201
+ originalConsoleError.apply(console, args);
13202
+ };
13203
+ // Suppress console.warn for similar issues
13204
+ const originalConsoleWarn = console.warn;
13205
+ console.warn = (...args) => {
13206
+ const message = args.join(' ');
13207
+ if (message.includes('Cannot inline img src=') ||
13208
+ message.includes('Cross-Origin') ||
13209
+ message.includes('CORS') ||
13210
+ message.includes('Access-Control-Allow-Origin') ||
13211
+ message.includes('Failed to load resource') ||
13212
+ message.includes('net::ERR_BLOCKED_BY_CLIENT')) {
13213
+ // Silently suppress these common rrweb warnings
13214
+ return;
13215
+ }
13216
+ originalConsoleWarn.apply(console, args);
13217
+ };
13218
+ // Add global error handler for any remaining rrweb errors
13219
+ window.addEventListener('error', (event) => {
13220
+ const message = event.message || '';
13221
+ if (message.includes('SecurityError') ||
13222
+ message.includes('Tainted canvases') ||
13223
+ message.includes('toDataURL') ||
13224
+ message.includes('Cross-Origin') ||
13225
+ message.includes('CORS')) {
13226
+ event.preventDefault();
13227
+ return false;
13228
+ }
13229
+ });
13230
+ }
13184
13231
  // Return existing instance if already initialized
13185
13232
  if (isBrowser && window.__humanBehaviorGlobalTracker) {
13186
13233
  logDebug('Tracker already initialized, returning existing instance');
@@ -13202,16 +13249,6 @@ class HumanBehaviorTracker {
13202
13249
  if ((options === null || options === void 0 ? void 0 : options.enableAutomaticTracking) !== false) {
13203
13250
  tracker.setupAutomaticTracking(options === null || options === void 0 ? void 0 : options.automaticTrackingOptions);
13204
13251
  }
13205
- // Test connection (non-blocking)
13206
- if (isBrowser) {
13207
- const testUrl = tracker.api['baseUrl'] + '/api/health';
13208
- fetch(testUrl, { method: 'HEAD' })
13209
- .then(() => logDebug('Connection test successful'))
13210
- .catch((error) => {
13211
- logWarn('Connection test failed - ad blocker may be active:', error.message);
13212
- tracker._connectionBlocked = true;
13213
- });
13214
- }
13215
13252
  // Start tracking
13216
13253
  tracker.start();
13217
13254
  return tracker;
@@ -13774,6 +13811,7 @@ class HumanBehaviorTracker {
13774
13811
  const originalEndUserId = this.endUserId;
13775
13812
  // Store user properties
13776
13813
  this.userProperties = userProperties;
13814
+ logDebug('Identifying user:', { userProperties, originalEndUserId, sessionId: this.sessionId });
13777
13815
  // Send user data with the original endUserId
13778
13816
  yield this.api.sendUserData(originalEndUserId, userProperties, this.sessionId);
13779
13817
  // Don't update endUserId - keep it as the original UUID
@@ -13819,11 +13857,11 @@ class HumanBehaviorTracker {
13819
13857
  maskInputOptions: { password: true }, // HumanBehavior default
13820
13858
  maskInputFn: undefined,
13821
13859
  slimDOMOptions: {},
13822
- collectFonts: false, // HumanBehavior default
13823
- inlineStylesheet: true, // HumanBehavior default
13824
- recordCrossOriginIframes: false, // HumanBehavior default
13825
- // CANVAS RECORDING - Disabled to prevent large data URIs
13826
- recordCanvas: false, // Disabled to prevent large data URIs
13860
+ // ERROR SUPPRESSION SETTINGS - Disabled to prevent console noise
13861
+ collectFonts: false, // Disable font collection to reduce errors
13862
+ inlineStylesheet: false, // Disable inline stylesheet to reduce errors
13863
+ recordCrossOriginIframes: false, // Prevent cross-origin iframe errors
13864
+ recordCanvas: false, // Disabled to prevent large data URIs and canvas errors
13827
13865
  // ✅ FULLSNAPSHOT GENERATION - No periodic snapshots to avoid animation issues
13828
13866
  // Rely on initial FullSnapshot + navigation-triggered ones only
13829
13867
  });