@devskin/browser-sdk 1.0.32 → 1.0.33

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.
@@ -13587,11 +13587,12 @@
13587
13587
  // Send user identification immediately (don't queue)
13588
13588
  this.sendToBackend('/v1/analytics/identify', user);
13589
13589
  }
13590
- startSession(session) {
13591
- return __awaiter$1(this, void 0, void 0, function* () {
13590
+ startSession(session_1) {
13591
+ return __awaiter$1(this, arguments, void 0, function* (session, useBeacon = false) {
13592
13592
  // Send session start immediately to RUM endpoint
13593
13593
  // MUST await to ensure session is created before other requests
13594
- yield this.sendToBackend('/v1/rum/sessions', session);
13594
+ // Use beacon for page unload events (more reliable)
13595
+ yield this.sendToBackend('/v1/rum/sessions', session, useBeacon);
13595
13596
  });
13596
13597
  }
13597
13598
  sendError(error) {
@@ -14195,7 +14196,8 @@
14195
14196
  if (this.sessionId && this.sessionStartTime) {
14196
14197
  const endedAt = new Date();
14197
14198
  const durationMs = Date.now() - this.sessionStartTime;
14198
- (_a = this.transport) === null || _a === void 0 ? void 0 : _a.startSession(Object.assign({ sessionId: this.sessionId, userId: this.userId || undefined, anonymousId: this.anonymousId, endedAt: endedAt.toISOString(), durationMs: durationMs, platform: 'web' }, this.getContextData()));
14199
+ // Use beacon for reliable delivery during page unload
14200
+ (_a = this.transport) === null || _a === void 0 ? void 0 : _a.startSession(Object.assign({ sessionId: this.sessionId, userId: this.userId || undefined, anonymousId: this.anonymousId, endedAt: endedAt.toISOString(), durationMs: durationMs, platform: 'web' }, this.getContextData()), true); // true = use sendBeacon
14199
14201
  // Clear session storage since session is ending
14200
14202
  sessionStorage.removeItem('devskin_session_id');
14201
14203
  sessionStorage.removeItem('devskin_session_start');