@tracelog/lib 3.1.1-rc.120.7 → 3.2.0-rc.123.8

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.
@@ -1,6 +1,6 @@
1
- const pn = 9e5;
2
- const Sn = 120, En = 49152, vn = 100, Tn = 500, _n = 200;
3
- const yn = 1e3, In = 500, wn = 1e3;
1
+ const En = 9e5;
2
+ const vn = 120, Tn = 49152, _n = 100, yn = 500, In = 200;
3
+ const wn = 1e3, An = 500, bn = 1e3;
4
4
  const b = "data-tlog", vt = [
5
5
  "button",
6
6
  "a",
@@ -67,8 +67,8 @@ const y = {
67
67
  /<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
68
68
  /<embed\b[^>]*>/gi,
69
69
  /<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
70
- ], g = "tlog", z = `${g}:qa_mode`, Se = `${g}:uid`, nt = "tlog_mode", Ue = "qa", Fe = "qa_off", ce = (n) => n ? `${g}:${n}:queue` : `${g}:queue`, le = (n) => n ? `${g}:${n}:rate_limit` : `${g}:rate_limit`, It = (n, e) => `${g}:beacon:${n}:${e}`, wt = (n) => n ? `${g}:${n}:session` : `${g}:session`, At = (n) => n ? `${g}:${n}:broadcast` : `${g}:broadcast`, Ve = (n, e) => `${g}:${n}:session_counts:${e}`, He = 10080 * 60 * 1e3, xe = `${g}:session_counts_last_cleanup`, $e = 3600 * 1e3, ue = (n) => n ? `${g}:${n}:identity` : `${g}:identity`, P = `${g}:pending_identity`;
71
- var M = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(M || {}), w = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(w || {}), U = /* @__PURE__ */ ((n) => (n.EVENT = "event", n.QUEUE = "queue", n))(U || {});
70
+ ], g = "tlog", Y = `${g}:qa_mode`, Ee = `${g}:uid`, nt = "tlog_mode", Ue = "qa", Fe = "qa_off", le = (n) => n ? `${g}:${n}:queue` : `${g}:queue`, ue = (n) => n ? `${g}:${n}:rate_limit` : `${g}:rate_limit`, It = (n, e) => `${g}:beacon:${n}:${e}`, wt = (n) => n ? `${g}:${n}:session` : `${g}:session`, At = (n) => n ? `${g}:${n}:broadcast` : `${g}:broadcast`, Ve = (n, e) => `${g}:${n}:session_counts:${e}`, He = 10080 * 60 * 1e3, xe = `${g}:session_counts_last_cleanup`, $e = 3600 * 1e3, de = (n) => n ? `${g}:${n}:identity` : `${g}:identity`, P = `${g}:pending_identity`;
71
+ var M = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(M || {}), w = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(w || {}), V = /* @__PURE__ */ ((n) => (n.EVENT = "event", n.QUEUE = "queue", n))(V || {});
72
72
  class C extends Error {
73
73
  constructor(e, t, s) {
74
74
  super(e), this.statusCode = t, this.responseCode = s, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, C);
@@ -76,57 +76,57 @@ class C extends Error {
76
76
  statusCode;
77
77
  responseCode;
78
78
  }
79
- class J extends Error {
79
+ class Z extends Error {
80
80
  constructor(e) {
81
- super(e), this.name = "RateLimitError", Error.captureStackTrace && Error.captureStackTrace(this, J);
81
+ super(e), this.name = "RateLimitError", Error.captureStackTrace && Error.captureStackTrace(this, Z);
82
82
  }
83
83
  }
84
- class Z extends Error {
84
+ class ee extends Error {
85
85
  constructor(e) {
86
- super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this, Z);
86
+ super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this, ee);
87
87
  }
88
88
  }
89
- var d = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n))(d || {}), Ee = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(Ee || {}), V = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n))(V || {}), ee = /* @__PURE__ */ ((n) => (n.QA = "qa", n))(ee || {});
90
- class $ extends Error {
89
+ var d = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n))(d || {}), ve = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(ve || {}), x = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n))(x || {}), te = /* @__PURE__ */ ((n) => (n.QA = "qa", n))(te || {});
90
+ class X extends Error {
91
91
  constructor(e, t, s) {
92
92
  super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
93
93
  }
94
94
  errorCode;
95
95
  layer;
96
96
  }
97
- class m extends $ {
97
+ class m extends X {
98
98
  constructor(e, t = "config") {
99
99
  super(e, "APP_CONFIG_INVALID", t);
100
100
  }
101
101
  }
102
- class bt extends $ {
102
+ class bt extends X {
103
103
  constructor(e, t = "config") {
104
104
  super(e, "SESSION_TIMEOUT_INVALID", t);
105
105
  }
106
106
  }
107
- class Be extends $ {
107
+ class Be extends X {
108
108
  constructor(e, t = "config") {
109
109
  super(e, "SAMPLING_RATE_INVALID", t);
110
110
  }
111
111
  }
112
- class Xe extends $ {
112
+ class Xe extends X {
113
113
  constructor(e, t = "config") {
114
114
  super(e, "INTEGRATION_INVALID", t);
115
115
  }
116
116
  }
117
- class An extends $ {
117
+ class Ln extends X {
118
118
  constructor(e, t, s = "runtime") {
119
119
  super(e, "INITIALIZATION_TIMEOUT", s), this.timeoutMs = t;
120
120
  }
121
121
  timeoutMs;
122
122
  }
123
- const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], de = () => {
123
+ const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], he = () => {
124
124
  const n = new URLSearchParams(window.location.search), e = {};
125
125
  return Lt.forEach((s) => {
126
126
  const r = n.get(s);
127
127
  r && (e[s] = r);
128
128
  }), Object.keys(e).length ? e : void 0;
129
- }, Mt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Ct = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Rt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Nt = (n, e) => {
129
+ }, Mt = "https://ingest.tracelog.io", Ct = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Rt = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Nt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Ot = (n, e) => {
130
130
  if (e) {
131
131
  if (e instanceof Error) {
132
132
  const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
@@ -145,24 +145,24 @@ const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], de = () => {
145
145
  return `[TraceLog] ${n}: ${String(e)}`;
146
146
  }
147
147
  return `[TraceLog] ${n}`;
148
- }, Ot = () => {
148
+ }, Pt = () => {
149
149
  if (typeof window > "u" || typeof sessionStorage > "u")
150
150
  return !1;
151
151
  try {
152
- return sessionStorage.getItem(z) === "true";
152
+ return sessionStorage.getItem(Y) === "true";
153
153
  } catch {
154
154
  return !1;
155
155
  }
156
156
  }, a = (n, e, t) => {
157
- const { error: s, data: r, showToClient: i = !1, style: o, visibility: c } = t ?? {}, l = s ? Nt(e, s) : `[TraceLog] ${e}`, u = n === "error" ? "error" : n === "warn" ? "warn" : "log";
158
- if (!Pt(c, i))
157
+ const { error: s, data: r, showToClient: i = !1, style: o, visibility: c } = t ?? {}, l = s ? Ot(e, s) : `[TraceLog] ${e}`, u = n === "error" ? "error" : n === "warn" ? "warn" : "log";
158
+ if (!kt(c, i))
159
159
  return;
160
- const p = kt(c, o), S = r !== void 0 ? ve(r) : void 0;
161
- Dt(u, l, p, S);
162
- }, Pt = (n, e) => n === "critical" ? !0 : n === "qa" || e ? Ot() : !1, kt = (n, e) => e !== void 0 && e !== "" ? e : n === "critical" ? Rt : "", Dt = (n, e, t, s) => {
160
+ const p = Dt(c, o), S = r !== void 0 ? Te(r) : void 0;
161
+ Ut(u, l, p, S);
162
+ }, kt = (n, e) => n === "critical" ? !0 : n === "qa" || e ? Pt() : !1, Dt = (n, e) => e !== void 0 && e !== "" ? e : n === "critical" ? Nt : "", Ut = (n, e, t, s) => {
163
163
  const r = t !== void 0 && t !== "", i = r ? `%c${e}` : e;
164
164
  s !== void 0 ? r ? console[n](i, t, s) : console[n](i, s) : r ? console[n](i, t) : console[n](i);
165
- }, ve = (n) => {
165
+ }, Te = (n) => {
166
166
  const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
167
167
  for (const [s, r] of Object.entries(n)) {
168
168
  const i = s.toLowerCase();
@@ -170,16 +170,16 @@ const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], de = () => {
170
170
  e[s] = "[REDACTED]";
171
171
  continue;
172
172
  }
173
- r !== null && typeof r == "object" && !Array.isArray(r) ? e[s] = ve(r) : Array.isArray(r) ? e[s] = r.map(
174
- (o) => o !== null && typeof o == "object" && !Array.isArray(o) ? ve(o) : o
173
+ r !== null && typeof r == "object" && !Array.isArray(r) ? e[s] = Te(r) : Array.isArray(r) ? e[s] = r.map(
174
+ (o) => o !== null && typeof o == "object" && !Array.isArray(o) ? Te(o) : o
175
175
  ) : e[s] = r;
176
176
  }
177
177
  return e;
178
178
  };
179
- let Te, rt;
180
- const Ut = () => {
181
- typeof window < "u" && !Te && (Te = window.matchMedia("(pointer: coarse)"), rt = window.matchMedia("(hover: none)"));
182
- }, te = "Unknown", Ft = (n) => {
179
+ let _e, rt;
180
+ const Ft = () => {
181
+ typeof window < "u" && !_e && (_e = window.matchMedia("(pointer: coarse)"), rt = window.matchMedia("(hover: none)"));
182
+ }, se = "Unknown", Vt = (n) => {
183
183
  const e = n.userAgentData?.platform;
184
184
  if (e != null && e !== "") {
185
185
  if (/windows/i.test(e)) return "Windows";
@@ -190,8 +190,8 @@ const Ut = () => {
190
190
  if (/ios/i.test(e)) return "iOS";
191
191
  }
192
192
  const t = navigator.userAgent;
193
- return /Windows/i.test(t) ? "Windows" : /iPhone|iPad|iPod/i.test(t) ? "iOS" : /Mac OS X|Macintosh/i.test(t) ? "macOS" : /Android/i.test(t) ? "Android" : /CrOS/i.test(t) ? "ChromeOS" : /Linux/i.test(t) ? "Linux" : te;
194
- }, Vt = (n) => {
193
+ return /Windows/i.test(t) ? "Windows" : /iPhone|iPad|iPod/i.test(t) ? "iOS" : /Mac OS X|Macintosh/i.test(t) ? "macOS" : /Android/i.test(t) ? "Android" : /CrOS/i.test(t) ? "ChromeOS" : /Linux/i.test(t) ? "Linux" : se;
194
+ }, Ht = (n) => {
195
195
  const e = n.userAgentData?.brands;
196
196
  if (e != null && e.length > 0) {
197
197
  const r = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
@@ -201,36 +201,36 @@ const Ut = () => {
201
201
  }
202
202
  }
203
203
  const t = navigator.userAgent;
204
- return /Edg\//i.test(t) ? "Edge" : /OPR\//i.test(t) ? "Opera" : /Chrome/i.test(t) ? "Chrome" : /Firefox/i.test(t) ? "Firefox" : /Safari/i.test(t) && !/Chrome/i.test(t) ? "Safari" : te;
205
- }, Ht = () => {
204
+ return /Edg\//i.test(t) ? "Edge" : /OPR\//i.test(t) ? "Opera" : /Chrome/i.test(t) ? "Chrome" : /Firefox/i.test(t) ? "Firefox" : /Safari/i.test(t) && !/Chrome/i.test(t) ? "Safari" : se;
205
+ }, xt = () => {
206
206
  try {
207
207
  const n = navigator;
208
208
  if (n.userAgentData != null && typeof n.userAgentData.mobile == "boolean") {
209
209
  const l = n.userAgentData.platform;
210
210
  return l != null && l !== "" && /ipad|tablet/i.test(l) ? w.Tablet : n.userAgentData.mobile ? w.Mobile : w.Desktop;
211
211
  }
212
- Ut();
213
- const e = window.innerWidth, t = Te?.matches ?? !1, s = rt?.matches ?? !1, r = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), c = /tablet|ipad|android(?!.*mobile)/.test(i);
212
+ Ft();
213
+ const e = window.innerWidth, t = _e?.matches ?? !1, s = rt?.matches ?? !1, r = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), c = /tablet|ipad|android(?!.*mobile)/.test(i);
214
214
  return e <= 767 || o && r ? w.Mobile : e >= 768 && e <= 1024 || c || t && s && r ? w.Tablet : w.Desktop;
215
215
  } catch (n) {
216
216
  return a("debug", "Device detection failed, defaulting to desktop", { error: n }), w.Desktop;
217
217
  }
218
- }, xt = () => {
218
+ }, $t = () => {
219
219
  try {
220
220
  const n = navigator;
221
221
  return {
222
- type: Ht(),
223
- os: Ft(n),
224
- browser: Vt(n)
222
+ type: xt(),
223
+ os: Vt(n),
224
+ browser: Ht(n)
225
225
  };
226
226
  } catch (n) {
227
227
  return a("debug", "Device info detection failed, using defaults", { error: n }), {
228
228
  type: w.Desktop,
229
- os: te,
230
- browser: te
229
+ os: se,
230
+ browser: se
231
231
  };
232
232
  }
233
- }, je = 500, Ge = 2e3, We = 5e3, Q = 50, $t = Q * 2, it = 1, Bt = 1e3, Xt = 10, Ke = 5e3, jt = 3, Gt = 200, Wt = 6e4, Kt = 64, zt = 10 * 6e4, Qt = 200, bn = {
233
+ }, je = 500, Ge = 2e3, We = 5e3, q = 50, Bt = q * 2, it = 1, Xt = 1e3, jt = 10, Ke = 5e3, Gt = 3, Wt = 200, Kt = 6e4, zt = 64, Qt = 10 * 6e4, Yt = 200, Mn = {
234
234
  LCP: 2500,
235
235
  FCP: 1800,
236
236
  CLS: 0.1,
@@ -242,24 +242,24 @@ const Ut = () => {
242
242
  CLS: 0.1,
243
243
  INP: 200,
244
244
  TTFB: 800
245
- }, Yt = {
245
+ }, qt = {
246
246
  LCP: 4e3,
247
247
  FCP: 3e3,
248
248
  CLS: 0.25,
249
249
  INP: 500,
250
250
  TTFB: 1800
251
- }, _e = "needs-improvement", Qe = (n = _e) => {
251
+ }, ye = "needs-improvement", Qe = (n = ye) => {
252
252
  switch (n) {
253
253
  case "all":
254
254
  return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0 };
255
255
  case "needs-improvement":
256
256
  return ze;
257
257
  case "poor":
258
- return Yt;
258
+ return qt;
259
259
  default:
260
260
  return ze;
261
261
  }
262
- }, qt = 50, Jt = "3.1.1", Zt = Jt, es = () => typeof window < "u" && typeof sessionStorage < "u", ts = () => {
262
+ }, Jt = 50, Zt = "3.2.0", es = Zt, ts = () => typeof window < "u" && typeof sessionStorage < "u", ss = () => {
263
263
  try {
264
264
  const n = new URLSearchParams(window.location.search);
265
265
  n.delete(nt);
@@ -267,23 +267,75 @@ const Ut = () => {
267
267
  window.history.replaceState({}, "", t);
268
268
  } catch {
269
269
  }
270
- }, ss = () => {
271
- if (!es())
270
+ }, ns = () => {
271
+ if (!ts())
272
272
  return !1;
273
273
  try {
274
- const e = new URLSearchParams(window.location.search).get(nt), t = sessionStorage.getItem(z);
274
+ const e = new URLSearchParams(window.location.search).get(nt), t = sessionStorage.getItem(Y);
275
275
  let s = null;
276
- return e === Ue ? (s = !0, sessionStorage.setItem(z, "true"), a("info", "QA Mode ACTIVE", {
277
- visibility: "qa",
278
- style: Mt
279
- })) : e === Fe && (s = !1, sessionStorage.setItem(z, "false"), a("info", "QA Mode DISABLED", {
276
+ return e === Ue ? (s = !0, sessionStorage.setItem(Y, "true"), a("info", "QA Mode ACTIVE", {
280
277
  visibility: "qa",
281
278
  style: Ct
282
- })), (e === Ue || e === Fe) && ts(), s ?? t === "true";
279
+ })) : e === Fe && (s = !1, sessionStorage.setItem(Y, "false"), a("info", "QA Mode DISABLED", {
280
+ visibility: "qa",
281
+ style: Rt
282
+ })), (e === Ue || e === Fe) && ss(), s ?? t === "true";
283
283
  } catch {
284
284
  return !1;
285
285
  }
286
- }, ot = () => typeof document < "u" && document.prerendering === !0, ns = [
286
+ }, ot = () => typeof document < "u" && document.prerendering === !0, rs = (n) => {
287
+ try {
288
+ return new URL(n).protocol === "https:";
289
+ } catch {
290
+ return !1;
291
+ }
292
+ }, is = (n) => `${Mt}/p/${encodeURIComponent(n)}/collect`, os = (n) => {
293
+ try {
294
+ const t = new URL(window.location.href).hostname;
295
+ if (!t || typeof t != "string")
296
+ throw new Error("Invalid hostname");
297
+ if (t === "localhost" || t === "127.0.0.1" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t))
298
+ throw new Error(
299
+ "SaaS integration requires a domain hostname; localhost and IP addresses are not supported. For local development, omit `integrations.tracelog` to run in standalone mode (events emitted locally, no network requests), or test against a staging domain that resolves to your dev machine via /etc/hosts."
300
+ );
301
+ const s = t.split(".");
302
+ if (!s || !Array.isArray(s) || s.length === 0 || s.length === 1 && s[0] === "")
303
+ throw new Error("Invalid hostname structure");
304
+ if (s.length === 1)
305
+ throw new Error("Single-part domain not supported for SaaS integration");
306
+ const r = s.length === 2 ? s.join(".") : s.slice(-2).join(".");
307
+ if (!r || r.split(".").length < 2)
308
+ throw new Error("Invalid domain structure for SaaS");
309
+ const i = `https://${n}.${r}/collect`;
310
+ if (!rs(i))
311
+ throw new Error("Generated URL failed validation");
312
+ return i;
313
+ } catch (e) {
314
+ throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
315
+ }
316
+ }, as = (n) => {
317
+ const e = {}, t = n.integrations?.tracelog;
318
+ return t?.projectId && (e.saas = t.firstParty ? os(t.projectId) : is(t.projectId)), e;
319
+ }, D = (n, e = []) => {
320
+ if (!n || typeof n != "string")
321
+ return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof n } }), n || "";
322
+ try {
323
+ let t, s = !1;
324
+ try {
325
+ t = new URL(n);
326
+ } catch {
327
+ const c = window.location.href;
328
+ t = new URL(n, c), s = t.origin === new URL(c).origin;
329
+ }
330
+ const r = t.searchParams, i = [.../* @__PURE__ */ new Set([..._t, ...e])];
331
+ let o = !1;
332
+ for (const c of i)
333
+ r.has(c) && (r.delete(c), o = !0);
334
+ return !o && (s || n.includes("?")) ? n : (t.search = r.toString(), s ? `${t.pathname}${t.search}${t.hash}` : t.toString());
335
+ } catch (t) {
336
+ return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: n?.length } }), n;
337
+ }
338
+ }, cs = [
287
339
  "co.uk",
288
340
  "org.uk",
289
341
  "com.au",
@@ -300,18 +352,18 @@ const Ut = () => {
300
352
  if (e.length <= 2)
301
353
  return n.toLowerCase();
302
354
  const t = e.slice(-2).join(".");
303
- return ns.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
304
- }, rs = (n, e) => n === e ? !0 : Ye(n) === Ye(e), he = () => {
305
- const n = document.referrer;
306
- if (!n)
355
+ return cs.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
356
+ }, ls = (n, e) => n === e ? !0 : Ye(n) === Ye(e), fe = (n = []) => {
357
+ const e = document.referrer;
358
+ if (!e)
307
359
  return "Direct";
308
360
  try {
309
- const e = new URL(n).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
310
- return rs(e, t) ? "Direct" : n;
311
- } catch (e) {
312
- return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: n } }), n;
361
+ const t = new URL(e).hostname.toLowerCase(), s = window.location.hostname.toLowerCase();
362
+ return ls(t, s) ? "Direct" : D(e, n);
363
+ } catch (t) {
364
+ return a("debug", "Failed to parse referrer URL, using raw value", { error: t, data: { referrer: e } }), e;
313
365
  }
314
- }, fe = () => {
366
+ }, ge = () => {
315
367
  const n = new URLSearchParams(window.location.search), e = {};
316
368
  return Tt.forEach((s) => {
317
369
  const r = n.get(s);
@@ -324,11 +376,11 @@ const Ut = () => {
324
376
  const e = Math.random() * 16 | 0;
325
377
  return (n === "x" ? e : e & 3 | 8).toString(16);
326
378
  });
327
- let G = 0, W = 0;
328
- const is = () => {
379
+ let K = 0, z = 0;
380
+ const us = () => {
329
381
  let n = Date.now();
330
- n < W && (n = W), n === W ? G = (G + 1) % 1e3 : G = 0, W = n;
331
- const e = G.toString().padStart(3, "0");
382
+ n < z && (n = z), n === z ? K = (K + 1) % 1e3 : K = 0, z = n;
383
+ const e = K.toString().padStart(3, "0");
332
384
  let t = "";
333
385
  try {
334
386
  if (typeof crypto < "u" && crypto.getRandomValues) {
@@ -338,52 +390,6 @@ const is = () => {
338
390
  } catch {
339
391
  }
340
392
  return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${n}-${e}-${t}`;
341
- }, os = (n) => {
342
- try {
343
- return new URL(n).protocol === "https:";
344
- } catch {
345
- return !1;
346
- }
347
- }, as = (n) => {
348
- try {
349
- const t = new URL(window.location.href).hostname;
350
- if (!t || typeof t != "string")
351
- throw new Error("Invalid hostname");
352
- if (t === "localhost" || t === "127.0.0.1" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t))
353
- throw new Error(
354
- "SaaS integration requires a domain hostname; localhost and IP addresses are not supported. For local development, omit `integrations.tracelog` to run in standalone mode (events emitted locally, no network requests), or test against a staging domain that resolves to your dev machine via /etc/hosts."
355
- );
356
- const s = t.split(".");
357
- if (!s || !Array.isArray(s) || s.length === 0 || s.length === 1 && s[0] === "")
358
- throw new Error("Invalid hostname structure");
359
- if (s.length === 1)
360
- throw new Error("Single-part domain not supported for SaaS integration");
361
- const r = s.length === 2 ? s.join(".") : s.slice(-2).join(".");
362
- if (!r || r.split(".").length < 2)
363
- throw new Error("Invalid domain structure for SaaS");
364
- const i = `https://${n}.${r}/collect`;
365
- if (!os(i))
366
- throw new Error("Generated URL failed validation");
367
- return i;
368
- } catch (e) {
369
- throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
370
- }
371
- }, cs = (n) => {
372
- const e = {};
373
- return n.integrations?.tracelog?.projectId && (e.saas = as(n.integrations.tracelog.projectId)), e;
374
- }, ye = (n, e = []) => {
375
- if (!n || typeof n != "string")
376
- return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof n } }), n || "";
377
- try {
378
- const t = new URL(n), s = t.searchParams, r = [.../* @__PURE__ */ new Set([..._t, ...e])];
379
- let i = !1;
380
- const o = [];
381
- return r.forEach((c) => {
382
- s.has(c) && (s.delete(c), i = !0, o.push(c));
383
- }), !i && n.includes("?") ? n : (t.search = s.toString(), t.toString());
384
- } catch (t) {
385
- return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: n?.length } }), n;
386
- }
387
393
  }, qe = (n) => {
388
394
  if (!n || typeof n != "string" || n.trim().length === 0)
389
395
  return "";
@@ -425,7 +431,7 @@ const is = () => {
425
431
  return t;
426
432
  }
427
433
  return null;
428
- }, ls = (n) => {
434
+ }, ds = (n) => {
429
435
  if (typeof n != "object" || n === null)
430
436
  return {};
431
437
  try {
@@ -435,7 +441,7 @@ const is = () => {
435
441
  const t = e instanceof Error ? e.message : String(e);
436
442
  throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
437
443
  }
438
- }, us = [
444
+ }, hs = [
439
445
  // Email addresses.
440
446
  // Quantifiers are bounded (local part ≤64, each label ≤63, TLD ≤63 per RFC/DNS limits)
441
447
  // and the domain is matched as discrete dot-separated labels so the local-part and
@@ -456,12 +462,12 @@ const is = () => {
456
462
  /:\/\/[^:/]+:([^@]+)@/gi,
457
463
  // Sensitive URL query parameters (token=, password=, auth=, secret=, api_key=, …)
458
464
  /[?&](token|password|passwd|auth|secret|secret_key|private_key|auth_key|api_key|apikey|access_token)=[^&\s]+/gi
459
- ], Y = (n) => {
465
+ ], U = (n) => {
460
466
  let e = n;
461
- for (const t of us)
467
+ for (const t of hs)
462
468
  e = e.replace(t, "[REDACTED]");
463
469
  return e;
464
- }, ds = (n) => {
470
+ }, fs = (n) => {
465
471
  if (n !== void 0 && (n === null || typeof n != "object"))
466
472
  throw new m("Configuration must be an object", "config");
467
473
  if (n) {
@@ -469,7 +475,7 @@ const is = () => {
469
475
  throw new bt(y.INVALID_SESSION_TIMEOUT, "config");
470
476
  if (n.globalMetadata !== void 0 && (typeof n.globalMetadata != "object" || n.globalMetadata === null))
471
477
  throw new m(y.INVALID_GLOBAL_METADATA, "config");
472
- if (n.integrations && hs(n.integrations), n.sensitiveQueryParams !== void 0) {
478
+ if (n.integrations && gs(n.integrations), n.sensitiveQueryParams !== void 0) {
473
479
  if (!Array.isArray(n.sensitiveQueryParams))
474
480
  throw new m(y.INVALID_SENSITIVE_QUERY_PARAMS, "config");
475
481
  for (const e of n.sensitiveQueryParams)
@@ -529,14 +535,14 @@ const is = () => {
529
535
  }
530
536
  }
531
537
  }
532
- }, hs = (n) => {
538
+ }, gs = (n) => {
533
539
  if (n && n.tracelog) {
534
540
  if (!n.tracelog.projectId || typeof n.tracelog.projectId != "string" || n.tracelog.projectId.trim() === "")
535
541
  throw new Xe(y.INVALID_TRACELOG_PROJECT_ID, "config");
536
542
  if (n.tracelog.shopify !== void 0 && typeof n.tracelog.shopify != "boolean")
537
543
  throw new Xe("tracelog.shopify must be a boolean", "config");
538
544
  }
539
- }, fs = (n) => (ds(n), {
545
+ }, ms = (n) => (fs(n), {
540
546
  ...n ?? {},
541
547
  sessionTimeout: n?.sessionTimeout ?? 9e5,
542
548
  globalMetadata: n?.globalMetadata ?? {},
@@ -554,13 +560,13 @@ const is = () => {
554
560
  return !0;
555
561
  const t = typeof n;
556
562
  return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(n) ? !1 : (e.add(n), Array.isArray(n) ? n.every((s) => we(s, e)) : t === "object" ? Object.values(n).every((s) => we(s, e)) : !1);
557
- }, gs = (n) => typeof n != "object" || n === null ? !1 : we(n), Ae = (n) => {
563
+ }, ps = (n) => typeof n != "object" || n === null ? !1 : we(n), Ae = (n) => {
558
564
  if (typeof n != "object" || n === null || Array.isArray(n)) return;
559
565
  const e = {};
560
566
  for (const [t, s] of Object.entries(n))
561
567
  typeof s == "string" && (e[t] = s);
562
568
  return Object.keys(e).length > 0 ? e : void 0;
563
- }, ms = (n) => typeof n != "string" ? {
569
+ }, Ss = (n) => typeof n != "string" ? {
564
570
  valid: !1,
565
571
  error: "Event name must be a string"
566
572
  } : n.length === 0 ? {
@@ -576,8 +582,8 @@ const is = () => {
576
582
  valid: !1,
577
583
  error: "Event name cannot be a reserved word"
578
584
  } : { valid: !0 }, Je = (n, e, t) => {
579
- const s = ls(e), r = `${t} "${n}" metadata error`;
580
- if (!gs(s))
585
+ const s = ds(e), r = `${t} "${n}" metadata error`;
586
+ if (!ps(s))
581
587
  return {
582
588
  valid: !1,
583
589
  error: `${r}: object has invalid types. Valid types are string, number, boolean or string arrays.`
@@ -625,7 +631,7 @@ const is = () => {
625
631
  valid: !0,
626
632
  sanitizedMetadata: s
627
633
  };
628
- }, ps = (n, e, t) => {
634
+ }, Es = (n, e, t) => {
629
635
  if (Array.isArray(e)) {
630
636
  const s = [], r = `${t} "${n}" metadata error`;
631
637
  for (let i = 0; i < e.length; i++) {
@@ -649,15 +655,15 @@ const is = () => {
649
655
  };
650
656
  }
651
657
  return Je(n, e, t);
652
- }, Ss = (n, e) => {
653
- const t = ms(n);
658
+ }, vs = (n, e) => {
659
+ const t = Ss(n);
654
660
  if (!t.valid)
655
661
  return a("error", "Event name validation failed", {
656
662
  data: { eventName: n, error: t.error }
657
663
  }), t;
658
664
  if (!e)
659
665
  return { valid: !0 };
660
- const s = ps(n, e, "customEvent");
666
+ const s = Es(n, e, "customEvent");
661
667
  return s.valid || a("error", "Event metadata validation failed", {
662
668
  data: {
663
669
  eventName: n,
@@ -665,7 +671,7 @@ const is = () => {
665
671
  }
666
672
  }), s;
667
673
  };
668
- class Es {
674
+ class Ts {
669
675
  listeners = /* @__PURE__ */ new Map();
670
676
  /**
671
677
  * Subscribes to an event channel
@@ -782,15 +788,15 @@ class Es {
782
788
  this.listeners.clear();
783
789
  }
784
790
  }
785
- const vs = /https?:\/\/\S+/g, Ts = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, _s = /0x[0-9a-fA-F]{4,}/g, ys = /(?<!\d)\d{4,}(?!\d)/g, Is = /(['"])[^'"]{20,}\1/g;
786
- function ws(n) {
787
- return n.replace(vs, "[URL]").replace(Ts, "[ID]").replace(_s, "[ADDR]").replace(ys, "[N]").replace(Is, "$1[VAR]$1").toLowerCase().trim();
791
+ const _s = /https?:\/\/\S+/g, ys = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, Is = /0x[0-9a-fA-F]{4,}/g, ws = /(?<!\d)\d{4,}(?!\d)/g, As = /(['"])[^'"]{20,}\1/g;
792
+ function bs(n) {
793
+ return n.replace(_s, "[URL]").replace(ys, "[ID]").replace(Is, "[ADDR]").replace(ws, "[N]").replace(As, "$1[VAR]$1").toLowerCase().trim();
788
794
  }
789
795
  function Ze(n) {
790
796
  const e = n.search(/[?#]/);
791
797
  return e === -1 ? n : n.slice(0, e);
792
798
  }
793
- function As(n, e) {
799
+ function Ls(n, e) {
794
800
  const t = Ze((n ?? "").trim());
795
801
  if (!t) return "";
796
802
  let s;
@@ -803,32 +809,32 @@ function As(n, e) {
803
809
  const r = Ze((e ?? "").trim());
804
810
  return r && t === r ? s.origin : t;
805
811
  }
806
- function bs(n) {
807
- const e = ws(n.message), t = As(n.filename, n.page_url), s = n.line == null ? "" : String(n.line);
812
+ function Ms(n) {
813
+ const e = bs(n.message), t = Ls(n.filename, n.page_url), s = n.line == null ? "" : String(n.line);
808
814
  return `${e}|${t}|${s}`;
809
815
  }
810
- const ge = { config: {} };
816
+ const me = { config: {} };
811
817
  class T {
812
818
  /**
813
819
  * Retrieves a value from global state.
814
820
  */
815
821
  get(e) {
816
- return ge[e];
822
+ return me[e];
817
823
  }
818
824
  /**
819
825
  * Sets a value in global state.
820
826
  */
821
827
  set(e, t) {
822
- ge[e] = t;
828
+ me[e] = t;
823
829
  }
824
830
  /**
825
831
  * Returns an immutable snapshot of the entire global state.
826
832
  */
827
833
  getState() {
828
- return { ...ge };
834
+ return { ...me };
829
835
  }
830
836
  }
831
- class Ls extends T {
837
+ class Cs extends T {
832
838
  storeManager;
833
839
  apiUrl;
834
840
  lastPermanentErrorLog = null;
@@ -880,7 +886,7 @@ class Ls extends T {
880
886
  * cases so the migration is one-shot per browser.
881
887
  */
882
888
  migrateLegacyV2Keys() {
883
- const e = this.get("userId") || "anonymous", t = `${ce(e)}:saas`, s = `${ce(e)}:custom`, r = `${le(e)}:saas`, i = `${le(e)}:custom`;
889
+ const e = this.get("userId") || "anonymous", t = `${le(e)}:saas`, s = `${le(e)}:custom`, r = `${ue(e)}:saas`, i = `${ue(e)}:custom`;
884
890
  try {
885
891
  const o = this.storeManager.getItem(t);
886
892
  if (o) {
@@ -926,11 +932,11 @@ class Ls extends T {
926
932
  }
927
933
  getQueueStorageKey() {
928
934
  const e = this.get("userId") || "anonymous";
929
- return ce(e);
935
+ return le(e);
930
936
  }
931
937
  getRateLimitStorageKey() {
932
938
  const e = this.get("userId") || "anonymous";
933
- return le(e);
939
+ return ue(e);
934
940
  }
935
941
  getActiveRateLimitKey() {
936
942
  return this.rateLimitStorageKeyAtArm ?? this.getRateLimitStorageKey();
@@ -1101,13 +1107,13 @@ class Ls extends T {
1101
1107
  const u = c === 3;
1102
1108
  if (l instanceof C)
1103
1109
  throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l.statusCode === 403 && this.emitHealthBeacon("events_blocked", l.message), l;
1104
- if (l instanceof J) {
1110
+ if (l instanceof Z) {
1105
1111
  this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, i = !1, o = !0, this.armRateLimitCooldown(Date.now() + 6e4), a("warn", "Rate limited, skipping retries", {
1106
1112
  data: { events: e.events.length, attempt: c, cooldownMs: 6e4 }
1107
1113
  });
1108
1114
  break;
1109
1115
  }
1110
- if (l instanceof Z || (i = !1), l instanceof TypeError || (o = !0), a(
1116
+ if (l instanceof ee || (i = !1), l instanceof TypeError || (o = !0), a(
1111
1117
  u ? "error" : "warn",
1112
1118
  `Send attempt ${c} failed${u ? " (all retries exhausted)" : ", will retry"}`,
1113
1119
  {
@@ -1155,11 +1161,11 @@ class Ls extends T {
1155
1161
  const l = await this.readTraceLogErrorCode(o), u = l ? `HTTP ${o.status}: ${o.statusText} (${l})` : `HTTP ${o.status}: ${o.statusText}`;
1156
1162
  throw new C(u, o.status, l);
1157
1163
  }
1158
- throw o.status === 429 ? new J(`HTTP 429: ${o.statusText}`) : new Error(`HTTP ${o.status}: ${o.statusText}`);
1164
+ throw o.status === 429 ? new Z(`HTTP 429: ${o.statusText}`) : new Error(`HTTP ${o.status}: ${o.statusText}`);
1159
1165
  }
1160
1166
  return o;
1161
1167
  } catch (o) {
1162
- throw o instanceof C ? o : r ? new Z("Request timed out") : o;
1168
+ throw o instanceof C ? o : r ? new ee("Request timed out") : o;
1163
1169
  } finally {
1164
1170
  clearTimeout(i), this.pendingControllers.delete(s);
1165
1171
  }
@@ -1167,7 +1173,7 @@ class Ls extends T {
1167
1173
  async readTraceLogErrorCode(e) {
1168
1174
  try {
1169
1175
  const t = await e.clone().json();
1170
- if (typeof t.code == "string" && t.code.length > 0 && t.code.length <= Kt)
1176
+ if (typeof t.code == "string" && t.code.length > 0 && t.code.length <= zt)
1171
1177
  return t.code;
1172
1178
  } catch {
1173
1179
  }
@@ -1194,7 +1200,7 @@ class Ls extends T {
1194
1200
  idempotency_token: e._metadata?.idempotency_token ?? this.computeContentToken(e),
1195
1201
  referer: typeof window < "u" ? window.location.href : void 0,
1196
1202
  timestamp: t,
1197
- client_version: Zt
1203
+ client_version: es
1198
1204
  }
1199
1205
  };
1200
1206
  return {
@@ -1286,7 +1292,7 @@ class Ls extends T {
1286
1292
  }
1287
1293
  logPermanentError(e, t) {
1288
1294
  const s = Date.now(), r = `${t.statusCode ?? "unknown"}:${t.responseCode ?? ""}`;
1289
- (!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== r || s - this.lastPermanentErrorLog.timestamp >= Wt) && (a("error", e, {
1295
+ (!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== r || s - this.lastPermanentErrorLog.timestamp >= Kt) && (a("error", e, {
1290
1296
  data: { status: t.statusCode, code: t.responseCode, message: t.message }
1291
1297
  }), this.lastPermanentErrorLog = { key: r, timestamp: s });
1292
1298
  }
@@ -1307,7 +1313,7 @@ class Ls extends T {
1307
1313
  projectId: s.projectId,
1308
1314
  reason: e,
1309
1315
  origin: i,
1310
- ...t ? { lastError: t.slice(0, Qt) } : {}
1316
+ ...t ? { lastError: t.slice(0, Yt) } : {}
1311
1317
  });
1312
1318
  this.postBeacon(r, o);
1313
1319
  } catch {
@@ -1331,7 +1337,7 @@ class Ls extends T {
1331
1337
  Number.isFinite(o) && o > i && (i = o);
1332
1338
  } catch {
1333
1339
  }
1334
- if (s - i < zt) return !1;
1340
+ if (s - i < Qt) return !1;
1335
1341
  this.lastBeaconAt[t] = s;
1336
1342
  try {
1337
1343
  this.storeManager.setItem(r, String(s));
@@ -1357,7 +1363,7 @@ class Ls extends T {
1357
1363
  });
1358
1364
  }
1359
1365
  }
1360
- class Ms extends T {
1366
+ class Rs extends T {
1361
1367
  bootTime;
1362
1368
  bootTimestamp;
1363
1369
  hasPerformanceNow;
@@ -1391,8 +1397,8 @@ class Ms extends T {
1391
1397
  } : { valid: !0 };
1392
1398
  }
1393
1399
  }
1394
- const Cs = new Set(Object.values(d));
1395
- class Rs extends T {
1400
+ const Ns = new Set(Object.values(d));
1401
+ class Os extends T {
1396
1402
  dataSenders;
1397
1403
  emitter;
1398
1404
  timeManager;
@@ -1424,9 +1430,9 @@ class Rs extends T {
1424
1430
  * @param emitter - Optional event emitter for local event consumption
1425
1431
  */
1426
1432
  constructor(e, t = null) {
1427
- super(), this.emitter = t, this.timeManager = new Ms(), this.dataSenders = [];
1433
+ super(), this.emitter = t, this.timeManager = new Rs(), this.dataSenders = [];
1428
1434
  const s = this.get("collectApiUrls");
1429
- s?.saas && this.dataSenders.push(new Ls(e, s.saas)), this.saveSessionCountsDebounced = this.debounce((r) => {
1435
+ s?.saas && this.dataSenders.push(new Cs(e, s.saas)), this.saveSessionCountsDebounced = this.debounce((r) => {
1430
1436
  this.saveSessionCounts(r);
1431
1437
  }, 500), this.cleanupExpiredSessionCounts();
1432
1438
  }
@@ -1544,7 +1550,7 @@ class Rs extends T {
1544
1550
  a("error", "Event type is required - event will be ignored");
1545
1551
  return;
1546
1552
  }
1547
- if (!Cs.has(e)) {
1553
+ if (!Ns.has(e)) {
1548
1554
  a("error", "Invalid event type - event will be ignored", {
1549
1555
  data: { type: e }
1550
1556
  });
@@ -1587,12 +1593,12 @@ class Rs extends T {
1587
1593
  }
1588
1594
  const _ = this.getTypeLimitForEvent(S);
1589
1595
  if (_) {
1590
- const ae = this.sessionEventCounts[S];
1591
- if (ae !== void 0 && ae >= _) {
1596
+ const ce = this.sessionEventCounts[S];
1597
+ if (ce !== void 0 && ce >= _) {
1592
1598
  a("warn", "Session event type limit reached", {
1593
1599
  data: {
1594
1600
  type: S,
1595
- count: ae,
1601
+ count: ce,
1596
1602
  limit: _
1597
1603
  }
1598
1604
  });
@@ -1605,7 +1611,7 @@ class Rs extends T {
1605
1611
  if (!this.checkPerEventRateLimit(o.name, _))
1606
1612
  return;
1607
1613
  }
1608
- const St = S === d.SESSION_START, Et = t || this.get("pageUrl"), j = this.buildEventPayload({
1614
+ const St = S === d.SESSION_START, Et = t || this.get("pageUrl"), W = this.buildEventPayload({
1609
1615
  type: S,
1610
1616
  page_url: Et,
1611
1617
  from_page_url: s,
@@ -1616,7 +1622,7 @@ class Rs extends T {
1616
1622
  error_data: l,
1617
1623
  page_view: u
1618
1624
  });
1619
- if (j && !(!p && !this.shouldSample())) {
1625
+ if (W && !(!p && !this.shouldSample())) {
1620
1626
  if (St) {
1621
1627
  const _ = this.get("sessionId");
1622
1628
  if (!_) {
@@ -1631,18 +1637,18 @@ class Rs extends T {
1631
1637
  }
1632
1638
  this.set("hasStartSession", !0);
1633
1639
  }
1634
- if (!this.isDuplicateEvent(j)) {
1635
- if (this.get("mode") === ee.QA && S === d.CUSTOM && o) {
1640
+ if (!this.isDuplicateEvent(W)) {
1641
+ if (this.get("mode") === te.QA && S === d.CUSTOM && o) {
1636
1642
  a("info", `Custom Event: ${o.name}`, {
1637
1643
  visibility: "qa",
1638
1644
  data: {
1639
1645
  name: o.name,
1640
1646
  ...o.metadata && { metadata: o.metadata }
1641
1647
  }
1642
- }), this.emitEvent(j);
1648
+ }), this.emitEvent(W);
1643
1649
  return;
1644
1650
  }
1645
- if (this.addToQueue(j), !p) {
1651
+ if (this.addToQueue(W), !p) {
1646
1652
  this.sessionEventCounts.total++, this.sessionEventCounts[S] !== void 0 && this.sessionEventCounts[S]++;
1647
1653
  const _ = this.get("sessionId");
1648
1654
  _ && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(_);
@@ -2100,7 +2106,7 @@ class Rs extends T {
2100
2106
  });
2101
2107
  const c = this.get("sessionReferrer"), l = this.get("sessionUtm"), u = this.get("sessionClickIds");
2102
2108
  return { ...{
2103
- id: is(),
2109
+ id: us(),
2104
2110
  type: e.type,
2105
2111
  page_url: r,
2106
2112
  timestamp: i,
@@ -2208,11 +2214,11 @@ class Rs extends T {
2208
2214
  emitEvent(e) {
2209
2215
  if (this.emitter) {
2210
2216
  const { _session_id: t, ...s } = e;
2211
- this.emitter.emit(U.EVENT, s);
2217
+ this.emitter.emit(V.EVENT, s);
2212
2218
  }
2213
2219
  }
2214
2220
  emitEventsQueue(e) {
2215
- this.emitter && this.emitter.emit(U.QUEUE, e);
2221
+ this.emitter && this.emitter.emit(V.QUEUE, e);
2216
2222
  }
2217
2223
  /**
2218
2224
  * Creates a debounced version of a function that delays execution until after
@@ -2412,7 +2418,7 @@ class Rs extends T {
2412
2418
  }
2413
2419
  }
2414
2420
  }
2415
- class Ns {
2421
+ class Ps {
2416
2422
  /**
2417
2423
  * Gets or creates a unique user ID.
2418
2424
  *
@@ -2430,15 +2436,15 @@ class Ns {
2430
2436
  * @returns Persistent unique user ID (UUID v4 format)
2431
2437
  */
2432
2438
  static getId(e) {
2433
- const t = e.getItem(Se);
2439
+ const t = e.getItem(Ee);
2434
2440
  if (t)
2435
2441
  return t;
2436
2442
  const s = at();
2437
- return e.setItem(Se, s), s;
2443
+ return e.setItem(Ee, s), s;
2438
2444
  }
2439
2445
  }
2440
- const Os = /^\d{13}-[a-z0-9]{9}$/;
2441
- class Ps extends T {
2446
+ const ks = /^\d{13}-[a-z0-9]{9}$/;
2447
+ class Ds extends T {
2442
2448
  storageManager;
2443
2449
  eventManager;
2444
2450
  projectId;
@@ -2490,7 +2496,7 @@ class Ps extends T {
2490
2496
  const e = this.loadStoredSession();
2491
2497
  if (!e)
2492
2498
  return null;
2493
- if (!Os.test(e.id))
2499
+ if (!ks.test(e.id))
2494
2500
  return a("warn", "Invalid session ID format recovered from storage, clearing", {
2495
2501
  data: { sessionId: e.id }
2496
2502
  }), this.clearStoredSession(), null;
@@ -2609,9 +2615,9 @@ class Ps extends T {
2609
2615
  let s, r, i;
2610
2616
  if (e) {
2611
2617
  const o = this.loadStoredSession();
2612
- s = o?.referrer ?? he(), r = o?.utm ?? fe(), i = o?.clickIds ?? de();
2618
+ s = o?.referrer ?? fe(this.get("config")?.sensitiveQueryParams), r = o?.utm ?? ge(), i = o?.clickIds ?? he();
2613
2619
  } else
2614
- s = he(), r = fe(), i = de();
2620
+ s = fe(this.get("config")?.sensitiveQueryParams), r = ge(), i = he();
2615
2621
  a("debug", "Session tracking initialized", {
2616
2622
  data: {
2617
2623
  sessionId: t,
@@ -2683,7 +2689,7 @@ class Ps extends T {
2683
2689
  */
2684
2690
  renewSession() {
2685
2691
  this.needsRenewal = !1;
2686
- const e = this.generateSessionId(), t = he(), s = fe(), r = de();
2692
+ const e = this.generateSessionId(), t = fe(this.get("config")?.sensitiveQueryParams), s = ge(), r = he();
2687
2693
  a("debug", "Renewing session after timeout", {
2688
2694
  data: { newSessionId: e }
2689
2695
  }), this.set("sessionId", e), this.set("sessionReferrer", t), this.set("sessionUtm", s), this.set("sessionClickIds", r), this.persistSession(e, Date.now(), t, s, r), this.cleanupCrossTabSync(), this.initCrossTabSync(), this.shareSession(e), this.eventManager.track({
@@ -2813,7 +2819,7 @@ class Ps extends T {
2813
2819
  this.prerenderActivationHandler && (document.removeEventListener("prerenderingchange", this.prerenderActivationHandler), this.prerenderActivationHandler = null);
2814
2820
  }
2815
2821
  }
2816
- class ks extends T {
2822
+ class Us extends T {
2817
2823
  eventManager;
2818
2824
  storageManager;
2819
2825
  sessionManager = null;
@@ -2848,7 +2854,7 @@ class ks extends T {
2848
2854
  }
2849
2855
  const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
2850
2856
  try {
2851
- this.sessionManager = new Ps(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
2857
+ this.sessionManager = new Ds(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
2852
2858
  } catch (s) {
2853
2859
  if (this.sessionManager) {
2854
2860
  try {
@@ -2901,7 +2907,7 @@ class ks extends T {
2901
2907
  this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
2902
2908
  }
2903
2909
  }
2904
- class Ds extends T {
2910
+ class Fs extends T {
2905
2911
  eventManager;
2906
2912
  onTrack;
2907
2913
  originalPushState;
@@ -2941,7 +2947,7 @@ class Ds extends T {
2941
2947
  };
2942
2948
  }
2943
2949
  trackCurrentPage = () => {
2944
- const e = window.location.href, t = ye(e, this.get("config").sensitiveQueryParams);
2950
+ const e = window.location.href, t = D(e, this.get("config").sensitiveQueryParams);
2945
2951
  if (this.get("pageUrl") === t)
2946
2952
  return;
2947
2953
  const s = Date.now(), r = this.get("config").pageViewThrottleMs ?? 1e3;
@@ -2959,7 +2965,7 @@ class Ds extends T {
2959
2965
  }), this.get("config").flushOnSpaNavigation === !0 && this.eventManager.flushImmediately();
2960
2966
  };
2961
2967
  trackInitialPageView() {
2962
- const e = ye(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
2968
+ const e = D(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
2963
2969
  this.lastPageViewTime = Date.now(), this.eventManager.track({
2964
2970
  type: d.PAGE_VIEW,
2965
2971
  page_url: e,
@@ -2967,7 +2973,7 @@ class Ds extends T {
2967
2973
  }), this.onTrack();
2968
2974
  }
2969
2975
  extractPageViewData() {
2970
- const { referrer: e } = document, { title: t } = document;
2976
+ const e = document.referrer ? D(document.referrer, this.get("config").sensitiveQueryParams) : "", { title: t } = document;
2971
2977
  if (!(!e && !t))
2972
2978
  return {
2973
2979
  ...e && { referrer: e },
@@ -2975,7 +2981,7 @@ class Ds extends T {
2975
2981
  };
2976
2982
  }
2977
2983
  }
2978
- class Us extends T {
2984
+ class Vs extends T {
2979
2985
  eventManager;
2980
2986
  lastClickTimes = /* @__PURE__ */ new Map();
2981
2987
  clickHandler;
@@ -3144,15 +3150,15 @@ class Us extends T {
3144
3150
  };
3145
3151
  }
3146
3152
  generateClickData(e, t, s) {
3147
- const { x: r, y: i } = s, o = this.getRelevantText(e, t), c = t.getAttribute("href") ?? void 0;
3153
+ const { x: r, y: i } = s, o = this.getRelevantText(e, t), c = t.getAttribute("href"), l = c ? D(c, this.get("config")?.sensitiveQueryParams) : void 0;
3148
3154
  return {
3149
3155
  x: r,
3150
3156
  y: i,
3151
3157
  tag: t.tagName.toLowerCase(),
3152
- ...t.id && { id: t.id },
3153
- ...t.className && { class: t.className },
3158
+ ...t.id && { id: U(t.id) },
3159
+ ...t.className && { class: U(t.className) },
3154
3160
  ...o && { text: o },
3155
- ...c && { href: c }
3161
+ ...l && { href: l }
3156
3162
  };
3157
3163
  }
3158
3164
  getRelevantText(e, t) {
@@ -3160,7 +3166,7 @@ class Us extends T {
3160
3166
  if (!s && !r)
3161
3167
  return "";
3162
3168
  let i = "";
3163
- return s && s.length <= 255 ? i = s : r.length <= 255 ? i = r : i = r.slice(0, 252) + "...", Y(i);
3169
+ return s && s.length <= 255 ? i = s : r.length <= 255 ? i = r : i = r.slice(0, 252) + "...", U(i);
3164
3170
  }
3165
3171
  createCustomEventData(e) {
3166
3172
  return {
@@ -3169,7 +3175,7 @@ class Us extends T {
3169
3175
  };
3170
3176
  }
3171
3177
  }
3172
- class Fs extends T {
3178
+ class Hs extends T {
3173
3179
  eventManager;
3174
3180
  containers = [];
3175
3181
  limitWarningLogged = !1;
@@ -3295,7 +3301,7 @@ class Fs extends T {
3295
3301
  e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
3296
3302
  }
3297
3303
  getScrollDirection(e, t) {
3298
- return e > t ? Ee.DOWN : Ee.UP;
3304
+ return e > t ? ve.DOWN : ve.UP;
3299
3305
  }
3300
3306
  calculateScrollDepth(e, t, s) {
3301
3307
  if (t <= s)
@@ -3324,8 +3330,8 @@ class Fs extends T {
3324
3330
  return s && r;
3325
3331
  }
3326
3332
  }
3327
- const Vs = "tracelog_session_id", Hs = "tracelog_user_id";
3328
- class xs extends T {
3333
+ const xs = "tracelog_session_id", $s = "tracelog_user_id";
3334
+ class Bs extends T {
3329
3335
  visibilityHandler = null;
3330
3336
  pageshowHandler = null;
3331
3337
  lastSyncedKey = null;
@@ -3346,8 +3352,8 @@ class xs extends T {
3346
3352
  r !== this.lastSyncedKey && (this.lastSyncedKey = r, this.postCartUpdate(e, s));
3347
3353
  }
3348
3354
  postCartUpdate(e, t) {
3349
- const s = { [Vs]: e };
3350
- t.length > 0 && (s[Hs] = t);
3355
+ const s = { [xs]: e };
3356
+ t.length > 0 && (s[$s] = t);
3351
3357
  try {
3352
3358
  fetch("/cart/update.js", {
3353
3359
  method: "POST",
@@ -3384,7 +3390,7 @@ class xs extends T {
3384
3390
  this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.pageshowHandler && (window.removeEventListener("pageshow", this.pageshowHandler), this.pageshowHandler = null);
3385
3391
  }
3386
3392
  }
3387
- class $s {
3393
+ class Xs {
3388
3394
  storage;
3389
3395
  sessionStorageRef;
3390
3396
  fallbackStorage = /* @__PURE__ */ new Map();
@@ -3497,7 +3503,7 @@ class $s {
3497
3503
  this.fallbackSessionStorage.delete(e);
3498
3504
  }
3499
3505
  }
3500
- class Bs extends T {
3506
+ class js extends T {
3501
3507
  eventManager;
3502
3508
  reportedByNav = /* @__PURE__ */ new Map();
3503
3509
  navigationHistory = [];
@@ -3505,9 +3511,11 @@ class Bs extends T {
3505
3511
  observers = [];
3506
3512
  vitalThresholds;
3507
3513
  navigationCounter = 0;
3508
- // Counter for handling simultaneous navigations edge case
3514
+ // Suffix counter for repeat navigations to the same path (SPA A→B→A)
3515
+ currentNavBase = null;
3516
+ currentNavId = null;
3509
3517
  constructor(e) {
3510
- super(), this.eventManager = e, this.vitalThresholds = Qe(_e);
3518
+ super(), this.eventManager = e, this.vitalThresholds = Qe(ye);
3511
3519
  }
3512
3520
  /**
3513
3521
  * Starts tracking Web Vitals and performance metrics.
@@ -3523,7 +3531,7 @@ class Bs extends T {
3523
3531
  * @returns Promise that resolves when tracking is initialized
3524
3532
  */
3525
3533
  async startTracking() {
3526
- const e = this.get("config"), t = e?.webVitalsMode ?? _e;
3534
+ const e = this.get("config"), t = e?.webVitalsMode ?? ye;
3527
3535
  this.vitalThresholds = Qe(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals();
3528
3536
  }
3529
3537
  /**
@@ -3542,7 +3550,7 @@ class Bs extends T {
3542
3550
  } catch (s) {
3543
3551
  a("debug", "Failed to disconnect performance observer", { error: s, data: { observerIndex: t } });
3544
3552
  }
3545
- }), this.observers.length = 0, this.reportedByNav.clear(), this.navigationHistory.length = 0;
3553
+ }), this.observers.length = 0, this.reportedByNav.clear(), this.navigationHistory.length = 0, this.navigationCounter = 0, this.currentNavBase = null, this.currentNavId = null;
3546
3554
  }
3547
3555
  observeWebVitalsFallback() {
3548
3556
  this.reportTTFB(), this.safeObserve(
@@ -3594,7 +3602,7 @@ class Bs extends T {
3594
3602
  }
3595
3603
  async initWebVitals() {
3596
3604
  try {
3597
- const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() => mn), o = (c) => (l) => {
3605
+ const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() => Sn), o = (c) => (l) => {
3598
3606
  const u = Number(l.value.toFixed(2));
3599
3607
  this.sendVital({ type: c, value: u });
3600
3608
  };
@@ -3624,7 +3632,7 @@ class Bs extends T {
3624
3632
  return;
3625
3633
  if (s)
3626
3634
  s.add(e.type);
3627
- else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > qt) {
3635
+ else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Jt) {
3628
3636
  const i = this.navigationHistory.shift();
3629
3637
  i && this.reportedByNav.delete(i);
3630
3638
  }
@@ -3645,21 +3653,23 @@ class Bs extends T {
3645
3653
  });
3646
3654
  }
3647
3655
  /**
3648
- * Generates a unique navigation identifier for deduplication.
3649
- *
3650
- * **Purpose**: Creates deterministic IDs to prevent duplicate Web Vitals reporting
3651
- * across multiple metrics for the same navigation event.
3656
+ * Generates a deterministic navigation identifier for deduplication.
3652
3657
  *
3653
- * **ID Format**: `{timestamp}_{pathname}` or `{timestamp}_{pathname}_{counter}`
3658
+ * **Purpose**: Every call within the same navigation must return the SAME id,
3659
+ * so `reportedByNav` can collapse duplicate Web Vitals (one emission per
3660
+ * metric type per navigation — critical for the fallback observers, which
3661
+ * fire per entry batch).
3654
3662
  *
3655
- * **Edge Case Handling**:
3656
- * - If multiple navigations occur to the same pathname in the same millisecond,
3657
- * a counter suffix is appended (e.g., `1234.56_/home_2`)
3658
- * - Counter only added when > 1 to minimize ID length for common case
3663
+ * **ID Format**: `{startTime}_{pathname}` or `{startTime}_{pathname}_{counter}`
3659
3664
  *
3660
- * **Why Deterministic**:
3661
- * - Previous implementation used random string duplicate metrics on page reload
3662
- * - Now: Same navigation = same ID = proper deduplication via reportedByNav Map
3665
+ * **Determinism**:
3666
+ * - Base id is derived only from the navigation entry's `startTime` (0 by spec
3667
+ * for the document navigation no `performance.now()` fallback, which made
3668
+ * every call unique) and the current pathname.
3669
+ * - The id is cached per navigation; the counter suffix is appended ONLY on a
3670
+ * real collision: a new navigation whose base id was already reported
3671
+ * (SPA revisit to the same path, e.g. A→B→A), so the revisit's vitals are
3672
+ * not suppressed by the first visit's dedup entries.
3663
3673
  *
3664
3674
  * @returns Navigation ID string or null if navigation timing unavailable
3665
3675
  *
@@ -3670,8 +3680,8 @@ class Bs extends T {
3670
3680
  const e = performance.getEntriesByType("navigation")[0];
3671
3681
  if (!e)
3672
3682
  return null;
3673
- const t = e.startTime || performance.now(), s = ++this.navigationCounter, r = `${t.toFixed(2)}_${window.location.pathname}`;
3674
- return s > 1 ? `${r}_${s}` : r;
3683
+ const t = `${e.startTime.toFixed(2)}_${window.location.pathname}`;
3684
+ return t === this.currentNavBase && this.currentNavId !== null ? this.currentNavId : (this.currentNavBase = t, this.currentNavId = this.reportedByNav.has(t) ? `${t}_${++this.navigationCounter}` : t, this.currentNavId);
3675
3685
  } catch (e) {
3676
3686
  return a("debug", "Failed to get navigation ID", { error: e }), null;
3677
3687
  }
@@ -3715,7 +3725,7 @@ class Bs extends T {
3715
3725
  return !(typeof s == "number" && t <= s);
3716
3726
  }
3717
3727
  }
3718
- class se extends T {
3728
+ class ne extends T {
3719
3729
  eventManager;
3720
3730
  emitter;
3721
3731
  recentErrors = /* @__PURE__ */ new Map();
@@ -3742,7 +3752,7 @@ class se extends T {
3742
3752
  this.resetPageviewCounter();
3743
3753
  }, window.addEventListener("pagehide", this.pagehideHandler, { passive: !0 }), this.emitter && (this.pageviewResetListener = (e) => {
3744
3754
  (e.type === d.SESSION_START || e.type === d.PAGE_VIEW) && this.resetPageviewCounter();
3745
- }, this.emitter.on(U.EVENT, this.pageviewResetListener));
3755
+ }, this.emitter.on(V.EVENT, this.pageviewResetListener));
3746
3756
  }
3747
3757
  /**
3748
3758
  * Stops tracking errors and cleans up resources.
@@ -3753,7 +3763,7 @@ class se extends T {
3753
3763
  * - Resets burst detection counters
3754
3764
  */
3755
3765
  stopTracking() {
3756
- window.removeEventListener("error", this.handleError), window.removeEventListener("unhandledrejection", this.handleRejection), this.pagehideHandler && (window.removeEventListener("pagehide", this.pagehideHandler), this.pagehideHandler = null), this.emitter && this.pageviewResetListener && (this.emitter.off(U.EVENT, this.pageviewResetListener), this.pageviewResetListener = null), this.recentErrors.clear(), this.pageviewSignatureCounts.clear(), this.errorBurstCounter = 0, this.burstWindowStart = 0, this.burstBackoffUntil = 0;
3766
+ window.removeEventListener("error", this.handleError), window.removeEventListener("unhandledrejection", this.handleRejection), this.pagehideHandler && (window.removeEventListener("pagehide", this.pagehideHandler), this.pagehideHandler = null), this.emitter && this.pageviewResetListener && (this.emitter.off(V.EVENT, this.pageviewResetListener), this.pageviewResetListener = null), this.recentErrors.clear(), this.pageviewSignatureCounts.clear(), this.errorBurstCounter = 0, this.burstWindowStart = 0, this.burstBackoffUntil = 0;
3757
3767
  }
3758
3768
  /**
3759
3769
  * Clears the per-pageview signature counter.
@@ -3772,7 +3782,7 @@ class se extends T {
3772
3782
  const e = Date.now();
3773
3783
  if (e < this.burstBackoffUntil)
3774
3784
  return !1;
3775
- if (e - this.burstWindowStart > Bt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > Xt)
3785
+ if (e - this.burstWindowStart > Xt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > jt)
3776
3786
  return this.burstBackoffUntil = e + Ke, a("debug", "Error burst detected - entering cooldown", {
3777
3787
  data: {
3778
3788
  errorsInWindow: this.errorBurstCounter,
@@ -3789,19 +3799,19 @@ class se extends T {
3789
3799
  * later signature that recycles the same map key after a counter reset.
3790
3800
  */
3791
3801
  shouldThrottleBySignature(e) {
3792
- const t = bs(e), s = this.pageviewSignatureCounts.get(t) ?? 0;
3793
- if (s >= jt)
3802
+ const t = Ms(e), s = this.pageviewSignatureCounts.get(t) ?? 0;
3803
+ if (s >= Gt)
3794
3804
  return a("debug", "Error throttled (pageview cap)", {
3795
3805
  data: { signature: t, count: s }
3796
3806
  }), !0;
3797
3807
  const r = s + 1;
3798
- return this.pageviewSignatureCounts.set(t, r), this.pageviewSignatureCounts.size > Gt && (this.pageviewSignatureCounts.clear(), this.pageviewSignatureCounts.set(t, r)), !1;
3808
+ return this.pageviewSignatureCounts.set(t, r), this.pageviewSignatureCounts.size > Wt && (this.pageviewSignatureCounts.clear(), this.pageviewSignatureCounts.set(t, r)), !1;
3799
3809
  }
3800
3810
  handleError = (e) => {
3801
3811
  if (!this.shouldSample())
3802
3812
  return;
3803
3813
  const t = this.sanitize(e.message || "Unknown error");
3804
- if (this.shouldSuppressError(V.JS_ERROR, t) || this.shouldThrottleBySignature({
3814
+ if (this.shouldSuppressError(x.JS_ERROR, t) || this.shouldThrottleBySignature({
3805
3815
  message: t,
3806
3816
  filename: e.filename,
3807
3817
  line: e.lineno,
@@ -3816,7 +3826,7 @@ class se extends T {
3816
3826
  this.eventManager.track({
3817
3827
  type: d.ERROR,
3818
3828
  error_data: {
3819
- type: V.JS_ERROR,
3829
+ type: x.JS_ERROR,
3820
3830
  message: t,
3821
3831
  ...r !== void 0 && { name: r },
3822
3832
  ...e.filename !== "" && { filename: e.filename },
@@ -3830,13 +3840,13 @@ class se extends T {
3830
3840
  if (!this.shouldSample())
3831
3841
  return;
3832
3842
  const t = this.extractRejectionMessage(e.reason), s = this.sanitize(t);
3833
- if (this.shouldSuppressError(V.PROMISE_REJECTION, s) || this.shouldThrottleBySignature({ message: s }))
3843
+ if (this.shouldSuppressError(x.PROMISE_REJECTION, s) || this.shouldThrottleBySignature({ message: s }))
3834
3844
  return;
3835
3845
  const r = e.reason instanceof Error && typeof e.reason.stack == "string" ? this.truncateStack(e.reason.stack) : void 0, i = e.reason instanceof Error && e.reason.name !== "Error" ? e.reason.name : void 0;
3836
3846
  this.eventManager.track({
3837
3847
  type: d.ERROR,
3838
3848
  error_data: {
3839
- type: V.PROMISE_REJECTION,
3849
+ type: x.PROMISE_REJECTION,
3840
3850
  message: s,
3841
3851
  ...i !== void 0 && { name: i },
3842
3852
  ...r !== void 0 && { stack: r }
@@ -3858,40 +3868,40 @@ class se extends T {
3858
3868
  }
3859
3869
  sanitize(e) {
3860
3870
  const t = e.length > je ? e.slice(0, je) + "..." : e;
3861
- return Y(t);
3871
+ return U(t);
3862
3872
  }
3863
3873
  shouldSuppressError(e, t) {
3864
3874
  const s = Date.now(), r = `${e}:${t}`, i = this.recentErrors.get(r);
3865
- return i !== void 0 && s - i < We ? (this.recentErrors.set(r, s), !0) : (this.recentErrors.set(r, s), this.recentErrors.size > $t ? (this.recentErrors.clear(), this.recentErrors.set(r, s), !1) : (this.recentErrors.size > Q && this.pruneOldErrors(), !1));
3875
+ return i !== void 0 && s - i < We ? (this.recentErrors.set(r, s), !0) : (this.recentErrors.set(r, s), this.recentErrors.size > Bt ? (this.recentErrors.clear(), this.recentErrors.set(r, s), !1) : (this.recentErrors.size > q && this.pruneOldErrors(), !1));
3866
3876
  }
3867
3877
  static TRUNCATION_SUFFIX = `
3868
3878
  ...truncated`;
3869
3879
  truncateStack(e) {
3870
- if (e.length <= Ge) return Y(e);
3871
- const t = Ge - se.TRUNCATION_SUFFIX.length, s = e.slice(0, t) + se.TRUNCATION_SUFFIX;
3872
- return Y(s);
3880
+ if (e.length <= Ge) return U(e);
3881
+ const t = Ge - ne.TRUNCATION_SUFFIX.length, s = e.slice(0, t) + ne.TRUNCATION_SUFFIX;
3882
+ return U(s);
3873
3883
  }
3874
3884
  pruneOldErrors() {
3875
3885
  const e = Date.now();
3876
3886
  for (const [r, i] of this.recentErrors.entries())
3877
3887
  e - i > We && this.recentErrors.delete(r);
3878
- if (this.recentErrors.size <= Q)
3888
+ if (this.recentErrors.size <= q)
3879
3889
  return;
3880
- const t = Array.from(this.recentErrors.entries()).sort((r, i) => r[1] - i[1]), s = this.recentErrors.size - Q;
3890
+ const t = Array.from(this.recentErrors.entries()).sort((r, i) => r[1] - i[1]), s = this.recentErrors.size - q;
3881
3891
  for (let r = 0; r < s; r += 1) {
3882
3892
  const i = t[r];
3883
3893
  i && this.recentErrors.delete(i[0]);
3884
3894
  }
3885
3895
  }
3886
3896
  }
3887
- class Xs extends T {
3897
+ class Gs extends T {
3888
3898
  isInitialized = !1;
3889
3899
  suppressNextScrollTimer = null;
3890
3900
  pageUnloadHandler = null;
3891
3901
  pageShowHandler = null;
3892
3902
  visibilityFlushHandler = null;
3893
3903
  prerenderActivationHandler = null;
3894
- emitter = new Es();
3904
+ emitter = new Ts();
3895
3905
  managers = {};
3896
3906
  handlers = {};
3897
3907
  integrationInstances = {};
@@ -3906,9 +3916,9 @@ class Xs extends T {
3906
3916
  async init(e = {}) {
3907
3917
  if (this.isInitialized)
3908
3918
  return { sessionId: this.get("sessionId") ?? "" };
3909
- this.managers.storage = new $s();
3919
+ this.managers.storage = new Xs();
3910
3920
  try {
3911
- return this.setupState(e), this.managers.event = new Rs(this.managers.storage, this.emitter), this.loadPersistedIdentity(), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((t) => {
3921
+ return this.setupState(e), this.managers.event = new Os(this.managers.storage, this.emitter), this.loadPersistedIdentity(), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((t) => {
3912
3922
  a("warn", "Failed to recover persisted events", { error: t });
3913
3923
  }), this.isInitialized = !0, { sessionId: this.get("sessionId") ?? "" };
3914
3924
  } catch (t) {
@@ -3929,9 +3939,9 @@ class Xs extends T {
3929
3939
  }
3930
3940
  let r = t;
3931
3941
  t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
3932
- const { valid: i, error: o, sanitizedMetadata: c } = Ss(e, r);
3942
+ const { valid: i, error: o, sanitizedMetadata: c } = vs(e, r);
3933
3943
  if (!i) {
3934
- if (this.get("mode") === ee.QA)
3944
+ if (this.get("mode") === te.QA)
3935
3945
  throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${o}`);
3936
3946
  a("warn", `Custom event "${e}" dropped: ${o}`);
3937
3947
  return;
@@ -3968,14 +3978,14 @@ class Xs extends T {
3968
3978
  }
3969
3979
  setupState(e = {}) {
3970
3980
  this.set("config", e);
3971
- const t = Ns.getId(this.managers.storage);
3981
+ const t = Ps.getId(this.managers.storage);
3972
3982
  this.set("userId", t);
3973
- const s = cs(e);
3983
+ const s = as(e);
3974
3984
  this.set("collectApiUrls", s);
3975
- const r = xt();
3985
+ const r = $t();
3976
3986
  this.set("device", r);
3977
- const i = ye(window.location.href, e.sensitiveQueryParams);
3978
- this.set("pageUrl", i), ss() && this.set("mode", ee.QA);
3987
+ const i = D(window.location.href, e.sensitiveQueryParams);
3988
+ this.set("pageUrl", i), ns() && this.set("mode", te.QA);
3979
3989
  }
3980
3990
  /**
3981
3991
  * @internal Used by api.ts for configuration access
@@ -4054,7 +4064,7 @@ class Xs extends T {
4054
4064
  async resetIdentity() {
4055
4065
  await this.managers.event?.flushImmediately().catch((t) => (a("debug", "Failed to flush before identity reset", { error: t }), !1)), this.set("identity", void 0), this.clearPersistedIdentity();
4056
4066
  const e = at();
4057
- this.managers.storage.setItem(Se, e), this.set("userId", e), this.set("hasStartSession", !1), this.set("sessionId", null), this.handlers.session?.stopTracking(), this.handlers.session?.startTracking(), a("debug", "Identity reset, new UUID generated");
4067
+ this.managers.storage.setItem(Ee, e), this.set("userId", e), this.set("hasStartSession", !1), this.set("sessionId", null), this.handlers.session?.stopTracking(), this.handlers.session?.startTracking(), a("debug", "Identity reset, new UUID generated");
4058
4068
  }
4059
4069
  /**
4060
4070
  * Returns the project ID used for identity storage scoping.
@@ -4067,7 +4077,7 @@ class Xs extends T {
4067
4077
  */
4068
4078
  persistIdentity(e) {
4069
4079
  try {
4070
- const t = this.getProjectId(), s = ue(t);
4080
+ const t = this.getProjectId(), s = de(t);
4071
4081
  this.managers.storage.setItem(s, JSON.stringify(e));
4072
4082
  } catch {
4073
4083
  a("debug", "Failed to persist identity to localStorage");
@@ -4078,7 +4088,7 @@ class Xs extends T {
4078
4088
  * Also migrates pending identity (set before init) to the project-scoped key.
4079
4089
  */
4080
4090
  loadPersistedIdentity() {
4081
- const e = this.managers.storage, t = this.getProjectId(), s = ue(t);
4091
+ const e = this.managers.storage, t = this.getProjectId(), s = de(t);
4082
4092
  try {
4083
4093
  const r = e.getItem(P);
4084
4094
  if (r) {
@@ -4138,7 +4148,7 @@ class Xs extends T {
4138
4148
  clearPersistedIdentity() {
4139
4149
  try {
4140
4150
  const e = this.managers.storage, t = this.getProjectId();
4141
- e.removeItem(ue(t)), e.removeItem(P);
4151
+ e.removeItem(de(t)), e.removeItem(P);
4142
4152
  } catch {
4143
4153
  a("debug", "Failed to clear persisted identity");
4144
4154
  }
@@ -4156,7 +4166,7 @@ class Xs extends T {
4156
4166
  }
4157
4167
  initializeHandlers() {
4158
4168
  const e = this.get("config");
4159
- this.handlers.session = new ks(
4169
+ this.handlers.session = new Us(
4160
4170
  this.managers.storage,
4161
4171
  this.managers.event
4162
4172
  ), this.handlers.session.startTracking();
@@ -4165,13 +4175,13 @@ class Xs extends T {
4165
4175
  this.set("suppressNextScroll", !1);
4166
4176
  }, 500);
4167
4177
  };
4168
- this.handlers.pageView = new Ds(this.managers.event, t), this.handlers.click = new Us(this.managers.event), this.handlers.scroll = new Fs(this.managers.event), this.handlers.performance = new Bs(this.managers.event), this.handlers.error = new se(this.managers.event, this.emitter);
4178
+ this.handlers.pageView = new Fs(this.managers.event, t), this.handlers.click = new Vs(this.managers.event), this.handlers.scroll = new Hs(this.managers.event), this.handlers.performance = new js(this.managers.event), this.handlers.error = new ne(this.managers.event, this.emitter);
4169
4179
  const s = () => {
4170
4180
  if (this.handlers.pageView?.startTracking(), this.handlers.click?.startTracking(), this.handlers.scroll?.startTracking(), this.handlers.performance?.startTracking().catch((r) => {
4171
4181
  a("warn", "Failed to start performance tracking", { error: r });
4172
4182
  }), this.handlers.error?.startTracking(), e.integrations?.tracelog?.shopify) {
4173
- const r = new xs();
4174
- r.activate(), this.integrationInstances.shopifyCartLinker = r, this.emitter.on(U.EVENT, (i) => {
4183
+ const r = new Bs();
4184
+ r.activate(), this.integrationInstances.shopifyCartLinker = r, this.emitter.on(V.EVENT, (i) => {
4175
4185
  i.type === d.SESSION_START && r.onSessionChange();
4176
4186
  });
4177
4187
  }
@@ -4182,10 +4192,10 @@ class Xs extends T {
4182
4192
  }
4183
4193
  }
4184
4194
  const N = [];
4185
- let f = null, D = !1, A = !1, R = null;
4186
- const js = async (n) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (A = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : f ? { sessionId: f.getSessionId() ?? "" } : (D && R || (D = !0, R = (async () => {
4195
+ let f = null, F = !1, A = !1, R = null;
4196
+ const Ws = async (n) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (A = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : f ? { sessionId: f.getSessionId() ?? "" } : (F && R || (F = !0, R = (async () => {
4187
4197
  try {
4188
- const e = fs(n ?? {}), t = new Xs();
4198
+ const e = ms(n ?? {}), t = new Gs();
4189
4199
  try {
4190
4200
  N.forEach(({ event: o, callback: c }) => {
4191
4201
  t.on(o, c);
@@ -4207,9 +4217,9 @@ const js = async (n) => typeof window > "u" || typeof document > "u" ? { session
4207
4217
  } catch (e) {
4208
4218
  throw f = null, e;
4209
4219
  } finally {
4210
- D = !1, R = null;
4220
+ F = !1, R = null;
4211
4221
  }
4212
- })()), R)), Gs = (n, e, t) => {
4222
+ })()), R)), Ks = (n, e, t) => {
4213
4223
  if (!(typeof window > "u" || typeof document > "u")) {
4214
4224
  if (!f)
4215
4225
  throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
@@ -4217,15 +4227,15 @@ const js = async (n) => typeof window > "u" || typeof document > "u" ? { session
4217
4227
  throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
4218
4228
  f.sendCustomEvent(n, e, t);
4219
4229
  }
4220
- }, Ws = (n, e) => {
4230
+ }, zs = (n, e) => {
4221
4231
  if (!(typeof window > "u" || typeof document > "u")) {
4222
- if (!f || D) {
4232
+ if (!f || F) {
4223
4233
  N.push({ event: n, callback: e });
4224
4234
  return;
4225
4235
  }
4226
4236
  f.on(n, e);
4227
4237
  }
4228
- }, Ks = (n, e) => {
4238
+ }, Qs = (n, e) => {
4229
4239
  if (!(typeof window > "u" || typeof document > "u")) {
4230
4240
  if (!f) {
4231
4241
  const t = N.findIndex((s) => s.event === n && s.callback === e);
@@ -4234,7 +4244,7 @@ const js = async (n) => typeof window > "u" || typeof document > "u" ? { session
4234
4244
  }
4235
4245
  f.off(n, e);
4236
4246
  }
4237
- }, zs = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, Qs = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getSessionId(), Ys = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getUserId(), qs = () => {
4247
+ }, Ys = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, qs = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getSessionId(), Js = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getUserId(), Zs = () => {
4238
4248
  if (!(typeof window > "u" || typeof document > "u")) {
4239
4249
  if (A)
4240
4250
  throw new Error("[TraceLog] Destroy operation already in progress");
@@ -4244,12 +4254,12 @@ const js = async (n) => typeof window > "u" || typeof document > "u" ? { session
4244
4254
  }
4245
4255
  A = !0;
4246
4256
  try {
4247
- f.destroy(), f = null, D = !1, R = null, N.length = 0, A = !1;
4257
+ f.destroy(), f = null, F = !1, R = null, N.length = 0, A = !1;
4248
4258
  } catch (n) {
4249
- f = null, D = !1, R = null, N.length = 0, A = !1, a("warn", "Error during destroy, forced cleanup completed", { error: n });
4259
+ f = null, F = !1, R = null, N.length = 0, A = !1, a("warn", "Error during destroy, forced cleanup completed", { error: n });
4250
4260
  }
4251
4261
  }
4252
- }, Js = (n, e) => {
4262
+ }, en = (n, e) => {
4253
4263
  if (!(typeof window > "u" || typeof document > "u")) {
4254
4264
  if (!n || typeof n != "string" || n.trim().length === 0) {
4255
4265
  a("warn", "identify() called with invalid userId");
@@ -4277,7 +4287,7 @@ const js = async (n) => typeof window > "u" || typeof document > "u" ? { session
4277
4287
  a("debug", "Failed to persist pre-init identity");
4278
4288
  }
4279
4289
  }
4280
- }, Zs = async () => {
4290
+ }, tn = async () => {
4281
4291
  if (!(typeof window > "u" || typeof document > "u")) {
4282
4292
  if (!f) {
4283
4293
  try {
@@ -4290,32 +4300,32 @@ const js = async (n) => typeof window > "u" || typeof document > "u" ? { session
4290
4300
  throw new Error("[TraceLog] Cannot reset identity while TraceLog is being destroyed");
4291
4301
  await f.resetIdentity();
4292
4302
  }
4293
- }, Ln = {
4294
- init: js,
4295
- event: Gs,
4296
- on: Ws,
4297
- off: Ks,
4298
- isInitialized: zs,
4299
- getSessionId: Qs,
4300
- getUserId: Ys,
4301
- destroy: qs,
4302
- identify: Js,
4303
- resetIdentity: Zs
4303
+ }, Cn = {
4304
+ init: Ws,
4305
+ event: Ks,
4306
+ on: zs,
4307
+ off: Qs,
4308
+ isInitialized: Ys,
4309
+ getSessionId: qs,
4310
+ getUserId: Js,
4311
+ destroy: Zs,
4312
+ identify: en,
4313
+ resetIdentity: tn
4304
4314
  };
4305
- var be, L, x, ct, ne, lt = -1, O = function(n) {
4315
+ var be, L, B, ct, re, lt = -1, O = function(n) {
4306
4316
  addEventListener("pageshow", (function(e) {
4307
4317
  e.persisted && (lt = e.timeStamp, n(e));
4308
4318
  }), !0);
4309
4319
  }, Pe = function() {
4310
4320
  var n = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
4311
4321
  if (n && n.responseStart > 0 && n.responseStart < performance.now()) return n;
4312
- }, ie = function() {
4322
+ }, oe = function() {
4313
4323
  var n = Pe();
4314
4324
  return n && n.activationStart || 0;
4315
4325
  }, E = function(n, e) {
4316
4326
  var t = Pe(), s = "navigate";
4317
- return lt >= 0 ? s = "back-forward-cache" : t && (document.prerendering || ie() > 0 ? s = "prerender" : document.wasDiscarded ? s = "restore" : t.type && (s = t.type.replace(/_/g, "-"))), { name: n, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: s };
4318
- }, F = function(n, e, t) {
4327
+ return lt >= 0 ? s = "back-forward-cache" : t && (document.prerendering || oe() > 0 ? s = "prerender" : document.wasDiscarded ? s = "restore" : t.type && (s = t.type.replace(/_/g, "-"))), { name: n, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: s };
4328
+ }, H = function(n, e, t) {
4319
4329
  try {
4320
4330
  if (PerformanceObserver.supportedEntryTypes.includes(n)) {
4321
4331
  var s = new PerformanceObserver((function(r) {
@@ -4340,23 +4350,23 @@ var be, L, x, ct, ne, lt = -1, O = function(n) {
4340
4350
  return n();
4341
4351
  }));
4342
4352
  }));
4343
- }, B = function(n) {
4353
+ }, j = function(n) {
4344
4354
  document.addEventListener("visibilitychange", (function() {
4345
4355
  document.visibilityState === "hidden" && n();
4346
4356
  }));
4347
- }, oe = function(n) {
4357
+ }, ae = function(n) {
4348
4358
  var e = !1;
4349
4359
  return function() {
4350
4360
  e || (n(), e = !0);
4351
4361
  };
4352
4362
  }, k = -1, et = function() {
4353
4363
  return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
4354
- }, re = function(n) {
4355
- document.visibilityState === "hidden" && k > -1 && (k = n.type === "visibilitychange" ? n.timeStamp : 0, en());
4364
+ }, ie = function(n) {
4365
+ document.visibilityState === "hidden" && k > -1 && (k = n.type === "visibilitychange" ? n.timeStamp : 0, sn());
4356
4366
  }, tt = function() {
4357
- addEventListener("visibilitychange", re, !0), addEventListener("prerenderingchange", re, !0);
4358
- }, en = function() {
4359
- removeEventListener("visibilitychange", re, !0), removeEventListener("prerenderingchange", re, !0);
4367
+ addEventListener("visibilitychange", ie, !0), addEventListener("prerenderingchange", ie, !0);
4368
+ }, sn = function() {
4369
+ removeEventListener("visibilitychange", ie, !0), removeEventListener("prerenderingchange", ie, !0);
4360
4370
  }, De = function() {
4361
4371
  return k < 0 && (k = et(), tt(), O((function() {
4362
4372
  setTimeout((function() {
@@ -4365,15 +4375,15 @@ var be, L, x, ct, ne, lt = -1, O = function(n) {
4365
4375
  }))), { get firstHiddenTime() {
4366
4376
  return k;
4367
4377
  } };
4368
- }, X = function(n) {
4378
+ }, G = function(n) {
4369
4379
  document.prerendering ? addEventListener("prerenderingchange", (function() {
4370
4380
  return n();
4371
4381
  }), !0) : n();
4372
4382
  }, Le = [1800, 3e3], ut = function(n, e) {
4373
- e = e || {}, X((function() {
4374
- var t, s = De(), r = E("FCP"), i = F("paint", (function(o) {
4383
+ e = e || {}, G((function() {
4384
+ var t, s = De(), r = E("FCP"), i = H("paint", (function(o) {
4375
4385
  o.forEach((function(c) {
4376
- c.name === "first-contentful-paint" && (i.disconnect(), c.startTime < s.firstHiddenTime && (r.value = Math.max(c.startTime - ie(), 0), r.entries.push(c), t(!0)));
4386
+ c.name === "first-contentful-paint" && (i.disconnect(), c.startTime < s.firstHiddenTime && (r.value = Math.max(c.startTime - oe(), 0), r.entries.push(c), t(!0)));
4377
4387
  }));
4378
4388
  }));
4379
4389
  i && (t = v(n, r, Le, e.reportAllChanges), O((function(o) {
@@ -4382,8 +4392,8 @@ var be, L, x, ct, ne, lt = -1, O = function(n) {
4382
4392
  }));
4383
4393
  })));
4384
4394
  }));
4385
- }, Me = [0.1, 0.25], tn = function(n, e) {
4386
- e = e || {}, ut(oe((function() {
4395
+ }, Me = [0.1, 0.25], nn = function(n, e) {
4396
+ e = e || {}, ut(ae((function() {
4387
4397
  var t, s = E("CLS", 0), r = 0, i = [], o = function(l) {
4388
4398
  l.forEach((function(u) {
4389
4399
  if (!u.hadRecentInput) {
@@ -4391,8 +4401,8 @@ var be, L, x, ct, ne, lt = -1, O = function(n) {
4391
4401
  r && u.startTime - p.startTime < 1e3 && u.startTime - h.startTime < 5e3 ? (r += u.value, i.push(u)) : (r = u.value, i = [u]);
4392
4402
  }
4393
4403
  })), r > s.value && (s.value = r, s.entries = i, t());
4394
- }, c = F("layout-shift", o);
4395
- c && (t = v(n, s, Me, e.reportAllChanges), B((function() {
4404
+ }, c = H("layout-shift", o);
4405
+ c && (t = v(n, s, Me, e.reportAllChanges), j((function() {
4396
4406
  o(c.takeRecords()), t(!0);
4397
4407
  })), O((function() {
4398
4408
  r = 0, s = E("CLS", 0), t = v(n, s, Me, e.reportAllChanges), ke((function() {
@@ -4400,103 +4410,103 @@ var be, L, x, ct, ne, lt = -1, O = function(n) {
4400
4410
  }));
4401
4411
  })), setTimeout(t, 0));
4402
4412
  })));
4403
- }, dt = 0, me = 1 / 0, K = 0, sn = function(n) {
4413
+ }, dt = 0, pe = 1 / 0, Q = 0, rn = function(n) {
4404
4414
  n.forEach((function(e) {
4405
- e.interactionId && (me = Math.min(me, e.interactionId), K = Math.max(K, e.interactionId), dt = K ? (K - me) / 7 + 1 : 0);
4415
+ e.interactionId && (pe = Math.min(pe, e.interactionId), Q = Math.max(Q, e.interactionId), dt = Q ? (Q - pe) / 7 + 1 : 0);
4406
4416
  }));
4407
4417
  }, ht = function() {
4408
4418
  return be ? dt : performance.interactionCount || 0;
4409
- }, nn = function() {
4410
- "interactionCount" in performance || be || (be = F("event", sn, { type: "event", buffered: !0, durationThreshold: 0 }));
4411
- }, I = [], q = /* @__PURE__ */ new Map(), ft = 0, rn = function() {
4419
+ }, on = function() {
4420
+ "interactionCount" in performance || be || (be = H("event", rn, { type: "event", buffered: !0, durationThreshold: 0 }));
4421
+ }, I = [], J = /* @__PURE__ */ new Map(), ft = 0, an = function() {
4412
4422
  var n = Math.min(I.length - 1, Math.floor((ht() - ft) / 50));
4413
4423
  return I[n];
4414
- }, on = [], an = function(n) {
4415
- if (on.forEach((function(r) {
4424
+ }, cn = [], ln = function(n) {
4425
+ if (cn.forEach((function(r) {
4416
4426
  return r(n);
4417
4427
  })), n.interactionId || n.entryType === "first-input") {
4418
- var e = I[I.length - 1], t = q.get(n.interactionId);
4428
+ var e = I[I.length - 1], t = J.get(n.interactionId);
4419
4429
  if (t || I.length < 10 || n.duration > e.latency) {
4420
4430
  if (t) n.duration > t.latency ? (t.entries = [n], t.latency = n.duration) : n.duration === t.latency && n.startTime === t.entries[0].startTime && t.entries.push(n);
4421
4431
  else {
4422
4432
  var s = { id: n.interactionId, latency: n.duration, entries: [n] };
4423
- q.set(s.id, s), I.push(s);
4433
+ J.set(s.id, s), I.push(s);
4424
4434
  }
4425
4435
  I.sort((function(r, i) {
4426
4436
  return i.latency - r.latency;
4427
4437
  })), I.length > 10 && I.splice(10).forEach((function(r) {
4428
- return q.delete(r.id);
4438
+ return J.delete(r.id);
4429
4439
  }));
4430
4440
  }
4431
4441
  }
4432
4442
  }, gt = function(n) {
4433
4443
  var e = self.requestIdleCallback || self.setTimeout, t = -1;
4434
- return n = oe(n), document.visibilityState === "hidden" ? n() : (t = e(n), B(n)), t;
4435
- }, Ce = [200, 500], cn = function(n, e) {
4436
- "PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, X((function() {
4444
+ return n = ae(n), document.visibilityState === "hidden" ? n() : (t = e(n), j(n)), t;
4445
+ }, Ce = [200, 500], un = function(n, e) {
4446
+ "PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, G((function() {
4437
4447
  var t;
4438
- nn();
4448
+ on();
4439
4449
  var s, r = E("INP"), i = function(c) {
4440
4450
  gt((function() {
4441
- c.forEach(an);
4442
- var l = rn();
4451
+ c.forEach(ln);
4452
+ var l = an();
4443
4453
  l && l.latency !== r.value && (r.value = l.latency, r.entries = l.entries, s());
4444
4454
  }));
4445
- }, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
4446
- s = v(n, r, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), B((function() {
4455
+ }, o = H("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
4456
+ s = v(n, r, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), j((function() {
4447
4457
  i(o.takeRecords()), s(!0);
4448
4458
  })), O((function() {
4449
- ft = ht(), I.length = 0, q.clear(), r = E("INP"), s = v(n, r, Ce, e.reportAllChanges);
4459
+ ft = ht(), I.length = 0, J.clear(), r = E("INP"), s = v(n, r, Ce, e.reportAllChanges);
4450
4460
  })));
4451
4461
  })));
4452
- }, Re = [2500, 4e3], pe = {}, ln = function(n, e) {
4453
- e = e || {}, X((function() {
4462
+ }, Re = [2500, 4e3], Se = {}, dn = function(n, e) {
4463
+ e = e || {}, G((function() {
4454
4464
  var t, s = De(), r = E("LCP"), i = function(l) {
4455
4465
  e.reportAllChanges || (l = l.slice(-1)), l.forEach((function(u) {
4456
- u.startTime < s.firstHiddenTime && (r.value = Math.max(u.startTime - ie(), 0), r.entries = [u], t());
4466
+ u.startTime < s.firstHiddenTime && (r.value = Math.max(u.startTime - oe(), 0), r.entries = [u], t());
4457
4467
  }));
4458
- }, o = F("largest-contentful-paint", i);
4468
+ }, o = H("largest-contentful-paint", i);
4459
4469
  if (o) {
4460
4470
  t = v(n, r, Re, e.reportAllChanges);
4461
- var c = oe((function() {
4462
- pe[r.id] || (i(o.takeRecords()), o.disconnect(), pe[r.id] = !0, t(!0));
4471
+ var c = ae((function() {
4472
+ Se[r.id] || (i(o.takeRecords()), o.disconnect(), Se[r.id] = !0, t(!0));
4463
4473
  }));
4464
4474
  ["keydown", "click"].forEach((function(l) {
4465
4475
  addEventListener(l, (function() {
4466
4476
  return gt(c);
4467
4477
  }), { once: !0, capture: !0 });
4468
- })), B(c), O((function(l) {
4478
+ })), j(c), O((function(l) {
4469
4479
  r = E("LCP"), t = v(n, r, Re, e.reportAllChanges), ke((function() {
4470
- r.value = performance.now() - l.timeStamp, pe[r.id] = !0, t(!0);
4480
+ r.value = performance.now() - l.timeStamp, Se[r.id] = !0, t(!0);
4471
4481
  }));
4472
4482
  }));
4473
4483
  }
4474
4484
  }));
4475
- }, Ne = [800, 1800], un = function n(e) {
4476
- document.prerendering ? X((function() {
4485
+ }, Ne = [800, 1800], hn = function n(e) {
4486
+ document.prerendering ? G((function() {
4477
4487
  return n(e);
4478
4488
  })) : document.readyState !== "complete" ? addEventListener("load", (function() {
4479
4489
  return n(e);
4480
4490
  }), !0) : setTimeout(e, 0);
4481
- }, dn = function(n, e) {
4491
+ }, fn = function(n, e) {
4482
4492
  e = e || {};
4483
4493
  var t = E("TTFB"), s = v(n, t, Ne, e.reportAllChanges);
4484
- un((function() {
4494
+ hn((function() {
4485
4495
  var r = Pe();
4486
- r && (t.value = Math.max(r.responseStart - ie(), 0), t.entries = [r], s(!0), O((function() {
4496
+ r && (t.value = Math.max(r.responseStart - oe(), 0), t.entries = [r], s(!0), O((function() {
4487
4497
  t = E("TTFB", 0), (s = v(n, t, Ne, e.reportAllChanges))(!0);
4488
4498
  })));
4489
4499
  }));
4490
- }, H = { passive: !0, capture: !0 }, hn = /* @__PURE__ */ new Date(), st = function(n, e) {
4491
- L || (L = e, x = n, ct = /* @__PURE__ */ new Date(), pt(removeEventListener), mt());
4500
+ }, $ = { passive: !0, capture: !0 }, gn = /* @__PURE__ */ new Date(), st = function(n, e) {
4501
+ L || (L = e, B = n, ct = /* @__PURE__ */ new Date(), pt(removeEventListener), mt());
4492
4502
  }, mt = function() {
4493
- if (x >= 0 && x < ct - hn) {
4494
- var n = { entryType: "first-input", name: L.type, target: L.target, cancelable: L.cancelable, startTime: L.timeStamp, processingStart: L.timeStamp + x };
4495
- ne.forEach((function(e) {
4503
+ if (B >= 0 && B < ct - gn) {
4504
+ var n = { entryType: "first-input", name: L.type, target: L.target, cancelable: L.cancelable, startTime: L.timeStamp, processingStart: L.timeStamp + B };
4505
+ re.forEach((function(e) {
4496
4506
  e(n);
4497
- })), ne = [];
4507
+ })), re = [];
4498
4508
  }
4499
- }, fn = function(n) {
4509
+ }, mn = function(n) {
4500
4510
  if (n.cancelable) {
4501
4511
  var e = (n.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - n.timeStamp;
4502
4512
  n.type == "pointerdown" ? (function(t, s) {
@@ -4505,31 +4515,31 @@ var be, L, x, ct, ne, lt = -1, O = function(n) {
4505
4515
  }, i = function() {
4506
4516
  o();
4507
4517
  }, o = function() {
4508
- removeEventListener("pointerup", r, H), removeEventListener("pointercancel", i, H);
4518
+ removeEventListener("pointerup", r, $), removeEventListener("pointercancel", i, $);
4509
4519
  };
4510
- addEventListener("pointerup", r, H), addEventListener("pointercancel", i, H);
4520
+ addEventListener("pointerup", r, $), addEventListener("pointercancel", i, $);
4511
4521
  })(e, n) : st(e, n);
4512
4522
  }
4513
4523
  }, pt = function(n) {
4514
4524
  ["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
4515
- return n(e, fn, H);
4525
+ return n(e, mn, $);
4516
4526
  }));
4517
- }, Oe = [100, 300], gn = function(n, e) {
4518
- e = e || {}, X((function() {
4527
+ }, Oe = [100, 300], pn = function(n, e) {
4528
+ e = e || {}, G((function() {
4519
4529
  var t, s = De(), r = E("FID"), i = function(l) {
4520
4530
  l.startTime < s.firstHiddenTime && (r.value = l.processingStart - l.startTime, r.entries.push(l), t(!0));
4521
4531
  }, o = function(l) {
4522
4532
  l.forEach(i);
4523
- }, c = F("first-input", o);
4524
- t = v(n, r, Oe, e.reportAllChanges), c && (B(oe((function() {
4533
+ }, c = H("first-input", o);
4534
+ t = v(n, r, Oe, e.reportAllChanges), c && (j(ae((function() {
4525
4535
  o(c.takeRecords()), c.disconnect();
4526
4536
  }))), O((function() {
4527
4537
  var l;
4528
- r = E("FID"), t = v(n, r, Oe, e.reportAllChanges), ne = [], x = -1, L = null, pt(addEventListener), l = i, ne.push(l), mt();
4538
+ r = E("FID"), t = v(n, r, Oe, e.reportAllChanges), re = [], B = -1, L = null, pt(addEventListener), l = i, re.push(l), mt();
4529
4539
  })));
4530
4540
  }));
4531
4541
  };
4532
- const mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4542
+ const Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4533
4543
  __proto__: null,
4534
4544
  CLSThresholds: Me,
4535
4545
  FCPThresholds: Le,
@@ -4537,44 +4547,44 @@ const mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4537
4547
  INPThresholds: Ce,
4538
4548
  LCPThresholds: Re,
4539
4549
  TTFBThresholds: Ne,
4540
- onCLS: tn,
4550
+ onCLS: nn,
4541
4551
  onFCP: ut,
4542
- onFID: gn,
4543
- onINP: cn,
4544
- onLCP: ln,
4545
- onTTFB: dn
4552
+ onFID: pn,
4553
+ onINP: un,
4554
+ onLCP: dn,
4555
+ onTTFB: fn
4546
4556
  }, Symbol.toStringTag, { value: "Module" }));
4547
4557
  export {
4548
4558
  m as AppConfigValidationError,
4549
- pn as DEFAULT_SESSION_TIMEOUT,
4550
- _e as DEFAULT_WEB_VITALS_MODE,
4559
+ En as DEFAULT_SESSION_TIMEOUT,
4560
+ ye as DEFAULT_WEB_VITALS_MODE,
4551
4561
  w as DeviceType,
4552
- U as EmitterEvent,
4553
- V as ErrorType,
4562
+ V as EmitterEvent,
4563
+ x as ErrorType,
4554
4564
  d as EventType,
4555
- An as InitializationTimeoutError,
4565
+ Ln as InitializationTimeoutError,
4556
4566
  Xe as IntegrationValidationError,
4557
- wn as MAX_ARRAY_LENGTH,
4558
- Tn as MAX_CUSTOM_EVENT_ARRAY_SIZE,
4559
- vn as MAX_CUSTOM_EVENT_KEYS,
4560
- Sn as MAX_CUSTOM_EVENT_NAME_LENGTH,
4561
- En as MAX_CUSTOM_EVENT_STRING_SIZE,
4562
- _n as MAX_NESTED_OBJECT_KEYS,
4563
- yn as MAX_STRING_LENGTH,
4564
- In as MAX_STRING_LENGTH_IN_ARRAY,
4565
- ee as Mode,
4566
- us as PII_PATTERNS,
4567
+ bn as MAX_ARRAY_LENGTH,
4568
+ yn as MAX_CUSTOM_EVENT_ARRAY_SIZE,
4569
+ _n as MAX_CUSTOM_EVENT_KEYS,
4570
+ vn as MAX_CUSTOM_EVENT_NAME_LENGTH,
4571
+ Tn as MAX_CUSTOM_EVENT_STRING_SIZE,
4572
+ In as MAX_NESTED_OBJECT_KEYS,
4573
+ wn as MAX_STRING_LENGTH,
4574
+ An as MAX_STRING_LENGTH_IN_ARRAY,
4575
+ te as Mode,
4576
+ hs as PII_PATTERNS,
4567
4577
  C as PermanentError,
4568
- J as RateLimitError,
4578
+ Z as RateLimitError,
4569
4579
  Be as SamplingRateValidationError,
4570
- Ee as ScrollDirection,
4580
+ ve as ScrollDirection,
4571
4581
  bt as SessionTimeoutValidationError,
4572
4582
  M as SpecialApiUrl,
4573
- Z as TimeoutError,
4574
- $ as TraceLogValidationError,
4575
- bn as WEB_VITALS_GOOD_THRESHOLDS,
4583
+ ee as TimeoutError,
4584
+ X as TraceLogValidationError,
4585
+ Mn as WEB_VITALS_GOOD_THRESHOLDS,
4576
4586
  ze as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
4577
- Yt as WEB_VITALS_POOR_THRESHOLDS,
4587
+ qt as WEB_VITALS_POOR_THRESHOLDS,
4578
4588
  Qe as getWebVitalsThresholds,
4579
- Ln as tracelog
4589
+ Cn as tracelog
4580
4590
  };