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