@devskin/browser-sdk 1.0.10 → 1.0.11

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.
@@ -13248,7 +13248,7 @@
13248
13248
  }
13249
13249
  try {
13250
13250
  console.log('[RRWeb] Starting session recording:', this.sessionId);
13251
- console.log('[RRWeb] SDK Version: 1.0.10');
13251
+ console.log('[RRWeb] SDK Version: 1.0.11');
13252
13252
  this.stopFn = record({
13253
13253
  emit: (event) => {
13254
13254
  // DEBUG: Log ALL event types to diagnose issue
@@ -13430,18 +13430,32 @@
13430
13430
  }, {});
13431
13431
  console.log(`[DevSkin SDK] Sending ${events.length} recording events:`, eventTypes);
13432
13432
  console.log(`[DevSkin SDK] First 3 events:`, events.slice(0, 3).map(e => ({ type: e.type, timestamp: e.timestamp })));
13433
- // Recording events can be large, send immediately
13434
- try {
13435
- yield this.sendToBackend('/v1/rum/recordings', {
13436
- session_id: sessionId,
13437
- events,
13438
- timestamp: new Date().toISOString(),
13439
- });
13440
- console.log(`[DevSkin SDK] ✅ Recording events sent successfully`);
13441
- }
13442
- catch (error) {
13443
- console.error(`[DevSkin SDK] ❌ Failed to send recording events:`, error);
13433
+ // Check if this batch contains FullSnapshot (type 2)
13434
+ const hasFullSnapshot = events.some(e => e.type === 2);
13435
+ const maxRetries = hasFullSnapshot ? 3 : 1; // Retry FullSnapshot batches up to 3 times
13436
+ // Recording events can be large, send immediately with retry logic
13437
+ let lastError = null;
13438
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
13439
+ try {
13440
+ yield this.sendToBackend('/v1/rum/recordings', {
13441
+ session_id: sessionId,
13442
+ events,
13443
+ timestamp: new Date().toISOString(),
13444
+ });
13445
+ console.log(`[DevSkin SDK] ✅ Recording events sent successfully${attempt > 1 ? ` (attempt ${attempt})` : ''}`);
13446
+ return; // Success, exit
13447
+ }
13448
+ catch (error) {
13449
+ lastError = error;
13450
+ if (attempt < maxRetries) {
13451
+ const delay = attempt * 1000; // 1s, 2s, 3s...
13452
+ console.warn(`[DevSkin SDK] ⚠️ Failed to send recording events (attempt ${attempt}/${maxRetries}), retrying in ${delay}ms...`);
13453
+ yield new Promise(resolve => setTimeout(resolve, delay));
13454
+ }
13455
+ }
13444
13456
  }
13457
+ // All retries failed
13458
+ console.error(`[DevSkin SDK] ❌ Failed to send recording events after ${maxRetries} attempts:`, lastError);
13445
13459
  });
13446
13460
  }
13447
13461
  sendHeatmapData(heatmapData) {
@@ -13645,10 +13659,15 @@
13645
13659
  // Send rrweb events to backend
13646
13660
  (_a = this.transport) === null || _a === void 0 ? void 0 : _a.sendRecordingEvents(this.sessionId, events);
13647
13661
  });
13648
- this.rrwebRecorder.start();
13649
- if (this.config.debug) {
13650
- console.log('[DevSkin] RRWeb recording started for session:', this.sessionId);
13651
- }
13662
+ // Wait 500ms before starting recording to ensure session is created in backend
13663
+ // This prevents race condition where FullSnapshot is sent before session exists
13664
+ setTimeout(() => {
13665
+ var _a, _b;
13666
+ (_a = this.rrwebRecorder) === null || _a === void 0 ? void 0 : _a.start();
13667
+ if ((_b = this.config) === null || _b === void 0 ? void 0 : _b.debug) {
13668
+ console.log('[DevSkin] RRWeb recording started for session:', this.sessionId);
13669
+ }
13670
+ }, 500);
13652
13671
  }
13653
13672
  // Track initial page view
13654
13673
  this.trackPageView();