@devskin/browser-sdk 1.0.5 → 1.0.7

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.
@@ -5007,15 +5007,16 @@
5007
5007
  console.log('[RRWeb] Starting session recording:', this.sessionId);
5008
5008
  this.stopFn = record({
5009
5009
  emit: (event) => {
5010
+ this.events.push(event);
5010
5011
  // Check if this is a FullSnapshot (type 2)
5011
5012
  if (event.type === 2) {
5012
5013
  this.hasFullSnapshot = true;
5013
- console.log('[RRWeb] FullSnapshot captured! Recording is ready.');
5014
+ console.log('[RRWeb] FullSnapshot captured! Sending immediately...');
5015
+ // Send immediately to ensure FullSnapshot reaches backend first
5016
+ this.flush();
5014
5017
  }
5015
- this.events.push(event);
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) {
5018
+ else if (this.hasFullSnapshot && this.events.length >= 50) {
5019
+ // After FullSnapshot, batch other events
5019
5020
  this.flush();
5020
5021
  }
5021
5022
  },
@@ -5519,15 +5520,11 @@
5519
5520
  window.addEventListener('beforeunload', () => {
5520
5521
  var _a, _b;
5521
5522
  this.track('page_unload');
5522
- // Send session end update with duration
5523
+ // Send session end update with duration AND context data
5523
5524
  if (this.sessionId && this.sessionStartTime) {
5524
5525
  const endedAt = new Date();
5525
5526
  const durationMs = Date.now() - this.sessionStartTime;
5526
- (_a = this.transport) === null || _a === void 0 ? void 0 : _a.startSession({
5527
- session_id: this.sessionId,
5528
- ended_at: endedAt.toISOString(),
5529
- duration_ms: durationMs,
5530
- });
5527
+ (_a = this.transport) === null || _a === void 0 ? void 0 : _a.startSession(Object.assign({ session_id: this.sessionId, user_id: this.userId || undefined, anonymous_id: this.anonymousId, ended_at: endedAt.toISOString(), duration_ms: durationMs }, this.getContextData()));
5531
5528
  }
5532
5529
  // Send any pending data
5533
5530
  (_b = this.transport) === null || _b === void 0 ? void 0 : _b.flush(true); // Use beacon for reliability