@tracelog/lib 3.1.1 → 3.2.0-rc.123.9
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.
- package/README.md +3 -2
- package/dist/browser/tracelog.esm.js +512 -424
- package/dist/browser/tracelog.esm.js.map +1 -1
- package/dist/browser/tracelog.js +2 -2
- package/dist/browser/tracelog.js.map +1 -1
- package/dist/public-api.cjs +2 -2
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +40 -15
- package/dist/public-api.d.ts +40 -15
- package/dist/public-api.js +2 -2
- package/dist/public-api.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
1
|
+
const En = 9e5;
|
|
2
|
+
const vn = 120, Tn = 49152, _n = 100, yn = 500, In = 200;
|
|
3
|
+
const wn = 1e3, An = 500, bn = 1e3;
|
|
4
|
+
const b = "data-tlog", vt = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
7
7
|
'input[type="button"]',
|
|
@@ -38,6 +38,11 @@ const L = "data-tlog", vt = [
|
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
40
40
|
"session",
|
|
41
|
+
"sessionid",
|
|
42
|
+
"session_id",
|
|
43
|
+
"jwt",
|
|
44
|
+
"bearer",
|
|
45
|
+
"oauth",
|
|
41
46
|
"reset",
|
|
42
47
|
"password",
|
|
43
48
|
"api_key",
|
|
@@ -67,66 +72,66 @@ const y = {
|
|
|
67
72
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
68
73
|
/<embed\b[^>]*>/gi,
|
|
69
74
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
70
|
-
], g = "tlog",
|
|
71
|
-
var
|
|
72
|
-
class
|
|
75
|
+
], g = "tlog", Y = `${g}:qa_mode`, Ee = `${g}:uid`, nt = "tlog_mode", Ue = "qa", Fe = "qa_off", le = (n) => n ? `${g}:${n}:queue` : `${g}:queue`, ue = (n) => n ? `${g}:${n}:rate_limit` : `${g}:rate_limit`, It = (n, e) => `${g}:beacon:${n}:${e}`, wt = (n) => n ? `${g}:${n}:session` : `${g}:session`, At = (n) => n ? `${g}:${n}:broadcast` : `${g}:broadcast`, Ve = (n, e) => `${g}:${n}:session_counts:${e}`, He = 10080 * 60 * 1e3, xe = `${g}:session_counts_last_cleanup`, $e = 3600 * 1e3, de = (n) => n ? `${g}:${n}:identity` : `${g}:identity`, P = `${g}:pending_identity`;
|
|
76
|
+
var M = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(M || {}), w = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(w || {}), V = /* @__PURE__ */ ((n) => (n.EVENT = "event", n.QUEUE = "queue", n))(V || {});
|
|
77
|
+
class C extends Error {
|
|
73
78
|
constructor(e, t, s) {
|
|
74
|
-
super(e), this.statusCode = t, this.responseCode = s, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
79
|
+
super(e), this.statusCode = t, this.responseCode = s, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, C);
|
|
75
80
|
}
|
|
76
81
|
statusCode;
|
|
77
82
|
responseCode;
|
|
78
83
|
}
|
|
79
|
-
class
|
|
84
|
+
class Z extends Error {
|
|
80
85
|
constructor(e) {
|
|
81
|
-
super(e), this.name = "RateLimitError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
86
|
+
super(e), this.name = "RateLimitError", Error.captureStackTrace && Error.captureStackTrace(this, Z);
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
|
-
class
|
|
89
|
+
class ee extends Error {
|
|
85
90
|
constructor(e) {
|
|
86
|
-
super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
91
|
+
super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this, ee);
|
|
87
92
|
}
|
|
88
93
|
}
|
|
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 || {}),
|
|
90
|
-
class
|
|
94
|
+
var d = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n))(d || {}), ve = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(ve || {}), x = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n))(x || {}), te = /* @__PURE__ */ ((n) => (n.QA = "qa", n))(te || {});
|
|
95
|
+
class X extends Error {
|
|
91
96
|
constructor(e, t, s) {
|
|
92
97
|
super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
93
98
|
}
|
|
94
99
|
errorCode;
|
|
95
100
|
layer;
|
|
96
101
|
}
|
|
97
|
-
class m extends
|
|
102
|
+
class m extends X {
|
|
98
103
|
constructor(e, t = "config") {
|
|
99
104
|
super(e, "APP_CONFIG_INVALID", t);
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
|
-
class
|
|
107
|
+
class bt extends X {
|
|
103
108
|
constructor(e, t = "config") {
|
|
104
109
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
|
-
class Be extends
|
|
112
|
+
class Be extends X {
|
|
108
113
|
constructor(e, t = "config") {
|
|
109
114
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
|
-
class Xe extends
|
|
117
|
+
class Xe extends X {
|
|
113
118
|
constructor(e, t = "config") {
|
|
114
119
|
super(e, "INTEGRATION_INVALID", t);
|
|
115
120
|
}
|
|
116
121
|
}
|
|
117
|
-
class
|
|
122
|
+
class Ln extends X {
|
|
118
123
|
constructor(e, t, s = "runtime") {
|
|
119
124
|
super(e, "INITIALIZATION_TIMEOUT", s), this.timeoutMs = t;
|
|
120
125
|
}
|
|
121
126
|
timeoutMs;
|
|
122
127
|
}
|
|
123
|
-
const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"],
|
|
128
|
+
const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], he = () => {
|
|
124
129
|
const n = new URLSearchParams(window.location.search), e = {};
|
|
125
130
|
return Lt.forEach((s) => {
|
|
126
131
|
const r = n.get(s);
|
|
127
132
|
r && (e[s] = r);
|
|
128
133
|
}), Object.keys(e).length ? e : void 0;
|
|
129
|
-
},
|
|
134
|
+
}, Mt = "https://ingest.tracelog.io", Ct = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Rt = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Nt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Ot = (n, e) => {
|
|
130
135
|
if (e) {
|
|
131
136
|
if (e instanceof Error) {
|
|
132
137
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
@@ -145,24 +150,24 @@ const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], de = () => {
|
|
|
145
150
|
return `[TraceLog] ${n}: ${String(e)}`;
|
|
146
151
|
}
|
|
147
152
|
return `[TraceLog] ${n}`;
|
|
148
|
-
},
|
|
153
|
+
}, Pt = () => {
|
|
149
154
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
150
155
|
return !1;
|
|
151
156
|
try {
|
|
152
|
-
return sessionStorage.getItem(
|
|
157
|
+
return sessionStorage.getItem(Y) === "true";
|
|
153
158
|
} catch {
|
|
154
159
|
return !1;
|
|
155
160
|
}
|
|
156
161
|
}, a = (n, e, t) => {
|
|
157
|
-
const { error: s, data: r, showToClient: i = !1, style: o, visibility: c } = t ?? {}, l = s ?
|
|
158
|
-
if (!
|
|
162
|
+
const { error: s, data: r, showToClient: i = !1, style: o, visibility: c } = t ?? {}, l = s ? Ot(e, s) : `[TraceLog] ${e}`, u = n === "error" ? "error" : n === "warn" ? "warn" : "log";
|
|
163
|
+
if (!kt(c, i))
|
|
159
164
|
return;
|
|
160
|
-
const p =
|
|
161
|
-
|
|
162
|
-
},
|
|
165
|
+
const p = Dt(c, o), S = r !== void 0 ? Te(r) : void 0;
|
|
166
|
+
Ut(u, l, p, S);
|
|
167
|
+
}, kt = (n, e) => n === "critical" ? !0 : n === "qa" || e ? Pt() : !1, Dt = (n, e) => e !== void 0 && e !== "" ? e : n === "critical" ? Nt : "", Ut = (n, e, t, s) => {
|
|
163
168
|
const r = t !== void 0 && t !== "", i = r ? `%c${e}` : e;
|
|
164
169
|
s !== void 0 ? r ? console[n](i, t, s) : console[n](i, s) : r ? console[n](i, t) : console[n](i);
|
|
165
|
-
},
|
|
170
|
+
}, Te = (n) => {
|
|
166
171
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
167
172
|
for (const [s, r] of Object.entries(n)) {
|
|
168
173
|
const i = s.toLowerCase();
|
|
@@ -170,16 +175,16 @@ const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], de = () => {
|
|
|
170
175
|
e[s] = "[REDACTED]";
|
|
171
176
|
continue;
|
|
172
177
|
}
|
|
173
|
-
r !== null && typeof r == "object" && !Array.isArray(r) ? e[s] =
|
|
174
|
-
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ?
|
|
178
|
+
r !== null && typeof r == "object" && !Array.isArray(r) ? e[s] = Te(r) : Array.isArray(r) ? e[s] = r.map(
|
|
179
|
+
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? Te(o) : o
|
|
175
180
|
) : e[s] = r;
|
|
176
181
|
}
|
|
177
182
|
return e;
|
|
178
183
|
};
|
|
179
|
-
let
|
|
180
|
-
const
|
|
181
|
-
typeof window < "u" && !
|
|
182
|
-
},
|
|
184
|
+
let _e, rt;
|
|
185
|
+
const Ft = () => {
|
|
186
|
+
typeof window < "u" && !_e && (_e = window.matchMedia("(pointer: coarse)"), rt = window.matchMedia("(hover: none)"));
|
|
187
|
+
}, se = "Unknown", Vt = (n) => {
|
|
183
188
|
const e = n.userAgentData?.platform;
|
|
184
189
|
if (e != null && e !== "") {
|
|
185
190
|
if (/windows/i.test(e)) return "Windows";
|
|
@@ -190,8 +195,8 @@ const Dt = () => {
|
|
|
190
195
|
if (/ios/i.test(e)) return "iOS";
|
|
191
196
|
}
|
|
192
197
|
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" :
|
|
194
|
-
},
|
|
198
|
+
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;
|
|
199
|
+
}, Ht = (n) => {
|
|
195
200
|
const e = n.userAgentData?.brands;
|
|
196
201
|
if (e != null && e.length > 0) {
|
|
197
202
|
const r = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
@@ -201,36 +206,36 @@ const Dt = () => {
|
|
|
201
206
|
}
|
|
202
207
|
}
|
|
203
208
|
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" :
|
|
205
|
-
},
|
|
209
|
+
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;
|
|
210
|
+
}, xt = () => {
|
|
206
211
|
try {
|
|
207
212
|
const n = navigator;
|
|
208
213
|
if (n.userAgentData != null && typeof n.userAgentData.mobile == "boolean") {
|
|
209
214
|
const l = n.userAgentData.platform;
|
|
210
215
|
return l != null && l !== "" && /ipad|tablet/i.test(l) ? w.Tablet : n.userAgentData.mobile ? w.Mobile : w.Desktop;
|
|
211
216
|
}
|
|
212
|
-
|
|
213
|
-
const e = window.innerWidth, t =
|
|
217
|
+
Ft();
|
|
218
|
+
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
219
|
return e <= 767 || o && r ? w.Mobile : e >= 768 && e <= 1024 || c || t && s && r ? w.Tablet : w.Desktop;
|
|
215
220
|
} catch (n) {
|
|
216
221
|
return a("debug", "Device detection failed, defaulting to desktop", { error: n }), w.Desktop;
|
|
217
222
|
}
|
|
218
|
-
},
|
|
223
|
+
}, $t = () => {
|
|
219
224
|
try {
|
|
220
225
|
const n = navigator;
|
|
221
226
|
return {
|
|
222
|
-
type:
|
|
223
|
-
os:
|
|
224
|
-
browser:
|
|
227
|
+
type: xt(),
|
|
228
|
+
os: Vt(n),
|
|
229
|
+
browser: Ht(n)
|
|
225
230
|
};
|
|
226
231
|
} catch (n) {
|
|
227
232
|
return a("debug", "Device info detection failed, using defaults", { error: n }), {
|
|
228
233
|
type: w.Desktop,
|
|
229
|
-
os:
|
|
230
|
-
browser:
|
|
234
|
+
os: se,
|
|
235
|
+
browser: se
|
|
231
236
|
};
|
|
232
237
|
}
|
|
233
|
-
},
|
|
238
|
+
}, je = 500, Ge = 2e3, We = 5e3, q = 50, Bt = q * 2, it = 1, Xt = 1e3, jt = 10, Ke = 5e3, Gt = 3, Wt = 200, Kt = 6e4, zt = 64, Qt = 10 * 6e4, Yt = 200, Mn = {
|
|
234
239
|
LCP: 2500,
|
|
235
240
|
FCP: 1800,
|
|
236
241
|
CLS: 0.1,
|
|
@@ -242,24 +247,24 @@ const Dt = () => {
|
|
|
242
247
|
CLS: 0.1,
|
|
243
248
|
INP: 200,
|
|
244
249
|
TTFB: 800
|
|
245
|
-
},
|
|
250
|
+
}, qt = {
|
|
246
251
|
LCP: 4e3,
|
|
247
252
|
FCP: 3e3,
|
|
248
253
|
CLS: 0.25,
|
|
249
254
|
INP: 500,
|
|
250
255
|
TTFB: 1800
|
|
251
|
-
},
|
|
256
|
+
}, ye = "needs-improvement", Qe = (n = ye) => {
|
|
252
257
|
switch (n) {
|
|
253
258
|
case "all":
|
|
254
259
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0 };
|
|
255
260
|
case "needs-improvement":
|
|
256
261
|
return ze;
|
|
257
262
|
case "poor":
|
|
258
|
-
return
|
|
263
|
+
return qt;
|
|
259
264
|
default:
|
|
260
265
|
return ze;
|
|
261
266
|
}
|
|
262
|
-
},
|
|
267
|
+
}, Jt = 50, Zt = "3.2.0", es = Zt, ts = () => typeof window < "u" && typeof sessionStorage < "u", ss = () => {
|
|
263
268
|
try {
|
|
264
269
|
const n = new URLSearchParams(window.location.search);
|
|
265
270
|
n.delete(nt);
|
|
@@ -267,23 +272,75 @@ const Dt = () => {
|
|
|
267
272
|
window.history.replaceState({}, "", t);
|
|
268
273
|
} catch {
|
|
269
274
|
}
|
|
270
|
-
},
|
|
271
|
-
if (!
|
|
275
|
+
}, ns = () => {
|
|
276
|
+
if (!ts())
|
|
272
277
|
return !1;
|
|
273
278
|
try {
|
|
274
|
-
const e = new URLSearchParams(window.location.search).get(nt), t = sessionStorage.getItem(
|
|
279
|
+
const e = new URLSearchParams(window.location.search).get(nt), t = sessionStorage.getItem(Y);
|
|
275
280
|
let s = null;
|
|
276
|
-
return e === Ue ? (s = !0, sessionStorage.setItem(
|
|
281
|
+
return e === Ue ? (s = !0, sessionStorage.setItem(Y, "true"), a("info", "QA Mode ACTIVE", {
|
|
277
282
|
visibility: "qa",
|
|
278
|
-
style:
|
|
279
|
-
})) : e === Fe && (s = !1, sessionStorage.setItem(
|
|
283
|
+
style: Ct
|
|
284
|
+
})) : e === Fe && (s = !1, sessionStorage.setItem(Y, "false"), a("info", "QA Mode DISABLED", {
|
|
280
285
|
visibility: "qa",
|
|
281
|
-
style:
|
|
282
|
-
})), (e === Ue || e === Fe) &&
|
|
286
|
+
style: Rt
|
|
287
|
+
})), (e === Ue || e === Fe) && ss(), s ?? t === "true";
|
|
288
|
+
} catch {
|
|
289
|
+
return !1;
|
|
290
|
+
}
|
|
291
|
+
}, ot = () => typeof document < "u" && document.prerendering === !0, rs = (n) => {
|
|
292
|
+
try {
|
|
293
|
+
return new URL(n).protocol === "https:";
|
|
283
294
|
} catch {
|
|
284
295
|
return !1;
|
|
285
296
|
}
|
|
286
|
-
},
|
|
297
|
+
}, is = (n) => `${Mt}/p/${encodeURIComponent(n)}/collect`, os = (n) => {
|
|
298
|
+
try {
|
|
299
|
+
const t = new URL(window.location.href).hostname;
|
|
300
|
+
if (!t || typeof t != "string")
|
|
301
|
+
throw new Error("Invalid hostname");
|
|
302
|
+
if (t === "localhost" || t === "127.0.0.1" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t))
|
|
303
|
+
throw new Error(
|
|
304
|
+
"SaaS integration requires a domain hostname; localhost and IP addresses are not supported. For local development, omit `integrations.tracelog` to run in standalone mode (events emitted locally, no network requests), or test against a staging domain that resolves to your dev machine via /etc/hosts."
|
|
305
|
+
);
|
|
306
|
+
const s = t.split(".");
|
|
307
|
+
if (!s || !Array.isArray(s) || s.length === 0 || s.length === 1 && s[0] === "")
|
|
308
|
+
throw new Error("Invalid hostname structure");
|
|
309
|
+
if (s.length === 1)
|
|
310
|
+
throw new Error("Single-part domain not supported for SaaS integration");
|
|
311
|
+
const r = s.length === 2 ? s.join(".") : s.slice(-2).join(".");
|
|
312
|
+
if (!r || r.split(".").length < 2)
|
|
313
|
+
throw new Error("Invalid domain structure for SaaS");
|
|
314
|
+
const i = `https://${n}.${r}/collect`;
|
|
315
|
+
if (!rs(i))
|
|
316
|
+
throw new Error("Generated URL failed validation");
|
|
317
|
+
return i;
|
|
318
|
+
} catch (e) {
|
|
319
|
+
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
320
|
+
}
|
|
321
|
+
}, as = (n) => {
|
|
322
|
+
const e = {}, t = n.integrations?.tracelog;
|
|
323
|
+
return t?.projectId && (e.saas = t.firstParty ? os(t.projectId) : is(t.projectId)), e;
|
|
324
|
+
}, D = (n, e = []) => {
|
|
325
|
+
if (!n || typeof n != "string")
|
|
326
|
+
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof n } }), n || "";
|
|
327
|
+
try {
|
|
328
|
+
let t, s = !1;
|
|
329
|
+
try {
|
|
330
|
+
t = new URL(n);
|
|
331
|
+
} catch {
|
|
332
|
+
const c = window.location.href;
|
|
333
|
+
t = new URL(n, c), s = t.origin === new URL(c).origin;
|
|
334
|
+
}
|
|
335
|
+
const r = t.searchParams, i = [.../* @__PURE__ */ new Set([..._t, ...e])];
|
|
336
|
+
let o = !1;
|
|
337
|
+
for (const c of i)
|
|
338
|
+
r.has(c) && (r.delete(c), o = !0);
|
|
339
|
+
return !o && (s || n.includes("?")) ? n : (t.search = r.toString(), s ? `${t.pathname}${t.search}${t.hash}` : t.toString());
|
|
340
|
+
} catch (t) {
|
|
341
|
+
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: n?.length } }), n;
|
|
342
|
+
}
|
|
343
|
+
}, cs = [
|
|
287
344
|
"co.uk",
|
|
288
345
|
"org.uk",
|
|
289
346
|
"com.au",
|
|
@@ -300,18 +357,18 @@ const Dt = () => {
|
|
|
300
357
|
if (e.length <= 2)
|
|
301
358
|
return n.toLowerCase();
|
|
302
359
|
const t = e.slice(-2).join(".");
|
|
303
|
-
return
|
|
304
|
-
},
|
|
305
|
-
const
|
|
306
|
-
if (!
|
|
360
|
+
return cs.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
361
|
+
}, ls = (n, e) => n === e ? !0 : Ye(n) === Ye(e), fe = (n = []) => {
|
|
362
|
+
const e = document.referrer;
|
|
363
|
+
if (!e)
|
|
307
364
|
return "Direct";
|
|
308
365
|
try {
|
|
309
|
-
const
|
|
310
|
-
return
|
|
311
|
-
} catch (
|
|
312
|
-
return a("debug", "Failed to parse referrer URL, using raw value", { error:
|
|
366
|
+
const t = new URL(e).hostname.toLowerCase(), s = window.location.hostname.toLowerCase();
|
|
367
|
+
return ls(t, s) ? "Direct" : D(e, n);
|
|
368
|
+
} catch (t) {
|
|
369
|
+
return a("debug", "Failed to parse referrer URL, using raw value", { error: t, data: { referrer: e } }), e;
|
|
313
370
|
}
|
|
314
|
-
},
|
|
371
|
+
}, ge = () => {
|
|
315
372
|
const n = new URLSearchParams(window.location.search), e = {};
|
|
316
373
|
return Tt.forEach((s) => {
|
|
317
374
|
const r = n.get(s);
|
|
@@ -324,11 +381,11 @@ const Dt = () => {
|
|
|
324
381
|
const e = Math.random() * 16 | 0;
|
|
325
382
|
return (n === "x" ? e : e & 3 | 8).toString(16);
|
|
326
383
|
});
|
|
327
|
-
let
|
|
328
|
-
const
|
|
384
|
+
let K = 0, z = 0;
|
|
385
|
+
const us = () => {
|
|
329
386
|
let n = Date.now();
|
|
330
|
-
n <
|
|
331
|
-
const e =
|
|
387
|
+
n < z && (n = z), n === z ? K = (K + 1) % 1e3 : K = 0, z = n;
|
|
388
|
+
const e = K.toString().padStart(3, "0");
|
|
332
389
|
let t = "";
|
|
333
390
|
try {
|
|
334
391
|
if (typeof crypto < "u" && crypto.getRandomValues) {
|
|
@@ -338,52 +395,6 @@ const ss = () => {
|
|
|
338
395
|
} catch {
|
|
339
396
|
}
|
|
340
397
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${n}-${e}-${t}`;
|
|
341
|
-
}, ns = (n) => {
|
|
342
|
-
try {
|
|
343
|
-
return new URL(n).protocol === "https:";
|
|
344
|
-
} catch {
|
|
345
|
-
return !1;
|
|
346
|
-
}
|
|
347
|
-
}, rs = (n) => {
|
|
348
|
-
try {
|
|
349
|
-
const t = new URL(window.location.href).hostname;
|
|
350
|
-
if (!t || typeof t != "string")
|
|
351
|
-
throw new Error("Invalid hostname");
|
|
352
|
-
if (t === "localhost" || t === "127.0.0.1" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t))
|
|
353
|
-
throw new Error(
|
|
354
|
-
"SaaS integration requires a domain hostname; localhost and IP addresses are not supported. For local development, omit `integrations.tracelog` to run in standalone mode (events emitted locally, no network requests), or test against a staging domain that resolves to your dev machine via /etc/hosts."
|
|
355
|
-
);
|
|
356
|
-
const s = t.split(".");
|
|
357
|
-
if (!s || !Array.isArray(s) || s.length === 0 || s.length === 1 && s[0] === "")
|
|
358
|
-
throw new Error("Invalid hostname structure");
|
|
359
|
-
if (s.length === 1)
|
|
360
|
-
throw new Error("Single-part domain not supported for SaaS integration");
|
|
361
|
-
const r = s.length === 2 ? s.join(".") : s.slice(-2).join(".");
|
|
362
|
-
if (!r || r.split(".").length < 2)
|
|
363
|
-
throw new Error("Invalid domain structure for SaaS");
|
|
364
|
-
const i = `https://${n}.${r}/collect`;
|
|
365
|
-
if (!ns(i))
|
|
366
|
-
throw new Error("Generated URL failed validation");
|
|
367
|
-
return i;
|
|
368
|
-
} catch (e) {
|
|
369
|
-
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
370
|
-
}
|
|
371
|
-
}, is = (n) => {
|
|
372
|
-
const e = {};
|
|
373
|
-
return n.integrations?.tracelog?.projectId && (e.saas = rs(n.integrations.tracelog.projectId)), e;
|
|
374
|
-
}, ye = (n, e = []) => {
|
|
375
|
-
if (!n || typeof n != "string")
|
|
376
|
-
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof n } }), n || "";
|
|
377
|
-
try {
|
|
378
|
-
const t = new URL(n), s = t.searchParams, r = [.../* @__PURE__ */ new Set([..._t, ...e])];
|
|
379
|
-
let i = !1;
|
|
380
|
-
const o = [];
|
|
381
|
-
return r.forEach((c) => {
|
|
382
|
-
s.has(c) && (s.delete(c), i = !0, o.push(c));
|
|
383
|
-
}), !i && n.includes("?") ? n : (t.search = s.toString(), t.toString());
|
|
384
|
-
} catch (t) {
|
|
385
|
-
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: n?.length } }), n;
|
|
386
|
-
}
|
|
387
398
|
}, qe = (n) => {
|
|
388
399
|
if (!n || typeof n != "string" || n.trim().length === 0)
|
|
389
400
|
return "";
|
|
@@ -425,7 +436,7 @@ const ss = () => {
|
|
|
425
436
|
return t;
|
|
426
437
|
}
|
|
427
438
|
return null;
|
|
428
|
-
},
|
|
439
|
+
}, ds = (n) => {
|
|
429
440
|
if (typeof n != "object" || n === null)
|
|
430
441
|
return {};
|
|
431
442
|
try {
|
|
@@ -435,7 +446,7 @@ const ss = () => {
|
|
|
435
446
|
const t = e instanceof Error ? e.message : String(e);
|
|
436
447
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
437
448
|
}
|
|
438
|
-
},
|
|
449
|
+
}, hs = [
|
|
439
450
|
// Email addresses.
|
|
440
451
|
// Quantifiers are bounded (local part ≤64, each label ≤63, TLD ≤63 per RFC/DNS limits)
|
|
441
452
|
// and the domain is matched as discrete dot-separated labels so the local-part and
|
|
@@ -456,20 +467,20 @@ const ss = () => {
|
|
|
456
467
|
/:\/\/[^:/]+:([^@]+)@/gi,
|
|
457
468
|
// Sensitive URL query parameters (token=, password=, auth=, secret=, api_key=, …)
|
|
458
469
|
/[?&](token|password|passwd|auth|secret|secret_key|private_key|auth_key|api_key|apikey|access_token)=[^&\s]+/gi
|
|
459
|
-
],
|
|
470
|
+
], U = (n) => {
|
|
460
471
|
let e = n;
|
|
461
|
-
for (const t of
|
|
472
|
+
for (const t of hs)
|
|
462
473
|
e = e.replace(t, "[REDACTED]");
|
|
463
474
|
return e;
|
|
464
|
-
},
|
|
475
|
+
}, fs = (n) => {
|
|
465
476
|
if (n !== void 0 && (n === null || typeof n != "object"))
|
|
466
477
|
throw new m("Configuration must be an object", "config");
|
|
467
478
|
if (n) {
|
|
468
479
|
if (n.sessionTimeout !== void 0 && (typeof n.sessionTimeout != "number" || n.sessionTimeout < 3e4 || n.sessionTimeout > 864e5))
|
|
469
|
-
throw new
|
|
480
|
+
throw new bt(y.INVALID_SESSION_TIMEOUT, "config");
|
|
470
481
|
if (n.globalMetadata !== void 0 && (typeof n.globalMetadata != "object" || n.globalMetadata === null))
|
|
471
482
|
throw new m(y.INVALID_GLOBAL_METADATA, "config");
|
|
472
|
-
if (n.integrations &&
|
|
483
|
+
if (n.integrations && gs(n.integrations), n.sensitiveQueryParams !== void 0) {
|
|
473
484
|
if (!Array.isArray(n.sensitiveQueryParams))
|
|
474
485
|
throw new m(y.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
475
486
|
for (const e of n.sensitiveQueryParams)
|
|
@@ -529,14 +540,14 @@ const ss = () => {
|
|
|
529
540
|
}
|
|
530
541
|
}
|
|
531
542
|
}
|
|
532
|
-
},
|
|
543
|
+
}, gs = (n) => {
|
|
533
544
|
if (n && n.tracelog) {
|
|
534
545
|
if (!n.tracelog.projectId || typeof n.tracelog.projectId != "string" || n.tracelog.projectId.trim() === "")
|
|
535
546
|
throw new Xe(y.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
536
547
|
if (n.tracelog.shopify !== void 0 && typeof n.tracelog.shopify != "boolean")
|
|
537
548
|
throw new Xe("tracelog.shopify must be a boolean", "config");
|
|
538
549
|
}
|
|
539
|
-
},
|
|
550
|
+
}, ms = (n) => (fs(n), {
|
|
540
551
|
...n ?? {},
|
|
541
552
|
sessionTimeout: n?.sessionTimeout ?? 9e5,
|
|
542
553
|
globalMetadata: n?.globalMetadata ?? {},
|
|
@@ -554,13 +565,13 @@ const ss = () => {
|
|
|
554
565
|
return !0;
|
|
555
566
|
const t = typeof n;
|
|
556
567
|
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
|
-
},
|
|
568
|
+
}, ps = (n) => typeof n != "object" || n === null ? !1 : we(n), Ae = (n) => {
|
|
558
569
|
if (typeof n != "object" || n === null || Array.isArray(n)) return;
|
|
559
570
|
const e = {};
|
|
560
571
|
for (const [t, s] of Object.entries(n))
|
|
561
572
|
typeof s == "string" && (e[t] = s);
|
|
562
573
|
return Object.keys(e).length > 0 ? e : void 0;
|
|
563
|
-
},
|
|
574
|
+
}, Ss = (n) => typeof n != "string" ? {
|
|
564
575
|
valid: !1,
|
|
565
576
|
error: "Event name must be a string"
|
|
566
577
|
} : n.length === 0 ? {
|
|
@@ -576,8 +587,8 @@ const ss = () => {
|
|
|
576
587
|
valid: !1,
|
|
577
588
|
error: "Event name cannot be a reserved word"
|
|
578
589
|
} : { valid: !0 }, Je = (n, e, t) => {
|
|
579
|
-
const s =
|
|
580
|
-
if (!
|
|
590
|
+
const s = ds(e), r = `${t} "${n}" metadata error`;
|
|
591
|
+
if (!ps(s))
|
|
581
592
|
return {
|
|
582
593
|
valid: !1,
|
|
583
594
|
error: `${r}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -625,7 +636,7 @@ const ss = () => {
|
|
|
625
636
|
valid: !0,
|
|
626
637
|
sanitizedMetadata: s
|
|
627
638
|
};
|
|
628
|
-
},
|
|
639
|
+
}, Es = (n, e, t) => {
|
|
629
640
|
if (Array.isArray(e)) {
|
|
630
641
|
const s = [], r = `${t} "${n}" metadata error`;
|
|
631
642
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -649,15 +660,15 @@ const ss = () => {
|
|
|
649
660
|
};
|
|
650
661
|
}
|
|
651
662
|
return Je(n, e, t);
|
|
652
|
-
},
|
|
653
|
-
const t =
|
|
663
|
+
}, vs = (n, e) => {
|
|
664
|
+
const t = Ss(n);
|
|
654
665
|
if (!t.valid)
|
|
655
666
|
return a("error", "Event name validation failed", {
|
|
656
667
|
data: { eventName: n, error: t.error }
|
|
657
668
|
}), t;
|
|
658
669
|
if (!e)
|
|
659
670
|
return { valid: !0 };
|
|
660
|
-
const s =
|
|
671
|
+
const s = Es(n, e, "customEvent");
|
|
661
672
|
return s.valid || a("error", "Event metadata validation failed", {
|
|
662
673
|
data: {
|
|
663
674
|
eventName: n,
|
|
@@ -665,7 +676,7 @@ const ss = () => {
|
|
|
665
676
|
}
|
|
666
677
|
}), s;
|
|
667
678
|
};
|
|
668
|
-
class
|
|
679
|
+
class Ts {
|
|
669
680
|
listeners = /* @__PURE__ */ new Map();
|
|
670
681
|
/**
|
|
671
682
|
* Subscribes to an event channel
|
|
@@ -782,15 +793,15 @@ class ms {
|
|
|
782
793
|
this.listeners.clear();
|
|
783
794
|
}
|
|
784
795
|
}
|
|
785
|
-
const
|
|
786
|
-
function
|
|
787
|
-
return n.replace(
|
|
796
|
+
const _s = /https?:\/\/\S+/g, ys = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, Is = /0x[0-9a-fA-F]{4,}/g, ws = /(?<!\d)\d{4,}(?!\d)/g, As = /(['"])[^'"]{20,}\1/g;
|
|
797
|
+
function bs(n) {
|
|
798
|
+
return n.replace(_s, "[URL]").replace(ys, "[ID]").replace(Is, "[ADDR]").replace(ws, "[N]").replace(As, "$1[VAR]$1").toLowerCase().trim();
|
|
788
799
|
}
|
|
789
800
|
function Ze(n) {
|
|
790
801
|
const e = n.search(/[?#]/);
|
|
791
802
|
return e === -1 ? n : n.slice(0, e);
|
|
792
803
|
}
|
|
793
|
-
function
|
|
804
|
+
function Ls(n, e) {
|
|
794
805
|
const t = Ze((n ?? "").trim());
|
|
795
806
|
if (!t) return "";
|
|
796
807
|
let s;
|
|
@@ -803,35 +814,42 @@ function ys(n, e) {
|
|
|
803
814
|
const r = Ze((e ?? "").trim());
|
|
804
815
|
return r && t === r ? s.origin : t;
|
|
805
816
|
}
|
|
806
|
-
function
|
|
807
|
-
const e =
|
|
817
|
+
function Ms(n) {
|
|
818
|
+
const e = bs(n.message), t = Ls(n.filename, n.page_url), s = n.line == null ? "" : String(n.line);
|
|
808
819
|
return `${e}|${t}|${s}`;
|
|
809
820
|
}
|
|
810
|
-
const
|
|
821
|
+
const me = { config: {} };
|
|
811
822
|
class T {
|
|
812
823
|
/**
|
|
813
824
|
* Retrieves a value from global state.
|
|
814
825
|
*/
|
|
815
826
|
get(e) {
|
|
816
|
-
return
|
|
827
|
+
return me[e];
|
|
817
828
|
}
|
|
818
829
|
/**
|
|
819
830
|
* Sets a value in global state.
|
|
820
831
|
*/
|
|
821
832
|
set(e, t) {
|
|
822
|
-
|
|
833
|
+
me[e] = t;
|
|
823
834
|
}
|
|
824
835
|
/**
|
|
825
836
|
* Returns an immutable snapshot of the entire global state.
|
|
826
837
|
*/
|
|
827
838
|
getState() {
|
|
828
|
-
return { ...
|
|
839
|
+
return { ...me };
|
|
829
840
|
}
|
|
830
841
|
}
|
|
831
|
-
class
|
|
842
|
+
class Cs extends T {
|
|
832
843
|
storeManager;
|
|
833
844
|
apiUrl;
|
|
834
845
|
lastPermanentErrorLog = null;
|
|
846
|
+
/**
|
|
847
|
+
* In-memory fallback for the beacon throttle when localStorage is
|
|
848
|
+
* unavailable. The primary throttle state lives in localStorage (see
|
|
849
|
+
* {@link HEALTH_BEACON_KEY}) so it survives MPA navigations and is shared
|
|
850
|
+
* across tabs.
|
|
851
|
+
*/
|
|
852
|
+
lastBeaconAt = {};
|
|
835
853
|
recoveryInProgress = !1;
|
|
836
854
|
lastMetadataTimestamp = 0;
|
|
837
855
|
pendingControllers = /* @__PURE__ */ new Set();
|
|
@@ -873,7 +891,7 @@ class ws extends T {
|
|
|
873
891
|
* cases so the migration is one-shot per browser.
|
|
874
892
|
*/
|
|
875
893
|
migrateLegacyV2Keys() {
|
|
876
|
-
const e = this.get("userId") || "anonymous", t = `${
|
|
894
|
+
const e = this.get("userId") || "anonymous", t = `${le(e)}:saas`, s = `${le(e)}:custom`, r = `${ue(e)}:saas`, i = `${ue(e)}:custom`;
|
|
877
895
|
try {
|
|
878
896
|
const o = this.storeManager.getItem(t);
|
|
879
897
|
if (o) {
|
|
@@ -919,11 +937,11 @@ class ws extends T {
|
|
|
919
937
|
}
|
|
920
938
|
getQueueStorageKey() {
|
|
921
939
|
const e = this.get("userId") || "anonymous";
|
|
922
|
-
return
|
|
940
|
+
return le(e);
|
|
923
941
|
}
|
|
924
942
|
getRateLimitStorageKey() {
|
|
925
943
|
const e = this.get("userId") || "anonymous";
|
|
926
|
-
return
|
|
944
|
+
return ue(e);
|
|
927
945
|
}
|
|
928
946
|
getActiveRateLimitKey() {
|
|
929
947
|
return this.rateLimitStorageKeyAtArm ?? this.getRateLimitStorageKey();
|
|
@@ -991,7 +1009,7 @@ class ws extends T {
|
|
|
991
1009
|
const t = this.ensureBatchMetadata(e), s = this.getPersistedData(), r = typeof s?.recoveryFailures == "number" && Number.isFinite(s.recoveryFailures) ? s.recoveryFailures : 0;
|
|
992
1010
|
return this.persistEventsWithFailureCount(t, r, !0), !1;
|
|
993
1011
|
}
|
|
994
|
-
return this.apiUrl.includes(
|
|
1012
|
+
return this.apiUrl.includes(M.Fail) ? (a("warn", "Fail mode: simulating network failure (sync)", { data: { events: e.events.length } }), !1) : this.apiUrl.includes(M.Localhost) ? (a("debug", "Success mode: simulating successful send (sync)", { data: { events: e.events.length } }), !0) : this.sendQueueSyncInternal(e);
|
|
995
1013
|
}
|
|
996
1014
|
/**
|
|
997
1015
|
* Sends events asynchronously using `fetch()` with retry, circuit breaker, and 429 cooldown.
|
|
@@ -1003,7 +1021,7 @@ class ws extends T {
|
|
|
1003
1021
|
const r = await this.send(s);
|
|
1004
1022
|
return r ? (this.clearPersistedEvents(), t?.onSuccess?.(s.events.length, s.events, s)) : (this.persistEvents(s), t?.onFailure?.()), r;
|
|
1005
1023
|
} catch (r) {
|
|
1006
|
-
return r instanceof
|
|
1024
|
+
return r instanceof C ? (this.logPermanentError("Permanent error, not retrying", r), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(s), t?.onFailure?.(), !1);
|
|
1007
1025
|
}
|
|
1008
1026
|
}
|
|
1009
1027
|
/**
|
|
@@ -1041,7 +1059,7 @@ class ws extends T {
|
|
|
1041
1059
|
}
|
|
1042
1060
|
await this.send(t) ? (this.clearPersistedEvents(), e?.onSuccess?.(r.events.length, r.events, t)) : (this.persistEventsWithFailureCount(t, s + 1, !0), e?.onFailure?.());
|
|
1043
1061
|
} catch (r) {
|
|
1044
|
-
if (r instanceof
|
|
1062
|
+
if (r instanceof C) {
|
|
1045
1063
|
this.logPermanentError("Permanent error during recovery, clearing persisted events", r), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1046
1064
|
return;
|
|
1047
1065
|
}
|
|
@@ -1062,9 +1080,9 @@ class ws extends T {
|
|
|
1062
1080
|
}
|
|
1063
1081
|
async send(e) {
|
|
1064
1082
|
const t = this.ensureBatchMetadata(e, e._metadata?.idempotency_token);
|
|
1065
|
-
if (this.apiUrl.includes(
|
|
1083
|
+
if (this.apiUrl.includes(M.Fail))
|
|
1066
1084
|
return a("debug", "Fail mode: simulating network failure", { data: { events: t.events.length } }), !1;
|
|
1067
|
-
if (this.apiUrl.includes(
|
|
1085
|
+
if (this.apiUrl.includes(M.Localhost))
|
|
1068
1086
|
return a("debug", "Success mode: simulating successful send", { data: { events: t.events.length } }), !0;
|
|
1069
1087
|
if (this.isRateLimited())
|
|
1070
1088
|
return a("debug", "Rate-limit cooldown active, skipping send", {
|
|
@@ -1092,15 +1110,15 @@ class ws extends T {
|
|
|
1092
1110
|
}), this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, !0) : !1;
|
|
1093
1111
|
} catch (l) {
|
|
1094
1112
|
const u = c === 3;
|
|
1095
|
-
if (l instanceof
|
|
1096
|
-
throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l;
|
|
1097
|
-
if (l instanceof
|
|
1113
|
+
if (l instanceof C)
|
|
1114
|
+
throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l.statusCode === 403 && this.emitHealthBeacon("events_blocked", l.message), l;
|
|
1115
|
+
if (l instanceof Z) {
|
|
1098
1116
|
this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, i = !1, o = !0, this.armRateLimitCooldown(Date.now() + 6e4), a("warn", "Rate limited, skipping retries", {
|
|
1099
1117
|
data: { events: e.events.length, attempt: c, cooldownMs: 6e4 }
|
|
1100
1118
|
});
|
|
1101
1119
|
break;
|
|
1102
1120
|
}
|
|
1103
|
-
if (l instanceof
|
|
1121
|
+
if (l instanceof ee || (i = !1), l instanceof TypeError || (o = !0), a(
|
|
1104
1122
|
u ? "error" : "warn",
|
|
1105
1123
|
`Send attempt ${c} failed${u ? " (all retries exhausted)" : ", will retry"}`,
|
|
1106
1124
|
{
|
|
@@ -1146,13 +1164,13 @@ class ws extends T {
|
|
|
1146
1164
|
if (!o.ok) {
|
|
1147
1165
|
if (o.status >= 400 && o.status < 500 && o.status !== 408 && o.status !== 429) {
|
|
1148
1166
|
const l = await this.readTraceLogErrorCode(o), u = l ? `HTTP ${o.status}: ${o.statusText} (${l})` : `HTTP ${o.status}: ${o.statusText}`;
|
|
1149
|
-
throw new
|
|
1167
|
+
throw new C(u, o.status, l);
|
|
1150
1168
|
}
|
|
1151
|
-
throw o.status === 429 ? new
|
|
1169
|
+
throw o.status === 429 ? new Z(`HTTP 429: ${o.statusText}`) : new Error(`HTTP ${o.status}: ${o.statusText}`);
|
|
1152
1170
|
}
|
|
1153
1171
|
return o;
|
|
1154
1172
|
} catch (o) {
|
|
1155
|
-
throw o instanceof
|
|
1173
|
+
throw o instanceof C ? o : r ? new ee("Request timed out") : o;
|
|
1156
1174
|
} finally {
|
|
1157
1175
|
clearTimeout(i), this.pendingControllers.delete(s);
|
|
1158
1176
|
}
|
|
@@ -1160,7 +1178,7 @@ class ws extends T {
|
|
|
1160
1178
|
async readTraceLogErrorCode(e) {
|
|
1161
1179
|
try {
|
|
1162
1180
|
const t = await e.clone().json();
|
|
1163
|
-
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <=
|
|
1181
|
+
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <= zt)
|
|
1164
1182
|
return t.code;
|
|
1165
1183
|
} catch {
|
|
1166
1184
|
}
|
|
@@ -1187,7 +1205,7 @@ class ws extends T {
|
|
|
1187
1205
|
idempotency_token: e._metadata?.idempotency_token ?? this.computeContentToken(e),
|
|
1188
1206
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1189
1207
|
timestamp: t,
|
|
1190
|
-
client_version:
|
|
1208
|
+
client_version: es
|
|
1191
1209
|
}
|
|
1192
1210
|
};
|
|
1193
1211
|
return {
|
|
@@ -1279,12 +1297,78 @@ class ws extends T {
|
|
|
1279
1297
|
}
|
|
1280
1298
|
logPermanentError(e, t) {
|
|
1281
1299
|
const s = Date.now(), r = `${t.statusCode ?? "unknown"}:${t.responseCode ?? ""}`;
|
|
1282
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== r || s - this.lastPermanentErrorLog.timestamp >=
|
|
1300
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== r || s - this.lastPermanentErrorLog.timestamp >= Kt) && (a("error", e, {
|
|
1283
1301
|
data: { status: t.statusCode, code: t.responseCode, message: t.message }
|
|
1284
1302
|
}), this.lastPermanentErrorLog = { key: r, timestamp: s });
|
|
1285
1303
|
}
|
|
1304
|
+
/**
|
|
1305
|
+
* Emits a low-frequency, deduplicated diagnostic "health beacon" to the gate-bypassing
|
|
1306
|
+
* `/client-error` endpoint. Best-effort and silent: never blocks, never throws, never logs to the
|
|
1307
|
+
* host page. Opt out via `integrations.tracelog.healthBeacon: false`.
|
|
1308
|
+
*/
|
|
1309
|
+
emitHealthBeacon(e, t) {
|
|
1310
|
+
try {
|
|
1311
|
+
const s = this.get("config")?.integrations?.tracelog;
|
|
1312
|
+
if (!s?.projectId || s.healthBeacon === !1) return;
|
|
1313
|
+
const r = this.resolveBeaconUrl();
|
|
1314
|
+
if (!r) return;
|
|
1315
|
+
const i = typeof window < "u" && window.location ? window.location.origin : "";
|
|
1316
|
+
if (!i || !this.markBeaconEmitted(s.projectId, e)) return;
|
|
1317
|
+
const o = JSON.stringify({
|
|
1318
|
+
projectId: s.projectId,
|
|
1319
|
+
reason: e,
|
|
1320
|
+
origin: i,
|
|
1321
|
+
...t ? { lastError: t.slice(0, Yt) } : {}
|
|
1322
|
+
});
|
|
1323
|
+
this.postBeacon(r, o);
|
|
1324
|
+
} catch {
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Throttle gate: returns `true` and records the emit timestamp when the
|
|
1329
|
+
* beacon may fire, `false` when still inside {@link HEALTH_BEACON_THROTTLE_MS}.
|
|
1330
|
+
*
|
|
1331
|
+
* State lives in localStorage so the window survives MPA navigations and is
|
|
1332
|
+
* shared across tabs; the in-memory map covers storage-disabled browsers.
|
|
1333
|
+
* The timestamp is deliberately recorded BEFORE the send attempt: if both
|
|
1334
|
+
* transports fail, waiting out the window is fine for a diagnostic signal
|
|
1335
|
+
* and avoids turning transport failures into retry bursts.
|
|
1336
|
+
*/
|
|
1337
|
+
markBeaconEmitted(e, t) {
|
|
1338
|
+
const s = Date.now(), r = It(e, t);
|
|
1339
|
+
let i = this.lastBeaconAt[t] ?? 0;
|
|
1340
|
+
try {
|
|
1341
|
+
const o = Number(this.storeManager.getItem(r));
|
|
1342
|
+
Number.isFinite(o) && o > i && (i = o);
|
|
1343
|
+
} catch {
|
|
1344
|
+
}
|
|
1345
|
+
if (s - i < Qt) return !1;
|
|
1346
|
+
this.lastBeaconAt[t] = s;
|
|
1347
|
+
try {
|
|
1348
|
+
this.storeManager.setItem(r, String(s));
|
|
1349
|
+
} catch {
|
|
1350
|
+
}
|
|
1351
|
+
return !0;
|
|
1352
|
+
}
|
|
1353
|
+
/** The collect URL the lib already derived, with the path swapped to the diagnostics route. */
|
|
1354
|
+
resolveBeaconUrl() {
|
|
1355
|
+
return this.apiUrl.includes(M.Localhost) || this.apiUrl.includes(M.Fail) || !/\/collect$/.test(this.apiUrl) ? null : this.apiUrl.replace(/\/collect$/, "/client-error");
|
|
1356
|
+
}
|
|
1357
|
+
postBeacon(e, t) {
|
|
1358
|
+
if (this.isSendBeaconAvailable()) {
|
|
1359
|
+
const s = new Blob([t], { type: "application/json" });
|
|
1360
|
+
if (navigator.sendBeacon(e, s)) return;
|
|
1361
|
+
}
|
|
1362
|
+
typeof fetch == "function" && fetch(e, {
|
|
1363
|
+
method: "POST",
|
|
1364
|
+
body: t,
|
|
1365
|
+
keepalive: !0,
|
|
1366
|
+
headers: { "Content-Type": "application/json" }
|
|
1367
|
+
}).catch(() => {
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1286
1370
|
}
|
|
1287
|
-
class
|
|
1371
|
+
class Rs extends T {
|
|
1288
1372
|
bootTime;
|
|
1289
1373
|
bootTimestamp;
|
|
1290
1374
|
hasPerformanceNow;
|
|
@@ -1318,8 +1402,8 @@ class As extends T {
|
|
|
1318
1402
|
} : { valid: !0 };
|
|
1319
1403
|
}
|
|
1320
1404
|
}
|
|
1321
|
-
const
|
|
1322
|
-
class
|
|
1405
|
+
const Ns = new Set(Object.values(d));
|
|
1406
|
+
class Os extends T {
|
|
1323
1407
|
dataSenders;
|
|
1324
1408
|
emitter;
|
|
1325
1409
|
timeManager;
|
|
@@ -1351,9 +1435,9 @@ class bs extends T {
|
|
|
1351
1435
|
* @param emitter - Optional event emitter for local event consumption
|
|
1352
1436
|
*/
|
|
1353
1437
|
constructor(e, t = null) {
|
|
1354
|
-
super(), this.emitter = t, this.timeManager = new
|
|
1438
|
+
super(), this.emitter = t, this.timeManager = new Rs(), this.dataSenders = [];
|
|
1355
1439
|
const s = this.get("collectApiUrls");
|
|
1356
|
-
s?.saas && this.dataSenders.push(new
|
|
1440
|
+
s?.saas && this.dataSenders.push(new Cs(e, s.saas)), this.saveSessionCountsDebounced = this.debounce((r) => {
|
|
1357
1441
|
this.saveSessionCounts(r);
|
|
1358
1442
|
}, 500), this.cleanupExpiredSessionCounts();
|
|
1359
1443
|
}
|
|
@@ -1471,7 +1555,7 @@ class bs extends T {
|
|
|
1471
1555
|
a("error", "Event type is required - event will be ignored");
|
|
1472
1556
|
return;
|
|
1473
1557
|
}
|
|
1474
|
-
if (!
|
|
1558
|
+
if (!Ns.has(e)) {
|
|
1475
1559
|
a("error", "Invalid event type - event will be ignored", {
|
|
1476
1560
|
data: { type: e }
|
|
1477
1561
|
});
|
|
@@ -1514,12 +1598,12 @@ class bs extends T {
|
|
|
1514
1598
|
}
|
|
1515
1599
|
const _ = this.getTypeLimitForEvent(S);
|
|
1516
1600
|
if (_) {
|
|
1517
|
-
const
|
|
1518
|
-
if (
|
|
1601
|
+
const ce = this.sessionEventCounts[S];
|
|
1602
|
+
if (ce !== void 0 && ce >= _) {
|
|
1519
1603
|
a("warn", "Session event type limit reached", {
|
|
1520
1604
|
data: {
|
|
1521
1605
|
type: S,
|
|
1522
|
-
count:
|
|
1606
|
+
count: ce,
|
|
1523
1607
|
limit: _
|
|
1524
1608
|
}
|
|
1525
1609
|
});
|
|
@@ -1532,7 +1616,7 @@ class bs extends T {
|
|
|
1532
1616
|
if (!this.checkPerEventRateLimit(o.name, _))
|
|
1533
1617
|
return;
|
|
1534
1618
|
}
|
|
1535
|
-
const St = S === d.SESSION_START, Et = t || this.get("pageUrl"),
|
|
1619
|
+
const St = S === d.SESSION_START, Et = t || this.get("pageUrl"), W = this.buildEventPayload({
|
|
1536
1620
|
type: S,
|
|
1537
1621
|
page_url: Et,
|
|
1538
1622
|
from_page_url: s,
|
|
@@ -1543,7 +1627,7 @@ class bs extends T {
|
|
|
1543
1627
|
error_data: l,
|
|
1544
1628
|
page_view: u
|
|
1545
1629
|
});
|
|
1546
|
-
if (
|
|
1630
|
+
if (W && !(!p && !this.shouldSample())) {
|
|
1547
1631
|
if (St) {
|
|
1548
1632
|
const _ = this.get("sessionId");
|
|
1549
1633
|
if (!_) {
|
|
@@ -1558,18 +1642,18 @@ class bs extends T {
|
|
|
1558
1642
|
}
|
|
1559
1643
|
this.set("hasStartSession", !0);
|
|
1560
1644
|
}
|
|
1561
|
-
if (!this.isDuplicateEvent(
|
|
1562
|
-
if (this.get("mode") ===
|
|
1645
|
+
if (!this.isDuplicateEvent(W)) {
|
|
1646
|
+
if (this.get("mode") === te.QA && S === d.CUSTOM && o) {
|
|
1563
1647
|
a("info", `Custom Event: ${o.name}`, {
|
|
1564
1648
|
visibility: "qa",
|
|
1565
1649
|
data: {
|
|
1566
1650
|
name: o.name,
|
|
1567
1651
|
...o.metadata && { metadata: o.metadata }
|
|
1568
1652
|
}
|
|
1569
|
-
}), this.emitEvent(
|
|
1653
|
+
}), this.emitEvent(W);
|
|
1570
1654
|
return;
|
|
1571
1655
|
}
|
|
1572
|
-
if (this.addToQueue(
|
|
1656
|
+
if (this.addToQueue(W), !p) {
|
|
1573
1657
|
this.sessionEventCounts.total++, this.sessionEventCounts[S] !== void 0 && this.sessionEventCounts[S]++;
|
|
1574
1658
|
const _ = this.get("sessionId");
|
|
1575
1659
|
_ && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(_);
|
|
@@ -2027,7 +2111,7 @@ class bs extends T {
|
|
|
2027
2111
|
});
|
|
2028
2112
|
const c = this.get("sessionReferrer"), l = this.get("sessionUtm"), u = this.get("sessionClickIds");
|
|
2029
2113
|
return { ...{
|
|
2030
|
-
id:
|
|
2114
|
+
id: us(),
|
|
2031
2115
|
type: e.type,
|
|
2032
2116
|
page_url: r,
|
|
2033
2117
|
timestamp: i,
|
|
@@ -2135,11 +2219,11 @@ class bs extends T {
|
|
|
2135
2219
|
emitEvent(e) {
|
|
2136
2220
|
if (this.emitter) {
|
|
2137
2221
|
const { _session_id: t, ...s } = e;
|
|
2138
|
-
this.emitter.emit(
|
|
2222
|
+
this.emitter.emit(V.EVENT, s);
|
|
2139
2223
|
}
|
|
2140
2224
|
}
|
|
2141
2225
|
emitEventsQueue(e) {
|
|
2142
|
-
this.emitter && this.emitter.emit(
|
|
2226
|
+
this.emitter && this.emitter.emit(V.QUEUE, e);
|
|
2143
2227
|
}
|
|
2144
2228
|
/**
|
|
2145
2229
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2339,7 +2423,7 @@ class bs extends T {
|
|
|
2339
2423
|
}
|
|
2340
2424
|
}
|
|
2341
2425
|
}
|
|
2342
|
-
class
|
|
2426
|
+
class Ps {
|
|
2343
2427
|
/**
|
|
2344
2428
|
* Gets or creates a unique user ID.
|
|
2345
2429
|
*
|
|
@@ -2357,15 +2441,15 @@ class Ms {
|
|
|
2357
2441
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2358
2442
|
*/
|
|
2359
2443
|
static getId(e) {
|
|
2360
|
-
const t = e.getItem(
|
|
2444
|
+
const t = e.getItem(Ee);
|
|
2361
2445
|
if (t)
|
|
2362
2446
|
return t;
|
|
2363
2447
|
const s = at();
|
|
2364
|
-
return e.setItem(
|
|
2448
|
+
return e.setItem(Ee, s), s;
|
|
2365
2449
|
}
|
|
2366
2450
|
}
|
|
2367
|
-
const
|
|
2368
|
-
class
|
|
2451
|
+
const ks = /^\d{13}-[a-z0-9]{9}$/;
|
|
2452
|
+
class Ds extends T {
|
|
2369
2453
|
storageManager;
|
|
2370
2454
|
eventManager;
|
|
2371
2455
|
projectId;
|
|
@@ -2392,7 +2476,7 @@ class Rs extends T {
|
|
|
2392
2476
|
return;
|
|
2393
2477
|
}
|
|
2394
2478
|
const e = this.getProjectId();
|
|
2395
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2479
|
+
this.broadcastChannel = new BroadcastChannel(At(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2396
2480
|
const { action: s, sessionId: r, timestamp: i, projectId: o } = t.data ?? {};
|
|
2397
2481
|
if (o === e)
|
|
2398
2482
|
if (s === "session_start" && r && typeof i == "number" && i > Date.now() - 5e3) {
|
|
@@ -2417,7 +2501,7 @@ class Rs extends T {
|
|
|
2417
2501
|
const e = this.loadStoredSession();
|
|
2418
2502
|
if (!e)
|
|
2419
2503
|
return null;
|
|
2420
|
-
if (!
|
|
2504
|
+
if (!ks.test(e.id))
|
|
2421
2505
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2422
2506
|
data: { sessionId: e.id }
|
|
2423
2507
|
}), this.clearStoredSession(), null;
|
|
@@ -2463,7 +2547,7 @@ class Rs extends T {
|
|
|
2463
2547
|
this.storageManager.setItem(t, s), this.storageManager.setSessionItem(t, s);
|
|
2464
2548
|
}
|
|
2465
2549
|
getSessionStorageKey() {
|
|
2466
|
-
return
|
|
2550
|
+
return wt(this.getProjectId());
|
|
2467
2551
|
}
|
|
2468
2552
|
getProjectId() {
|
|
2469
2553
|
return this.projectId;
|
|
@@ -2536,9 +2620,9 @@ class Rs extends T {
|
|
|
2536
2620
|
let s, r, i;
|
|
2537
2621
|
if (e) {
|
|
2538
2622
|
const o = this.loadStoredSession();
|
|
2539
|
-
s = o?.referrer ??
|
|
2623
|
+
s = o?.referrer ?? fe(this.get("config").sensitiveQueryParams), r = o?.utm ?? ge(), i = o?.clickIds ?? he();
|
|
2540
2624
|
} else
|
|
2541
|
-
s =
|
|
2625
|
+
s = fe(this.get("config").sensitiveQueryParams), r = ge(), i = he();
|
|
2542
2626
|
a("debug", "Session tracking initialized", {
|
|
2543
2627
|
data: {
|
|
2544
2628
|
sessionId: t,
|
|
@@ -2610,7 +2694,7 @@ class Rs extends T {
|
|
|
2610
2694
|
*/
|
|
2611
2695
|
renewSession() {
|
|
2612
2696
|
this.needsRenewal = !1;
|
|
2613
|
-
const e = this.generateSessionId(), t =
|
|
2697
|
+
const e = this.generateSessionId(), t = fe(this.get("config").sensitiveQueryParams), s = ge(), r = he();
|
|
2614
2698
|
a("debug", "Renewing session after timeout", {
|
|
2615
2699
|
data: { newSessionId: e }
|
|
2616
2700
|
}), 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({
|
|
@@ -2740,7 +2824,7 @@ class Rs extends T {
|
|
|
2740
2824
|
this.prerenderActivationHandler && (document.removeEventListener("prerenderingchange", this.prerenderActivationHandler), this.prerenderActivationHandler = null);
|
|
2741
2825
|
}
|
|
2742
2826
|
}
|
|
2743
|
-
class
|
|
2827
|
+
class Us extends T {
|
|
2744
2828
|
eventManager;
|
|
2745
2829
|
storageManager;
|
|
2746
2830
|
sessionManager = null;
|
|
@@ -2775,7 +2859,7 @@ class Ns extends T {
|
|
|
2775
2859
|
}
|
|
2776
2860
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
2777
2861
|
try {
|
|
2778
|
-
this.sessionManager = new
|
|
2862
|
+
this.sessionManager = new Ds(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
2779
2863
|
} catch (s) {
|
|
2780
2864
|
if (this.sessionManager) {
|
|
2781
2865
|
try {
|
|
@@ -2828,7 +2912,7 @@ class Ns extends T {
|
|
|
2828
2912
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
2829
2913
|
}
|
|
2830
2914
|
}
|
|
2831
|
-
class
|
|
2915
|
+
class Fs extends T {
|
|
2832
2916
|
eventManager;
|
|
2833
2917
|
onTrack;
|
|
2834
2918
|
originalPushState;
|
|
@@ -2868,7 +2952,7 @@ class Os extends T {
|
|
|
2868
2952
|
};
|
|
2869
2953
|
}
|
|
2870
2954
|
trackCurrentPage = () => {
|
|
2871
|
-
const e = window.location.href, t =
|
|
2955
|
+
const e = window.location.href, t = D(e, this.get("config").sensitiveQueryParams);
|
|
2872
2956
|
if (this.get("pageUrl") === t)
|
|
2873
2957
|
return;
|
|
2874
2958
|
const s = Date.now(), r = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -2886,7 +2970,7 @@ class Os extends T {
|
|
|
2886
2970
|
}), this.get("config").flushOnSpaNavigation === !0 && this.eventManager.flushImmediately();
|
|
2887
2971
|
};
|
|
2888
2972
|
trackInitialPageView() {
|
|
2889
|
-
const e =
|
|
2973
|
+
const e = D(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
2890
2974
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
2891
2975
|
type: d.PAGE_VIEW,
|
|
2892
2976
|
page_url: e,
|
|
@@ -2894,7 +2978,7 @@ class Os extends T {
|
|
|
2894
2978
|
}), this.onTrack();
|
|
2895
2979
|
}
|
|
2896
2980
|
extractPageViewData() {
|
|
2897
|
-
const
|
|
2981
|
+
const e = document.referrer ? D(document.referrer, this.get("config").sensitiveQueryParams) : "", { title: t } = document;
|
|
2898
2982
|
if (!(!e && !t))
|
|
2899
2983
|
return {
|
|
2900
2984
|
...e && { referrer: e },
|
|
@@ -2902,7 +2986,7 @@ class Os extends T {
|
|
|
2902
2986
|
};
|
|
2903
2987
|
}
|
|
2904
2988
|
}
|
|
2905
|
-
class
|
|
2989
|
+
class Vs extends T {
|
|
2906
2990
|
eventManager;
|
|
2907
2991
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
2908
2992
|
clickHandler;
|
|
@@ -2970,7 +3054,7 @@ class Ps extends T {
|
|
|
2970
3054
|
this.clickHandler && (window.removeEventListener("click", this.clickHandler, !0), this.clickHandler = void 0), this.lastClickTimes.clear(), this.lastPruneTime = 0;
|
|
2971
3055
|
}
|
|
2972
3056
|
shouldIgnoreElement(e) {
|
|
2973
|
-
return e.hasAttribute(`${
|
|
3057
|
+
return e.hasAttribute(`${b}-ignore`) ? !0 : e.closest(`[${b}-ignore]`) !== null;
|
|
2974
3058
|
}
|
|
2975
3059
|
/**
|
|
2976
3060
|
* Checks per-element click throttling to prevent double-clicks and rapid spam
|
|
@@ -3021,8 +3105,8 @@ class Ps extends T {
|
|
|
3021
3105
|
const t = e.getAttribute("data-testid");
|
|
3022
3106
|
if (t)
|
|
3023
3107
|
return `[data-testid="${t}"]`;
|
|
3024
|
-
const s = e.getAttribute(`${
|
|
3025
|
-
return s ? `[${
|
|
3108
|
+
const s = e.getAttribute(`${b}-name`);
|
|
3109
|
+
return s ? `[${b}-name="${s}"]` : this.getElementPath(e);
|
|
3026
3110
|
}
|
|
3027
3111
|
/**
|
|
3028
3112
|
* Generates a DOM path for an element (e.g., "body>div>button")
|
|
@@ -3041,7 +3125,7 @@ class Ps extends T {
|
|
|
3041
3125
|
return t.join(">") || "unknown";
|
|
3042
3126
|
}
|
|
3043
3127
|
findTrackingElement(e) {
|
|
3044
|
-
return e.hasAttribute(`${
|
|
3128
|
+
return e.hasAttribute(`${b}-name`) ? e : e.closest(`[${b}-name]`);
|
|
3045
3129
|
}
|
|
3046
3130
|
getRelevantClickElement(e) {
|
|
3047
3131
|
for (const t of vt)
|
|
@@ -3062,7 +3146,7 @@ class Ps extends T {
|
|
|
3062
3146
|
return typeof t != "number" || typeof s != "number" || !Number.isFinite(t) || !Number.isFinite(s) || t === 0 && s === 0 && !e.isTrusted ? null : { x: t, y: s };
|
|
3063
3147
|
}
|
|
3064
3148
|
extractTrackingData(e) {
|
|
3065
|
-
const t = e.getAttribute(`${
|
|
3149
|
+
const t = e.getAttribute(`${b}-name`), s = e.getAttribute(`${b}-value`);
|
|
3066
3150
|
if (t)
|
|
3067
3151
|
return {
|
|
3068
3152
|
element: e,
|
|
@@ -3071,15 +3155,15 @@ class Ps extends T {
|
|
|
3071
3155
|
};
|
|
3072
3156
|
}
|
|
3073
3157
|
generateClickData(e, t, s) {
|
|
3074
|
-
const { x: r, y: i } = s, o = this.getRelevantText(e, t), c = t.getAttribute("href")
|
|
3158
|
+
const { x: r, y: i } = s, o = this.getRelevantText(e, t), c = t.getAttribute("href"), l = c ? D(c, this.get("config").sensitiveQueryParams) : void 0;
|
|
3075
3159
|
return {
|
|
3076
3160
|
x: r,
|
|
3077
3161
|
y: i,
|
|
3078
3162
|
tag: t.tagName.toLowerCase(),
|
|
3079
|
-
...t.id && { id: t.id },
|
|
3080
|
-
...t.className && { class: t.className },
|
|
3163
|
+
...t.id && { id: U(t.id) },
|
|
3164
|
+
...t.className && { class: U(t.className) },
|
|
3081
3165
|
...o && { text: o },
|
|
3082
|
-
...
|
|
3166
|
+
...l && { href: l }
|
|
3083
3167
|
};
|
|
3084
3168
|
}
|
|
3085
3169
|
getRelevantText(e, t) {
|
|
@@ -3087,7 +3171,7 @@ class Ps extends T {
|
|
|
3087
3171
|
if (!s && !r)
|
|
3088
3172
|
return "";
|
|
3089
3173
|
let i = "";
|
|
3090
|
-
return s && s.length <= 255 ? i = s : r.length <= 255 ? i = r : i = r.slice(0, 252) + "...",
|
|
3174
|
+
return s && s.length <= 255 ? i = s : r.length <= 255 ? i = r : i = r.slice(0, 252) + "...", U(i);
|
|
3091
3175
|
}
|
|
3092
3176
|
createCustomEventData(e) {
|
|
3093
3177
|
return {
|
|
@@ -3096,7 +3180,7 @@ class Ps extends T {
|
|
|
3096
3180
|
};
|
|
3097
3181
|
}
|
|
3098
3182
|
}
|
|
3099
|
-
class
|
|
3183
|
+
class Hs extends T {
|
|
3100
3184
|
eventManager;
|
|
3101
3185
|
containers = [];
|
|
3102
3186
|
limitWarningLogged = !1;
|
|
@@ -3222,7 +3306,7 @@ class ks extends T {
|
|
|
3222
3306
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
3223
3307
|
}
|
|
3224
3308
|
getScrollDirection(e, t) {
|
|
3225
|
-
return e > t ?
|
|
3309
|
+
return e > t ? ve.DOWN : ve.UP;
|
|
3226
3310
|
}
|
|
3227
3311
|
calculateScrollDepth(e, t, s) {
|
|
3228
3312
|
if (t <= s)
|
|
@@ -3251,8 +3335,8 @@ class ks extends T {
|
|
|
3251
3335
|
return s && r;
|
|
3252
3336
|
}
|
|
3253
3337
|
}
|
|
3254
|
-
const
|
|
3255
|
-
class
|
|
3338
|
+
const xs = "tracelog_session_id", $s = "tracelog_user_id";
|
|
3339
|
+
class Bs extends T {
|
|
3256
3340
|
visibilityHandler = null;
|
|
3257
3341
|
pageshowHandler = null;
|
|
3258
3342
|
lastSyncedKey = null;
|
|
@@ -3273,8 +3357,8 @@ class Fs extends T {
|
|
|
3273
3357
|
r !== this.lastSyncedKey && (this.lastSyncedKey = r, this.postCartUpdate(e, s));
|
|
3274
3358
|
}
|
|
3275
3359
|
postCartUpdate(e, t) {
|
|
3276
|
-
const s = { [
|
|
3277
|
-
t.length > 0 && (s[
|
|
3360
|
+
const s = { [xs]: e };
|
|
3361
|
+
t.length > 0 && (s[$s] = t);
|
|
3278
3362
|
try {
|
|
3279
3363
|
fetch("/cart/update.js", {
|
|
3280
3364
|
method: "POST",
|
|
@@ -3311,7 +3395,7 @@ class Fs extends T {
|
|
|
3311
3395
|
this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.pageshowHandler && (window.removeEventListener("pageshow", this.pageshowHandler), this.pageshowHandler = null);
|
|
3312
3396
|
}
|
|
3313
3397
|
}
|
|
3314
|
-
class
|
|
3398
|
+
class Xs {
|
|
3315
3399
|
storage;
|
|
3316
3400
|
sessionStorageRef;
|
|
3317
3401
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -3424,7 +3508,7 @@ class Vs {
|
|
|
3424
3508
|
this.fallbackSessionStorage.delete(e);
|
|
3425
3509
|
}
|
|
3426
3510
|
}
|
|
3427
|
-
class
|
|
3511
|
+
class js extends T {
|
|
3428
3512
|
eventManager;
|
|
3429
3513
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
3430
3514
|
navigationHistory = [];
|
|
@@ -3432,9 +3516,11 @@ class Hs extends T {
|
|
|
3432
3516
|
observers = [];
|
|
3433
3517
|
vitalThresholds;
|
|
3434
3518
|
navigationCounter = 0;
|
|
3435
|
-
//
|
|
3519
|
+
// Suffix counter for repeat navigations to the same path (SPA A→B→A)
|
|
3520
|
+
currentNavBase = null;
|
|
3521
|
+
currentNavId = null;
|
|
3436
3522
|
constructor(e) {
|
|
3437
|
-
super(), this.eventManager = e, this.vitalThresholds = Qe(
|
|
3523
|
+
super(), this.eventManager = e, this.vitalThresholds = Qe(ye);
|
|
3438
3524
|
}
|
|
3439
3525
|
/**
|
|
3440
3526
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -3450,7 +3536,7 @@ class Hs extends T {
|
|
|
3450
3536
|
* @returns Promise that resolves when tracking is initialized
|
|
3451
3537
|
*/
|
|
3452
3538
|
async startTracking() {
|
|
3453
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
3539
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? ye;
|
|
3454
3540
|
this.vitalThresholds = Qe(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals();
|
|
3455
3541
|
}
|
|
3456
3542
|
/**
|
|
@@ -3469,7 +3555,7 @@ class Hs extends T {
|
|
|
3469
3555
|
} catch (s) {
|
|
3470
3556
|
a("debug", "Failed to disconnect performance observer", { error: s, data: { observerIndex: t } });
|
|
3471
3557
|
}
|
|
3472
|
-
}), this.observers.length = 0, this.reportedByNav.clear(), this.navigationHistory.length = 0;
|
|
3558
|
+
}), this.observers.length = 0, this.reportedByNav.clear(), this.navigationHistory.length = 0, this.navigationCounter = 0, this.currentNavBase = null, this.currentNavId = null;
|
|
3473
3559
|
}
|
|
3474
3560
|
observeWebVitalsFallback() {
|
|
3475
3561
|
this.reportTTFB(), this.safeObserve(
|
|
@@ -3521,7 +3607,7 @@ class Hs extends T {
|
|
|
3521
3607
|
}
|
|
3522
3608
|
async initWebVitals() {
|
|
3523
3609
|
try {
|
|
3524
|
-
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() =>
|
|
3610
|
+
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() => Sn), o = (c) => (l) => {
|
|
3525
3611
|
const u = Number(l.value.toFixed(2));
|
|
3526
3612
|
this.sendVital({ type: c, value: u });
|
|
3527
3613
|
};
|
|
@@ -3551,7 +3637,7 @@ class Hs extends T {
|
|
|
3551
3637
|
return;
|
|
3552
3638
|
if (s)
|
|
3553
3639
|
s.add(e.type);
|
|
3554
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
3640
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Jt) {
|
|
3555
3641
|
const i = this.navigationHistory.shift();
|
|
3556
3642
|
i && this.reportedByNav.delete(i);
|
|
3557
3643
|
}
|
|
@@ -3572,21 +3658,23 @@ class Hs extends T {
|
|
|
3572
3658
|
});
|
|
3573
3659
|
}
|
|
3574
3660
|
/**
|
|
3575
|
-
* Generates a
|
|
3661
|
+
* Generates a deterministic navigation identifier for deduplication.
|
|
3576
3662
|
*
|
|
3577
|
-
* **Purpose**:
|
|
3578
|
-
*
|
|
3663
|
+
* **Purpose**: Every call within the same navigation must return the SAME id,
|
|
3664
|
+
* so `reportedByNav` can collapse duplicate Web Vitals (one emission per
|
|
3665
|
+
* metric type per navigation — critical for the fallback observers, which
|
|
3666
|
+
* fire per entry batch).
|
|
3579
3667
|
*
|
|
3580
|
-
* **ID Format**: `{
|
|
3668
|
+
* **ID Format**: `{startTime}_{pathname}` or `{startTime}_{pathname}_{counter}`
|
|
3581
3669
|
*
|
|
3582
|
-
* **
|
|
3583
|
-
* -
|
|
3584
|
-
*
|
|
3585
|
-
*
|
|
3586
|
-
*
|
|
3587
|
-
*
|
|
3588
|
-
*
|
|
3589
|
-
*
|
|
3670
|
+
* **Determinism**:
|
|
3671
|
+
* - Base id is derived only from the navigation entry's `startTime` (0 by spec
|
|
3672
|
+
* for the document navigation — no `performance.now()` fallback, which made
|
|
3673
|
+
* every call unique) and the current pathname.
|
|
3674
|
+
* - The id is cached per navigation; the counter suffix is appended ONLY on a
|
|
3675
|
+
* real collision: a new navigation whose base id was already reported
|
|
3676
|
+
* (SPA revisit to the same path, e.g. A→B→A), so the revisit's vitals are
|
|
3677
|
+
* not suppressed by the first visit's dedup entries.
|
|
3590
3678
|
*
|
|
3591
3679
|
* @returns Navigation ID string or null if navigation timing unavailable
|
|
3592
3680
|
*
|
|
@@ -3597,8 +3685,8 @@ class Hs extends T {
|
|
|
3597
3685
|
const e = performance.getEntriesByType("navigation")[0];
|
|
3598
3686
|
if (!e)
|
|
3599
3687
|
return null;
|
|
3600
|
-
const t = e.startTime
|
|
3601
|
-
return
|
|
3688
|
+
const t = `${e.startTime.toFixed(2)}_${window.location.pathname}`;
|
|
3689
|
+
return t === this.currentNavBase && this.currentNavId !== null ? this.currentNavId : (this.currentNavBase = t, this.currentNavId = this.reportedByNav.has(t) ? `${t}_${++this.navigationCounter}` : t, this.currentNavId);
|
|
3602
3690
|
} catch (e) {
|
|
3603
3691
|
return a("debug", "Failed to get navigation ID", { error: e }), null;
|
|
3604
3692
|
}
|
|
@@ -3642,7 +3730,7 @@ class Hs extends T {
|
|
|
3642
3730
|
return !(typeof s == "number" && t <= s);
|
|
3643
3731
|
}
|
|
3644
3732
|
}
|
|
3645
|
-
class
|
|
3733
|
+
class ne extends T {
|
|
3646
3734
|
eventManager;
|
|
3647
3735
|
emitter;
|
|
3648
3736
|
recentErrors = /* @__PURE__ */ new Map();
|
|
@@ -3669,7 +3757,7 @@ class se extends T {
|
|
|
3669
3757
|
this.resetPageviewCounter();
|
|
3670
3758
|
}, window.addEventListener("pagehide", this.pagehideHandler, { passive: !0 }), this.emitter && (this.pageviewResetListener = (e) => {
|
|
3671
3759
|
(e.type === d.SESSION_START || e.type === d.PAGE_VIEW) && this.resetPageviewCounter();
|
|
3672
|
-
}, this.emitter.on(
|
|
3760
|
+
}, this.emitter.on(V.EVENT, this.pageviewResetListener));
|
|
3673
3761
|
}
|
|
3674
3762
|
/**
|
|
3675
3763
|
* Stops tracking errors and cleans up resources.
|
|
@@ -3680,7 +3768,7 @@ class se extends T {
|
|
|
3680
3768
|
* - Resets burst detection counters
|
|
3681
3769
|
*/
|
|
3682
3770
|
stopTracking() {
|
|
3683
|
-
window.removeEventListener("error", this.handleError), window.removeEventListener("unhandledrejection", this.handleRejection), this.pagehideHandler && (window.removeEventListener("pagehide", this.pagehideHandler), this.pagehideHandler = null), this.emitter && this.pageviewResetListener && (this.emitter.off(
|
|
3771
|
+
window.removeEventListener("error", this.handleError), window.removeEventListener("unhandledrejection", this.handleRejection), this.pagehideHandler && (window.removeEventListener("pagehide", this.pagehideHandler), this.pagehideHandler = null), this.emitter && this.pageviewResetListener && (this.emitter.off(V.EVENT, this.pageviewResetListener), this.pageviewResetListener = null), this.recentErrors.clear(), this.pageviewSignatureCounts.clear(), this.errorBurstCounter = 0, this.burstWindowStart = 0, this.burstBackoffUntil = 0;
|
|
3684
3772
|
}
|
|
3685
3773
|
/**
|
|
3686
3774
|
* Clears the per-pageview signature counter.
|
|
@@ -3699,7 +3787,7 @@ class se extends T {
|
|
|
3699
3787
|
const e = Date.now();
|
|
3700
3788
|
if (e < this.burstBackoffUntil)
|
|
3701
3789
|
return !1;
|
|
3702
|
-
if (e - this.burstWindowStart >
|
|
3790
|
+
if (e - this.burstWindowStart > Xt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > jt)
|
|
3703
3791
|
return this.burstBackoffUntil = e + Ke, a("debug", "Error burst detected - entering cooldown", {
|
|
3704
3792
|
data: {
|
|
3705
3793
|
errorsInWindow: this.errorBurstCounter,
|
|
@@ -3716,19 +3804,19 @@ class se extends T {
|
|
|
3716
3804
|
* later signature that recycles the same map key after a counter reset.
|
|
3717
3805
|
*/
|
|
3718
3806
|
shouldThrottleBySignature(e) {
|
|
3719
|
-
const t =
|
|
3720
|
-
if (s >=
|
|
3807
|
+
const t = Ms(e), s = this.pageviewSignatureCounts.get(t) ?? 0;
|
|
3808
|
+
if (s >= Gt)
|
|
3721
3809
|
return a("debug", "Error throttled (pageview cap)", {
|
|
3722
3810
|
data: { signature: t, count: s }
|
|
3723
3811
|
}), !0;
|
|
3724
3812
|
const r = s + 1;
|
|
3725
|
-
return this.pageviewSignatureCounts.set(t, r), this.pageviewSignatureCounts.size >
|
|
3813
|
+
return this.pageviewSignatureCounts.set(t, r), this.pageviewSignatureCounts.size > Wt && (this.pageviewSignatureCounts.clear(), this.pageviewSignatureCounts.set(t, r)), !1;
|
|
3726
3814
|
}
|
|
3727
3815
|
handleError = (e) => {
|
|
3728
3816
|
if (!this.shouldSample())
|
|
3729
3817
|
return;
|
|
3730
3818
|
const t = this.sanitize(e.message || "Unknown error");
|
|
3731
|
-
if (this.shouldSuppressError(
|
|
3819
|
+
if (this.shouldSuppressError(x.JS_ERROR, t) || this.shouldThrottleBySignature({
|
|
3732
3820
|
message: t,
|
|
3733
3821
|
filename: e.filename,
|
|
3734
3822
|
line: e.lineno,
|
|
@@ -3743,7 +3831,7 @@ class se extends T {
|
|
|
3743
3831
|
this.eventManager.track({
|
|
3744
3832
|
type: d.ERROR,
|
|
3745
3833
|
error_data: {
|
|
3746
|
-
type:
|
|
3834
|
+
type: x.JS_ERROR,
|
|
3747
3835
|
message: t,
|
|
3748
3836
|
...r !== void 0 && { name: r },
|
|
3749
3837
|
...e.filename !== "" && { filename: e.filename },
|
|
@@ -3757,13 +3845,13 @@ class se extends T {
|
|
|
3757
3845
|
if (!this.shouldSample())
|
|
3758
3846
|
return;
|
|
3759
3847
|
const t = this.extractRejectionMessage(e.reason), s = this.sanitize(t);
|
|
3760
|
-
if (this.shouldSuppressError(
|
|
3848
|
+
if (this.shouldSuppressError(x.PROMISE_REJECTION, s) || this.shouldThrottleBySignature({ message: s }))
|
|
3761
3849
|
return;
|
|
3762
3850
|
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;
|
|
3763
3851
|
this.eventManager.track({
|
|
3764
3852
|
type: d.ERROR,
|
|
3765
3853
|
error_data: {
|
|
3766
|
-
type:
|
|
3854
|
+
type: x.PROMISE_REJECTION,
|
|
3767
3855
|
message: s,
|
|
3768
3856
|
...i !== void 0 && { name: i },
|
|
3769
3857
|
...r !== void 0 && { stack: r }
|
|
@@ -3784,41 +3872,41 @@ class se extends T {
|
|
|
3784
3872
|
}
|
|
3785
3873
|
}
|
|
3786
3874
|
sanitize(e) {
|
|
3787
|
-
const t = e.length >
|
|
3788
|
-
return
|
|
3875
|
+
const t = e.length > je ? e.slice(0, je) + "..." : e;
|
|
3876
|
+
return U(t);
|
|
3789
3877
|
}
|
|
3790
3878
|
shouldSuppressError(e, t) {
|
|
3791
3879
|
const s = Date.now(), r = `${e}:${t}`, i = this.recentErrors.get(r);
|
|
3792
|
-
return i !== void 0 && s - i <
|
|
3880
|
+
return i !== void 0 && s - i < We ? (this.recentErrors.set(r, s), !0) : (this.recentErrors.set(r, s), this.recentErrors.size > Bt ? (this.recentErrors.clear(), this.recentErrors.set(r, s), !1) : (this.recentErrors.size > q && this.pruneOldErrors(), !1));
|
|
3793
3881
|
}
|
|
3794
3882
|
static TRUNCATION_SUFFIX = `
|
|
3795
3883
|
...truncated`;
|
|
3796
3884
|
truncateStack(e) {
|
|
3797
|
-
if (e.length <=
|
|
3798
|
-
const t =
|
|
3799
|
-
return
|
|
3885
|
+
if (e.length <= Ge) return U(e);
|
|
3886
|
+
const t = Ge - ne.TRUNCATION_SUFFIX.length, s = e.slice(0, t) + ne.TRUNCATION_SUFFIX;
|
|
3887
|
+
return U(s);
|
|
3800
3888
|
}
|
|
3801
3889
|
pruneOldErrors() {
|
|
3802
3890
|
const e = Date.now();
|
|
3803
3891
|
for (const [r, i] of this.recentErrors.entries())
|
|
3804
|
-
e - i >
|
|
3805
|
-
if (this.recentErrors.size <=
|
|
3892
|
+
e - i > We && this.recentErrors.delete(r);
|
|
3893
|
+
if (this.recentErrors.size <= q)
|
|
3806
3894
|
return;
|
|
3807
|
-
const t = Array.from(this.recentErrors.entries()).sort((r, i) => r[1] - i[1]), s = this.recentErrors.size -
|
|
3895
|
+
const t = Array.from(this.recentErrors.entries()).sort((r, i) => r[1] - i[1]), s = this.recentErrors.size - q;
|
|
3808
3896
|
for (let r = 0; r < s; r += 1) {
|
|
3809
3897
|
const i = t[r];
|
|
3810
3898
|
i && this.recentErrors.delete(i[0]);
|
|
3811
3899
|
}
|
|
3812
3900
|
}
|
|
3813
3901
|
}
|
|
3814
|
-
class
|
|
3902
|
+
class Gs extends T {
|
|
3815
3903
|
isInitialized = !1;
|
|
3816
3904
|
suppressNextScrollTimer = null;
|
|
3817
3905
|
pageUnloadHandler = null;
|
|
3818
3906
|
pageShowHandler = null;
|
|
3819
3907
|
visibilityFlushHandler = null;
|
|
3820
3908
|
prerenderActivationHandler = null;
|
|
3821
|
-
emitter = new
|
|
3909
|
+
emitter = new Ts();
|
|
3822
3910
|
managers = {};
|
|
3823
3911
|
handlers = {};
|
|
3824
3912
|
integrationInstances = {};
|
|
@@ -3833,9 +3921,9 @@ class xs extends T {
|
|
|
3833
3921
|
async init(e = {}) {
|
|
3834
3922
|
if (this.isInitialized)
|
|
3835
3923
|
return { sessionId: this.get("sessionId") ?? "" };
|
|
3836
|
-
this.managers.storage = new
|
|
3924
|
+
this.managers.storage = new Xs();
|
|
3837
3925
|
try {
|
|
3838
|
-
return this.setupState(e), this.managers.event = new
|
|
3926
|
+
return this.setupState(e), this.managers.event = new Os(this.managers.storage, this.emitter), this.loadPersistedIdentity(), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((t) => {
|
|
3839
3927
|
a("warn", "Failed to recover persisted events", { error: t });
|
|
3840
3928
|
}), this.isInitialized = !0, { sessionId: this.get("sessionId") ?? "" };
|
|
3841
3929
|
} catch (t) {
|
|
@@ -3856,9 +3944,9 @@ class xs extends T {
|
|
|
3856
3944
|
}
|
|
3857
3945
|
let r = t;
|
|
3858
3946
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
3859
|
-
const { valid: i, error: o, sanitizedMetadata: c } =
|
|
3947
|
+
const { valid: i, error: o, sanitizedMetadata: c } = vs(e, r);
|
|
3860
3948
|
if (!i) {
|
|
3861
|
-
if (this.get("mode") ===
|
|
3949
|
+
if (this.get("mode") === te.QA)
|
|
3862
3950
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${o}`);
|
|
3863
3951
|
a("warn", `Custom event "${e}" dropped: ${o}`);
|
|
3864
3952
|
return;
|
|
@@ -3895,14 +3983,14 @@ class xs extends T {
|
|
|
3895
3983
|
}
|
|
3896
3984
|
setupState(e = {}) {
|
|
3897
3985
|
this.set("config", e);
|
|
3898
|
-
const t =
|
|
3986
|
+
const t = Ps.getId(this.managers.storage);
|
|
3899
3987
|
this.set("userId", t);
|
|
3900
|
-
const s =
|
|
3988
|
+
const s = as(e);
|
|
3901
3989
|
this.set("collectApiUrls", s);
|
|
3902
|
-
const r =
|
|
3990
|
+
const r = $t();
|
|
3903
3991
|
this.set("device", r);
|
|
3904
|
-
const i =
|
|
3905
|
-
this.set("pageUrl", i),
|
|
3992
|
+
const i = D(window.location.href, e.sensitiveQueryParams);
|
|
3993
|
+
this.set("pageUrl", i), ns() && this.set("mode", te.QA);
|
|
3906
3994
|
}
|
|
3907
3995
|
/**
|
|
3908
3996
|
* @internal Used by api.ts for configuration access
|
|
@@ -3981,7 +4069,7 @@ class xs extends T {
|
|
|
3981
4069
|
async resetIdentity() {
|
|
3982
4070
|
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();
|
|
3983
4071
|
const e = at();
|
|
3984
|
-
this.managers.storage.setItem(
|
|
4072
|
+
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");
|
|
3985
4073
|
}
|
|
3986
4074
|
/**
|
|
3987
4075
|
* Returns the project ID used for identity storage scoping.
|
|
@@ -3994,7 +4082,7 @@ class xs extends T {
|
|
|
3994
4082
|
*/
|
|
3995
4083
|
persistIdentity(e) {
|
|
3996
4084
|
try {
|
|
3997
|
-
const t = this.getProjectId(), s =
|
|
4085
|
+
const t = this.getProjectId(), s = de(t);
|
|
3998
4086
|
this.managers.storage.setItem(s, JSON.stringify(e));
|
|
3999
4087
|
} catch {
|
|
4000
4088
|
a("debug", "Failed to persist identity to localStorage");
|
|
@@ -4005,12 +4093,12 @@ class xs extends T {
|
|
|
4005
4093
|
* Also migrates pending identity (set before init) to the project-scoped key.
|
|
4006
4094
|
*/
|
|
4007
4095
|
loadPersistedIdentity() {
|
|
4008
|
-
const e = this.managers.storage, t = this.getProjectId(), s =
|
|
4096
|
+
const e = this.managers.storage, t = this.getProjectId(), s = de(t);
|
|
4009
4097
|
try {
|
|
4010
|
-
const r = e.getItem(
|
|
4098
|
+
const r = e.getItem(P);
|
|
4011
4099
|
if (r) {
|
|
4012
4100
|
const i = JSON.parse(r);
|
|
4013
|
-
if (e.removeItem(
|
|
4101
|
+
if (e.removeItem(P), !this.isValidIdentityData(i)) {
|
|
4014
4102
|
a("debug", "Invalid pending identity in localStorage, discarded");
|
|
4015
4103
|
return;
|
|
4016
4104
|
}
|
|
@@ -4019,7 +4107,7 @@ class xs extends T {
|
|
|
4019
4107
|
return;
|
|
4020
4108
|
}
|
|
4021
4109
|
} catch {
|
|
4022
|
-
e.removeItem(
|
|
4110
|
+
e.removeItem(P);
|
|
4023
4111
|
}
|
|
4024
4112
|
try {
|
|
4025
4113
|
const r = e.getItem(s);
|
|
@@ -4065,7 +4153,7 @@ class xs extends T {
|
|
|
4065
4153
|
clearPersistedIdentity() {
|
|
4066
4154
|
try {
|
|
4067
4155
|
const e = this.managers.storage, t = this.getProjectId();
|
|
4068
|
-
e.removeItem(
|
|
4156
|
+
e.removeItem(de(t)), e.removeItem(P);
|
|
4069
4157
|
} catch {
|
|
4070
4158
|
a("debug", "Failed to clear persisted identity");
|
|
4071
4159
|
}
|
|
@@ -4083,7 +4171,7 @@ class xs extends T {
|
|
|
4083
4171
|
}
|
|
4084
4172
|
initializeHandlers() {
|
|
4085
4173
|
const e = this.get("config");
|
|
4086
|
-
this.handlers.session = new
|
|
4174
|
+
this.handlers.session = new Us(
|
|
4087
4175
|
this.managers.storage,
|
|
4088
4176
|
this.managers.event
|
|
4089
4177
|
), this.handlers.session.startTracking();
|
|
@@ -4092,13 +4180,13 @@ class xs extends T {
|
|
|
4092
4180
|
this.set("suppressNextScroll", !1);
|
|
4093
4181
|
}, 500);
|
|
4094
4182
|
};
|
|
4095
|
-
this.handlers.pageView = new
|
|
4183
|
+
this.handlers.pageView = new Fs(this.managers.event, t), this.handlers.click = new Vs(this.managers.event), this.handlers.scroll = new Hs(this.managers.event), this.handlers.performance = new js(this.managers.event), this.handlers.error = new ne(this.managers.event, this.emitter);
|
|
4096
4184
|
const s = () => {
|
|
4097
4185
|
if (this.handlers.pageView?.startTracking(), this.handlers.click?.startTracking(), this.handlers.scroll?.startTracking(), this.handlers.performance?.startTracking().catch((r) => {
|
|
4098
4186
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4099
4187
|
}), this.handlers.error?.startTracking(), e.integrations?.tracelog?.shopify) {
|
|
4100
|
-
const r = new
|
|
4101
|
-
r.activate(), this.integrationInstances.shopifyCartLinker = r, this.emitter.on(
|
|
4188
|
+
const r = new Bs();
|
|
4189
|
+
r.activate(), this.integrationInstances.shopifyCartLinker = r, this.emitter.on(V.EVENT, (i) => {
|
|
4102
4190
|
i.type === d.SESSION_START && r.onSessionChange();
|
|
4103
4191
|
});
|
|
4104
4192
|
}
|
|
@@ -4108,15 +4196,15 @@ class xs extends T {
|
|
|
4108
4196
|
}, document.addEventListener("prerenderingchange", this.prerenderActivationHandler, { once: !0 })) : s();
|
|
4109
4197
|
}
|
|
4110
4198
|
}
|
|
4111
|
-
const
|
|
4112
|
-
let f = null,
|
|
4113
|
-
const
|
|
4199
|
+
const N = [];
|
|
4200
|
+
let f = null, F = !1, A = !1, R = null;
|
|
4201
|
+
const Ws = async (n) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (A = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : f ? { sessionId: f.getSessionId() ?? "" } : (F && R || (F = !0, R = (async () => {
|
|
4114
4202
|
try {
|
|
4115
|
-
const e =
|
|
4203
|
+
const e = ms(n ?? {}), t = new Gs();
|
|
4116
4204
|
try {
|
|
4117
|
-
|
|
4205
|
+
N.forEach(({ event: o, callback: c }) => {
|
|
4118
4206
|
t.on(o, c);
|
|
4119
|
-
}),
|
|
4207
|
+
}), N.length = 0;
|
|
4120
4208
|
const s = t.init(e), r = new Promise((o, c) => {
|
|
4121
4209
|
setTimeout(() => {
|
|
4122
4210
|
c(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
@@ -4134,9 +4222,9 @@ const $s = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4134
4222
|
} catch (e) {
|
|
4135
4223
|
throw f = null, e;
|
|
4136
4224
|
} finally {
|
|
4137
|
-
|
|
4225
|
+
F = !1, R = null;
|
|
4138
4226
|
}
|
|
4139
|
-
})()),
|
|
4227
|
+
})()), R)), Ks = (n, e, t) => {
|
|
4140
4228
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4141
4229
|
if (!f)
|
|
4142
4230
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4144,24 +4232,24 @@ const $s = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4144
4232
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4145
4233
|
f.sendCustomEvent(n, e, t);
|
|
4146
4234
|
}
|
|
4147
|
-
},
|
|
4235
|
+
}, zs = (n, e) => {
|
|
4148
4236
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4149
|
-
if (!f ||
|
|
4150
|
-
|
|
4237
|
+
if (!f || F) {
|
|
4238
|
+
N.push({ event: n, callback: e });
|
|
4151
4239
|
return;
|
|
4152
4240
|
}
|
|
4153
4241
|
f.on(n, e);
|
|
4154
4242
|
}
|
|
4155
|
-
},
|
|
4243
|
+
}, Qs = (n, e) => {
|
|
4156
4244
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4157
4245
|
if (!f) {
|
|
4158
|
-
const t =
|
|
4159
|
-
t !== -1 &&
|
|
4246
|
+
const t = N.findIndex((s) => s.event === n && s.callback === e);
|
|
4247
|
+
t !== -1 && N.splice(t, 1);
|
|
4160
4248
|
return;
|
|
4161
4249
|
}
|
|
4162
4250
|
f.off(n, e);
|
|
4163
4251
|
}
|
|
4164
|
-
},
|
|
4252
|
+
}, Ys = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, qs = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getSessionId(), Js = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getUserId(), Zs = () => {
|
|
4165
4253
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4166
4254
|
if (A)
|
|
4167
4255
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -4171,12 +4259,12 @@ const $s = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4171
4259
|
}
|
|
4172
4260
|
A = !0;
|
|
4173
4261
|
try {
|
|
4174
|
-
f.destroy(), f = null,
|
|
4262
|
+
f.destroy(), f = null, F = !1, R = null, N.length = 0, A = !1;
|
|
4175
4263
|
} catch (n) {
|
|
4176
|
-
f = null,
|
|
4264
|
+
f = null, F = !1, R = null, N.length = 0, A = !1, a("warn", "Error during destroy, forced cleanup completed", { error: n });
|
|
4177
4265
|
}
|
|
4178
4266
|
}
|
|
4179
|
-
},
|
|
4267
|
+
}, en = (n, e) => {
|
|
4180
4268
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4181
4269
|
if (!n || typeof n != "string" || n.trim().length === 0) {
|
|
4182
4270
|
a("warn", "identify() called with invalid userId");
|
|
@@ -4199,16 +4287,16 @@ const $s = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4199
4287
|
userId: n.trim(),
|
|
4200
4288
|
...t ? { traits: t } : {}
|
|
4201
4289
|
};
|
|
4202
|
-
localStorage.setItem(
|
|
4290
|
+
localStorage.setItem(P, JSON.stringify(s)), a("debug", "Identity persisted pre-init (will be applied on init)");
|
|
4203
4291
|
} catch {
|
|
4204
4292
|
a("debug", "Failed to persist pre-init identity");
|
|
4205
4293
|
}
|
|
4206
4294
|
}
|
|
4207
|
-
},
|
|
4295
|
+
}, tn = async () => {
|
|
4208
4296
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4209
4297
|
if (!f) {
|
|
4210
4298
|
try {
|
|
4211
|
-
localStorage.removeItem(
|
|
4299
|
+
localStorage.removeItem(P);
|
|
4212
4300
|
} catch {
|
|
4213
4301
|
}
|
|
4214
4302
|
return;
|
|
@@ -4217,32 +4305,32 @@ const $s = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4217
4305
|
throw new Error("[TraceLog] Cannot reset identity while TraceLog is being destroyed");
|
|
4218
4306
|
await f.resetIdentity();
|
|
4219
4307
|
}
|
|
4220
|
-
},
|
|
4221
|
-
init:
|
|
4222
|
-
event:
|
|
4223
|
-
on:
|
|
4224
|
-
off:
|
|
4225
|
-
isInitialized:
|
|
4226
|
-
getSessionId:
|
|
4227
|
-
getUserId:
|
|
4228
|
-
destroy:
|
|
4229
|
-
identify:
|
|
4230
|
-
resetIdentity:
|
|
4308
|
+
}, Cn = {
|
|
4309
|
+
init: Ws,
|
|
4310
|
+
event: Ks,
|
|
4311
|
+
on: zs,
|
|
4312
|
+
off: Qs,
|
|
4313
|
+
isInitialized: Ys,
|
|
4314
|
+
getSessionId: qs,
|
|
4315
|
+
getUserId: Js,
|
|
4316
|
+
destroy: Zs,
|
|
4317
|
+
identify: en,
|
|
4318
|
+
resetIdentity: tn
|
|
4231
4319
|
};
|
|
4232
|
-
var
|
|
4320
|
+
var be, L, B, ct, re, lt = -1, O = function(n) {
|
|
4233
4321
|
addEventListener("pageshow", (function(e) {
|
|
4234
4322
|
e.persisted && (lt = e.timeStamp, n(e));
|
|
4235
4323
|
}), !0);
|
|
4236
4324
|
}, Pe = function() {
|
|
4237
4325
|
var n = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4238
4326
|
if (n && n.responseStart > 0 && n.responseStart < performance.now()) return n;
|
|
4239
|
-
},
|
|
4327
|
+
}, oe = function() {
|
|
4240
4328
|
var n = Pe();
|
|
4241
4329
|
return n && n.activationStart || 0;
|
|
4242
4330
|
}, E = function(n, e) {
|
|
4243
4331
|
var t = Pe(), s = "navigate";
|
|
4244
|
-
return lt >= 0 ? s = "back-forward-cache" : t && (document.prerendering ||
|
|
4245
|
-
},
|
|
4332
|
+
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 };
|
|
4333
|
+
}, H = function(n, e, t) {
|
|
4246
4334
|
try {
|
|
4247
4335
|
if (PerformanceObserver.supportedEntryTypes.includes(n)) {
|
|
4248
4336
|
var s = new PerformanceObserver((function(r) {
|
|
@@ -4267,50 +4355,50 @@ var Le, b, x, ct, ne, lt = -1, N = function(n) {
|
|
|
4267
4355
|
return n();
|
|
4268
4356
|
}));
|
|
4269
4357
|
}));
|
|
4270
|
-
},
|
|
4358
|
+
}, j = function(n) {
|
|
4271
4359
|
document.addEventListener("visibilitychange", (function() {
|
|
4272
4360
|
document.visibilityState === "hidden" && n();
|
|
4273
4361
|
}));
|
|
4274
|
-
},
|
|
4362
|
+
}, ae = function(n) {
|
|
4275
4363
|
var e = !1;
|
|
4276
4364
|
return function() {
|
|
4277
4365
|
e || (n(), e = !0);
|
|
4278
4366
|
};
|
|
4279
|
-
},
|
|
4367
|
+
}, k = -1, et = function() {
|
|
4280
4368
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4281
|
-
},
|
|
4282
|
-
document.visibilityState === "hidden" &&
|
|
4369
|
+
}, ie = function(n) {
|
|
4370
|
+
document.visibilityState === "hidden" && k > -1 && (k = n.type === "visibilitychange" ? n.timeStamp : 0, sn());
|
|
4283
4371
|
}, tt = function() {
|
|
4284
|
-
addEventListener("visibilitychange",
|
|
4285
|
-
},
|
|
4286
|
-
removeEventListener("visibilitychange",
|
|
4372
|
+
addEventListener("visibilitychange", ie, !0), addEventListener("prerenderingchange", ie, !0);
|
|
4373
|
+
}, sn = function() {
|
|
4374
|
+
removeEventListener("visibilitychange", ie, !0), removeEventListener("prerenderingchange", ie, !0);
|
|
4287
4375
|
}, De = function() {
|
|
4288
|
-
return
|
|
4376
|
+
return k < 0 && (k = et(), tt(), O((function() {
|
|
4289
4377
|
setTimeout((function() {
|
|
4290
|
-
|
|
4378
|
+
k = et(), tt();
|
|
4291
4379
|
}), 0);
|
|
4292
4380
|
}))), { get firstHiddenTime() {
|
|
4293
|
-
return
|
|
4381
|
+
return k;
|
|
4294
4382
|
} };
|
|
4295
|
-
},
|
|
4383
|
+
}, G = function(n) {
|
|
4296
4384
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4297
4385
|
return n();
|
|
4298
4386
|
}), !0) : n();
|
|
4299
|
-
},
|
|
4300
|
-
e = e || {},
|
|
4301
|
-
var t, s = De(), r = E("FCP"), i =
|
|
4387
|
+
}, Le = [1800, 3e3], ut = function(n, e) {
|
|
4388
|
+
e = e || {}, G((function() {
|
|
4389
|
+
var t, s = De(), r = E("FCP"), i = H("paint", (function(o) {
|
|
4302
4390
|
o.forEach((function(c) {
|
|
4303
|
-
c.name === "first-contentful-paint" && (i.disconnect(), c.startTime < s.firstHiddenTime && (r.value = Math.max(c.startTime -
|
|
4391
|
+
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)));
|
|
4304
4392
|
}));
|
|
4305
4393
|
}));
|
|
4306
|
-
i && (t = v(n, r,
|
|
4307
|
-
r = E("FCP"), t = v(n, r,
|
|
4394
|
+
i && (t = v(n, r, Le, e.reportAllChanges), O((function(o) {
|
|
4395
|
+
r = E("FCP"), t = v(n, r, Le, e.reportAllChanges), ke((function() {
|
|
4308
4396
|
r.value = performance.now() - o.timeStamp, t(!0);
|
|
4309
4397
|
}));
|
|
4310
4398
|
})));
|
|
4311
4399
|
}));
|
|
4312
|
-
}, Me = [0.1, 0.25],
|
|
4313
|
-
e = e || {}, ut(
|
|
4400
|
+
}, Me = [0.1, 0.25], nn = function(n, e) {
|
|
4401
|
+
e = e || {}, ut(ae((function() {
|
|
4314
4402
|
var t, s = E("CLS", 0), r = 0, i = [], o = function(l) {
|
|
4315
4403
|
l.forEach((function(u) {
|
|
4316
4404
|
if (!u.hadRecentInput) {
|
|
@@ -4318,112 +4406,112 @@ var Le, b, x, ct, ne, lt = -1, N = function(n) {
|
|
|
4318
4406
|
r && u.startTime - p.startTime < 1e3 && u.startTime - h.startTime < 5e3 ? (r += u.value, i.push(u)) : (r = u.value, i = [u]);
|
|
4319
4407
|
}
|
|
4320
4408
|
})), r > s.value && (s.value = r, s.entries = i, t());
|
|
4321
|
-
}, c =
|
|
4322
|
-
c && (t = v(n, s, Me, e.reportAllChanges),
|
|
4409
|
+
}, c = H("layout-shift", o);
|
|
4410
|
+
c && (t = v(n, s, Me, e.reportAllChanges), j((function() {
|
|
4323
4411
|
o(c.takeRecords()), t(!0);
|
|
4324
|
-
})),
|
|
4412
|
+
})), O((function() {
|
|
4325
4413
|
r = 0, s = E("CLS", 0), t = v(n, s, Me, e.reportAllChanges), ke((function() {
|
|
4326
4414
|
return t();
|
|
4327
4415
|
}));
|
|
4328
4416
|
})), setTimeout(t, 0));
|
|
4329
4417
|
})));
|
|
4330
|
-
}, dt = 0,
|
|
4418
|
+
}, dt = 0, pe = 1 / 0, Q = 0, rn = function(n) {
|
|
4331
4419
|
n.forEach((function(e) {
|
|
4332
|
-
e.interactionId && (
|
|
4420
|
+
e.interactionId && (pe = Math.min(pe, e.interactionId), Q = Math.max(Q, e.interactionId), dt = Q ? (Q - pe) / 7 + 1 : 0);
|
|
4333
4421
|
}));
|
|
4334
4422
|
}, ht = function() {
|
|
4335
|
-
return
|
|
4336
|
-
},
|
|
4337
|
-
"interactionCount" in performance ||
|
|
4338
|
-
}, I = [],
|
|
4423
|
+
return be ? dt : performance.interactionCount || 0;
|
|
4424
|
+
}, on = function() {
|
|
4425
|
+
"interactionCount" in performance || be || (be = H("event", rn, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4426
|
+
}, I = [], J = /* @__PURE__ */ new Map(), ft = 0, an = function() {
|
|
4339
4427
|
var n = Math.min(I.length - 1, Math.floor((ht() - ft) / 50));
|
|
4340
4428
|
return I[n];
|
|
4341
|
-
},
|
|
4342
|
-
if (
|
|
4429
|
+
}, cn = [], ln = function(n) {
|
|
4430
|
+
if (cn.forEach((function(r) {
|
|
4343
4431
|
return r(n);
|
|
4344
4432
|
})), n.interactionId || n.entryType === "first-input") {
|
|
4345
|
-
var e = I[I.length - 1], t =
|
|
4433
|
+
var e = I[I.length - 1], t = J.get(n.interactionId);
|
|
4346
4434
|
if (t || I.length < 10 || n.duration > e.latency) {
|
|
4347
4435
|
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);
|
|
4348
4436
|
else {
|
|
4349
4437
|
var s = { id: n.interactionId, latency: n.duration, entries: [n] };
|
|
4350
|
-
|
|
4438
|
+
J.set(s.id, s), I.push(s);
|
|
4351
4439
|
}
|
|
4352
4440
|
I.sort((function(r, i) {
|
|
4353
4441
|
return i.latency - r.latency;
|
|
4354
4442
|
})), I.length > 10 && I.splice(10).forEach((function(r) {
|
|
4355
|
-
return
|
|
4443
|
+
return J.delete(r.id);
|
|
4356
4444
|
}));
|
|
4357
4445
|
}
|
|
4358
4446
|
}
|
|
4359
4447
|
}, gt = function(n) {
|
|
4360
4448
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4361
|
-
return n =
|
|
4362
|
-
}, Ce = [200, 500],
|
|
4363
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
4449
|
+
return n = ae(n), document.visibilityState === "hidden" ? n() : (t = e(n), j(n)), t;
|
|
4450
|
+
}, Ce = [200, 500], un = function(n, e) {
|
|
4451
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, G((function() {
|
|
4364
4452
|
var t;
|
|
4365
|
-
|
|
4453
|
+
on();
|
|
4366
4454
|
var s, r = E("INP"), i = function(c) {
|
|
4367
4455
|
gt((function() {
|
|
4368
|
-
c.forEach(
|
|
4369
|
-
var l =
|
|
4456
|
+
c.forEach(ln);
|
|
4457
|
+
var l = an();
|
|
4370
4458
|
l && l.latency !== r.value && (r.value = l.latency, r.entries = l.entries, s());
|
|
4371
4459
|
}));
|
|
4372
|
-
}, o =
|
|
4373
|
-
s = v(n, r, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }),
|
|
4460
|
+
}, o = H("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4461
|
+
s = v(n, r, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), j((function() {
|
|
4374
4462
|
i(o.takeRecords()), s(!0);
|
|
4375
|
-
})),
|
|
4376
|
-
ft = ht(), I.length = 0,
|
|
4463
|
+
})), O((function() {
|
|
4464
|
+
ft = ht(), I.length = 0, J.clear(), r = E("INP"), s = v(n, r, Ce, e.reportAllChanges);
|
|
4377
4465
|
})));
|
|
4378
4466
|
})));
|
|
4379
|
-
}, Re = [2500, 4e3],
|
|
4380
|
-
e = e || {},
|
|
4467
|
+
}, Re = [2500, 4e3], Se = {}, dn = function(n, e) {
|
|
4468
|
+
e = e || {}, G((function() {
|
|
4381
4469
|
var t, s = De(), r = E("LCP"), i = function(l) {
|
|
4382
4470
|
e.reportAllChanges || (l = l.slice(-1)), l.forEach((function(u) {
|
|
4383
|
-
u.startTime < s.firstHiddenTime && (r.value = Math.max(u.startTime -
|
|
4471
|
+
u.startTime < s.firstHiddenTime && (r.value = Math.max(u.startTime - oe(), 0), r.entries = [u], t());
|
|
4384
4472
|
}));
|
|
4385
|
-
}, o =
|
|
4473
|
+
}, o = H("largest-contentful-paint", i);
|
|
4386
4474
|
if (o) {
|
|
4387
4475
|
t = v(n, r, Re, e.reportAllChanges);
|
|
4388
|
-
var c =
|
|
4389
|
-
|
|
4476
|
+
var c = ae((function() {
|
|
4477
|
+
Se[r.id] || (i(o.takeRecords()), o.disconnect(), Se[r.id] = !0, t(!0));
|
|
4390
4478
|
}));
|
|
4391
4479
|
["keydown", "click"].forEach((function(l) {
|
|
4392
4480
|
addEventListener(l, (function() {
|
|
4393
4481
|
return gt(c);
|
|
4394
4482
|
}), { once: !0, capture: !0 });
|
|
4395
|
-
})),
|
|
4483
|
+
})), j(c), O((function(l) {
|
|
4396
4484
|
r = E("LCP"), t = v(n, r, Re, e.reportAllChanges), ke((function() {
|
|
4397
|
-
r.value = performance.now() - l.timeStamp,
|
|
4485
|
+
r.value = performance.now() - l.timeStamp, Se[r.id] = !0, t(!0);
|
|
4398
4486
|
}));
|
|
4399
4487
|
}));
|
|
4400
4488
|
}
|
|
4401
4489
|
}));
|
|
4402
|
-
}, Ne = [800, 1800],
|
|
4403
|
-
document.prerendering ?
|
|
4490
|
+
}, Ne = [800, 1800], hn = function n(e) {
|
|
4491
|
+
document.prerendering ? G((function() {
|
|
4404
4492
|
return n(e);
|
|
4405
4493
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4406
4494
|
return n(e);
|
|
4407
4495
|
}), !0) : setTimeout(e, 0);
|
|
4408
|
-
},
|
|
4496
|
+
}, fn = function(n, e) {
|
|
4409
4497
|
e = e || {};
|
|
4410
4498
|
var t = E("TTFB"), s = v(n, t, Ne, e.reportAllChanges);
|
|
4411
|
-
|
|
4499
|
+
hn((function() {
|
|
4412
4500
|
var r = Pe();
|
|
4413
|
-
r && (t.value = Math.max(r.responseStart -
|
|
4501
|
+
r && (t.value = Math.max(r.responseStart - oe(), 0), t.entries = [r], s(!0), O((function() {
|
|
4414
4502
|
t = E("TTFB", 0), (s = v(n, t, Ne, e.reportAllChanges))(!0);
|
|
4415
4503
|
})));
|
|
4416
4504
|
}));
|
|
4417
|
-
},
|
|
4418
|
-
|
|
4505
|
+
}, $ = { passive: !0, capture: !0 }, gn = /* @__PURE__ */ new Date(), st = function(n, e) {
|
|
4506
|
+
L || (L = e, B = n, ct = /* @__PURE__ */ new Date(), pt(removeEventListener), mt());
|
|
4419
4507
|
}, mt = function() {
|
|
4420
|
-
if (
|
|
4421
|
-
var n = { entryType: "first-input", name:
|
|
4422
|
-
|
|
4508
|
+
if (B >= 0 && B < ct - gn) {
|
|
4509
|
+
var n = { entryType: "first-input", name: L.type, target: L.target, cancelable: L.cancelable, startTime: L.timeStamp, processingStart: L.timeStamp + B };
|
|
4510
|
+
re.forEach((function(e) {
|
|
4423
4511
|
e(n);
|
|
4424
|
-
})),
|
|
4512
|
+
})), re = [];
|
|
4425
4513
|
}
|
|
4426
|
-
},
|
|
4514
|
+
}, mn = function(n) {
|
|
4427
4515
|
if (n.cancelable) {
|
|
4428
4516
|
var e = (n.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - n.timeStamp;
|
|
4429
4517
|
n.type == "pointerdown" ? (function(t, s) {
|
|
@@ -4432,76 +4520,76 @@ var Le, b, x, ct, ne, lt = -1, N = function(n) {
|
|
|
4432
4520
|
}, i = function() {
|
|
4433
4521
|
o();
|
|
4434
4522
|
}, o = function() {
|
|
4435
|
-
removeEventListener("pointerup", r,
|
|
4523
|
+
removeEventListener("pointerup", r, $), removeEventListener("pointercancel", i, $);
|
|
4436
4524
|
};
|
|
4437
|
-
addEventListener("pointerup", r,
|
|
4525
|
+
addEventListener("pointerup", r, $), addEventListener("pointercancel", i, $);
|
|
4438
4526
|
})(e, n) : st(e, n);
|
|
4439
4527
|
}
|
|
4440
4528
|
}, pt = function(n) {
|
|
4441
4529
|
["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
|
|
4442
|
-
return n(e,
|
|
4530
|
+
return n(e, mn, $);
|
|
4443
4531
|
}));
|
|
4444
|
-
}, Oe = [100, 300],
|
|
4445
|
-
e = e || {},
|
|
4532
|
+
}, Oe = [100, 300], pn = function(n, e) {
|
|
4533
|
+
e = e || {}, G((function() {
|
|
4446
4534
|
var t, s = De(), r = E("FID"), i = function(l) {
|
|
4447
4535
|
l.startTime < s.firstHiddenTime && (r.value = l.processingStart - l.startTime, r.entries.push(l), t(!0));
|
|
4448
4536
|
}, o = function(l) {
|
|
4449
4537
|
l.forEach(i);
|
|
4450
|
-
}, c =
|
|
4451
|
-
t = v(n, r, Oe, e.reportAllChanges), c && (
|
|
4538
|
+
}, c = H("first-input", o);
|
|
4539
|
+
t = v(n, r, Oe, e.reportAllChanges), c && (j(ae((function() {
|
|
4452
4540
|
o(c.takeRecords()), c.disconnect();
|
|
4453
|
-
}))),
|
|
4541
|
+
}))), O((function() {
|
|
4454
4542
|
var l;
|
|
4455
|
-
r = E("FID"), t = v(n, r, Oe, e.reportAllChanges),
|
|
4543
|
+
r = E("FID"), t = v(n, r, Oe, e.reportAllChanges), re = [], B = -1, L = null, pt(addEventListener), l = i, re.push(l), mt();
|
|
4456
4544
|
})));
|
|
4457
4545
|
}));
|
|
4458
4546
|
};
|
|
4459
|
-
const
|
|
4547
|
+
const Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4460
4548
|
__proto__: null,
|
|
4461
4549
|
CLSThresholds: Me,
|
|
4462
|
-
FCPThresholds:
|
|
4550
|
+
FCPThresholds: Le,
|
|
4463
4551
|
FIDThresholds: Oe,
|
|
4464
4552
|
INPThresholds: Ce,
|
|
4465
4553
|
LCPThresholds: Re,
|
|
4466
4554
|
TTFBThresholds: Ne,
|
|
4467
|
-
onCLS:
|
|
4555
|
+
onCLS: nn,
|
|
4468
4556
|
onFCP: ut,
|
|
4469
|
-
onFID:
|
|
4470
|
-
onINP:
|
|
4471
|
-
onLCP:
|
|
4472
|
-
onTTFB:
|
|
4557
|
+
onFID: pn,
|
|
4558
|
+
onINP: un,
|
|
4559
|
+
onLCP: dn,
|
|
4560
|
+
onTTFB: fn
|
|
4473
4561
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4474
4562
|
export {
|
|
4475
4563
|
m as AppConfigValidationError,
|
|
4476
|
-
|
|
4477
|
-
|
|
4564
|
+
En as DEFAULT_SESSION_TIMEOUT,
|
|
4565
|
+
ye as DEFAULT_WEB_VITALS_MODE,
|
|
4478
4566
|
w as DeviceType,
|
|
4479
|
-
|
|
4480
|
-
|
|
4567
|
+
V as EmitterEvent,
|
|
4568
|
+
x as ErrorType,
|
|
4481
4569
|
d as EventType,
|
|
4482
|
-
|
|
4570
|
+
Ln as InitializationTimeoutError,
|
|
4483
4571
|
Xe as IntegrationValidationError,
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4572
|
+
bn as MAX_ARRAY_LENGTH,
|
|
4573
|
+
yn as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
4574
|
+
_n as MAX_CUSTOM_EVENT_KEYS,
|
|
4575
|
+
vn as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
4576
|
+
Tn as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
4577
|
+
In as MAX_NESTED_OBJECT_KEYS,
|
|
4578
|
+
wn as MAX_STRING_LENGTH,
|
|
4579
|
+
An as MAX_STRING_LENGTH_IN_ARRAY,
|
|
4580
|
+
te as Mode,
|
|
4581
|
+
hs as PII_PATTERNS,
|
|
4582
|
+
C as PermanentError,
|
|
4583
|
+
Z as RateLimitError,
|
|
4496
4584
|
Be as SamplingRateValidationError,
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4585
|
+
ve as ScrollDirection,
|
|
4586
|
+
bt as SessionTimeoutValidationError,
|
|
4587
|
+
M as SpecialApiUrl,
|
|
4588
|
+
ee as TimeoutError,
|
|
4589
|
+
X as TraceLogValidationError,
|
|
4590
|
+
Mn as WEB_VITALS_GOOD_THRESHOLDS,
|
|
4503
4591
|
ze as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
4504
|
-
|
|
4592
|
+
qt as WEB_VITALS_POOR_THRESHOLDS,
|
|
4505
4593
|
Qe as getWebVitalsThresholds,
|
|
4506
|
-
|
|
4594
|
+
Cn as tracelog
|
|
4507
4595
|
};
|