@devskin/browser-sdk 1.0.3 → 1.0.4

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.
@@ -4989,6 +4989,7 @@
4989
4989
  this.events = [];
4990
4990
  this.onEventsReady = null;
4991
4991
  this.flushInterval = null;
4992
+ this.hasFullSnapshot = false;
4992
4993
  this.sessionId = sessionId;
4993
4994
  this.config = config;
4994
4995
  this.onEventsReady = onEventsReady;
@@ -5006,9 +5007,15 @@
5006
5007
  console.log('[RRWeb] Starting session recording:', this.sessionId);
5007
5008
  this.stopFn = record({
5008
5009
  emit: (event) => {
5010
+ // Check if this is a FullSnapshot (type 2)
5011
+ if (event.type === 2) {
5012
+ this.hasFullSnapshot = true;
5013
+ console.log('[RRWeb] FullSnapshot captured! Recording is ready.');
5014
+ }
5009
5015
  this.events.push(event);
5010
- // Flush events periodically to avoid memory buildup
5011
- if (this.events.length >= 50) {
5016
+ // Only flush if we have the FullSnapshot
5017
+ // This ensures the first batch always contains the full DOM
5018
+ if (this.hasFullSnapshot && this.events.length >= 50) {
5012
5019
  this.flush();
5013
5020
  }
5014
5021
  },
@@ -5048,8 +5055,9 @@
5048
5055
  recordCrossOriginIframes: false, // Security: don't record cross-origin iframes
5049
5056
  });
5050
5057
  // Set up periodic flush (every 10 seconds)
5058
+ // Only flush if we have FullSnapshot to ensure first batch is complete
5051
5059
  this.flushInterval = window.setInterval(() => {
5052
- if (this.events.length > 0) {
5060
+ if (this.hasFullSnapshot && this.events.length > 0) {
5053
5061
  this.flush();
5054
5062
  }
5055
5063
  }, 10000);
@@ -5069,8 +5077,11 @@
5069
5077
  clearInterval(this.flushInterval);
5070
5078
  this.flushInterval = null;
5071
5079
  }
5072
- // Flush remaining events
5080
+ // Flush remaining events (even without FullSnapshot, to not lose data)
5073
5081
  if (this.events.length > 0) {
5082
+ if (!this.hasFullSnapshot) {
5083
+ console.warn('[RRWeb] Flushing events without FullSnapshot - recording may not replay correctly');
5084
+ }
5074
5085
  this.flush();
5075
5086
  }
5076
5087
  }
@@ -5135,6 +5146,13 @@
5135
5146
  this.enqueue('performance', metric);
5136
5147
  }
5137
5148
  sendRecordingEvents(sessionId, events) {
5149
+ // DEBUG: Log event types being sent
5150
+ const eventTypes = events.reduce((acc, e) => {
5151
+ acc[e.type] = (acc[e.type] || 0) + 1;
5152
+ return acc;
5153
+ }, {});
5154
+ console.log(`[DevSkin SDK] Sending ${events.length} recording events:`, eventTypes);
5155
+ console.log(`[DevSkin SDK] First 3 events:`, events.slice(0, 3).map(e => ({ type: e.type, timestamp: e.timestamp })));
5138
5156
  // Recording events can be large, send immediately
5139
5157
  this.sendToBackend('/v1/rum/recordings', {
5140
5158
  session_id: sessionId,