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