@zaplier/sdk 1.3.6 → 1.3.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.
package/dist/index.esm.js CHANGED
@@ -19067,15 +19067,17 @@ class SessionReplayEngine {
19067
19067
  // WORKAROUND: Force FullSnapshot creation IMMEDIATELY to fix rrweb 2.0.0-alpha bug
19068
19068
  // where FullSnapshot is sometimes not created as the first event
19069
19069
  setTimeout(() => {
19070
- console.log("[Zaplier] Forcing immediate FullSnapshot to ensure correct event order...");
19071
- try {
19072
- takeFullSnapshot(true); // Force a new FullSnapshot immediately
19073
- console.log("[Zaplier] FullSnapshot manually triggered");
19074
- }
19075
- catch (error) {
19076
- console.error("[Zaplier] Failed to force FullSnapshot:", error);
19070
+ if (!this.hasFullSnapshot) {
19071
+ console.log("[Zaplier] Forcing immediate FullSnapshot to ensure correct event order...");
19072
+ try {
19073
+ takeFullSnapshot(true); // Force a new FullSnapshot immediately
19074
+ console.log("[Zaplier] FullSnapshot manually triggered");
19075
+ }
19076
+ catch (error) {
19077
+ console.error("[Zaplier] Failed to force FullSnapshot:", error);
19078
+ }
19077
19079
  }
19078
- }, 100); // Very short delay to ensure it comes first
19080
+ }, 50); // Very short delay but let natural events come first
19079
19081
  // Set timeout to check if FullSnapshot was captured
19080
19082
  this.snapshotTimeout = window.setTimeout(() => {
19081
19083
  if (!this.hasFullSnapshot) {
@@ -19227,12 +19229,21 @@ class SessionReplayEngine {
19227
19229
  }
19228
19230
  const batch = [...this.events];
19229
19231
  this.events = [];
19232
+ // IMPORTANT: Ensure FullSnapshot comes first in the batch
19233
+ const fullSnapshotIndex = batch.findIndex((e) => e.type === EventType.FullSnapshot);
19234
+ if (fullSnapshotIndex > 0) {
19235
+ console.log("[Zaplier] Reordering events - moving FullSnapshot to first position");
19236
+ const fullSnapshot = batch.splice(fullSnapshotIndex, 1)[0];
19237
+ if (fullSnapshot) {
19238
+ batch.unshift(fullSnapshot);
19239
+ }
19240
+ }
19230
19241
  // Verify batch has FullSnapshot
19231
19242
  const hasSnapshot = batch.some((e) => e.type === EventType.FullSnapshot);
19232
19243
  if (!hasSnapshot && this.hasFullSnapshot) {
19233
19244
  console.warn("[Zaplier] Batch missing FullSnapshot, but one was captured earlier");
19234
19245
  }
19235
- console.log(`[Zaplier] Sending batch with ${batch.length} events for session ${this.sessionId}`, { hasSnapshot, firstEventType: batch[0]?.type });
19246
+ console.log(`[Zaplier] Sending batch with ${batch.length} events for session ${this.sessionId}`, { hasSnapshot, firstEventType: batch[0]?.type, eventTypes: batch.slice(0, 5).map(e => e.type) });
19236
19247
  const payload = {
19237
19248
  sessionId: this.sessionId,
19238
19249
  events: batch,
@@ -19334,7 +19345,7 @@ const DEFAULT_CONFIG = {
19334
19345
  */
19335
19346
  class ZaplierSDK {
19336
19347
  constructor(userConfig) {
19337
- this.version = "1.3.5";
19348
+ this.version = "1.3.7";
19338
19349
  this.isInitialized = false;
19339
19350
  this.eventQueue = [];
19340
19351
  /**