@tracelog/lib 2.3.1-rc.84.4 → 2.3.1-rc.84.5

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.
@@ -149,9 +149,9 @@ const Xe = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
149
149
  const { error: r, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = r ? St(e, r) : `[TraceLog] ${e}`, u = s === "error" ? "error" : s === "warn" ? "warn" : "log";
150
150
  if (!Tt(l, i))
151
151
  return;
152
- const g = vt(l, o), p = n !== void 0 ? ce(n) : void 0;
153
- _t(u, c, g, p);
154
- }, Tt = (s, e) => s === "critical" ? !0 : s === "qa" || e ? pt() : !1, vt = (s, e) => e !== void 0 && e !== "" ? e : s === "critical" ? Et : "", _t = (s, e, t, r) => {
152
+ const g = _t(l, o), p = n !== void 0 ? ce(n) : void 0;
153
+ vt(u, c, g, p);
154
+ }, Tt = (s, e) => s === "critical" ? !0 : s === "qa" || e ? pt() : !1, _t = (s, e) => e !== void 0 && e !== "" ? e : s === "critical" ? Et : "", vt = (s, e, t, r) => {
155
155
  const n = t !== void 0 && t !== "", i = n ? `%c${e}` : e;
156
156
  r !== void 0 ? n ? console[s](i, t, r) : console[s](i, r) : n ? console[s](i, t) : console[s](i);
157
157
  }, ce = (s) => {
@@ -518,7 +518,7 @@ const Bt = () => {
518
518
  throw new f(m.INVALID_CLICK_THROTTLE, "config");
519
519
  if (s.maxSameEventPerMinute !== void 0 && (typeof s.maxSameEventPerMinute != "number" || s.maxSameEventPerMinute <= 0))
520
520
  throw new f(m.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
521
- if (s.sendIntervalMs !== void 0 && (typeof s.sendIntervalMs != "number" || s.sendIntervalMs < 1e3 || s.sendIntervalMs > 6e4))
521
+ if (s.sendIntervalMs !== void 0 && (!Number.isFinite(s.sendIntervalMs) || s.sendIntervalMs < 1e3 || s.sendIntervalMs > 6e4))
522
522
  throw new f(m.INVALID_SEND_INTERVAL, "config");
523
523
  if (s.viewport !== void 0 && jt(s.viewport), s.webVitalsMode !== void 0) {
524
524
  if (typeof s.webVitalsMode != "string")
@@ -882,7 +882,7 @@ function et(s, e, t) {
882
882
  }
883
883
  }
884
884
  const ie = {};
885
- class _ {
885
+ class v {
886
886
  /**
887
887
  * Retrieves a value from global state.
888
888
  *
@@ -940,7 +940,7 @@ class _ {
940
940
  return { ...ie };
941
941
  }
942
942
  }
943
- class $e extends _ {
943
+ class $e extends v {
944
944
  storeManager;
945
945
  integrationId;
946
946
  apiUrl;
@@ -1626,7 +1626,7 @@ class $e extends _ {
1626
1626
  }), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: r });
1627
1627
  }
1628
1628
  }
1629
- class tr extends _ {
1629
+ class tr extends v {
1630
1630
  bootTime;
1631
1631
  bootTimestamp;
1632
1632
  hasPerformanceNow;
@@ -1776,7 +1776,7 @@ class tr extends _ {
1776
1776
  }
1777
1777
  }
1778
1778
  const rr = new Set(Object.values(d));
1779
- class sr extends _ {
1779
+ class sr extends v {
1780
1780
  dataSenders;
1781
1781
  emitter;
1782
1782
  transformers;
@@ -1785,7 +1785,7 @@ class sr extends _ {
1785
1785
  perEventRateLimits = /* @__PURE__ */ new Map();
1786
1786
  eventsQueue = [];
1787
1787
  pendingEventsBuffer = [];
1788
- sendIntervalId = null;
1788
+ sendTimeoutId = null;
1789
1789
  sendInProgress = !1;
1790
1790
  consecutiveSendFailures = 0;
1791
1791
  rateLimitCounter = 0;
@@ -2103,7 +2103,7 @@ class sr extends _ {
2103
2103
  * @see src/managers/README.md (lines 5-75) for cleanup details
2104
2104
  */
2105
2105
  stop() {
2106
- this.clearSendInterval(), this.sendInProgress = !1, this.consecutiveSendFailures = 0;
2106
+ this.clearSendTimeout(), this.sendInProgress = !1, this.consecutiveSendFailures = 0;
2107
2107
  const e = this.get("sessionId");
2108
2108
  e && this.saveSessionCounts(e), this.eventsQueue = [], this.pendingEventsBuffer = [], this.recentEventFingerprints.clear(), this.rateLimitCounter = 0, this.rateLimitWindowStart = 0, this.perEventRateLimits.clear(), this.sessionEventCounts = {
2109
2109
  total: 0,
@@ -2316,8 +2316,8 @@ class sr extends _ {
2316
2316
  this.track(r);
2317
2317
  });
2318
2318
  }
2319
- clearSendInterval() {
2320
- this.sendIntervalId !== null && (clearTimeout(this.sendIntervalId), this.sendIntervalId = null);
2319
+ clearSendTimeout() {
2320
+ this.sendTimeoutId !== null && (clearTimeout(this.sendTimeoutId), this.sendTimeoutId = null);
2321
2321
  }
2322
2322
  isSuccessfulResult(e) {
2323
2323
  return e.status === "fulfilled" && e.value === !0;
@@ -2327,10 +2327,10 @@ class sr extends _ {
2327
2327
  return e ? !0 : Promise.resolve(!0);
2328
2328
  const t = this.buildEventsPayload(), r = [...this.eventsQueue], n = r.map((i) => i.id);
2329
2329
  if (this.dataSenders.length === 0)
2330
- return this.removeProcessedEvents(n), this.clearSendInterval(), this.emitEventsQueue(t), e ? !0 : Promise.resolve(!0);
2330
+ return this.removeProcessedEvents(n), this.clearSendTimeout(), this.emitEventsQueue(t), e ? !0 : Promise.resolve(!0);
2331
2331
  if (e) {
2332
2332
  const o = this.dataSenders.map((l) => l.sendEventsQueueSync(t)).some((l) => l);
2333
- return o ? (this.removeProcessedEvents(n), this.clearSendInterval(), this.emitEventsQueue(t)) : (this.clearSendInterval(), a("debug", "Sync flush complete failure, events kept in queue for retry", {
2333
+ return o ? (this.removeProcessedEvents(n), this.clearSendTimeout(), this.emitEventsQueue(t)) : (this.clearSendTimeout(), a("debug", "Sync flush complete failure, events kept in queue for retry", {
2334
2334
  data: { eventCount: n.length }
2335
2335
  })), o;
2336
2336
  } else {
@@ -2344,7 +2344,7 @@ class sr extends _ {
2344
2344
  );
2345
2345
  return Promise.allSettled(i).then((o) => {
2346
2346
  const l = o.some((c) => this.isSuccessfulResult(c));
2347
- return l ? (this.removeProcessedEvents(n), this.clearSendInterval(), this.emitEventsQueue(t)) : a("debug", "Async flush complete failure, events kept in queue for retry", {
2347
+ return l ? (this.removeProcessedEvents(n), this.clearSendTimeout(), this.emitEventsQueue(t)) : a("debug", "Async flush complete failure, events kept in queue for retry", {
2348
2348
  data: { eventCount: r.length }
2349
2349
  }), l;
2350
2350
  });
@@ -2377,7 +2377,7 @@ class sr extends _ {
2377
2377
  this.consecutiveSendFailures++, a("debug", "Periodic send complete failure, events kept in queue for retry", {
2378
2378
  data: { eventCount: t.length }
2379
2379
  });
2380
- this.eventsQueue.length === 0 ? this.clearSendInterval() : this.scheduleSendTimeout();
2380
+ this.eventsQueue.length === 0 ? this.clearSendTimeout() : this.scheduleSendTimeout();
2381
2381
  } finally {
2382
2382
  this.sendInProgress = !1;
2383
2383
  }
@@ -2478,10 +2478,10 @@ class sr extends _ {
2478
2478
  this.consecutiveSendFailures >= 5 && (this.consecutiveSendFailures = 0), this.scheduleSendTimeout(), this.eventsQueue.length >= 50 && this.sendEventsQueue();
2479
2479
  }
2480
2480
  scheduleSendTimeout() {
2481
- if (this.sendIntervalId !== null || this.consecutiveSendFailures >= 5) return;
2481
+ if (this.sendTimeoutId !== null || this.consecutiveSendFailures >= 5) return;
2482
2482
  const e = this.calculateSendDelay();
2483
- this.sendIntervalId = window.setTimeout(() => {
2484
- this.sendIntervalId = null, this.eventsQueue.length > 0 && this.sendEventsQueue();
2483
+ this.sendTimeoutId = window.setTimeout(() => {
2484
+ this.sendTimeoutId = null, this.eventsQueue.length > 0 && this.sendEventsQueue();
2485
2485
  }, e);
2486
2486
  }
2487
2487
  calculateSendDelay() {
@@ -2753,7 +2753,7 @@ class nr {
2753
2753
  }
2754
2754
  }
2755
2755
  const ir = /^\d{13}-[a-z0-9]{9}$/;
2756
- class or extends _ {
2756
+ class or extends v {
2757
2757
  storageManager;
2758
2758
  eventManager;
2759
2759
  projectId;
@@ -3073,7 +3073,7 @@ class or extends _ {
3073
3073
  this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
3074
3074
  }
3075
3075
  }
3076
- class ar extends _ {
3076
+ class ar extends v {
3077
3077
  eventManager;
3078
3078
  storageManager;
3079
3079
  sessionManager = null;
@@ -3161,7 +3161,7 @@ class ar extends _ {
3161
3161
  this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
3162
3162
  }
3163
3163
  }
3164
- class lr extends _ {
3164
+ class lr extends v {
3165
3165
  eventManager;
3166
3166
  onTrack;
3167
3167
  originalPushState;
@@ -3237,7 +3237,7 @@ class lr extends _ {
3237
3237
  };
3238
3238
  }
3239
3239
  }
3240
- class cr extends _ {
3240
+ class cr extends v {
3241
3241
  eventManager;
3242
3242
  lastClickTimes = /* @__PURE__ */ new Map();
3243
3243
  clickHandler;
@@ -3494,7 +3494,7 @@ class cr extends _ {
3494
3494
  };
3495
3495
  }
3496
3496
  }
3497
- class ur extends _ {
3497
+ class ur extends v {
3498
3498
  eventManager;
3499
3499
  containers = [];
3500
3500
  limitWarningLogged = !1;
@@ -3722,7 +3722,7 @@ class ur extends _ {
3722
3722
  e.isPrimary = t;
3723
3723
  }
3724
3724
  }
3725
- class dr extends _ {
3725
+ class dr extends v {
3726
3726
  eventManager;
3727
3727
  trackedElements = /* @__PURE__ */ new Map();
3728
3728
  observer = null;
@@ -4166,7 +4166,7 @@ class hr {
4166
4166
  this.fallbackSessionStorage.delete(e);
4167
4167
  }
4168
4168
  }
4169
- class fr extends _ {
4169
+ class fr extends v {
4170
4170
  eventManager;
4171
4171
  reportedByNav = /* @__PURE__ */ new Map();
4172
4172
  navigationHistory = [];
@@ -4399,7 +4399,7 @@ class fr extends _ {
4399
4399
  return !(typeof r == "number" && t <= r);
4400
4400
  }
4401
4401
  }
4402
- class mr extends _ {
4402
+ class mr extends v {
4403
4403
  eventManager;
4404
4404
  recentErrors = /* @__PURE__ */ new Map();
4405
4405
  errorBurstCounter = 0;
@@ -4510,7 +4510,7 @@ class mr extends _ {
4510
4510
  }
4511
4511
  }
4512
4512
  }
4513
- class gr extends _ {
4513
+ class gr extends v {
4514
4514
  isInitialized = !1;
4515
4515
  suppressNextScrollTimer = null;
4516
4516
  pageUnloadHandler = null;
@@ -4758,8 +4758,8 @@ class gr extends _ {
4758
4758
  }
4759
4759
  }
4760
4760
  const O = [], M = [];
4761
- let N = null, h = null, C = !1, v = !1, R = null;
4762
- const Er = async (s) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (v = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : h ? { sessionId: h.getSessionId() ?? "" } : (C && R || (C = !0, R = (async () => {
4761
+ let N = null, h = null, C = !1, _ = !1, R = null;
4762
+ const Er = async (s) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (_ = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : h ? { sessionId: h.getSessionId() ?? "" } : (C && R || (C = !0, R = (async () => {
4763
4763
  try {
4764
4764
  const e = Kt(s ?? {}), t = new gr();
4765
4765
  try {
@@ -4791,7 +4791,7 @@ const Er = async (s) => typeof window > "u" || typeof document > "u" ? { session
4791
4791
  if (!(typeof window > "u" || typeof document > "u")) {
4792
4792
  if (!h)
4793
4793
  throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
4794
- if (v)
4794
+ if (_)
4795
4795
  throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
4796
4796
  h.sendCustomEvent(s, e);
4797
4797
  }
@@ -4813,7 +4813,7 @@ const Er = async (s) => typeof window > "u" || typeof document > "u" ? { session
4813
4813
  h.off(s, e);
4814
4814
  }
4815
4815
  };
4816
- function vr(s, e) {
4816
+ function _r(s, e) {
4817
4817
  if (!(typeof window > "u" || typeof document > "u")) {
4818
4818
  if (typeof e != "function")
4819
4819
  throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
@@ -4822,19 +4822,19 @@ function vr(s, e) {
4822
4822
  t !== -1 && M.splice(t, 1), M.push({ hook: s, fn: e });
4823
4823
  return;
4824
4824
  }
4825
- if (v)
4825
+ if (_)
4826
4826
  throw new Error("[TraceLog] Cannot set transformers while TraceLog is being destroyed");
4827
4827
  s === "beforeSend" ? h.setTransformer("beforeSend", e) : h.setTransformer("beforeBatch", e);
4828
4828
  }
4829
4829
  }
4830
- const _r = (s) => {
4830
+ const vr = (s) => {
4831
4831
  if (!(typeof window > "u" || typeof document > "u")) {
4832
4832
  if (!h) {
4833
4833
  const e = M.findIndex((t) => t.hook === s);
4834
4834
  e !== -1 && M.splice(e, 1);
4835
4835
  return;
4836
4836
  }
4837
- if (v)
4837
+ if (_)
4838
4838
  throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
4839
4839
  h.removeTransformer(s);
4840
4840
  }
@@ -4846,7 +4846,7 @@ const _r = (s) => {
4846
4846
  N = s;
4847
4847
  return;
4848
4848
  }
4849
- if (v)
4849
+ if (_)
4850
4850
  throw new Error("[TraceLog] Cannot set custom headers while TraceLog is being destroyed");
4851
4851
  h.setCustomHeaders(s);
4852
4852
  }
@@ -4856,23 +4856,23 @@ const _r = (s) => {
4856
4856
  N = null;
4857
4857
  return;
4858
4858
  }
4859
- if (v)
4859
+ if (_)
4860
4860
  throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
4861
4861
  h.removeCustomHeaders();
4862
4862
  }
4863
4863
  }, yr = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, br = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getSessionId(), Lr = () => {
4864
4864
  if (!(typeof window > "u" || typeof document > "u")) {
4865
- if (v)
4865
+ if (_)
4866
4866
  throw new Error("[TraceLog] Destroy operation already in progress");
4867
4867
  if (!h) {
4868
- v = !1;
4868
+ _ = !1;
4869
4869
  return;
4870
4870
  }
4871
- v = !0;
4871
+ _ = !0;
4872
4872
  try {
4873
- h.destroy(), h = null, C = !1, R = null, O.length = 0, M.length = 0, N = null, v = !1;
4873
+ h.destroy(), h = null, C = !1, R = null, O.length = 0, M.length = 0, N = null, _ = !1;
4874
4874
  } catch (s) {
4875
- h = null, C = !1, R = null, O.length = 0, M.length = 0, N = null, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error: s });
4875
+ h = null, C = !1, R = null, O.length = 0, M.length = 0, N = null, _ = !1, a("warn", "Error during destroy, forced cleanup completed", { error: s });
4876
4876
  }
4877
4877
  }
4878
4878
  }, Ar = (s) => {
@@ -4881,7 +4881,7 @@ const _r = (s) => {
4881
4881
  if (!(typeof window > "u" || typeof document > "u")) {
4882
4882
  if (!h)
4883
4883
  throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
4884
- if (v)
4884
+ if (_)
4885
4885
  throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
4886
4886
  h.updateGlobalMetadata(s);
4887
4887
  }
@@ -4889,7 +4889,7 @@ const _r = (s) => {
4889
4889
  if (!(typeof window > "u" || typeof document > "u")) {
4890
4890
  if (!h)
4891
4891
  throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
4892
- if (v)
4892
+ if (_)
4893
4893
  throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
4894
4894
  h.mergeGlobalMetadata(s);
4895
4895
  }
@@ -4898,8 +4898,8 @@ const _r = (s) => {
4898
4898
  event: Sr,
4899
4899
  on: pr,
4900
4900
  off: Tr,
4901
- setTransformer: vr,
4902
- removeTransformer: _r,
4901
+ setTransformer: _r,
4902
+ removeTransformer: vr,
4903
4903
  setCustomHeaders: Ir,
4904
4904
  removeCustomHeaders: wr,
4905
4905
  isInitialized: yr,
@@ -4913,14 +4913,14 @@ var ge, tt = -1, V = function(s) {
4913
4913
  addEventListener("pageshow", (function(e) {
4914
4914
  e.persisted && (tt = e.timeStamp, s(e));
4915
4915
  }), !0);
4916
- }, _e = function() {
4916
+ }, ve = function() {
4917
4917
  var s = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
4918
4918
  if (s && s.responseStart > 0 && s.responseStart < performance.now()) return s;
4919
4919
  }, Z = function() {
4920
- var s = _e();
4920
+ var s = ve();
4921
4921
  return s && s.activationStart || 0;
4922
4922
  }, b = function(s, e) {
4923
- var t = _e(), r = "navigate";
4923
+ var t = ve(), r = "navigate";
4924
4924
  return tt >= 0 ? r = "back-forward-cache" : t && (document.prerendering || Z() > 0 ? r = "prerender" : document.wasDiscarded ? r = "restore" : t.type && (r = t.type.replace(/_/g, "-"))), { name: s, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: r };
4925
4925
  }, B = function(s, e, t) {
4926
4926
  try {
@@ -5079,7 +5079,7 @@ var ge, tt = -1, V = function(s) {
5079
5079
  }));
5080
5080
  }
5081
5081
  }));
5082
- }, ve = [800, 1800], xr = function s(e) {
5082
+ }, _e = [800, 1800], xr = function s(e) {
5083
5083
  document.prerendering ? te((function() {
5084
5084
  return s(e);
5085
5085
  })) : document.readyState !== "complete" ? addEventListener("load", (function() {
@@ -5087,11 +5087,11 @@ var ge, tt = -1, V = function(s) {
5087
5087
  }), !0) : setTimeout(e, 0);
5088
5088
  }, Fr = function(s, e) {
5089
5089
  e = e || {};
5090
- var t = b("TTFB"), r = L(s, t, ve, e.reportAllChanges);
5090
+ var t = b("TTFB"), r = L(s, t, _e, e.reportAllChanges);
5091
5091
  xr((function() {
5092
- var n = _e();
5092
+ var n = ve();
5093
5093
  n && (t.value = Math.max(n.responseStart - Z(), 0), t.entries = [n], r(!0), V((function() {
5094
- t = b("TTFB", 0), (r = L(s, t, ve, e.reportAllChanges))(!0);
5094
+ t = b("TTFB", 0), (r = L(s, t, _e, e.reportAllChanges))(!0);
5095
5095
  })));
5096
5096
  }));
5097
5097
  };
@@ -5101,7 +5101,7 @@ const $r = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5101
5101
  FCPThresholds: Ee,
5102
5102
  INPThresholds: pe,
5103
5103
  LCPThresholds: Te,
5104
- TTFBThresholds: ve,
5104
+ TTFBThresholds: _e,
5105
5105
  onCLS: Nr,
5106
5106
  onFCP: st,
5107
5107
  onINP: Ur,