humanbehavior-js 0.2.4 → 0.2.6

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/cjs/index.js CHANGED
@@ -5521,6 +5521,22 @@ class HumanBehaviorTracker {
5521
5521
  // Start recording with redaction enabled
5522
5522
  record({
5523
5523
  emit: (event) => {
5524
+ // Add additional validation for FullSnapshot events
5525
+ if (event.type === 2) { // FullSnapshot event
5526
+ if (!event.data || !event.data.node) {
5527
+ logWarn('rrweb generated malformed FullSnapshot event:', {
5528
+ hasData: !!event.data,
5529
+ hasNode: !!(event.data && event.data.node),
5530
+ dataType: typeof event.data,
5531
+ eventType: event.type,
5532
+ timestamp: event.timestamp
5533
+ });
5534
+ // Don't skip - let the addEvent method handle it
5535
+ }
5536
+ else {
5537
+ logDebug('Valid FullSnapshot event received from rrweb');
5538
+ }
5539
+ }
5524
5540
  this.addEvent(event);
5525
5541
  },
5526
5542
  inlineStylesheet: true,
@@ -5529,7 +5545,10 @@ class HumanBehaviorTracker {
5529
5545
  inlineImages: true,
5530
5546
  blockClass: 'rr-block',
5531
5547
  ignoreClass: 'rr-ignore',
5532
- maskTextClass: 'rr-ignore'
5548
+ maskTextClass: 'rr-ignore',
5549
+ // Add more robust configuration
5550
+ checkoutEveryNms: 5000, // Take full snapshot every 5 seconds
5551
+ checkoutEveryNth: 100 // Take full snapshot every 100 events
5533
5552
  });
5534
5553
  });
5535
5554
  }
@@ -5551,6 +5570,18 @@ class HumanBehaviorTracker {
5551
5570
  addEvent(event) {
5552
5571
  return __awaiter$1(this, void 0, void 0, function* () {
5553
5572
  yield this.ensureInitialized();
5573
+ // Validate FullSnapshot events before processing
5574
+ if (event.type === 2) { // FullSnapshot event
5575
+ if (!event.data || !event.data.node) {
5576
+ logWarn('Malformed FullSnapshot event detected, skipping:', {
5577
+ hasData: !!event.data,
5578
+ hasNode: !!(event.data && event.data.node),
5579
+ dataType: typeof event.data,
5580
+ eventType: event.type
5581
+ });
5582
+ return; // Skip malformed FullSnapshot events
5583
+ }
5584
+ }
5554
5585
  // Process event through redaction manager if active
5555
5586
  const processedEvent = this.redactionManager.processEvent(event);
5556
5587
  const eventSize = new TextEncoder().encode(JSON.stringify(processedEvent)).length;