@tracelog/lib 3.1.0 → 3.1.1-rc.118.4

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,7 +1,7 @@
1
- const dn = 9e5;
2
- const hn = 120, fn = 49152, gn = 100, mn = 500, pn = 200;
3
- const Sn = 1e3, En = 500, vn = 1e3;
4
- const L = "data-tlog", Et = [
1
+ const fn = 9e5;
2
+ const gn = 120, mn = 49152, pn = 100, Sn = 500, En = 200;
3
+ const vn = 1e3, Tn = 500, _n = 1e3;
4
+ const L = "data-tlog", vt = [
5
5
  "button",
6
6
  "a",
7
7
  'input[type="button"]',
@@ -33,7 +33,7 @@ const L = "data-tlog", Et = [
33
33
  ".menu-item",
34
34
  "[data-testid]",
35
35
  '[tabindex="0"]'
36
- ], vt = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], Tt = [
36
+ ], Tt = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], _t = [
37
37
  "token",
38
38
  "auth",
39
39
  "key",
@@ -60,15 +60,15 @@ const y = {
60
60
  INVALID_CLICK_THROTTLE: "Click throttle must be a non-negative number",
61
61
  INVALID_MAX_SAME_EVENT_PER_MINUTE: "Max same event per minute must be a positive number",
62
62
  INVALID_SEND_INTERVAL: "Send interval must be between 1000ms (1 second) and 60000ms (60 seconds)"
63
- }, _t = [
63
+ }, yt = [
64
64
  /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
65
65
  /javascript:/gi,
66
66
  /on\w+\s*=/gi,
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`, st = "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`, yt = (n) => n ? `${g}:${n}:session` : `${g}:session`, It = (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`, O = `${g}:pending_identity`;
71
- var F = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(F || {}), w = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(w || {}), D = /* @__PURE__ */ ((n) => (n.EVENT = "event", n.QUEUE = "queue", n))(D || {});
70
+ ], g = "tlog", Q = `${g}:qa_mode`, Ee = `${g}:uid`, nt = "tlog_mode", Fe = "qa", Ve = "qa_off", le = (n) => n ? `${g}:${n}:queue` : `${g}:queue`, ue = (n) => n ? `${g}:${n}:rate_limit` : `${g}:rate_limit`, It = (n) => n ? `${g}:${n}:session` : `${g}:session`, wt = (n) => n ? `${g}:${n}:broadcast` : `${g}:broadcast`, He = (n, e) => `${g}:${n}:session_counts:${e}`, xe = 10080 * 60 * 1e3, $e = `${g}:session_counts_last_cleanup`, Be = 3600 * 1e3, de = (n) => n ? `${g}:${n}:identity` : `${g}:identity`, O = `${g}:pending_identity`;
71
+ var V = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(V || {}), w = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(w || {}), D = /* @__PURE__ */ ((n) => (n.EVENT = "event", n.QUEUE = "queue", n))(D || {});
72
72
  class M 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, M);
@@ -76,57 +76,57 @@ class M 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 || {}), H = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n))(H || {}), te = /* @__PURE__ */ ((n) => (n.QA = "qa", n))(te || {});
90
+ class B 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 B {
98
98
  constructor(e, t = "config") {
99
99
  super(e, "APP_CONFIG_INVALID", t);
100
100
  }
101
101
  }
102
- class wt extends $ {
102
+ class At extends B {
103
103
  constructor(e, t = "config") {
104
104
  super(e, "SESSION_TIMEOUT_INVALID", t);
105
105
  }
106
106
  }
107
- class Be extends $ {
107
+ class Xe extends B {
108
108
  constructor(e, t = "config") {
109
109
  super(e, "SAMPLING_RATE_INVALID", t);
110
110
  }
111
111
  }
112
- class Xe extends $ {
112
+ class F extends B {
113
113
  constructor(e, t = "config") {
114
114
  super(e, "INTEGRATION_INVALID", t);
115
115
  }
116
116
  }
117
- class Tn extends $ {
117
+ class yn extends B {
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 At = ["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
- return At.forEach((s) => {
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
- }, Lt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", bt = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Mt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Ct = (n, e) => {
129
+ }, bt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Mt = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Ct = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Rt = (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 At = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], de = () => {
145
145
  return `[TraceLog] ${n}: ${String(e)}`;
146
146
  }
147
147
  return `[TraceLog] ${n}`;
148
- }, Rt = () => {
148
+ }, Nt = () => {
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(Q) === "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 ? Ct(e, s) : `[TraceLog] ${e}`, u = n === "error" ? "error" : n === "warn" ? "warn" : "log";
158
- if (!Nt(c, i))
157
+ const { error: s, data: r, showToClient: i = !1, style: o, visibility: c } = t ?? {}, l = s ? Rt(e, s) : `[TraceLog] ${e}`, u = n === "error" ? "error" : n === "warn" ? "warn" : "log";
158
+ if (!Ot(c, i))
159
159
  return;
160
- const p = Ot(c, o), S = r !== void 0 ? ve(r) : void 0;
161
- Pt(u, l, p, S);
162
- }, Nt = (n, e) => n === "critical" ? !0 : n === "qa" || e ? Rt() : !1, Ot = (n, e) => e !== void 0 && e !== "" ? e : n === "critical" ? Mt : "", Pt = (n, e, t, s) => {
160
+ const p = Pt(c, o), S = r !== void 0 ? Te(r) : void 0;
161
+ kt(u, l, p, S);
162
+ }, Ot = (n, e) => n === "critical" ? !0 : n === "qa" || e ? Nt() : !1, Pt = (n, e) => e !== void 0 && e !== "" ? e : n === "critical" ? Ct : "", kt = (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 At = ["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, nt;
180
- const kt = () => {
181
- typeof window < "u" && !Te && (Te = window.matchMedia("(pointer: coarse)"), nt = window.matchMedia("(hover: none)"));
182
- }, te = "Unknown", Dt = (n) => {
179
+ let _e, rt;
180
+ const Dt = () => {
181
+ typeof window < "u" && !_e && (_e = window.matchMedia("(pointer: coarse)"), rt = window.matchMedia("(hover: none)"));
182
+ }, se = "Unknown", Ut = (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 kt = () => {
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
- }, Ut = (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
+ }, Ft = (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 kt = () => {
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
- }, Ft = () => {
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
+ }, Vt = () => {
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
- kt();
213
- const e = window.innerWidth, t = Te?.matches ?? !1, s = nt?.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
+ Dt();
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
- }, Vt = () => {
218
+ }, Ht = () => {
219
219
  try {
220
220
  const n = navigator;
221
221
  return {
222
- type: Ft(),
223
- os: Dt(n),
224
- browser: Ut(n)
222
+ type: Vt(),
223
+ os: Ut(n),
224
+ browser: Ft(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
- }, Ge = 500, We = 2e3, je = 5e3, Q = 50, Ht = Q * 2, rt = 1, xt = 1e3, $t = 10, Ke = 5e3, Bt = 3, Xt = 200, Gt = 6e4, Wt = 64, _n = {
233
+ }, Ge = 500, We = 2e3, je = 5e3, Y = 50, xt = Y * 2, it = 1, $t = 1e3, Bt = 10, Ke = 5e3, Xt = 3, Gt = 200, Wt = 6e4, jt = 64, In = {
234
234
  LCP: 2500,
235
235
  FCP: 1800,
236
236
  CLS: 0.1,
@@ -242,48 +242,48 @@ const kt = () => {
242
242
  CLS: 0.1,
243
243
  INP: 200,
244
244
  TTFB: 800
245
- }, jt = {
245
+ }, Kt = {
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 jt;
258
+ return Kt;
259
259
  default:
260
260
  return ze;
261
261
  }
262
- }, Kt = 50, zt = "3.0.0", Qt = zt, Yt = () => typeof window < "u" && typeof sessionStorage < "u", qt = () => {
262
+ }, zt = 50, Qt = "3.1.1", Yt = Qt, qt = () => typeof window < "u" && typeof sessionStorage < "u", Jt = () => {
263
263
  try {
264
264
  const n = new URLSearchParams(window.location.search);
265
- n.delete(st);
265
+ n.delete(nt);
266
266
  const e = n.toString(), t = window.location.pathname + (e ? "?" + e : "") + window.location.hash;
267
267
  window.history.replaceState({}, "", t);
268
268
  } catch {
269
269
  }
270
- }, Jt = () => {
271
- if (!Yt())
270
+ }, Zt = () => {
271
+ if (!qt())
272
272
  return !1;
273
273
  try {
274
- const e = new URLSearchParams(window.location.search).get(st), t = sessionStorage.getItem(z);
274
+ const e = new URLSearchParams(window.location.search).get(nt), t = sessionStorage.getItem(Q);
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: Lt
279
- })) : e === Fe && (s = !1, sessionStorage.setItem(z, "false"), a("info", "QA Mode DISABLED", {
276
+ return e === Fe ? (s = !0, sessionStorage.setItem(Q, "true"), a("info", "QA Mode ACTIVE", {
280
277
  visibility: "qa",
281
278
  style: bt
282
- })), (e === Ue || e === Fe) && qt(), s ?? t === "true";
279
+ })) : e === Ve && (s = !1, sessionStorage.setItem(Q, "false"), a("info", "QA Mode DISABLED", {
280
+ visibility: "qa",
281
+ style: Mt
282
+ })), (e === Fe || e === Ve) && Jt(), s ?? t === "true";
283
283
  } catch {
284
284
  return !1;
285
285
  }
286
- }, it = () => typeof document < "u" && document.prerendering === !0, Zt = [
286
+ }, ot = () => typeof document < "u" && document.prerendering === !0, es = [
287
287
  "co.uk",
288
288
  "org.uk",
289
289
  "com.au",
@@ -300,35 +300,35 @@ const kt = () => {
300
300
  if (e.length <= 2)
301
301
  return n.toLowerCase();
302
302
  const t = e.slice(-2).join(".");
303
- return Zt.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
304
- }, es = (n, e) => n === e ? !0 : Ye(n) === Ye(e), he = () => {
303
+ return es.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
304
+ }, ts = (n, e) => n === e ? !0 : Ye(n) === Ye(e), fe = () => {
305
305
  const n = document.referrer;
306
306
  if (!n)
307
307
  return "Direct";
308
308
  try {
309
309
  const e = new URL(n).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
310
- return es(e, t) ? "Direct" : n;
310
+ return ts(e, t) ? "Direct" : n;
311
311
  } catch (e) {
312
312
  return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: n } }), n;
313
313
  }
314
- }, fe = () => {
314
+ }, ge = () => {
315
315
  const n = new URLSearchParams(window.location.search), e = {};
316
- return vt.forEach((s) => {
316
+ return Tt.forEach((s) => {
317
317
  const r = n.get(s);
318
318
  if (r) {
319
319
  const i = s.split("utm_")[1];
320
320
  e[i] = r;
321
321
  }
322
322
  }), Object.keys(e).length ? e : void 0;
323
- }, ot = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (n) => {
323
+ }, at = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (n) => {
324
324
  const e = Math.random() * 16 | 0;
325
325
  return (n === "x" ? e : e & 3 | 8).toString(16);
326
326
  });
327
- let W = 0, j = 0;
328
- const ts = () => {
327
+ let j = 0, K = 0;
328
+ const ss = () => {
329
329
  let n = Date.now();
330
- n < j && (n = j), n === j ? W = (W + 1) % 1e3 : W = 0, j = n;
331
- const e = W.toString().padStart(3, "0");
330
+ n < K && (n = K), n === K ? j = (j + 1) % 1e3 : j = 0, K = n;
331
+ const e = j.toString().padStart(3, "0");
332
332
  let t = "";
333
333
  try {
334
334
  if (typeof crypto < "u" && crypto.getRandomValues) {
@@ -338,13 +338,13 @@ const ts = () => {
338
338
  } catch {
339
339
  }
340
340
  return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${n}-${e}-${t}`;
341
- }, ss = (n) => {
341
+ }, ns = (n) => {
342
342
  try {
343
343
  return new URL(n).protocol === "https:";
344
344
  } catch {
345
345
  return !1;
346
346
  }
347
- }, ns = (n) => {
347
+ }, rs = (n) => {
348
348
  try {
349
349
  const t = new URL(window.location.href).hostname;
350
350
  if (!t || typeof t != "string")
@@ -362,20 +362,20 @@ const ts = () => {
362
362
  if (!r || r.split(".").length < 2)
363
363
  throw new Error("Invalid domain structure for SaaS");
364
364
  const i = `https://${n}.${r}/collect`;
365
- if (!ss(i))
365
+ if (!ns(i))
366
366
  throw new Error("Generated URL failed validation");
367
367
  return i;
368
368
  } catch (e) {
369
369
  throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
370
370
  }
371
- }, rs = (n) => {
371
+ }, is = (n) => {
372
372
  const e = {};
373
- return n.integrations?.tracelog?.projectId && (e.saas = ns(n.integrations.tracelog.projectId)), e;
374
- }, ye = (n, e = []) => {
373
+ return n.integrations?.tracelog?.projectId && (e.saas = n.integrations.tracelog.collectUrl ?? rs(n.integrations.tracelog.projectId)), e;
374
+ }, Ie = (n, e = []) => {
375
375
  if (!n || typeof n != "string")
376
376
  return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof n } }), n || "";
377
377
  try {
378
- const t = new URL(n), s = t.searchParams, r = [.../* @__PURE__ */ new Set([...Tt, ...e])];
378
+ const t = new URL(n), s = t.searchParams, r = [.../* @__PURE__ */ new Set([..._t, ...e])];
379
379
  let i = !1;
380
380
  const o = [];
381
381
  return r.forEach((c) => {
@@ -390,7 +390,7 @@ const ts = () => {
390
390
  let e = n;
391
391
  n.length > 1e3 && (e = n.slice(0, Math.max(0, 1e3)));
392
392
  let t = 0;
393
- for (const r of _t) {
393
+ for (const r of yt) {
394
394
  const i = e;
395
395
  e = e.replace(r, ""), i !== e && t++;
396
396
  }
@@ -400,7 +400,7 @@ const ts = () => {
400
400
  valueLength: n.length
401
401
  }
402
402
  }), e.trim();
403
- }, Ie = (n, e = 0) => {
403
+ }, we = (n, e = 0) => {
404
404
  if (n == null)
405
405
  return null;
406
406
  if (typeof n == "string")
@@ -412,30 +412,30 @@ const ts = () => {
412
412
  if (e > 10)
413
413
  return null;
414
414
  if (Array.isArray(n))
415
- return n.slice(0, 1e3).map((r) => Ie(r, e + 1)).filter((r) => r !== null);
415
+ return n.slice(0, 1e3).map((r) => we(r, e + 1)).filter((r) => r !== null);
416
416
  if (typeof n == "object") {
417
417
  const t = {}, r = Object.entries(n).slice(0, 200);
418
418
  for (const [i, o] of r) {
419
419
  const c = qe(i);
420
420
  if (c) {
421
- const l = Ie(o, e + 1);
421
+ const l = we(o, e + 1);
422
422
  l !== null && (t[c] = l);
423
423
  }
424
424
  }
425
425
  return t;
426
426
  }
427
427
  return null;
428
- }, is = (n) => {
428
+ }, os = (n) => {
429
429
  if (typeof n != "object" || n === null)
430
430
  return {};
431
431
  try {
432
- const e = Ie(n);
432
+ const e = we(n);
433
433
  return typeof e == "object" && e !== null ? e : {};
434
434
  } catch (e) {
435
435
  const t = e instanceof Error ? e.message : String(e);
436
436
  throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
437
437
  }
438
- }, os = [
438
+ }, as = [
439
439
  // Email addresses.
440
440
  // Quantifiers are bounded (local part ≤64, each label ≤63, TLD ≤63 per RFC/DNS limits)
441
441
  // and the domain is matched as discrete dot-separated labels so the local-part and
@@ -456,20 +456,20 @@ const ts = () => {
456
456
  /:\/\/[^:/]+:([^@]+)@/gi,
457
457
  // Sensitive URL query parameters (token=, password=, auth=, secret=, api_key=, …)
458
458
  /[?&](token|password|passwd|auth|secret|secret_key|private_key|auth_key|api_key|apikey|access_token)=[^&\s]+/gi
459
- ], Y = (n) => {
459
+ ], q = (n) => {
460
460
  let e = n;
461
- for (const t of os)
461
+ for (const t of as)
462
462
  e = e.replace(t, "[REDACTED]");
463
463
  return e;
464
- }, as = (n) => {
464
+ }, cs = (n) => {
465
465
  if (n !== void 0 && (n === null || typeof n != "object"))
466
466
  throw new m("Configuration must be an object", "config");
467
467
  if (n) {
468
468
  if (n.sessionTimeout !== void 0 && (typeof n.sessionTimeout != "number" || n.sessionTimeout < 3e4 || n.sessionTimeout > 864e5))
469
- throw new wt(y.INVALID_SESSION_TIMEOUT, "config");
469
+ throw new At(y.INVALID_SESSION_TIMEOUT, "config");
470
470
  if (n.globalMetadata !== void 0 && (typeof n.globalMetadata != "object" || n.globalMetadata === null))
471
471
  throw new m(y.INVALID_GLOBAL_METADATA, "config");
472
- if (n.integrations && cs(n.integrations), n.sensitiveQueryParams !== void 0) {
472
+ if (n.integrations && ls(n.integrations), n.sensitiveQueryParams !== void 0) {
473
473
  if (!Array.isArray(n.sensitiveQueryParams))
474
474
  throw new m(y.INVALID_SENSITIVE_QUERY_PARAMS, "config");
475
475
  for (const e of n.sensitiveQueryParams)
@@ -477,9 +477,9 @@ const ts = () => {
477
477
  throw new m("All sensitive query params must be strings", "config");
478
478
  }
479
479
  if (n.errorSampling !== void 0 && (typeof n.errorSampling != "number" || n.errorSampling < 0 || n.errorSampling > 1))
480
- throw new Be(y.INVALID_ERROR_SAMPLING_RATE, "config");
480
+ throw new Xe(y.INVALID_ERROR_SAMPLING_RATE, "config");
481
481
  if (n.samplingRate !== void 0 && (typeof n.samplingRate != "number" || n.samplingRate < 0 || n.samplingRate > 1))
482
- throw new Be(y.INVALID_SAMPLING_RATE, "config");
482
+ throw new Xe(y.INVALID_SAMPLING_RATE, "config");
483
483
  if (n.pageViewThrottleMs !== void 0 && (typeof n.pageViewThrottleMs != "number" || n.pageViewThrottleMs < 0))
484
484
  throw new m(y.INVALID_PAGE_VIEW_THROTTLE, "config");
485
485
  if (n.clickThrottleMs !== void 0 && (typeof n.clickThrottleMs != "number" || n.clickThrottleMs < 0))
@@ -529,19 +529,32 @@ const ts = () => {
529
529
  }
530
530
  }
531
531
  }
532
- }, cs = (n) => {
532
+ }, ls = (n) => {
533
533
  if (n && n.tracelog) {
534
534
  if (!n.tracelog.projectId || typeof n.tracelog.projectId != "string" || n.tracelog.projectId.trim() === "")
535
- throw new Xe(y.INVALID_TRACELOG_PROJECT_ID, "config");
535
+ throw new F(y.INVALID_TRACELOG_PROJECT_ID, "config");
536
536
  if (n.tracelog.shopify !== void 0 && typeof n.tracelog.shopify != "boolean")
537
- throw new Xe("tracelog.shopify must be a boolean", "config");
537
+ throw new F("tracelog.shopify must be a boolean", "config");
538
+ if (n.tracelog.collectUrl !== void 0) {
539
+ const e = "tracelog.collectUrl must be a non-empty HTTPS URL", { collectUrl: t } = n.tracelog;
540
+ if (typeof t != "string" || t.trim() === "")
541
+ throw new F(e, "config");
542
+ let s;
543
+ try {
544
+ s = new URL(t);
545
+ } catch {
546
+ throw new F(e, "config");
547
+ }
548
+ if (s.protocol !== "https:")
549
+ throw new F(e, "config");
550
+ }
538
551
  }
539
- }, ls = (n) => (as(n), {
552
+ }, us = (n) => (cs(n), {
540
553
  ...n ?? {},
541
554
  sessionTimeout: n?.sessionTimeout ?? 9e5,
542
555
  globalMetadata: n?.globalMetadata ?? {},
543
556
  sensitiveQueryParams: n?.sensitiveQueryParams ?? [],
544
- errorSampling: n?.errorSampling ?? rt,
557
+ errorSampling: n?.errorSampling ?? it,
545
558
  samplingRate: n?.samplingRate ?? 1,
546
559
  pageViewThrottleMs: n?.pageViewThrottleMs ?? 1e3,
547
560
  clickThrottleMs: n?.clickThrottleMs ?? 300,
@@ -549,18 +562,18 @@ const ts = () => {
549
562
  sendIntervalMs: n?.sendIntervalMs ?? 1e4,
550
563
  flushOnSpaNavigation: n?.flushOnSpaNavigation ?? !1,
551
564
  flushOnPageHidden: n?.flushOnPageHidden ?? !0
552
- }), we = (n, e = /* @__PURE__ */ new Set()) => {
565
+ }), Ae = (n, e = /* @__PURE__ */ new Set()) => {
553
566
  if (n == null)
554
567
  return !0;
555
568
  const t = typeof n;
556
- 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
- }, us = (n) => typeof n != "object" || n === null ? !1 : we(n), Ae = (n) => {
569
+ 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) => Ae(s, e)) : t === "object" ? Object.values(n).every((s) => Ae(s, e)) : !1);
570
+ }, ds = (n) => typeof n != "object" || n === null ? !1 : Ae(n), Le = (n) => {
558
571
  if (typeof n != "object" || n === null || Array.isArray(n)) return;
559
572
  const e = {};
560
573
  for (const [t, s] of Object.entries(n))
561
574
  typeof s == "string" && (e[t] = s);
562
575
  return Object.keys(e).length > 0 ? e : void 0;
563
- }, ds = (n) => typeof n != "string" ? {
576
+ }, hs = (n) => typeof n != "string" ? {
564
577
  valid: !1,
565
578
  error: "Event name must be a string"
566
579
  } : n.length === 0 ? {
@@ -576,8 +589,8 @@ const ts = () => {
576
589
  valid: !1,
577
590
  error: "Event name cannot be a reserved word"
578
591
  } : { valid: !0 }, Je = (n, e, t) => {
579
- const s = is(e), r = `${t} "${n}" metadata error`;
580
- if (!us(s))
592
+ const s = os(e), r = `${t} "${n}" metadata error`;
593
+ if (!ds(s))
581
594
  return {
582
595
  valid: !1,
583
596
  error: `${r}: object has invalid types. Valid types are string, number, boolean or string arrays.`
@@ -625,7 +638,7 @@ const ts = () => {
625
638
  valid: !0,
626
639
  sanitizedMetadata: s
627
640
  };
628
- }, hs = (n, e, t) => {
641
+ }, fs = (n, e, t) => {
629
642
  if (Array.isArray(e)) {
630
643
  const s = [], r = `${t} "${n}" metadata error`;
631
644
  for (let i = 0; i < e.length; i++) {
@@ -649,15 +662,15 @@ const ts = () => {
649
662
  };
650
663
  }
651
664
  return Je(n, e, t);
652
- }, fs = (n, e) => {
653
- const t = ds(n);
665
+ }, gs = (n, e) => {
666
+ const t = hs(n);
654
667
  if (!t.valid)
655
668
  return a("error", "Event name validation failed", {
656
669
  data: { eventName: n, error: t.error }
657
670
  }), t;
658
671
  if (!e)
659
672
  return { valid: !0 };
660
- const s = hs(n, e, "customEvent");
673
+ const s = fs(n, e, "customEvent");
661
674
  return s.valid || a("error", "Event metadata validation failed", {
662
675
  data: {
663
676
  eventName: n,
@@ -665,7 +678,7 @@ const ts = () => {
665
678
  }
666
679
  }), s;
667
680
  };
668
- class gs {
681
+ class ms {
669
682
  listeners = /* @__PURE__ */ new Map();
670
683
  /**
671
684
  * Subscribes to an event channel
@@ -782,36 +795,53 @@ class gs {
782
795
  this.listeners.clear();
783
796
  }
784
797
  }
785
- const ms = /https?:\/\/\S+/g, ps = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, Ss = /0x[0-9a-fA-F]{4,}/g, Es = /(?<!\d)\d{4,}(?!\d)/g, vs = /(['"])[^'"]{20,}\1/g;
786
- function Ts(n) {
787
- return n.replace(ms, "[URL]").replace(ps, "[ID]").replace(Ss, "[ADDR]").replace(Es, "[N]").replace(vs, "$1[VAR]$1").toLowerCase().trim();
788
- }
798
+ const ps = /https?:\/\/\S+/g, Ss = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, Es = /0x[0-9a-fA-F]{4,}/g, vs = /(?<!\d)\d{4,}(?!\d)/g, Ts = /(['"])[^'"]{20,}\1/g;
789
799
  function _s(n) {
790
- const e = Ts(n.message), t = (n.filename ?? "").trim(), s = t.search(/[?#]/), r = s === -1 ? t : t.slice(0, s), i = n.line == null ? "" : String(n.line);
791
- return `${e}|${r}|${i}`;
800
+ return n.replace(ps, "[URL]").replace(Ss, "[ID]").replace(Es, "[ADDR]").replace(vs, "[N]").replace(Ts, "$1[VAR]$1").toLowerCase().trim();
792
801
  }
793
- const ge = { config: {} };
802
+ function Ze(n) {
803
+ const e = n.search(/[?#]/);
804
+ return e === -1 ? n : n.slice(0, e);
805
+ }
806
+ function ys(n, e) {
807
+ const t = Ze((n ?? "").trim());
808
+ if (!t) return "";
809
+ let s;
810
+ try {
811
+ s = new URL(t);
812
+ } catch {
813
+ return t;
814
+ }
815
+ if (s.protocol !== "http:" && s.protocol !== "https:") return "";
816
+ const r = Ze((e ?? "").trim());
817
+ return r && t === r ? s.origin : t;
818
+ }
819
+ function Is(n) {
820
+ const e = _s(n.message), t = ys(n.filename, n.page_url), s = n.line == null ? "" : String(n.line);
821
+ return `${e}|${t}|${s}`;
822
+ }
823
+ const me = { config: {} };
794
824
  class T {
795
825
  /**
796
826
  * Retrieves a value from global state.
797
827
  */
798
828
  get(e) {
799
- return ge[e];
829
+ return me[e];
800
830
  }
801
831
  /**
802
832
  * Sets a value in global state.
803
833
  */
804
834
  set(e, t) {
805
- ge[e] = t;
835
+ me[e] = t;
806
836
  }
807
837
  /**
808
838
  * Returns an immutable snapshot of the entire global state.
809
839
  */
810
840
  getState() {
811
- return { ...ge };
841
+ return { ...me };
812
842
  }
813
843
  }
814
- class ys extends T {
844
+ class ws extends T {
815
845
  storeManager;
816
846
  apiUrl;
817
847
  lastPermanentErrorLog = null;
@@ -856,7 +886,7 @@ class ys extends T {
856
886
  * cases so the migration is one-shot per browser.
857
887
  */
858
888
  migrateLegacyV2Keys() {
859
- 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`;
860
890
  try {
861
891
  const o = this.storeManager.getItem(t);
862
892
  if (o) {
@@ -902,11 +932,11 @@ class ys extends T {
902
932
  }
903
933
  getQueueStorageKey() {
904
934
  const e = this.get("userId") || "anonymous";
905
- return ce(e);
935
+ return le(e);
906
936
  }
907
937
  getRateLimitStorageKey() {
908
938
  const e = this.get("userId") || "anonymous";
909
- return le(e);
939
+ return ue(e);
910
940
  }
911
941
  getActiveRateLimitKey() {
912
942
  return this.rateLimitStorageKeyAtArm ?? this.getRateLimitStorageKey();
@@ -974,7 +1004,7 @@ class ys extends T {
974
1004
  const t = this.ensureBatchMetadata(e), s = this.getPersistedData(), r = typeof s?.recoveryFailures == "number" && Number.isFinite(s.recoveryFailures) ? s.recoveryFailures : 0;
975
1005
  return this.persistEventsWithFailureCount(t, r, !0), !1;
976
1006
  }
977
- return this.apiUrl.includes(F.Fail) ? (a("warn", "Fail mode: simulating network failure (sync)", { data: { events: e.events.length } }), !1) : this.apiUrl.includes(F.Localhost) ? (a("debug", "Success mode: simulating successful send (sync)", { data: { events: e.events.length } }), !0) : this.sendQueueSyncInternal(e);
1007
+ return this.apiUrl.includes(V.Fail) ? (a("warn", "Fail mode: simulating network failure (sync)", { data: { events: e.events.length } }), !1) : this.apiUrl.includes(V.Localhost) ? (a("debug", "Success mode: simulating successful send (sync)", { data: { events: e.events.length } }), !0) : this.sendQueueSyncInternal(e);
978
1008
  }
979
1009
  /**
980
1010
  * Sends events asynchronously using `fetch()` with retry, circuit breaker, and 429 cooldown.
@@ -1045,9 +1075,9 @@ class ys extends T {
1045
1075
  }
1046
1076
  async send(e) {
1047
1077
  const t = this.ensureBatchMetadata(e, e._metadata?.idempotency_token);
1048
- if (this.apiUrl.includes(F.Fail))
1078
+ if (this.apiUrl.includes(V.Fail))
1049
1079
  return a("debug", "Fail mode: simulating network failure", { data: { events: t.events.length } }), !1;
1050
- if (this.apiUrl.includes(F.Localhost))
1080
+ if (this.apiUrl.includes(V.Localhost))
1051
1081
  return a("debug", "Success mode: simulating successful send", { data: { events: t.events.length } }), !0;
1052
1082
  if (this.isRateLimited())
1053
1083
  return a("debug", "Rate-limit cooldown active, skipping send", {
@@ -1077,13 +1107,13 @@ class ys extends T {
1077
1107
  const u = c === 3;
1078
1108
  if (l instanceof M)
1079
1109
  throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l;
1080
- if (l instanceof J) {
1110
+ if (l instanceof Z) {
1081
1111
  this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, i = !1, o = !0, this.armRateLimitCooldown(Date.now() + 6e4), a("warn", "Rate limited, skipping retries", {
1082
1112
  data: { events: e.events.length, attempt: c, cooldownMs: 6e4 }
1083
1113
  });
1084
1114
  break;
1085
1115
  }
1086
- 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(
1087
1117
  u ? "error" : "warn",
1088
1118
  `Send attempt ${c} failed${u ? " (all retries exhausted)" : ", will retry"}`,
1089
1119
  {
@@ -1131,11 +1161,11 @@ class ys extends T {
1131
1161
  const l = await this.readTraceLogErrorCode(o), u = l ? `HTTP ${o.status}: ${o.statusText} (${l})` : `HTTP ${o.status}: ${o.statusText}`;
1132
1162
  throw new M(u, o.status, l);
1133
1163
  }
1134
- 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}`);
1135
1165
  }
1136
1166
  return o;
1137
1167
  } catch (o) {
1138
- throw o instanceof M ? o : r ? new Z("Request timed out") : o;
1168
+ throw o instanceof M ? o : r ? new ee("Request timed out") : o;
1139
1169
  } finally {
1140
1170
  clearTimeout(i), this.pendingControllers.delete(s);
1141
1171
  }
@@ -1143,7 +1173,7 @@ class ys extends T {
1143
1173
  async readTraceLogErrorCode(e) {
1144
1174
  try {
1145
1175
  const t = await e.clone().json();
1146
- if (typeof t.code == "string" && t.code.length > 0 && t.code.length <= Wt)
1176
+ if (typeof t.code == "string" && t.code.length > 0 && t.code.length <= jt)
1147
1177
  return t.code;
1148
1178
  } catch {
1149
1179
  }
@@ -1170,7 +1200,7 @@ class ys extends T {
1170
1200
  idempotency_token: e._metadata?.idempotency_token ?? this.computeContentToken(e),
1171
1201
  referer: typeof window < "u" ? window.location.href : void 0,
1172
1202
  timestamp: t,
1173
- client_version: Qt
1203
+ client_version: Yt
1174
1204
  }
1175
1205
  };
1176
1206
  return {
@@ -1262,12 +1292,12 @@ class ys extends T {
1262
1292
  }
1263
1293
  logPermanentError(e, t) {
1264
1294
  const s = Date.now(), r = `${t.statusCode ?? "unknown"}:${t.responseCode ?? ""}`;
1265
- (!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== r || s - this.lastPermanentErrorLog.timestamp >= Gt) && (a("error", e, {
1295
+ (!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== r || s - this.lastPermanentErrorLog.timestamp >= Wt) && (a("error", e, {
1266
1296
  data: { status: t.statusCode, code: t.responseCode, message: t.message }
1267
1297
  }), this.lastPermanentErrorLog = { key: r, timestamp: s });
1268
1298
  }
1269
1299
  }
1270
- class Is extends T {
1300
+ class As extends T {
1271
1301
  bootTime;
1272
1302
  bootTimestamp;
1273
1303
  hasPerformanceNow;
@@ -1301,8 +1331,8 @@ class Is extends T {
1301
1331
  } : { valid: !0 };
1302
1332
  }
1303
1333
  }
1304
- const ws = new Set(Object.values(d));
1305
- class As extends T {
1334
+ const Ls = new Set(Object.values(d));
1335
+ class bs extends T {
1306
1336
  dataSenders;
1307
1337
  emitter;
1308
1338
  timeManager;
@@ -1334,9 +1364,9 @@ class As extends T {
1334
1364
  * @param emitter - Optional event emitter for local event consumption
1335
1365
  */
1336
1366
  constructor(e, t = null) {
1337
- super(), this.emitter = t, this.timeManager = new Is(), this.dataSenders = [];
1367
+ super(), this.emitter = t, this.timeManager = new As(), this.dataSenders = [];
1338
1368
  const s = this.get("collectApiUrls");
1339
- s?.saas && this.dataSenders.push(new ys(e, s.saas)), this.saveSessionCountsDebounced = this.debounce((r) => {
1369
+ s?.saas && this.dataSenders.push(new ws(e, s.saas)), this.saveSessionCountsDebounced = this.debounce((r) => {
1340
1370
  this.saveSessionCounts(r);
1341
1371
  }, 500), this.cleanupExpiredSessionCounts();
1342
1372
  }
@@ -1454,7 +1484,7 @@ class As extends T {
1454
1484
  a("error", "Event type is required - event will be ignored");
1455
1485
  return;
1456
1486
  }
1457
- if (!ws.has(e)) {
1487
+ if (!Ls.has(e)) {
1458
1488
  a("error", "Invalid event type - event will be ignored", {
1459
1489
  data: { type: e }
1460
1490
  });
@@ -1497,12 +1527,12 @@ class As extends T {
1497
1527
  }
1498
1528
  const _ = this.getTypeLimitForEvent(S);
1499
1529
  if (_) {
1500
- const ae = this.sessionEventCounts[S];
1501
- if (ae !== void 0 && ae >= _) {
1530
+ const ce = this.sessionEventCounts[S];
1531
+ if (ce !== void 0 && ce >= _) {
1502
1532
  a("warn", "Session event type limit reached", {
1503
1533
  data: {
1504
1534
  type: S,
1505
- count: ae,
1535
+ count: ce,
1506
1536
  limit: _
1507
1537
  }
1508
1538
  });
@@ -1515,9 +1545,9 @@ class As extends T {
1515
1545
  if (!this.checkPerEventRateLimit(o.name, _))
1516
1546
  return;
1517
1547
  }
1518
- const pt = S === d.SESSION_START, St = t || this.get("pageUrl"), G = this.buildEventPayload({
1548
+ const St = S === d.SESSION_START, Et = t || this.get("pageUrl"), W = this.buildEventPayload({
1519
1549
  type: S,
1520
- page_url: St,
1550
+ page_url: Et,
1521
1551
  from_page_url: s,
1522
1552
  scroll_data: r,
1523
1553
  click_data: i,
@@ -1526,8 +1556,8 @@ class As extends T {
1526
1556
  error_data: l,
1527
1557
  page_view: u
1528
1558
  });
1529
- if (G && !(!p && !this.shouldSample())) {
1530
- if (pt) {
1559
+ if (W && !(!p && !this.shouldSample())) {
1560
+ if (St) {
1531
1561
  const _ = this.get("sessionId");
1532
1562
  if (!_) {
1533
1563
  a("error", "Session start event requires sessionId - event will be ignored");
@@ -1541,18 +1571,18 @@ class As extends T {
1541
1571
  }
1542
1572
  this.set("hasStartSession", !0);
1543
1573
  }
1544
- if (!this.isDuplicateEvent(G)) {
1545
- if (this.get("mode") === ee.QA && S === d.CUSTOM && o) {
1574
+ if (!this.isDuplicateEvent(W)) {
1575
+ if (this.get("mode") === te.QA && S === d.CUSTOM && o) {
1546
1576
  a("info", `Custom Event: ${o.name}`, {
1547
1577
  visibility: "qa",
1548
1578
  data: {
1549
1579
  name: o.name,
1550
1580
  ...o.metadata && { metadata: o.metadata }
1551
1581
  }
1552
- }), this.emitEvent(G);
1582
+ }), this.emitEvent(W);
1553
1583
  return;
1554
1584
  }
1555
- if (this.addToQueue(G), !p) {
1585
+ if (this.addToQueue(W), !p) {
1556
1586
  this.sessionEventCounts.total++, this.sessionEventCounts[S] !== void 0 && this.sessionEventCounts[S]++;
1557
1587
  const _ = this.get("sessionId");
1558
1588
  _ && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(_);
@@ -2010,7 +2040,7 @@ class As extends T {
2010
2040
  });
2011
2041
  const c = this.get("sessionReferrer"), l = this.get("sessionUtm"), u = this.get("sessionClickIds");
2012
2042
  return { ...{
2013
- id: ts(),
2043
+ id: ss(),
2014
2044
  type: e.type,
2015
2045
  page_url: r,
2016
2046
  timestamp: i,
@@ -2197,13 +2227,13 @@ class As extends T {
2197
2227
  loadSessionCounts(e) {
2198
2228
  if (typeof window > "u" || typeof localStorage > "u")
2199
2229
  return this.getInitialCounts();
2200
- const t = this.get("userId") || "anonymous", s = Ve(t, e);
2230
+ const t = this.get("userId") || "anonymous", s = He(t, e);
2201
2231
  try {
2202
2232
  const r = localStorage.getItem(s);
2203
2233
  if (!r)
2204
2234
  return this.getInitialCounts();
2205
2235
  const i = JSON.parse(r);
2206
- return i._timestamp && Date.now() - i._timestamp > He ? (a("debug", "Session counts expired, clearing", {
2236
+ return i._timestamp && Date.now() - i._timestamp > xe ? (a("debug", "Session counts expired, clearing", {
2207
2237
  data: { sessionId: e, age: Date.now() - i._timestamp }
2208
2238
  }), localStorage.removeItem(s), this.getInitialCounts()) : typeof i.total == "number" && typeof i[d.CLICK] == "number" && typeof i[d.PAGE_VIEW] == "number" && typeof i[d.CUSTOM] == "number" && typeof i[d.SCROLL] == "number" ? {
2209
2239
  total: i.total,
@@ -2247,12 +2277,12 @@ class As extends T {
2247
2277
  cleanupExpiredSessionCounts() {
2248
2278
  if (!(typeof window > "u" || typeof localStorage > "u"))
2249
2279
  try {
2250
- const e = localStorage.getItem(xe);
2280
+ const e = localStorage.getItem($e);
2251
2281
  if (e) {
2252
2282
  const i = Date.now() - parseInt(e, 10);
2253
- if (i < $e) {
2283
+ if (i < Be) {
2254
2284
  a("debug", "Skipping session counts cleanup (throttled)", {
2255
- data: { timeSinceLastCleanup: i, throttleMs: $e }
2285
+ data: { timeSinceLastCleanup: i, throttleMs: Be }
2256
2286
  });
2257
2287
  return;
2258
2288
  }
@@ -2265,14 +2295,14 @@ class As extends T {
2265
2295
  const c = localStorage.getItem(o);
2266
2296
  if (c) {
2267
2297
  const l = JSON.parse(c);
2268
- l._timestamp && Date.now() - l._timestamp > He && r.push(o);
2298
+ l._timestamp && Date.now() - l._timestamp > xe && r.push(o);
2269
2299
  }
2270
2300
  } catch {
2271
2301
  }
2272
2302
  }
2273
2303
  r.forEach((i) => {
2274
2304
  localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
2275
- }), r.length > 0 && a("info", `Cleaned up ${r.length} expired session counts entries`), localStorage.setItem(xe, Date.now().toString());
2305
+ }), r.length > 0 && a("info", `Cleaned up ${r.length} expired session counts entries`), localStorage.setItem($e, Date.now().toString());
2276
2306
  } catch (e) {
2277
2307
  a("warn", "Failed to cleanup expired session counts", { error: e });
2278
2308
  }
@@ -2306,7 +2336,7 @@ class As extends T {
2306
2336
  * @internal
2307
2337
  */
2308
2338
  saveSessionCounts(e) {
2309
- const t = this.get("userId") || "anonymous", s = Ve(t, e);
2339
+ const t = this.get("userId") || "anonymous", s = He(t, e);
2310
2340
  try {
2311
2341
  const r = {
2312
2342
  ...this.sessionEventCounts,
@@ -2322,7 +2352,7 @@ class As extends T {
2322
2352
  }
2323
2353
  }
2324
2354
  }
2325
- class Ls {
2355
+ class Ms {
2326
2356
  /**
2327
2357
  * Gets or creates a unique user ID.
2328
2358
  *
@@ -2340,15 +2370,15 @@ class Ls {
2340
2370
  * @returns Persistent unique user ID (UUID v4 format)
2341
2371
  */
2342
2372
  static getId(e) {
2343
- const t = e.getItem(Se);
2373
+ const t = e.getItem(Ee);
2344
2374
  if (t)
2345
2375
  return t;
2346
- const s = ot();
2347
- return e.setItem(Se, s), s;
2376
+ const s = at();
2377
+ return e.setItem(Ee, s), s;
2348
2378
  }
2349
2379
  }
2350
- const bs = /^\d{13}-[a-z0-9]{9}$/;
2351
- class Ms extends T {
2380
+ const Cs = /^\d{13}-[a-z0-9]{9}$/;
2381
+ class Rs extends T {
2352
2382
  storageManager;
2353
2383
  eventManager;
2354
2384
  projectId;
@@ -2375,7 +2405,7 @@ class Ms extends T {
2375
2405
  return;
2376
2406
  }
2377
2407
  const e = this.getProjectId();
2378
- this.broadcastChannel = new BroadcastChannel(It(e)), this.broadcastChannel.onmessage = (t) => {
2408
+ this.broadcastChannel = new BroadcastChannel(wt(e)), this.broadcastChannel.onmessage = (t) => {
2379
2409
  const { action: s, sessionId: r, timestamp: i, projectId: o } = t.data ?? {};
2380
2410
  if (o === e)
2381
2411
  if (s === "session_start" && r && typeof i == "number" && i > Date.now() - 5e3) {
@@ -2400,7 +2430,7 @@ class Ms extends T {
2400
2430
  const e = this.loadStoredSession();
2401
2431
  if (!e)
2402
2432
  return null;
2403
- if (!bs.test(e.id))
2433
+ if (!Cs.test(e.id))
2404
2434
  return a("warn", "Invalid session ID format recovered from storage, clearing", {
2405
2435
  data: { sessionId: e.id }
2406
2436
  }), this.clearStoredSession(), null;
@@ -2446,7 +2476,7 @@ class Ms extends T {
2446
2476
  this.storageManager.setItem(t, s), this.storageManager.setSessionItem(t, s);
2447
2477
  }
2448
2478
  getSessionStorageKey() {
2449
- return yt(this.getProjectId());
2479
+ return It(this.getProjectId());
2450
2480
  }
2451
2481
  getProjectId() {
2452
2482
  return this.projectId;
@@ -2519,9 +2549,9 @@ class Ms extends T {
2519
2549
  let s, r, i;
2520
2550
  if (e) {
2521
2551
  const o = this.loadStoredSession();
2522
- s = o?.referrer ?? he(), r = o?.utm ?? fe(), i = o?.clickIds ?? de();
2552
+ s = o?.referrer ?? fe(), r = o?.utm ?? ge(), i = o?.clickIds ?? he();
2523
2553
  } else
2524
- s = he(), r = fe(), i = de();
2554
+ s = fe(), r = ge(), i = he();
2525
2555
  a("debug", "Session tracking initialized", {
2526
2556
  data: {
2527
2557
  sessionId: t,
@@ -2533,7 +2563,7 @@ class Ms extends T {
2533
2563
  }
2534
2564
  }), this.isTracking = !0;
2535
2565
  try {
2536
- if (this.set("sessionId", t), this.set("sessionReferrer", s), this.set("sessionUtm", r), this.set("sessionClickIds", i), it()) {
2566
+ if (this.set("sessionId", t), this.set("sessionReferrer", s), this.set("sessionUtm", r), this.set("sessionClickIds", i), ot()) {
2537
2567
  this.prerenderActivationHandler = () => {
2538
2568
  this.prerenderActivationHandler = null, this.activateSession(t, e, s, r, i);
2539
2569
  }, document.addEventListener("prerenderingchange", this.prerenderActivationHandler, { once: !0 });
@@ -2593,7 +2623,7 @@ class Ms extends T {
2593
2623
  */
2594
2624
  renewSession() {
2595
2625
  this.needsRenewal = !1;
2596
- const e = this.generateSessionId(), t = he(), s = fe(), r = de();
2626
+ const e = this.generateSessionId(), t = fe(), s = ge(), r = he();
2597
2627
  a("debug", "Renewing session after timeout", {
2598
2628
  data: { newSessionId: e }
2599
2629
  }), 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({
@@ -2723,7 +2753,7 @@ class Ms extends T {
2723
2753
  this.prerenderActivationHandler && (document.removeEventListener("prerenderingchange", this.prerenderActivationHandler), this.prerenderActivationHandler = null);
2724
2754
  }
2725
2755
  }
2726
- class Cs extends T {
2756
+ class Ns extends T {
2727
2757
  eventManager;
2728
2758
  storageManager;
2729
2759
  sessionManager = null;
@@ -2758,7 +2788,7 @@ class Cs extends T {
2758
2788
  }
2759
2789
  const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
2760
2790
  try {
2761
- this.sessionManager = new Ms(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
2791
+ this.sessionManager = new Rs(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
2762
2792
  } catch (s) {
2763
2793
  if (this.sessionManager) {
2764
2794
  try {
@@ -2811,7 +2841,7 @@ class Cs extends T {
2811
2841
  this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
2812
2842
  }
2813
2843
  }
2814
- class Rs extends T {
2844
+ class Os extends T {
2815
2845
  eventManager;
2816
2846
  onTrack;
2817
2847
  originalPushState;
@@ -2851,7 +2881,7 @@ class Rs extends T {
2851
2881
  };
2852
2882
  }
2853
2883
  trackCurrentPage = () => {
2854
- const e = window.location.href, t = ye(e, this.get("config").sensitiveQueryParams);
2884
+ const e = window.location.href, t = Ie(e, this.get("config").sensitiveQueryParams);
2855
2885
  if (this.get("pageUrl") === t)
2856
2886
  return;
2857
2887
  const s = Date.now(), r = this.get("config").pageViewThrottleMs ?? 1e3;
@@ -2869,7 +2899,7 @@ class Rs extends T {
2869
2899
  }), this.get("config").flushOnSpaNavigation === !0 && this.eventManager.flushImmediately();
2870
2900
  };
2871
2901
  trackInitialPageView() {
2872
- const e = ye(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
2902
+ const e = Ie(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
2873
2903
  this.lastPageViewTime = Date.now(), this.eventManager.track({
2874
2904
  type: d.PAGE_VIEW,
2875
2905
  page_url: e,
@@ -2885,7 +2915,7 @@ class Rs extends T {
2885
2915
  };
2886
2916
  }
2887
2917
  }
2888
- class Ns extends T {
2918
+ class Ps extends T {
2889
2919
  eventManager;
2890
2920
  lastClickTimes = /* @__PURE__ */ new Map();
2891
2921
  clickHandler;
@@ -3027,7 +3057,7 @@ class Ns extends T {
3027
3057
  return e.hasAttribute(`${L}-name`) ? e : e.closest(`[${L}-name]`);
3028
3058
  }
3029
3059
  getRelevantClickElement(e) {
3030
- for (const t of Et)
3060
+ for (const t of vt)
3031
3061
  try {
3032
3062
  if (e.matches(t))
3033
3063
  return e;
@@ -3070,7 +3100,7 @@ class Ns extends T {
3070
3100
  if (!s && !r)
3071
3101
  return "";
3072
3102
  let i = "";
3073
- return s && s.length <= 255 ? i = s : r.length <= 255 ? i = r : i = r.slice(0, 252) + "...", Y(i);
3103
+ return s && s.length <= 255 ? i = s : r.length <= 255 ? i = r : i = r.slice(0, 252) + "...", q(i);
3074
3104
  }
3075
3105
  createCustomEventData(e) {
3076
3106
  return {
@@ -3079,7 +3109,7 @@ class Ns extends T {
3079
3109
  };
3080
3110
  }
3081
3111
  }
3082
- class Os extends T {
3112
+ class ks extends T {
3083
3113
  eventManager;
3084
3114
  containers = [];
3085
3115
  limitWarningLogged = !1;
@@ -3205,7 +3235,7 @@ class Os extends T {
3205
3235
  e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
3206
3236
  }
3207
3237
  getScrollDirection(e, t) {
3208
- return e > t ? Ee.DOWN : Ee.UP;
3238
+ return e > t ? ve.DOWN : ve.UP;
3209
3239
  }
3210
3240
  calculateScrollDepth(e, t, s) {
3211
3241
  if (t <= s)
@@ -3234,8 +3264,8 @@ class Os extends T {
3234
3264
  return s && r;
3235
3265
  }
3236
3266
  }
3237
- const Ps = "tracelog_session_id", ks = "tracelog_user_id";
3238
- class Ds extends T {
3267
+ const Ds = "tracelog_session_id", Us = "tracelog_user_id";
3268
+ class Fs extends T {
3239
3269
  visibilityHandler = null;
3240
3270
  pageshowHandler = null;
3241
3271
  lastSyncedKey = null;
@@ -3256,8 +3286,8 @@ class Ds extends T {
3256
3286
  r !== this.lastSyncedKey && (this.lastSyncedKey = r, this.postCartUpdate(e, s));
3257
3287
  }
3258
3288
  postCartUpdate(e, t) {
3259
- const s = { [Ps]: e };
3260
- t.length > 0 && (s[ks] = t);
3289
+ const s = { [Ds]: e };
3290
+ t.length > 0 && (s[Us] = t);
3261
3291
  try {
3262
3292
  fetch("/cart/update.js", {
3263
3293
  method: "POST",
@@ -3294,7 +3324,7 @@ class Ds extends T {
3294
3324
  this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.pageshowHandler && (window.removeEventListener("pageshow", this.pageshowHandler), this.pageshowHandler = null);
3295
3325
  }
3296
3326
  }
3297
- class Us {
3327
+ class Vs {
3298
3328
  storage;
3299
3329
  sessionStorageRef;
3300
3330
  fallbackStorage = /* @__PURE__ */ new Map();
@@ -3407,7 +3437,7 @@ class Us {
3407
3437
  this.fallbackSessionStorage.delete(e);
3408
3438
  }
3409
3439
  }
3410
- class Fs extends T {
3440
+ class Hs extends T {
3411
3441
  eventManager;
3412
3442
  reportedByNav = /* @__PURE__ */ new Map();
3413
3443
  navigationHistory = [];
@@ -3417,7 +3447,7 @@ class Fs extends T {
3417
3447
  navigationCounter = 0;
3418
3448
  // Counter for handling simultaneous navigations edge case
3419
3449
  constructor(e) {
3420
- super(), this.eventManager = e, this.vitalThresholds = Qe(_e);
3450
+ super(), this.eventManager = e, this.vitalThresholds = Qe(ye);
3421
3451
  }
3422
3452
  /**
3423
3453
  * Starts tracking Web Vitals and performance metrics.
@@ -3433,7 +3463,7 @@ class Fs extends T {
3433
3463
  * @returns Promise that resolves when tracking is initialized
3434
3464
  */
3435
3465
  async startTracking() {
3436
- const e = this.get("config"), t = e?.webVitalsMode ?? _e;
3466
+ const e = this.get("config"), t = e?.webVitalsMode ?? ye;
3437
3467
  this.vitalThresholds = Qe(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals();
3438
3468
  }
3439
3469
  /**
@@ -3504,7 +3534,7 @@ class Fs extends T {
3504
3534
  }
3505
3535
  async initWebVitals() {
3506
3536
  try {
3507
- const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() => un), o = (c) => (l) => {
3537
+ const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() => hn), o = (c) => (l) => {
3508
3538
  const u = Number(l.value.toFixed(2));
3509
3539
  this.sendVital({ type: c, value: u });
3510
3540
  };
@@ -3534,7 +3564,7 @@ class Fs extends T {
3534
3564
  return;
3535
3565
  if (s)
3536
3566
  s.add(e.type);
3537
- else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Kt) {
3567
+ else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > zt) {
3538
3568
  const i = this.navigationHistory.shift();
3539
3569
  i && this.reportedByNav.delete(i);
3540
3570
  }
@@ -3625,7 +3655,7 @@ class Fs extends T {
3625
3655
  return !(typeof s == "number" && t <= s);
3626
3656
  }
3627
3657
  }
3628
- class se extends T {
3658
+ class ne extends T {
3629
3659
  eventManager;
3630
3660
  emitter;
3631
3661
  recentErrors = /* @__PURE__ */ new Map();
@@ -3682,14 +3712,14 @@ class se extends T {
3682
3712
  const e = Date.now();
3683
3713
  if (e < this.burstBackoffUntil)
3684
3714
  return !1;
3685
- if (e - this.burstWindowStart > xt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > $t)
3715
+ if (e - this.burstWindowStart > $t && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > Bt)
3686
3716
  return this.burstBackoffUntil = e + Ke, a("debug", "Error burst detected - entering cooldown", {
3687
3717
  data: {
3688
3718
  errorsInWindow: this.errorBurstCounter,
3689
3719
  cooldownMs: Ke
3690
3720
  }
3691
3721
  }), !1;
3692
- const s = this.get("config").errorSampling ?? rt;
3722
+ const s = this.get("config").errorSampling ?? it;
3693
3723
  return Math.random() < s;
3694
3724
  }
3695
3725
  /**
@@ -3699,33 +3729,34 @@ class se extends T {
3699
3729
  * later signature that recycles the same map key after a counter reset.
3700
3730
  */
3701
3731
  shouldThrottleBySignature(e) {
3702
- const t = _s({
3703
- message: e.message,
3704
- filename: e.filename,
3705
- line: e.line
3706
- }), s = this.pageviewSignatureCounts.get(t) ?? 0;
3707
- if (s >= Bt)
3732
+ const t = Is(e), s = this.pageviewSignatureCounts.get(t) ?? 0;
3733
+ if (s >= Xt)
3708
3734
  return a("debug", "Error throttled (pageview cap)", {
3709
3735
  data: { signature: t, count: s }
3710
3736
  }), !0;
3711
3737
  const r = s + 1;
3712
- return this.pageviewSignatureCounts.set(t, r), this.pageviewSignatureCounts.size > Xt && (this.pageviewSignatureCounts.clear(), this.pageviewSignatureCounts.set(t, r)), !1;
3738
+ return this.pageviewSignatureCounts.set(t, r), this.pageviewSignatureCounts.size > Gt && (this.pageviewSignatureCounts.clear(), this.pageviewSignatureCounts.set(t, r)), !1;
3713
3739
  }
3714
3740
  handleError = (e) => {
3715
3741
  if (!this.shouldSample())
3716
3742
  return;
3717
3743
  const t = this.sanitize(e.message || "Unknown error");
3718
- if (this.shouldSuppressError(V.JS_ERROR, t) || this.shouldThrottleBySignature({
3744
+ if (this.shouldSuppressError(H.JS_ERROR, t) || this.shouldThrottleBySignature({
3719
3745
  message: t,
3720
3746
  filename: e.filename,
3721
- line: e.lineno
3747
+ line: e.lineno,
3748
+ // Inline-script errors report the page URL as `filename`; passing the current
3749
+ // page URL lets buildErrorSignatureKey collapse them to origin, matching the
3750
+ // normalized input the server hashes for cap/dedup. normalizeFilename strips
3751
+ // query/hash internally.
3752
+ page_url: window.location.href
3722
3753
  }))
3723
3754
  return;
3724
3755
  const s = typeof e.error?.stack == "string" ? this.truncateStack(e.error.stack) : void 0, r = typeof e.error?.name == "string" && e.error.name !== "Error" ? e.error.name : void 0;
3725
3756
  this.eventManager.track({
3726
3757
  type: d.ERROR,
3727
3758
  error_data: {
3728
- type: V.JS_ERROR,
3759
+ type: H.JS_ERROR,
3729
3760
  message: t,
3730
3761
  ...r !== void 0 && { name: r },
3731
3762
  ...e.filename !== "" && { filename: e.filename },
@@ -3739,13 +3770,13 @@ class se extends T {
3739
3770
  if (!this.shouldSample())
3740
3771
  return;
3741
3772
  const t = this.extractRejectionMessage(e.reason), s = this.sanitize(t);
3742
- if (this.shouldSuppressError(V.PROMISE_REJECTION, s) || this.shouldThrottleBySignature({ message: s }))
3773
+ if (this.shouldSuppressError(H.PROMISE_REJECTION, s) || this.shouldThrottleBySignature({ message: s }))
3743
3774
  return;
3744
3775
  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;
3745
3776
  this.eventManager.track({
3746
3777
  type: d.ERROR,
3747
3778
  error_data: {
3748
- type: V.PROMISE_REJECTION,
3779
+ type: H.PROMISE_REJECTION,
3749
3780
  message: s,
3750
3781
  ...i !== void 0 && { name: i },
3751
3782
  ...r !== void 0 && { stack: r }
@@ -3767,40 +3798,40 @@ class se extends T {
3767
3798
  }
3768
3799
  sanitize(e) {
3769
3800
  const t = e.length > Ge ? e.slice(0, Ge) + "..." : e;
3770
- return Y(t);
3801
+ return q(t);
3771
3802
  }
3772
3803
  shouldSuppressError(e, t) {
3773
3804
  const s = Date.now(), r = `${e}:${t}`, i = this.recentErrors.get(r);
3774
- return i !== void 0 && s - i < je ? (this.recentErrors.set(r, s), !0) : (this.recentErrors.set(r, s), this.recentErrors.size > Ht ? (this.recentErrors.clear(), this.recentErrors.set(r, s), !1) : (this.recentErrors.size > Q && this.pruneOldErrors(), !1));
3805
+ return i !== void 0 && s - i < je ? (this.recentErrors.set(r, s), !0) : (this.recentErrors.set(r, s), this.recentErrors.size > xt ? (this.recentErrors.clear(), this.recentErrors.set(r, s), !1) : (this.recentErrors.size > Y && this.pruneOldErrors(), !1));
3775
3806
  }
3776
3807
  static TRUNCATION_SUFFIX = `
3777
3808
  ...truncated`;
3778
3809
  truncateStack(e) {
3779
- if (e.length <= We) return Y(e);
3780
- const t = We - se.TRUNCATION_SUFFIX.length, s = e.slice(0, t) + se.TRUNCATION_SUFFIX;
3781
- return Y(s);
3810
+ if (e.length <= We) return q(e);
3811
+ const t = We - ne.TRUNCATION_SUFFIX.length, s = e.slice(0, t) + ne.TRUNCATION_SUFFIX;
3812
+ return q(s);
3782
3813
  }
3783
3814
  pruneOldErrors() {
3784
3815
  const e = Date.now();
3785
3816
  for (const [r, i] of this.recentErrors.entries())
3786
3817
  e - i > je && this.recentErrors.delete(r);
3787
- if (this.recentErrors.size <= Q)
3818
+ if (this.recentErrors.size <= Y)
3788
3819
  return;
3789
- const t = Array.from(this.recentErrors.entries()).sort((r, i) => r[1] - i[1]), s = this.recentErrors.size - Q;
3820
+ const t = Array.from(this.recentErrors.entries()).sort((r, i) => r[1] - i[1]), s = this.recentErrors.size - Y;
3790
3821
  for (let r = 0; r < s; r += 1) {
3791
3822
  const i = t[r];
3792
3823
  i && this.recentErrors.delete(i[0]);
3793
3824
  }
3794
3825
  }
3795
3826
  }
3796
- class Vs extends T {
3827
+ class xs extends T {
3797
3828
  isInitialized = !1;
3798
3829
  suppressNextScrollTimer = null;
3799
3830
  pageUnloadHandler = null;
3800
3831
  pageShowHandler = null;
3801
3832
  visibilityFlushHandler = null;
3802
3833
  prerenderActivationHandler = null;
3803
- emitter = new gs();
3834
+ emitter = new ms();
3804
3835
  managers = {};
3805
3836
  handlers = {};
3806
3837
  integrationInstances = {};
@@ -3815,9 +3846,9 @@ class Vs extends T {
3815
3846
  async init(e = {}) {
3816
3847
  if (this.isInitialized)
3817
3848
  return { sessionId: this.get("sessionId") ?? "" };
3818
- this.managers.storage = new Us();
3849
+ this.managers.storage = new Vs();
3819
3850
  try {
3820
- return this.setupState(e), this.managers.event = new As(this.managers.storage, this.emitter), this.loadPersistedIdentity(), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((t) => {
3851
+ return this.setupState(e), this.managers.event = new bs(this.managers.storage, this.emitter), this.loadPersistedIdentity(), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((t) => {
3821
3852
  a("warn", "Failed to recover persisted events", { error: t });
3822
3853
  }), this.isInitialized = !0, { sessionId: this.get("sessionId") ?? "" };
3823
3854
  } catch (t) {
@@ -3838,9 +3869,9 @@ class Vs extends T {
3838
3869
  }
3839
3870
  let r = t;
3840
3871
  t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
3841
- const { valid: i, error: o, sanitizedMetadata: c } = fs(e, r);
3872
+ const { valid: i, error: o, sanitizedMetadata: c } = gs(e, r);
3842
3873
  if (!i) {
3843
- if (this.get("mode") === ee.QA)
3874
+ if (this.get("mode") === te.QA)
3844
3875
  throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${o}`);
3845
3876
  a("warn", `Custom event "${e}" dropped: ${o}`);
3846
3877
  return;
@@ -3877,14 +3908,14 @@ class Vs extends T {
3877
3908
  }
3878
3909
  setupState(e = {}) {
3879
3910
  this.set("config", e);
3880
- const t = Ls.getId(this.managers.storage);
3911
+ const t = Ms.getId(this.managers.storage);
3881
3912
  this.set("userId", t);
3882
- const s = rs(e);
3913
+ const s = is(e);
3883
3914
  this.set("collectApiUrls", s);
3884
- const r = Vt();
3915
+ const r = Ht();
3885
3916
  this.set("device", r);
3886
- const i = ye(window.location.href, e.sensitiveQueryParams);
3887
- this.set("pageUrl", i), Jt() && this.set("mode", ee.QA);
3917
+ const i = Ie(window.location.href, e.sensitiveQueryParams);
3918
+ this.set("pageUrl", i), Zt() && this.set("mode", te.QA);
3888
3919
  }
3889
3920
  /**
3890
3921
  * @internal Used by api.ts for configuration access
@@ -3939,7 +3970,7 @@ class Vs extends T {
3939
3970
  a("warn", "identify() userId exceeds 256 characters", { data: { length: e.trim().length } });
3940
3971
  return;
3941
3972
  }
3942
- const s = e.trim(), r = Ae(t), i = {
3973
+ const s = e.trim(), r = Le(t), i = {
3943
3974
  userId: s,
3944
3975
  ...r ? { traits: r } : {}
3945
3976
  };
@@ -3962,8 +3993,8 @@ class Vs extends T {
3962
3993
  */
3963
3994
  async resetIdentity() {
3964
3995
  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();
3965
- const e = ot();
3966
- 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");
3996
+ const e = at();
3997
+ 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");
3967
3998
  }
3968
3999
  /**
3969
4000
  * Returns the project ID used for identity storage scoping.
@@ -3976,7 +4007,7 @@ class Vs extends T {
3976
4007
  */
3977
4008
  persistIdentity(e) {
3978
4009
  try {
3979
- const t = this.getProjectId(), s = ue(t);
4010
+ const t = this.getProjectId(), s = de(t);
3980
4011
  this.managers.storage.setItem(s, JSON.stringify(e));
3981
4012
  } catch {
3982
4013
  a("debug", "Failed to persist identity to localStorage");
@@ -3987,7 +4018,7 @@ class Vs extends T {
3987
4018
  * Also migrates pending identity (set before init) to the project-scoped key.
3988
4019
  */
3989
4020
  loadPersistedIdentity() {
3990
- const e = this.managers.storage, t = this.getProjectId(), s = ue(t);
4021
+ const e = this.managers.storage, t = this.getProjectId(), s = de(t);
3991
4022
  try {
3992
4023
  const r = e.getItem(O);
3993
4024
  if (r) {
@@ -4035,7 +4066,7 @@ class Vs extends T {
4035
4066
  * localStorage values.
4036
4067
  */
4037
4068
  normalizePersistedIdentity(e) {
4038
- const t = Ae(e.traits);
4069
+ const t = Le(e.traits);
4039
4070
  return {
4040
4071
  userId: e.userId.trim(),
4041
4072
  ...t ? { traits: t } : {}
@@ -4047,7 +4078,7 @@ class Vs extends T {
4047
4078
  clearPersistedIdentity() {
4048
4079
  try {
4049
4080
  const e = this.managers.storage, t = this.getProjectId();
4050
- e.removeItem(ue(t)), e.removeItem(O);
4081
+ e.removeItem(de(t)), e.removeItem(O);
4051
4082
  } catch {
4052
4083
  a("debug", "Failed to clear persisted identity");
4053
4084
  }
@@ -4065,7 +4096,7 @@ class Vs extends T {
4065
4096
  }
4066
4097
  initializeHandlers() {
4067
4098
  const e = this.get("config");
4068
- this.handlers.session = new Cs(
4099
+ this.handlers.session = new Ns(
4069
4100
  this.managers.storage,
4070
4101
  this.managers.event
4071
4102
  ), this.handlers.session.startTracking();
@@ -4074,27 +4105,27 @@ class Vs extends T {
4074
4105
  this.set("suppressNextScroll", !1);
4075
4106
  }, 500);
4076
4107
  };
4077
- this.handlers.pageView = new Rs(this.managers.event, t), this.handlers.click = new Ns(this.managers.event), this.handlers.scroll = new Os(this.managers.event), this.handlers.performance = new Fs(this.managers.event), this.handlers.error = new se(this.managers.event, this.emitter);
4108
+ this.handlers.pageView = new Os(this.managers.event, t), this.handlers.click = new Ps(this.managers.event), this.handlers.scroll = new ks(this.managers.event), this.handlers.performance = new Hs(this.managers.event), this.handlers.error = new ne(this.managers.event, this.emitter);
4078
4109
  const s = () => {
4079
4110
  if (this.handlers.pageView?.startTracking(), this.handlers.click?.startTracking(), this.handlers.scroll?.startTracking(), this.handlers.performance?.startTracking().catch((r) => {
4080
4111
  a("warn", "Failed to start performance tracking", { error: r });
4081
4112
  }), this.handlers.error?.startTracking(), e.integrations?.tracelog?.shopify) {
4082
- const r = new Ds();
4113
+ const r = new Fs();
4083
4114
  r.activate(), this.integrationInstances.shopifyCartLinker = r, this.emitter.on(D.EVENT, (i) => {
4084
4115
  i.type === d.SESSION_START && r.onSessionChange();
4085
4116
  });
4086
4117
  }
4087
4118
  };
4088
- it() ? (this.prerenderActivationHandler = () => {
4119
+ ot() ? (this.prerenderActivationHandler = () => {
4089
4120
  this.prerenderActivationHandler = null, s();
4090
4121
  }, document.addEventListener("prerenderingchange", this.prerenderActivationHandler, { once: !0 })) : s();
4091
4122
  }
4092
4123
  }
4093
4124
  const R = [];
4094
4125
  let f = null, k = !1, A = !1, C = null;
4095
- const Hs = async (n) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (A = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : f ? { sessionId: f.getSessionId() ?? "" } : (k && C || (k = !0, C = (async () => {
4126
+ const $s = async (n) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (A = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : f ? { sessionId: f.getSessionId() ?? "" } : (k && C || (k = !0, C = (async () => {
4096
4127
  try {
4097
- const e = ls(n ?? {}), t = new Vs();
4128
+ const e = us(n ?? {}), t = new xs();
4098
4129
  try {
4099
4130
  R.forEach(({ event: o, callback: c }) => {
4100
4131
  t.on(o, c);
@@ -4118,7 +4149,7 @@ const Hs = async (n) => typeof window > "u" || typeof document > "u" ? { session
4118
4149
  } finally {
4119
4150
  k = !1, C = null;
4120
4151
  }
4121
- })()), C)), xs = (n, e, t) => {
4152
+ })()), C)), Bs = (n, e, t) => {
4122
4153
  if (!(typeof window > "u" || typeof document > "u")) {
4123
4154
  if (!f)
4124
4155
  throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
@@ -4126,7 +4157,7 @@ const Hs = async (n) => typeof window > "u" || typeof document > "u" ? { session
4126
4157
  throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
4127
4158
  f.sendCustomEvent(n, e, t);
4128
4159
  }
4129
- }, $s = (n, e) => {
4160
+ }, Xs = (n, e) => {
4130
4161
  if (!(typeof window > "u" || typeof document > "u")) {
4131
4162
  if (!f || k) {
4132
4163
  R.push({ event: n, callback: e });
@@ -4134,7 +4165,7 @@ const Hs = async (n) => typeof window > "u" || typeof document > "u" ? { session
4134
4165
  }
4135
4166
  f.on(n, e);
4136
4167
  }
4137
- }, Bs = (n, e) => {
4168
+ }, Gs = (n, e) => {
4138
4169
  if (!(typeof window > "u" || typeof document > "u")) {
4139
4170
  if (!f) {
4140
4171
  const t = R.findIndex((s) => s.event === n && s.callback === e);
@@ -4143,7 +4174,7 @@ const Hs = async (n) => typeof window > "u" || typeof document > "u" ? { session
4143
4174
  }
4144
4175
  f.off(n, e);
4145
4176
  }
4146
- }, Xs = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, Gs = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getSessionId(), Ws = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getUserId(), js = () => {
4177
+ }, Ws = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, js = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getSessionId(), Ks = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getUserId(), zs = () => {
4147
4178
  if (!(typeof window > "u" || typeof document > "u")) {
4148
4179
  if (A)
4149
4180
  throw new Error("[TraceLog] Destroy operation already in progress");
@@ -4158,7 +4189,7 @@ const Hs = async (n) => typeof window > "u" || typeof document > "u" ? { session
4158
4189
  f = null, k = !1, C = null, R.length = 0, A = !1, a("warn", "Error during destroy, forced cleanup completed", { error: n });
4159
4190
  }
4160
4191
  }
4161
- }, Ks = (n, e) => {
4192
+ }, Qs = (n, e) => {
4162
4193
  if (!(typeof window > "u" || typeof document > "u")) {
4163
4194
  if (!n || typeof n != "string" || n.trim().length === 0) {
4164
4195
  a("warn", "identify() called with invalid userId");
@@ -4177,7 +4208,7 @@ const Hs = async (n) => typeof window > "u" || typeof document > "u" ? { session
4177
4208
  return;
4178
4209
  }
4179
4210
  try {
4180
- const t = Ae(e), s = {
4211
+ const t = Le(e), s = {
4181
4212
  userId: n.trim(),
4182
4213
  ...t ? { traits: t } : {}
4183
4214
  };
@@ -4186,7 +4217,7 @@ const Hs = async (n) => typeof window > "u" || typeof document > "u" ? { session
4186
4217
  a("debug", "Failed to persist pre-init identity");
4187
4218
  }
4188
4219
  }
4189
- }, zs = async () => {
4220
+ }, Ys = async () => {
4190
4221
  if (!(typeof window > "u" || typeof document > "u")) {
4191
4222
  if (!f) {
4192
4223
  try {
@@ -4199,31 +4230,31 @@ const Hs = async (n) => typeof window > "u" || typeof document > "u" ? { session
4199
4230
  throw new Error("[TraceLog] Cannot reset identity while TraceLog is being destroyed");
4200
4231
  await f.resetIdentity();
4201
4232
  }
4202
- }, yn = {
4203
- init: Hs,
4204
- event: xs,
4205
- on: $s,
4206
- off: Bs,
4207
- isInitialized: Xs,
4208
- getSessionId: Gs,
4209
- getUserId: Ws,
4210
- destroy: js,
4211
- identify: Ks,
4212
- resetIdentity: zs
4233
+ }, wn = {
4234
+ init: $s,
4235
+ event: Bs,
4236
+ on: Xs,
4237
+ off: Gs,
4238
+ isInitialized: Ws,
4239
+ getSessionId: js,
4240
+ getUserId: Ks,
4241
+ destroy: zs,
4242
+ identify: Qs,
4243
+ resetIdentity: Ys
4213
4244
  };
4214
- var Le, b, x, at, ne, ct = -1, N = function(n) {
4245
+ var be, b, $, ct, re, lt = -1, N = function(n) {
4215
4246
  addEventListener("pageshow", (function(e) {
4216
- e.persisted && (ct = e.timeStamp, n(e));
4247
+ e.persisted && (lt = e.timeStamp, n(e));
4217
4248
  }), !0);
4218
- }, Pe = function() {
4249
+ }, ke = function() {
4219
4250
  var n = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
4220
4251
  if (n && n.responseStart > 0 && n.responseStart < performance.now()) return n;
4221
- }, ie = function() {
4222
- var n = Pe();
4252
+ }, oe = function() {
4253
+ var n = ke();
4223
4254
  return n && n.activationStart || 0;
4224
4255
  }, E = function(n, e) {
4225
- var t = Pe(), s = "navigate";
4226
- return ct >= 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 };
4256
+ var t = ke(), s = "navigate";
4257
+ 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 };
4227
4258
  }, U = function(n, e, t) {
4228
4259
  try {
4229
4260
  if (PerformanceObserver.supportedEntryTypes.includes(n)) {
@@ -4243,56 +4274,56 @@ var Le, b, x, at, ne, ct = -1, N = function(n) {
4243
4274
  return c > l[1] ? "poor" : c > l[0] ? "needs-improvement" : "good";
4244
4275
  })(e.value, t), n(e));
4245
4276
  };
4246
- }, ke = function(n) {
4277
+ }, De = function(n) {
4247
4278
  requestAnimationFrame((function() {
4248
4279
  return requestAnimationFrame((function() {
4249
4280
  return n();
4250
4281
  }));
4251
4282
  }));
4252
- }, B = function(n) {
4283
+ }, X = function(n) {
4253
4284
  document.addEventListener("visibilitychange", (function() {
4254
4285
  document.visibilityState === "hidden" && n();
4255
4286
  }));
4256
- }, oe = function(n) {
4287
+ }, ae = function(n) {
4257
4288
  var e = !1;
4258
4289
  return function() {
4259
4290
  e || (n(), e = !0);
4260
4291
  };
4261
- }, P = -1, Ze = function() {
4292
+ }, P = -1, et = function() {
4262
4293
  return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
4263
- }, re = function(n) {
4264
- document.visibilityState === "hidden" && P > -1 && (P = n.type === "visibilitychange" ? n.timeStamp : 0, Qs());
4265
- }, et = function() {
4266
- addEventListener("visibilitychange", re, !0), addEventListener("prerenderingchange", re, !0);
4267
- }, Qs = function() {
4268
- removeEventListener("visibilitychange", re, !0), removeEventListener("prerenderingchange", re, !0);
4269
- }, De = function() {
4270
- return P < 0 && (P = Ze(), et(), N((function() {
4294
+ }, ie = function(n) {
4295
+ document.visibilityState === "hidden" && P > -1 && (P = n.type === "visibilitychange" ? n.timeStamp : 0, qs());
4296
+ }, tt = function() {
4297
+ addEventListener("visibilitychange", ie, !0), addEventListener("prerenderingchange", ie, !0);
4298
+ }, qs = function() {
4299
+ removeEventListener("visibilitychange", ie, !0), removeEventListener("prerenderingchange", ie, !0);
4300
+ }, Ue = function() {
4301
+ return P < 0 && (P = et(), tt(), N((function() {
4271
4302
  setTimeout((function() {
4272
- P = Ze(), et();
4303
+ P = et(), tt();
4273
4304
  }), 0);
4274
4305
  }))), { get firstHiddenTime() {
4275
4306
  return P;
4276
4307
  } };
4277
- }, X = function(n) {
4308
+ }, G = function(n) {
4278
4309
  document.prerendering ? addEventListener("prerenderingchange", (function() {
4279
4310
  return n();
4280
4311
  }), !0) : n();
4281
- }, be = [1800, 3e3], lt = function(n, e) {
4282
- e = e || {}, X((function() {
4283
- var t, s = De(), r = E("FCP"), i = U("paint", (function(o) {
4312
+ }, Me = [1800, 3e3], ut = function(n, e) {
4313
+ e = e || {}, G((function() {
4314
+ var t, s = Ue(), r = E("FCP"), i = U("paint", (function(o) {
4284
4315
  o.forEach((function(c) {
4285
- 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)));
4316
+ 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)));
4286
4317
  }));
4287
4318
  }));
4288
- i && (t = v(n, r, be, e.reportAllChanges), N((function(o) {
4289
- r = E("FCP"), t = v(n, r, be, e.reportAllChanges), ke((function() {
4319
+ i && (t = v(n, r, Me, e.reportAllChanges), N((function(o) {
4320
+ r = E("FCP"), t = v(n, r, Me, e.reportAllChanges), De((function() {
4290
4321
  r.value = performance.now() - o.timeStamp, t(!0);
4291
4322
  }));
4292
4323
  })));
4293
4324
  }));
4294
- }, Me = [0.1, 0.25], Ys = function(n, e) {
4295
- e = e || {}, lt(oe((function() {
4325
+ }, Ce = [0.1, 0.25], Js = function(n, e) {
4326
+ e = e || {}, ut(ae((function() {
4296
4327
  var t, s = E("CLS", 0), r = 0, i = [], o = function(l) {
4297
4328
  l.forEach((function(u) {
4298
4329
  if (!u.hadRecentInput) {
@@ -4301,189 +4332,189 @@ var Le, b, x, at, ne, ct = -1, N = function(n) {
4301
4332
  }
4302
4333
  })), r > s.value && (s.value = r, s.entries = i, t());
4303
4334
  }, c = U("layout-shift", o);
4304
- c && (t = v(n, s, Me, e.reportAllChanges), B((function() {
4335
+ c && (t = v(n, s, Ce, e.reportAllChanges), X((function() {
4305
4336
  o(c.takeRecords()), t(!0);
4306
4337
  })), N((function() {
4307
- r = 0, s = E("CLS", 0), t = v(n, s, Me, e.reportAllChanges), ke((function() {
4338
+ r = 0, s = E("CLS", 0), t = v(n, s, Ce, e.reportAllChanges), De((function() {
4308
4339
  return t();
4309
4340
  }));
4310
4341
  })), setTimeout(t, 0));
4311
4342
  })));
4312
- }, ut = 0, me = 1 / 0, K = 0, qs = function(n) {
4343
+ }, dt = 0, pe = 1 / 0, z = 0, Zs = function(n) {
4313
4344
  n.forEach((function(e) {
4314
- e.interactionId && (me = Math.min(me, e.interactionId), K = Math.max(K, e.interactionId), ut = K ? (K - me) / 7 + 1 : 0);
4345
+ e.interactionId && (pe = Math.min(pe, e.interactionId), z = Math.max(z, e.interactionId), dt = z ? (z - pe) / 7 + 1 : 0);
4315
4346
  }));
4316
- }, dt = function() {
4317
- return Le ? ut : performance.interactionCount || 0;
4318
- }, Js = function() {
4319
- "interactionCount" in performance || Le || (Le = U("event", qs, { type: "event", buffered: !0, durationThreshold: 0 }));
4320
- }, I = [], q = /* @__PURE__ */ new Map(), ht = 0, Zs = function() {
4321
- var n = Math.min(I.length - 1, Math.floor((dt() - ht) / 50));
4347
+ }, ht = function() {
4348
+ return be ? dt : performance.interactionCount || 0;
4349
+ }, en = function() {
4350
+ "interactionCount" in performance || be || (be = U("event", Zs, { type: "event", buffered: !0, durationThreshold: 0 }));
4351
+ }, I = [], J = /* @__PURE__ */ new Map(), ft = 0, tn = function() {
4352
+ var n = Math.min(I.length - 1, Math.floor((ht() - ft) / 50));
4322
4353
  return I[n];
4323
- }, en = [], tn = function(n) {
4324
- if (en.forEach((function(r) {
4354
+ }, sn = [], nn = function(n) {
4355
+ if (sn.forEach((function(r) {
4325
4356
  return r(n);
4326
4357
  })), n.interactionId || n.entryType === "first-input") {
4327
- var e = I[I.length - 1], t = q.get(n.interactionId);
4358
+ var e = I[I.length - 1], t = J.get(n.interactionId);
4328
4359
  if (t || I.length < 10 || n.duration > e.latency) {
4329
4360
  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);
4330
4361
  else {
4331
4362
  var s = { id: n.interactionId, latency: n.duration, entries: [n] };
4332
- q.set(s.id, s), I.push(s);
4363
+ J.set(s.id, s), I.push(s);
4333
4364
  }
4334
4365
  I.sort((function(r, i) {
4335
4366
  return i.latency - r.latency;
4336
4367
  })), I.length > 10 && I.splice(10).forEach((function(r) {
4337
- return q.delete(r.id);
4368
+ return J.delete(r.id);
4338
4369
  }));
4339
4370
  }
4340
4371
  }
4341
- }, ft = function(n) {
4372
+ }, gt = function(n) {
4342
4373
  var e = self.requestIdleCallback || self.setTimeout, t = -1;
4343
- return n = oe(n), document.visibilityState === "hidden" ? n() : (t = e(n), B(n)), t;
4344
- }, Ce = [200, 500], sn = function(n, e) {
4345
- "PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, X((function() {
4374
+ return n = ae(n), document.visibilityState === "hidden" ? n() : (t = e(n), X(n)), t;
4375
+ }, Re = [200, 500], rn = function(n, e) {
4376
+ "PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, G((function() {
4346
4377
  var t;
4347
- Js();
4378
+ en();
4348
4379
  var s, r = E("INP"), i = function(c) {
4349
- ft((function() {
4350
- c.forEach(tn);
4351
- var l = Zs();
4380
+ gt((function() {
4381
+ c.forEach(nn);
4382
+ var l = tn();
4352
4383
  l && l.latency !== r.value && (r.value = l.latency, r.entries = l.entries, s());
4353
4384
  }));
4354
4385
  }, o = U("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
4355
- s = v(n, r, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), B((function() {
4386
+ s = v(n, r, Re, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), X((function() {
4356
4387
  i(o.takeRecords()), s(!0);
4357
4388
  })), N((function() {
4358
- ht = dt(), I.length = 0, q.clear(), r = E("INP"), s = v(n, r, Ce, e.reportAllChanges);
4389
+ ft = ht(), I.length = 0, J.clear(), r = E("INP"), s = v(n, r, Re, e.reportAllChanges);
4359
4390
  })));
4360
4391
  })));
4361
- }, Re = [2500, 4e3], pe = {}, nn = function(n, e) {
4362
- e = e || {}, X((function() {
4363
- var t, s = De(), r = E("LCP"), i = function(l) {
4392
+ }, Ne = [2500, 4e3], Se = {}, on = function(n, e) {
4393
+ e = e || {}, G((function() {
4394
+ var t, s = Ue(), r = E("LCP"), i = function(l) {
4364
4395
  e.reportAllChanges || (l = l.slice(-1)), l.forEach((function(u) {
4365
- u.startTime < s.firstHiddenTime && (r.value = Math.max(u.startTime - ie(), 0), r.entries = [u], t());
4396
+ u.startTime < s.firstHiddenTime && (r.value = Math.max(u.startTime - oe(), 0), r.entries = [u], t());
4366
4397
  }));
4367
4398
  }, o = U("largest-contentful-paint", i);
4368
4399
  if (o) {
4369
- t = v(n, r, Re, e.reportAllChanges);
4370
- var c = oe((function() {
4371
- pe[r.id] || (i(o.takeRecords()), o.disconnect(), pe[r.id] = !0, t(!0));
4400
+ t = v(n, r, Ne, e.reportAllChanges);
4401
+ var c = ae((function() {
4402
+ Se[r.id] || (i(o.takeRecords()), o.disconnect(), Se[r.id] = !0, t(!0));
4372
4403
  }));
4373
4404
  ["keydown", "click"].forEach((function(l) {
4374
4405
  addEventListener(l, (function() {
4375
- return ft(c);
4406
+ return gt(c);
4376
4407
  }), { once: !0, capture: !0 });
4377
- })), B(c), N((function(l) {
4378
- r = E("LCP"), t = v(n, r, Re, e.reportAllChanges), ke((function() {
4379
- r.value = performance.now() - l.timeStamp, pe[r.id] = !0, t(!0);
4408
+ })), X(c), N((function(l) {
4409
+ r = E("LCP"), t = v(n, r, Ne, e.reportAllChanges), De((function() {
4410
+ r.value = performance.now() - l.timeStamp, Se[r.id] = !0, t(!0);
4380
4411
  }));
4381
4412
  }));
4382
4413
  }
4383
4414
  }));
4384
- }, Ne = [800, 1800], rn = function n(e) {
4385
- document.prerendering ? X((function() {
4415
+ }, Oe = [800, 1800], an = function n(e) {
4416
+ document.prerendering ? G((function() {
4386
4417
  return n(e);
4387
4418
  })) : document.readyState !== "complete" ? addEventListener("load", (function() {
4388
4419
  return n(e);
4389
4420
  }), !0) : setTimeout(e, 0);
4390
- }, on = function(n, e) {
4421
+ }, cn = function(n, e) {
4391
4422
  e = e || {};
4392
- var t = E("TTFB"), s = v(n, t, Ne, e.reportAllChanges);
4393
- rn((function() {
4394
- var r = Pe();
4395
- r && (t.value = Math.max(r.responseStart - ie(), 0), t.entries = [r], s(!0), N((function() {
4396
- t = E("TTFB", 0), (s = v(n, t, Ne, e.reportAllChanges))(!0);
4423
+ var t = E("TTFB"), s = v(n, t, Oe, e.reportAllChanges);
4424
+ an((function() {
4425
+ var r = ke();
4426
+ r && (t.value = Math.max(r.responseStart - oe(), 0), t.entries = [r], s(!0), N((function() {
4427
+ t = E("TTFB", 0), (s = v(n, t, Oe, e.reportAllChanges))(!0);
4397
4428
  })));
4398
4429
  }));
4399
- }, H = { passive: !0, capture: !0 }, an = /* @__PURE__ */ new Date(), tt = function(n, e) {
4400
- b || (b = e, x = n, at = /* @__PURE__ */ new Date(), mt(removeEventListener), gt());
4401
- }, gt = function() {
4402
- if (x >= 0 && x < at - an) {
4403
- var n = { entryType: "first-input", name: b.type, target: b.target, cancelable: b.cancelable, startTime: b.timeStamp, processingStart: b.timeStamp + x };
4404
- ne.forEach((function(e) {
4430
+ }, x = { passive: !0, capture: !0 }, ln = /* @__PURE__ */ new Date(), st = function(n, e) {
4431
+ b || (b = e, $ = n, ct = /* @__PURE__ */ new Date(), pt(removeEventListener), mt());
4432
+ }, mt = function() {
4433
+ if ($ >= 0 && $ < ct - ln) {
4434
+ var n = { entryType: "first-input", name: b.type, target: b.target, cancelable: b.cancelable, startTime: b.timeStamp, processingStart: b.timeStamp + $ };
4435
+ re.forEach((function(e) {
4405
4436
  e(n);
4406
- })), ne = [];
4437
+ })), re = [];
4407
4438
  }
4408
- }, cn = function(n) {
4439
+ }, un = function(n) {
4409
4440
  if (n.cancelable) {
4410
4441
  var e = (n.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - n.timeStamp;
4411
4442
  n.type == "pointerdown" ? (function(t, s) {
4412
4443
  var r = function() {
4413
- tt(t, s), o();
4444
+ st(t, s), o();
4414
4445
  }, i = function() {
4415
4446
  o();
4416
4447
  }, o = function() {
4417
- removeEventListener("pointerup", r, H), removeEventListener("pointercancel", i, H);
4448
+ removeEventListener("pointerup", r, x), removeEventListener("pointercancel", i, x);
4418
4449
  };
4419
- addEventListener("pointerup", r, H), addEventListener("pointercancel", i, H);
4420
- })(e, n) : tt(e, n);
4450
+ addEventListener("pointerup", r, x), addEventListener("pointercancel", i, x);
4451
+ })(e, n) : st(e, n);
4421
4452
  }
4422
- }, mt = function(n) {
4453
+ }, pt = function(n) {
4423
4454
  ["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
4424
- return n(e, cn, H);
4455
+ return n(e, un, x);
4425
4456
  }));
4426
- }, Oe = [100, 300], ln = function(n, e) {
4427
- e = e || {}, X((function() {
4428
- var t, s = De(), r = E("FID"), i = function(l) {
4457
+ }, Pe = [100, 300], dn = function(n, e) {
4458
+ e = e || {}, G((function() {
4459
+ var t, s = Ue(), r = E("FID"), i = function(l) {
4429
4460
  l.startTime < s.firstHiddenTime && (r.value = l.processingStart - l.startTime, r.entries.push(l), t(!0));
4430
4461
  }, o = function(l) {
4431
4462
  l.forEach(i);
4432
4463
  }, c = U("first-input", o);
4433
- t = v(n, r, Oe, e.reportAllChanges), c && (B(oe((function() {
4464
+ t = v(n, r, Pe, e.reportAllChanges), c && (X(ae((function() {
4434
4465
  o(c.takeRecords()), c.disconnect();
4435
4466
  }))), N((function() {
4436
4467
  var l;
4437
- r = E("FID"), t = v(n, r, Oe, e.reportAllChanges), ne = [], x = -1, b = null, mt(addEventListener), l = i, ne.push(l), gt();
4468
+ r = E("FID"), t = v(n, r, Pe, e.reportAllChanges), re = [], $ = -1, b = null, pt(addEventListener), l = i, re.push(l), mt();
4438
4469
  })));
4439
4470
  }));
4440
4471
  };
4441
- const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4472
+ const hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4442
4473
  __proto__: null,
4443
- CLSThresholds: Me,
4444
- FCPThresholds: be,
4445
- FIDThresholds: Oe,
4446
- INPThresholds: Ce,
4447
- LCPThresholds: Re,
4448
- TTFBThresholds: Ne,
4449
- onCLS: Ys,
4450
- onFCP: lt,
4451
- onFID: ln,
4452
- onINP: sn,
4453
- onLCP: nn,
4454
- onTTFB: on
4474
+ CLSThresholds: Ce,
4475
+ FCPThresholds: Me,
4476
+ FIDThresholds: Pe,
4477
+ INPThresholds: Re,
4478
+ LCPThresholds: Ne,
4479
+ TTFBThresholds: Oe,
4480
+ onCLS: Js,
4481
+ onFCP: ut,
4482
+ onFID: dn,
4483
+ onINP: rn,
4484
+ onLCP: on,
4485
+ onTTFB: cn
4455
4486
  }, Symbol.toStringTag, { value: "Module" }));
4456
4487
  export {
4457
4488
  m as AppConfigValidationError,
4458
- dn as DEFAULT_SESSION_TIMEOUT,
4459
- _e as DEFAULT_WEB_VITALS_MODE,
4489
+ fn as DEFAULT_SESSION_TIMEOUT,
4490
+ ye as DEFAULT_WEB_VITALS_MODE,
4460
4491
  w as DeviceType,
4461
4492
  D as EmitterEvent,
4462
- V as ErrorType,
4493
+ H as ErrorType,
4463
4494
  d as EventType,
4464
- Tn as InitializationTimeoutError,
4465
- Xe as IntegrationValidationError,
4466
- vn as MAX_ARRAY_LENGTH,
4467
- mn as MAX_CUSTOM_EVENT_ARRAY_SIZE,
4468
- gn as MAX_CUSTOM_EVENT_KEYS,
4469
- hn as MAX_CUSTOM_EVENT_NAME_LENGTH,
4470
- fn as MAX_CUSTOM_EVENT_STRING_SIZE,
4471
- pn as MAX_NESTED_OBJECT_KEYS,
4472
- Sn as MAX_STRING_LENGTH,
4473
- En as MAX_STRING_LENGTH_IN_ARRAY,
4474
- ee as Mode,
4475
- os as PII_PATTERNS,
4495
+ yn as InitializationTimeoutError,
4496
+ F as IntegrationValidationError,
4497
+ _n as MAX_ARRAY_LENGTH,
4498
+ Sn as MAX_CUSTOM_EVENT_ARRAY_SIZE,
4499
+ pn as MAX_CUSTOM_EVENT_KEYS,
4500
+ gn as MAX_CUSTOM_EVENT_NAME_LENGTH,
4501
+ mn as MAX_CUSTOM_EVENT_STRING_SIZE,
4502
+ En as MAX_NESTED_OBJECT_KEYS,
4503
+ vn as MAX_STRING_LENGTH,
4504
+ Tn as MAX_STRING_LENGTH_IN_ARRAY,
4505
+ te as Mode,
4506
+ as as PII_PATTERNS,
4476
4507
  M as PermanentError,
4477
- J as RateLimitError,
4478
- Be as SamplingRateValidationError,
4479
- Ee as ScrollDirection,
4480
- wt as SessionTimeoutValidationError,
4481
- F as SpecialApiUrl,
4482
- Z as TimeoutError,
4483
- $ as TraceLogValidationError,
4484
- _n as WEB_VITALS_GOOD_THRESHOLDS,
4508
+ Z as RateLimitError,
4509
+ Xe as SamplingRateValidationError,
4510
+ ve as ScrollDirection,
4511
+ At as SessionTimeoutValidationError,
4512
+ V as SpecialApiUrl,
4513
+ ee as TimeoutError,
4514
+ B as TraceLogValidationError,
4515
+ In as WEB_VITALS_GOOD_THRESHOLDS,
4485
4516
  ze as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
4486
- jt as WEB_VITALS_POOR_THRESHOLDS,
4517
+ Kt as WEB_VITALS_POOR_THRESHOLDS,
4487
4518
  Qe as getWebVitalsThresholds,
4488
- yn as tracelog
4519
+ wn as tracelog
4489
4520
  };