humanbehavior-js 0.4.12 → 0.4.13

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.
Files changed (40) hide show
  1. package/canvas-recording-demo.html +143 -0
  2. package/dist/cjs/angular/index.cjs +22 -6
  3. package/dist/cjs/angular/index.cjs.map +1 -1
  4. package/dist/cjs/index.cjs +11 -1
  5. package/dist/cjs/index.cjs.map +1 -1
  6. package/dist/cjs/react/index.cjs +19 -11
  7. package/dist/cjs/react/index.cjs.map +1 -1
  8. package/dist/cjs/remix/index.cjs +19 -11
  9. package/dist/cjs/remix/index.cjs.map +1 -1
  10. package/dist/cjs/svelte/index.cjs +13 -3
  11. package/dist/cjs/svelte/index.cjs.map +1 -1
  12. package/dist/cjs/vue/index.cjs +18 -2
  13. package/dist/cjs/vue/index.cjs.map +1 -1
  14. package/dist/esm/angular/index.js +22 -6
  15. package/dist/esm/angular/index.js.map +1 -1
  16. package/dist/esm/index.js +11 -1
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/react/index.js +19 -11
  19. package/dist/esm/react/index.js.map +1 -1
  20. package/dist/esm/remix/index.js +19 -11
  21. package/dist/esm/remix/index.js.map +1 -1
  22. package/dist/esm/svelte/index.js +13 -3
  23. package/dist/esm/svelte/index.js.map +1 -1
  24. package/dist/esm/vue/index.js +18 -2
  25. package/dist/esm/vue/index.js.map +1 -1
  26. package/dist/index.min.js +1 -1
  27. package/dist/index.min.js.map +1 -1
  28. package/dist/types/angular/index.d.ts +21 -2
  29. package/dist/types/index.d.ts +2 -0
  30. package/dist/types/react/index.d.ts +4 -0
  31. package/dist/types/remix/index.d.ts +4 -0
  32. package/dist/types/svelte/index.d.ts +9 -1
  33. package/dist/types/vue/index.d.ts +5 -0
  34. package/package.json +1 -1
  35. package/readme.md +20 -1
  36. package/src/angular/index.ts +31 -6
  37. package/src/react/index.tsx +12 -13
  38. package/src/svelte/index.ts +8 -2
  39. package/src/tracker.ts +13 -1
  40. package/src/vue/index.ts +12 -1
@@ -13181,6 +13181,7 @@ class HumanBehaviorTracker {
13181
13181
  * This is the main entry point - call this once per page
13182
13182
  */
13183
13183
  static init(apiKey, options) {
13184
+ var _a;
13184
13185
  // ✅ SUPPRESS COMMON RRWEB ERRORS FOR CLEAN CONSOLE
13185
13186
  if (isBrowser && (options === null || options === void 0 ? void 0 : options.suppressConsoleErrors) !== false) {
13186
13187
  // Suppress canvas security errors
@@ -13239,6 +13240,8 @@ class HumanBehaviorTracker {
13239
13240
  }
13240
13241
  // Create new tracker instance
13241
13242
  const tracker = new HumanBehaviorTracker(apiKey, options === null || options === void 0 ? void 0 : options.ingestionUrl);
13243
+ // Store canvas recording preference
13244
+ tracker.recordCanvas = (_a = options === null || options === void 0 ? void 0 : options.recordCanvas) !== null && _a !== void 0 ? _a : false;
13242
13245
  // Set redacted fields if specified
13243
13246
  if (options === null || options === void 0 ? void 0 : options.redactFields) {
13244
13247
  tracker.setRedactedFields(options.redactFields);
@@ -13277,6 +13280,7 @@ class HumanBehaviorTracker {
13277
13280
  this.sessionStartTime = Date.now();
13278
13281
  this.rrwebRecord = null;
13279
13282
  this.fullSnapshotTimeout = null;
13283
+ this.recordCanvas = false; // Store canvas recording preference
13280
13284
  if (!apiKey) {
13281
13285
  throw new Error('Human Behavior API Key is required');
13282
13286
  }
@@ -13861,7 +13865,13 @@ class HumanBehaviorTracker {
13861
13865
  collectFonts: false, // Disable font collection to reduce errors
13862
13866
  inlineStylesheet: true, // Keep styles for proper session replay
13863
13867
  recordCrossOriginIframes: false, // Prevent cross-origin iframe errors
13864
- recordCanvas: false, // Disabled to prevent large data URIs and canvas errors
13868
+ // CANVAS RECORDING - PostHog-style protection against overwhelm
13869
+ recordCanvas: this.recordCanvas, // Opt-in only
13870
+ sampling: this.recordCanvas ? { canvas: 4 } : undefined, // 4 FPS throttle
13871
+ dataURLOptions: this.recordCanvas ? {
13872
+ type: 'image/webp',
13873
+ quality: 0.4
13874
+ } : undefined, // WebP with 40% quality
13865
13875
  // ✅ FULLSNAPSHOT GENERATION - No periodic snapshots to avoid animation issues
13866
13876
  // Rely on initial FullSnapshot + navigation-triggered ones only
13867
13877
  });