@devskin/browser-sdk 1.0.2 → 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.
@@ -643,11 +643,16 @@
643
643
  console[level] = (...args) => {
644
644
  // Call original
645
645
  original.apply(console, args);
646
- // Add breadcrumb
646
+ // Add breadcrumb (skip DevSkin internal logs to avoid infinite loop)
647
647
  if (level === 'warn' || level === 'error') {
648
+ const message = args.map((arg) => String(arg)).join(' ');
649
+ // Skip DevSkin internal messages
650
+ if (message.startsWith('[DevSkin]')) {
651
+ return;
652
+ }
648
653
  this.addBreadcrumb({
649
654
  category: 'console',
650
- message: args.map((arg) => String(arg)).join(' '),
655
+ message: message,
651
656
  level: level === 'warn' ? 'warning' : 'error',
652
657
  data: { arguments: args },
653
658
  });
@@ -4984,6 +4989,7 @@
4984
4989
  this.events = [];
4985
4990
  this.onEventsReady = null;
4986
4991
  this.flushInterval = null;
4992
+ this.hasFullSnapshot = false;
4987
4993
  this.sessionId = sessionId;
4988
4994
  this.config = config;
4989
4995
  this.onEventsReady = onEventsReady;
@@ -5001,9 +5007,15 @@
5001
5007
  console.log('[RRWeb] Starting session recording:', this.sessionId);
5002
5008
  this.stopFn = record({
5003
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
+ }
5004
5015
  this.events.push(event);
5005
- // Flush events periodically to avoid memory buildup
5006
- 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) {
5007
5019
  this.flush();
5008
5020
  }
5009
5021
  },
@@ -5043,8 +5055,9 @@
5043
5055
  recordCrossOriginIframes: false, // Security: don't record cross-origin iframes
5044
5056
  });
5045
5057
  // Set up periodic flush (every 10 seconds)
5058
+ // Only flush if we have FullSnapshot to ensure first batch is complete
5046
5059
  this.flushInterval = window.setInterval(() => {
5047
- if (this.events.length > 0) {
5060
+ if (this.hasFullSnapshot && this.events.length > 0) {
5048
5061
  this.flush();
5049
5062
  }
5050
5063
  }, 10000);
@@ -5064,8 +5077,11 @@
5064
5077
  clearInterval(this.flushInterval);
5065
5078
  this.flushInterval = null;
5066
5079
  }
5067
- // Flush remaining events
5080
+ // Flush remaining events (even without FullSnapshot, to not lose data)
5068
5081
  if (this.events.length > 0) {
5082
+ if (!this.hasFullSnapshot) {
5083
+ console.warn('[RRWeb] Flushing events without FullSnapshot - recording may not replay correctly');
5084
+ }
5069
5085
  this.flush();
5070
5086
  }
5071
5087
  }
@@ -5130,6 +5146,13 @@
5130
5146
  this.enqueue('performance', metric);
5131
5147
  }
5132
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 })));
5133
5156
  // Recording events can be large, send immediately
5134
5157
  this.sendToBackend('/v1/rum/recordings', {
5135
5158
  session_id: sessionId,