@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.
@@ -5001,15 +5001,16 @@ class RRWebRecorder {
5001
5001
  console.log('[RRWeb] Starting session recording:', this.sessionId);
5002
5002
  this.stopFn = record({
5003
5003
  emit: (event) => {
5004
+ this.events.push(event);
5004
5005
  // Check if this is a FullSnapshot (type 2)
5005
5006
  if (event.type === 2) {
5006
5007
  this.hasFullSnapshot = true;
5007
- console.log('[RRWeb] FullSnapshot captured! Recording is ready.');
5008
+ console.log('[RRWeb] FullSnapshot captured! Sending immediately...');
5009
+ // Send immediately to ensure FullSnapshot reaches backend first
5010
+ this.flush();
5008
5011
  }
5009
- this.events.push(event);
5010
- // Only flush if we have the FullSnapshot
5011
- // This ensures the first batch always contains the full DOM
5012
- if (this.hasFullSnapshot && this.events.length >= 50) {
5012
+ else if (this.hasFullSnapshot && this.events.length >= 50) {
5013
+ // After FullSnapshot, batch other events
5013
5014
  this.flush();
5014
5015
  }
5015
5016
  },
@@ -5513,15 +5514,11 @@ class DevSkinSDK {
5513
5514
  window.addEventListener('beforeunload', () => {
5514
5515
  var _a, _b;
5515
5516
  this.track('page_unload');
5516
- // Send session end update with duration
5517
+ // Send session end update with duration AND context data
5517
5518
  if (this.sessionId && this.sessionStartTime) {
5518
5519
  const endedAt = new Date();
5519
5520
  const durationMs = Date.now() - this.sessionStartTime;
5520
- (_a = this.transport) === null || _a === void 0 ? void 0 : _a.startSession({
5521
- session_id: this.sessionId,
5522
- ended_at: endedAt.toISOString(),
5523
- duration_ms: durationMs,
5524
- });
5521
+ (_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()));
5525
5522
  }
5526
5523
  // Send any pending data
5527
5524
  (_b = this.transport) === null || _b === void 0 ? void 0 : _b.flush(true); // Use beacon for reliability