@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.cjs CHANGED
@@ -19071,15 +19071,17 @@ class SessionReplayEngine {
19071
19071
  // WORKAROUND: Force FullSnapshot creation IMMEDIATELY to fix rrweb 2.0.0-alpha bug
19072
19072
  // where FullSnapshot is sometimes not created as the first event
19073
19073
  setTimeout(() => {
19074
- console.log("[Zaplier] Forcing immediate FullSnapshot to ensure correct event order...");
19075
- try {
19076
- takeFullSnapshot(true); // Force a new FullSnapshot immediately
19077
- console.log("[Zaplier] FullSnapshot manually triggered");
19078
- }
19079
- catch (error) {
19080
- console.error("[Zaplier] Failed to force FullSnapshot:", error);
19074
+ if (!this.hasFullSnapshot) {
19075
+ console.log("[Zaplier] Forcing immediate FullSnapshot to ensure correct event order...");
19076
+ try {
19077
+ takeFullSnapshot(true); // Force a new FullSnapshot immediately
19078
+ console.log("[Zaplier] FullSnapshot manually triggered");
19079
+ }
19080
+ catch (error) {
19081
+ console.error("[Zaplier] Failed to force FullSnapshot:", error);
19082
+ }
19081
19083
  }
19082
- }, 100); // Very short delay to ensure it comes first
19084
+ }, 50); // Very short delay but let natural events come first
19083
19085
  // Set timeout to check if FullSnapshot was captured
19084
19086
  this.snapshotTimeout = window.setTimeout(() => {
19085
19087
  if (!this.hasFullSnapshot) {
@@ -19231,12 +19233,21 @@ class SessionReplayEngine {
19231
19233
  }
19232
19234
  const batch = [...this.events];
19233
19235
  this.events = [];
19236
+ // IMPORTANT: Ensure FullSnapshot comes first in the batch
19237
+ const fullSnapshotIndex = batch.findIndex((e) => e.type === EventType.FullSnapshot);
19238
+ if (fullSnapshotIndex > 0) {
19239
+ console.log("[Zaplier] Reordering events - moving FullSnapshot to first position");
19240
+ const fullSnapshot = batch.splice(fullSnapshotIndex, 1)[0];
19241
+ if (fullSnapshot) {
19242
+ batch.unshift(fullSnapshot);
19243
+ }
19244
+ }
19234
19245
  // Verify batch has FullSnapshot
19235
19246
  const hasSnapshot = batch.some((e) => e.type === EventType.FullSnapshot);
19236
19247
  if (!hasSnapshot && this.hasFullSnapshot) {
19237
19248
  console.warn("[Zaplier] Batch missing FullSnapshot, but one was captured earlier");
19238
19249
  }
19239
- console.log(`[Zaplier] Sending batch with ${batch.length} events for session ${this.sessionId}`, { hasSnapshot, firstEventType: batch[0]?.type });
19250
+ 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) });
19240
19251
  const payload = {
19241
19252
  sessionId: this.sessionId,
19242
19253
  events: batch,
@@ -19338,7 +19349,7 @@ const DEFAULT_CONFIG = {
19338
19349
  */
19339
19350
  class ZaplierSDK {
19340
19351
  constructor(userConfig) {
19341
- this.version = "1.3.5";
19352
+ this.version = "1.3.7";
19342
19353
  this.isInitialized = false;
19343
19354
  this.eventQueue = [];
19344
19355
  /**