@tracelog/lib 2.0.0 → 2.0.1-rc.69.3

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.

Potentially problematic release.


This version of @tracelog/lib might be problematic. Click here for more details.

@@ -237,7 +237,7 @@ const dt = () => {
237
237
  default:
238
238
  return Ne;
239
239
  }
240
- }, pt = 1e3, Tt = 50, _t = "1.8.1", vt = _t, It = () => {
240
+ }, pt = 1e3, Tt = 50, _t = "2.0.1", vt = _t, It = () => {
241
241
  if (typeof window > "u" || typeof document > "u")
242
242
  return !1;
243
243
  try {
@@ -2205,7 +2205,7 @@ class Ht extends p {
2205
2205
  return this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t), e ? !0 : Promise.resolve(!0);
2206
2206
  if (e) {
2207
2207
  const o = this.dataSenders.map((l) => l.sendEventsQueueSync(t)).some((l) => l);
2208
- return o ? (this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t)) : (this.clearSendInterval(), a("warn", "Sync flush failed for all integrations, events remain in queue for next flush", {
2208
+ return o ? (this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t)) : (this.clearSendInterval(), a("warn", "Sync flush complete failure, events kept in queue for retry", {
2209
2209
  data: { eventCount: s.length }
2210
2210
  })), o;
2211
2211
  } else {
@@ -2219,21 +2219,9 @@ class Ht extends p {
2219
2219
  );
2220
2220
  return Promise.allSettled(i).then((o) => {
2221
2221
  const l = o.some((c) => this.isSuccessfulResult(c));
2222
- if (l) {
2223
- this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t);
2224
- const c = o.filter((d) => !this.isSuccessfulResult(d)).length;
2225
- c > 0 && a(
2226
- "warn",
2227
- "Async flush completed with partial success, events removed from queue and persisted per failed integration",
2228
- {
2229
- data: { eventCount: r.length, succeededCount: o.length - c, failedCount: c }
2230
- }
2231
- );
2232
- } else
2233
- this.removeProcessedEvents(s), this.clearSendInterval(), a("error", "Async flush failed for all integrations, events persisted per-integration for recovery", {
2234
- data: { eventCount: r.length, integrations: this.dataSenders.length }
2235
- });
2236
- return l;
2222
+ return l ? (this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t)) : a("warn", "Async flush complete failure, events kept in queue for retry", {
2223
+ data: { eventCount: r.length }
2224
+ }), l;
2237
2225
  });
2238
2226
  }
2239
2227
  }
@@ -2245,19 +2233,25 @@ class Ht extends p {
2245
2233
  this.emitEventsQueue(e);
2246
2234
  return;
2247
2235
  }
2248
- const t = [...this.eventsQueue], r = t.map((c) => c.id), s = this.dataSenders.map(
2249
- async (c) => c.sendEventsQueue(e, {
2236
+ const t = [...this.eventsQueue], r = t.map((l) => l.id), s = this.dataSenders.map(
2237
+ async (l) => l.sendEventsQueue(e, {
2250
2238
  onSuccess: () => {
2251
2239
  },
2252
2240
  onFailure: () => {
2253
2241
  }
2254
2242
  })
2255
2243
  ), i = await Promise.allSettled(s);
2256
- this.removeProcessedEvents(r), i.some((c) => this.isSuccessfulResult(c)) && this.emitEventsQueue(e), this.eventsQueue.length === 0 && this.clearSendInterval();
2257
- const l = i.filter((c) => !this.isSuccessfulResult(c)).length;
2258
- l > 0 && a("warn", "Events send completed with some failures, removed from queue and persisted per-integration", {
2259
- data: { eventCount: t.length, failedCount: l }
2260
- });
2244
+ if (i.some((l) => this.isSuccessfulResult(l))) {
2245
+ this.removeProcessedEvents(r), this.emitEventsQueue(e);
2246
+ const l = i.filter((c) => !this.isSuccessfulResult(c)).length;
2247
+ l > 0 && a("warn", "Periodic send completed with some failures, removed from queue and persisted per-integration", {
2248
+ data: { eventCount: t.length, failedCount: l }
2249
+ });
2250
+ } else
2251
+ a("warn", "Periodic send complete failure, events kept in queue for retry", {
2252
+ data: { eventCount: t.length }
2253
+ });
2254
+ this.eventsQueue.length === 0 && this.clearSendInterval();
2261
2255
  }
2262
2256
  buildEventsPayload() {
2263
2257
  const e = /* @__PURE__ */ new Map(), t = [];
@@ -2811,7 +2805,7 @@ class Bt extends p {
2811
2805
  this.visibilityChangeHandler && (document.removeEventListener("visibilitychange", this.visibilityChangeHandler), this.visibilityChangeHandler = null);
2812
2806
  }
2813
2807
  resetSessionState() {
2814
- this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.isTracking = !1;
2808
+ this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.isTracking = !1;
2815
2809
  }
2816
2810
  /**
2817
2811
  * Stops session tracking and cleans up all resources.
@@ -2825,10 +2819,10 @@ class Bt extends p {
2825
2819
  * 3. Removes lifecycle listeners (visibilitychange)
2826
2820
  * 4. Closes BroadcastChannel
2827
2821
  * 5. Clears session from localStorage
2828
- * 6. Resets `sessionId` in global state
2822
+ * 6. Resets `sessionId` and `hasStartSession` in global state
2829
2823
  * 7. Sets `isTracking` to false
2830
2824
  *
2831
- * **Called by**: `App.destroy()` during application teardown
2825
+ * **Called by**: `App.destroy()` during application teardown or when session times out
2832
2826
  *
2833
2827
  * **Important**: After calling, session tracking is terminated and cannot be resumed.
2834
2828
  * A new session will be created on next `startTracking()` call.