humanbehavior-js 0.4.10 → 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
@@ -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;
@@ -13818,11 +13855,11 @@ class HumanBehaviorTracker {
13818
13855
  maskInputOptions: { password: true }, // HumanBehavior default
13819
13856
  maskInputFn: undefined,
13820
13857
  slimDOMOptions: {},
13821
- collectFonts: false, // HumanBehavior default
13822
- inlineStylesheet: true, // HumanBehavior default
13823
- recordCrossOriginIframes: false, // HumanBehavior default
13824
- // CANVAS RECORDING - Disabled to prevent large data URIs
13825
- 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
13826
13863
  // ✅ FULLSNAPSHOT GENERATION - No periodic snapshots to avoid animation issues
13827
13864
  // Rely on initial FullSnapshot + navigation-triggered ones only
13828
13865
  });