@tracelog/lib 3.1.1-rc.118.4 → 3.1.1-rc.120.6
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/dist/browser/tracelog.esm.js +462 -404
- 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 +7 -9
- package/dist/public-api.d.ts +7 -9
- 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 pn = 9e5;
|
|
2
|
+
const Sn = 120, En = 49152, vn = 100, Tn = 500, _n = 200;
|
|
3
|
+
const yn = 1e3, In = 500, wn = 1e3;
|
|
4
|
+
const b = "data-tlog", vt = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
7
7
|
'input[type="button"]',
|
|
@@ -67,26 +67,26 @@ const y = {
|
|
|
67
67
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
68
68
|
/<embed\b[^>]*>/gi,
|
|
69
69
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
70
|
-
], g = "tlog",
|
|
71
|
-
var
|
|
72
|
-
class
|
|
70
|
+
], g = "tlog", z = `${g}:qa_mode`, Se = `${g}:uid`, nt = "tlog_mode", Ue = "qa", Fe = "qa_off", ce = (n) => n ? `${g}:${n}:queue` : `${g}:queue`, le = (n) => n ? `${g}:${n}:rate_limit` : `${g}:rate_limit`, It = (n) => `${g}:beacon:${n}`, 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`, Be = 3600 * 1e3, ue = (n) => n ? `${g}:${n}:identity` : `${g}:identity`, P = `${g}:pending_identity`;
|
|
71
|
+
var M = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(M || {}), w = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(w || {}), U = /* @__PURE__ */ ((n) => (n.EVENT = "event", n.QUEUE = "queue", n))(U || {});
|
|
72
|
+
class C extends Error {
|
|
73
73
|
constructor(e, t, s) {
|
|
74
|
-
super(e), this.statusCode = t, this.responseCode = s, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
74
|
+
super(e), this.statusCode = t, this.responseCode = s, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, C);
|
|
75
75
|
}
|
|
76
76
|
statusCode;
|
|
77
77
|
responseCode;
|
|
78
78
|
}
|
|
79
|
-
class
|
|
79
|
+
class J extends Error {
|
|
80
80
|
constructor(e) {
|
|
81
|
-
super(e), this.name = "RateLimitError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
81
|
+
super(e), this.name = "RateLimitError", Error.captureStackTrace && Error.captureStackTrace(this, J);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
class
|
|
84
|
+
class Z extends Error {
|
|
85
85
|
constructor(e) {
|
|
86
|
-
super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
86
|
+
super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this, Z);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
var d = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n))(d || {}),
|
|
89
|
+
var d = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n))(d || {}), Ee = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(Ee || {}), V = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n))(V || {}), ee = /* @__PURE__ */ ((n) => (n.QA = "qa", n))(ee || {});
|
|
90
90
|
class B extends Error {
|
|
91
91
|
constructor(e, t, s) {
|
|
92
92
|
super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
@@ -99,34 +99,34 @@ class m extends B {
|
|
|
99
99
|
super(e, "APP_CONFIG_INVALID", t);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
class
|
|
102
|
+
class bt extends B {
|
|
103
103
|
constructor(e, t = "config") {
|
|
104
104
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
class
|
|
107
|
+
class $e extends B {
|
|
108
108
|
constructor(e, t = "config") {
|
|
109
109
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
class
|
|
112
|
+
class Xe extends B {
|
|
113
113
|
constructor(e, t = "config") {
|
|
114
114
|
super(e, "INTEGRATION_INVALID", t);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
class
|
|
117
|
+
class An extends B {
|
|
118
118
|
constructor(e, t, s = "runtime") {
|
|
119
119
|
super(e, "INITIALIZATION_TIMEOUT", s), this.timeoutMs = t;
|
|
120
120
|
}
|
|
121
121
|
timeoutMs;
|
|
122
122
|
}
|
|
123
|
-
const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"],
|
|
123
|
+
const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], de = () => {
|
|
124
124
|
const n = new URLSearchParams(window.location.search), e = {};
|
|
125
125
|
return Lt.forEach((s) => {
|
|
126
126
|
const r = n.get(s);
|
|
127
127
|
r && (e[s] = r);
|
|
128
128
|
}), Object.keys(e).length ? e : void 0;
|
|
129
|
-
},
|
|
129
|
+
}, Mt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Ct = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Rt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Nt = (n, e) => {
|
|
130
130
|
if (e) {
|
|
131
131
|
if (e instanceof Error) {
|
|
132
132
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
@@ -145,24 +145,24 @@ const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], he = () => {
|
|
|
145
145
|
return `[TraceLog] ${n}: ${String(e)}`;
|
|
146
146
|
}
|
|
147
147
|
return `[TraceLog] ${n}`;
|
|
148
|
-
},
|
|
148
|
+
}, Ot = () => {
|
|
149
149
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
150
150
|
return !1;
|
|
151
151
|
try {
|
|
152
|
-
return sessionStorage.getItem(
|
|
152
|
+
return sessionStorage.getItem(z) === "true";
|
|
153
153
|
} catch {
|
|
154
154
|
return !1;
|
|
155
155
|
}
|
|
156
156
|
}, a = (n, e, t) => {
|
|
157
|
-
const { error: s, data: r, showToClient: i = !1, style: o, visibility: c } = t ?? {}, l = s ?
|
|
158
|
-
if (!
|
|
157
|
+
const { error: s, data: r, showToClient: i = !1, style: o, visibility: c } = t ?? {}, l = s ? Nt(e, s) : `[TraceLog] ${e}`, u = n === "error" ? "error" : n === "warn" ? "warn" : "log";
|
|
158
|
+
if (!Pt(c, i))
|
|
159
159
|
return;
|
|
160
|
-
const p =
|
|
161
|
-
|
|
162
|
-
},
|
|
160
|
+
const p = kt(c, o), S = r !== void 0 ? ve(r) : void 0;
|
|
161
|
+
Dt(u, l, p, S);
|
|
162
|
+
}, Pt = (n, e) => n === "critical" ? !0 : n === "qa" || e ? Ot() : !1, kt = (n, e) => e !== void 0 && e !== "" ? e : n === "critical" ? Rt : "", Dt = (n, e, t, s) => {
|
|
163
163
|
const r = t !== void 0 && t !== "", i = r ? `%c${e}` : e;
|
|
164
164
|
s !== void 0 ? r ? console[n](i, t, s) : console[n](i, s) : r ? console[n](i, t) : console[n](i);
|
|
165
|
-
},
|
|
165
|
+
}, ve = (n) => {
|
|
166
166
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
167
167
|
for (const [s, r] of Object.entries(n)) {
|
|
168
168
|
const i = s.toLowerCase();
|
|
@@ -170,16 +170,16 @@ const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], he = () => {
|
|
|
170
170
|
e[s] = "[REDACTED]";
|
|
171
171
|
continue;
|
|
172
172
|
}
|
|
173
|
-
r !== null && typeof r == "object" && !Array.isArray(r) ? e[s] =
|
|
174
|
-
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ?
|
|
173
|
+
r !== null && typeof r == "object" && !Array.isArray(r) ? e[s] = ve(r) : Array.isArray(r) ? e[s] = r.map(
|
|
174
|
+
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? ve(o) : o
|
|
175
175
|
) : e[s] = r;
|
|
176
176
|
}
|
|
177
177
|
return e;
|
|
178
178
|
};
|
|
179
|
-
let
|
|
180
|
-
const
|
|
181
|
-
typeof window < "u" && !
|
|
182
|
-
},
|
|
179
|
+
let Te, rt;
|
|
180
|
+
const Ut = () => {
|
|
181
|
+
typeof window < "u" && !Te && (Te = window.matchMedia("(pointer: coarse)"), rt = window.matchMedia("(hover: none)"));
|
|
182
|
+
}, te = "Unknown", Ft = (n) => {
|
|
183
183
|
const e = n.userAgentData?.platform;
|
|
184
184
|
if (e != null && e !== "") {
|
|
185
185
|
if (/windows/i.test(e)) return "Windows";
|
|
@@ -190,8 +190,8 @@ const Dt = () => {
|
|
|
190
190
|
if (/ios/i.test(e)) return "iOS";
|
|
191
191
|
}
|
|
192
192
|
const t = navigator.userAgent;
|
|
193
|
-
return /Windows/i.test(t) ? "Windows" : /iPhone|iPad|iPod/i.test(t) ? "iOS" : /Mac OS X|Macintosh/i.test(t) ? "macOS" : /Android/i.test(t) ? "Android" : /CrOS/i.test(t) ? "ChromeOS" : /Linux/i.test(t) ? "Linux" :
|
|
194
|
-
},
|
|
193
|
+
return /Windows/i.test(t) ? "Windows" : /iPhone|iPad|iPod/i.test(t) ? "iOS" : /Mac OS X|Macintosh/i.test(t) ? "macOS" : /Android/i.test(t) ? "Android" : /CrOS/i.test(t) ? "ChromeOS" : /Linux/i.test(t) ? "Linux" : te;
|
|
194
|
+
}, Vt = (n) => {
|
|
195
195
|
const e = n.userAgentData?.brands;
|
|
196
196
|
if (e != null && e.length > 0) {
|
|
197
197
|
const r = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
@@ -201,36 +201,36 @@ const Dt = () => {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
const t = navigator.userAgent;
|
|
204
|
-
return /Edg\//i.test(t) ? "Edge" : /OPR\//i.test(t) ? "Opera" : /Chrome/i.test(t) ? "Chrome" : /Firefox/i.test(t) ? "Firefox" : /Safari/i.test(t) && !/Chrome/i.test(t) ? "Safari" :
|
|
205
|
-
},
|
|
204
|
+
return /Edg\//i.test(t) ? "Edge" : /OPR\//i.test(t) ? "Opera" : /Chrome/i.test(t) ? "Chrome" : /Firefox/i.test(t) ? "Firefox" : /Safari/i.test(t) && !/Chrome/i.test(t) ? "Safari" : te;
|
|
205
|
+
}, Ht = () => {
|
|
206
206
|
try {
|
|
207
207
|
const n = navigator;
|
|
208
208
|
if (n.userAgentData != null && typeof n.userAgentData.mobile == "boolean") {
|
|
209
209
|
const l = n.userAgentData.platform;
|
|
210
210
|
return l != null && l !== "" && /ipad|tablet/i.test(l) ? w.Tablet : n.userAgentData.mobile ? w.Mobile : w.Desktop;
|
|
211
211
|
}
|
|
212
|
-
|
|
213
|
-
const e = window.innerWidth, t =
|
|
212
|
+
Ut();
|
|
213
|
+
const e = window.innerWidth, t = Te?.matches ?? !1, s = rt?.matches ?? !1, r = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), c = /tablet|ipad|android(?!.*mobile)/.test(i);
|
|
214
214
|
return e <= 767 || o && r ? w.Mobile : e >= 768 && e <= 1024 || c || t && s && r ? w.Tablet : w.Desktop;
|
|
215
215
|
} catch (n) {
|
|
216
216
|
return a("debug", "Device detection failed, defaulting to desktop", { error: n }), w.Desktop;
|
|
217
217
|
}
|
|
218
|
-
},
|
|
218
|
+
}, xt = () => {
|
|
219
219
|
try {
|
|
220
220
|
const n = navigator;
|
|
221
221
|
return {
|
|
222
|
-
type:
|
|
223
|
-
os:
|
|
224
|
-
browser:
|
|
222
|
+
type: Ht(),
|
|
223
|
+
os: Ft(n),
|
|
224
|
+
browser: Vt(n)
|
|
225
225
|
};
|
|
226
226
|
} catch (n) {
|
|
227
227
|
return a("debug", "Device info detection failed, using defaults", { error: n }), {
|
|
228
228
|
type: w.Desktop,
|
|
229
|
-
os:
|
|
230
|
-
browser:
|
|
229
|
+
os: te,
|
|
230
|
+
browser: te
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
|
-
},
|
|
233
|
+
}, je = 500, Ge = 2e3, We = 5e3, Q = 50, Bt = Q * 2, it = 1, $t = 1e3, Xt = 10, Ke = 5e3, jt = 3, Gt = 200, Wt = 6e4, Kt = 64, zt = 10 * 6e4, Qt = 200, bn = {
|
|
234
234
|
LCP: 2500,
|
|
235
235
|
FCP: 1800,
|
|
236
236
|
CLS: 0.1,
|
|
@@ -242,24 +242,24 @@ const Dt = () => {
|
|
|
242
242
|
CLS: 0.1,
|
|
243
243
|
INP: 200,
|
|
244
244
|
TTFB: 800
|
|
245
|
-
},
|
|
245
|
+
}, Yt = {
|
|
246
246
|
LCP: 4e3,
|
|
247
247
|
FCP: 3e3,
|
|
248
248
|
CLS: 0.25,
|
|
249
249
|
INP: 500,
|
|
250
250
|
TTFB: 1800
|
|
251
|
-
},
|
|
251
|
+
}, _e = "needs-improvement", Qe = (n = _e) => {
|
|
252
252
|
switch (n) {
|
|
253
253
|
case "all":
|
|
254
254
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0 };
|
|
255
255
|
case "needs-improvement":
|
|
256
256
|
return ze;
|
|
257
257
|
case "poor":
|
|
258
|
-
return
|
|
258
|
+
return Yt;
|
|
259
259
|
default:
|
|
260
260
|
return ze;
|
|
261
261
|
}
|
|
262
|
-
},
|
|
262
|
+
}, qt = 50, Jt = "3.1.1", Zt = Jt, es = () => typeof window < "u" && typeof sessionStorage < "u", ts = () => {
|
|
263
263
|
try {
|
|
264
264
|
const n = new URLSearchParams(window.location.search);
|
|
265
265
|
n.delete(nt);
|
|
@@ -267,23 +267,23 @@ const Dt = () => {
|
|
|
267
267
|
window.history.replaceState({}, "", t);
|
|
268
268
|
} catch {
|
|
269
269
|
}
|
|
270
|
-
},
|
|
271
|
-
if (!
|
|
270
|
+
}, ss = () => {
|
|
271
|
+
if (!es())
|
|
272
272
|
return !1;
|
|
273
273
|
try {
|
|
274
|
-
const e = new URLSearchParams(window.location.search).get(nt), t = sessionStorage.getItem(
|
|
274
|
+
const e = new URLSearchParams(window.location.search).get(nt), t = sessionStorage.getItem(z);
|
|
275
275
|
let s = null;
|
|
276
|
-
return e ===
|
|
277
|
-
visibility: "qa",
|
|
278
|
-
style: bt
|
|
279
|
-
})) : e === Ve && (s = !1, sessionStorage.setItem(Q, "false"), a("info", "QA Mode DISABLED", {
|
|
276
|
+
return e === Ue ? (s = !0, sessionStorage.setItem(z, "true"), a("info", "QA Mode ACTIVE", {
|
|
280
277
|
visibility: "qa",
|
|
281
278
|
style: Mt
|
|
282
|
-
}))
|
|
279
|
+
})) : e === Fe && (s = !1, sessionStorage.setItem(z, "false"), a("info", "QA Mode DISABLED", {
|
|
280
|
+
visibility: "qa",
|
|
281
|
+
style: Ct
|
|
282
|
+
})), (e === Ue || e === Fe) && ts(), s ?? t === "true";
|
|
283
283
|
} catch {
|
|
284
284
|
return !1;
|
|
285
285
|
}
|
|
286
|
-
}, ot = () => typeof document < "u" && document.prerendering === !0,
|
|
286
|
+
}, ot = () => typeof document < "u" && document.prerendering === !0, ns = [
|
|
287
287
|
"co.uk",
|
|
288
288
|
"org.uk",
|
|
289
289
|
"com.au",
|
|
@@ -300,18 +300,18 @@ const Dt = () => {
|
|
|
300
300
|
if (e.length <= 2)
|
|
301
301
|
return n.toLowerCase();
|
|
302
302
|
const t = e.slice(-2).join(".");
|
|
303
|
-
return
|
|
304
|
-
},
|
|
303
|
+
return ns.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
304
|
+
}, rs = (n, e) => n === e ? !0 : Ye(n) === Ye(e), he = () => {
|
|
305
305
|
const n = document.referrer;
|
|
306
306
|
if (!n)
|
|
307
307
|
return "Direct";
|
|
308
308
|
try {
|
|
309
309
|
const e = new URL(n).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
|
|
310
|
-
return
|
|
310
|
+
return rs(e, t) ? "Direct" : n;
|
|
311
311
|
} catch (e) {
|
|
312
312
|
return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: n } }), n;
|
|
313
313
|
}
|
|
314
|
-
},
|
|
314
|
+
}, fe = () => {
|
|
315
315
|
const n = new URLSearchParams(window.location.search), e = {};
|
|
316
316
|
return Tt.forEach((s) => {
|
|
317
317
|
const r = n.get(s);
|
|
@@ -324,11 +324,11 @@ const Dt = () => {
|
|
|
324
324
|
const e = Math.random() * 16 | 0;
|
|
325
325
|
return (n === "x" ? e : e & 3 | 8).toString(16);
|
|
326
326
|
});
|
|
327
|
-
let
|
|
328
|
-
const
|
|
327
|
+
let G = 0, W = 0;
|
|
328
|
+
const is = () => {
|
|
329
329
|
let n = Date.now();
|
|
330
|
-
n <
|
|
331
|
-
const e =
|
|
330
|
+
n < W && (n = W), n === W ? G = (G + 1) % 1e3 : G = 0, W = n;
|
|
331
|
+
const e = G.toString().padStart(3, "0");
|
|
332
332
|
let t = "";
|
|
333
333
|
try {
|
|
334
334
|
if (typeof crypto < "u" && crypto.getRandomValues) {
|
|
@@ -338,13 +338,13 @@ const ss = () => {
|
|
|
338
338
|
} catch {
|
|
339
339
|
}
|
|
340
340
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${n}-${e}-${t}`;
|
|
341
|
-
},
|
|
341
|
+
}, os = (n) => {
|
|
342
342
|
try {
|
|
343
343
|
return new URL(n).protocol === "https:";
|
|
344
344
|
} catch {
|
|
345
345
|
return !1;
|
|
346
346
|
}
|
|
347
|
-
},
|
|
347
|
+
}, as = (n) => {
|
|
348
348
|
try {
|
|
349
349
|
const t = new URL(window.location.href).hostname;
|
|
350
350
|
if (!t || typeof t != "string")
|
|
@@ -362,16 +362,16 @@ const ss = () => {
|
|
|
362
362
|
if (!r || r.split(".").length < 2)
|
|
363
363
|
throw new Error("Invalid domain structure for SaaS");
|
|
364
364
|
const i = `https://${n}.${r}/collect`;
|
|
365
|
-
if (!
|
|
365
|
+
if (!os(i))
|
|
366
366
|
throw new Error("Generated URL failed validation");
|
|
367
367
|
return i;
|
|
368
368
|
} catch (e) {
|
|
369
369
|
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
370
370
|
}
|
|
371
|
-
},
|
|
371
|
+
}, cs = (n) => {
|
|
372
372
|
const e = {};
|
|
373
|
-
return n.integrations?.tracelog?.projectId && (e.saas =
|
|
374
|
-
},
|
|
373
|
+
return n.integrations?.tracelog?.projectId && (e.saas = as(n.integrations.tracelog.projectId)), e;
|
|
374
|
+
}, ye = (n, e = []) => {
|
|
375
375
|
if (!n || typeof n != "string")
|
|
376
376
|
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof n } }), n || "";
|
|
377
377
|
try {
|
|
@@ -400,7 +400,7 @@ const ss = () => {
|
|
|
400
400
|
valueLength: n.length
|
|
401
401
|
}
|
|
402
402
|
}), e.trim();
|
|
403
|
-
},
|
|
403
|
+
}, Ie = (n, e = 0) => {
|
|
404
404
|
if (n == null)
|
|
405
405
|
return null;
|
|
406
406
|
if (typeof n == "string")
|
|
@@ -412,30 +412,30 @@ const ss = () => {
|
|
|
412
412
|
if (e > 10)
|
|
413
413
|
return null;
|
|
414
414
|
if (Array.isArray(n))
|
|
415
|
-
return n.slice(0, 1e3).map((r) =>
|
|
415
|
+
return n.slice(0, 1e3).map((r) => Ie(r, e + 1)).filter((r) => r !== null);
|
|
416
416
|
if (typeof n == "object") {
|
|
417
417
|
const t = {}, r = Object.entries(n).slice(0, 200);
|
|
418
418
|
for (const [i, o] of r) {
|
|
419
419
|
const c = qe(i);
|
|
420
420
|
if (c) {
|
|
421
|
-
const l =
|
|
421
|
+
const l = Ie(o, e + 1);
|
|
422
422
|
l !== null && (t[c] = l);
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
return t;
|
|
426
426
|
}
|
|
427
427
|
return null;
|
|
428
|
-
},
|
|
428
|
+
}, ls = (n) => {
|
|
429
429
|
if (typeof n != "object" || n === null)
|
|
430
430
|
return {};
|
|
431
431
|
try {
|
|
432
|
-
const e =
|
|
432
|
+
const e = Ie(n);
|
|
433
433
|
return typeof e == "object" && e !== null ? e : {};
|
|
434
434
|
} catch (e) {
|
|
435
435
|
const t = e instanceof Error ? e.message : String(e);
|
|
436
436
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
437
437
|
}
|
|
438
|
-
},
|
|
438
|
+
}, us = [
|
|
439
439
|
// Email addresses.
|
|
440
440
|
// Quantifiers are bounded (local part ≤64, each label ≤63, TLD ≤63 per RFC/DNS limits)
|
|
441
441
|
// and the domain is matched as discrete dot-separated labels so the local-part and
|
|
@@ -456,20 +456,20 @@ const ss = () => {
|
|
|
456
456
|
/:\/\/[^:/]+:([^@]+)@/gi,
|
|
457
457
|
// Sensitive URL query parameters (token=, password=, auth=, secret=, api_key=, …)
|
|
458
458
|
/[?&](token|password|passwd|auth|secret|secret_key|private_key|auth_key|api_key|apikey|access_token)=[^&\s]+/gi
|
|
459
|
-
],
|
|
459
|
+
], Y = (n) => {
|
|
460
460
|
let e = n;
|
|
461
|
-
for (const t of
|
|
461
|
+
for (const t of us)
|
|
462
462
|
e = e.replace(t, "[REDACTED]");
|
|
463
463
|
return e;
|
|
464
|
-
},
|
|
464
|
+
}, ds = (n) => {
|
|
465
465
|
if (n !== void 0 && (n === null || typeof n != "object"))
|
|
466
466
|
throw new m("Configuration must be an object", "config");
|
|
467
467
|
if (n) {
|
|
468
468
|
if (n.sessionTimeout !== void 0 && (typeof n.sessionTimeout != "number" || n.sessionTimeout < 3e4 || n.sessionTimeout > 864e5))
|
|
469
|
-
throw new
|
|
469
|
+
throw new bt(y.INVALID_SESSION_TIMEOUT, "config");
|
|
470
470
|
if (n.globalMetadata !== void 0 && (typeof n.globalMetadata != "object" || n.globalMetadata === null))
|
|
471
471
|
throw new m(y.INVALID_GLOBAL_METADATA, "config");
|
|
472
|
-
if (n.integrations &&
|
|
472
|
+
if (n.integrations && hs(n.integrations), n.sensitiveQueryParams !== void 0) {
|
|
473
473
|
if (!Array.isArray(n.sensitiveQueryParams))
|
|
474
474
|
throw new m(y.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
475
475
|
for (const e of n.sensitiveQueryParams)
|
|
@@ -477,9 +477,9 @@ const ss = () => {
|
|
|
477
477
|
throw new m("All sensitive query params must be strings", "config");
|
|
478
478
|
}
|
|
479
479
|
if (n.errorSampling !== void 0 && (typeof n.errorSampling != "number" || n.errorSampling < 0 || n.errorSampling > 1))
|
|
480
|
-
throw new
|
|
480
|
+
throw new $e(y.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
481
481
|
if (n.samplingRate !== void 0 && (typeof n.samplingRate != "number" || n.samplingRate < 0 || n.samplingRate > 1))
|
|
482
|
-
throw new
|
|
482
|
+
throw new $e(y.INVALID_SAMPLING_RATE, "config");
|
|
483
483
|
if (n.pageViewThrottleMs !== void 0 && (typeof n.pageViewThrottleMs != "number" || n.pageViewThrottleMs < 0))
|
|
484
484
|
throw new m(y.INVALID_PAGE_VIEW_THROTTLE, "config");
|
|
485
485
|
if (n.clickThrottleMs !== void 0 && (typeof n.clickThrottleMs != "number" || n.clickThrottleMs < 0))
|
|
@@ -529,27 +529,14 @@ const ss = () => {
|
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
531
|
}
|
|
532
|
-
},
|
|
532
|
+
}, hs = (n) => {
|
|
533
533
|
if (n && n.tracelog) {
|
|
534
534
|
if (!n.tracelog.projectId || typeof n.tracelog.projectId != "string" || n.tracelog.projectId.trim() === "")
|
|
535
|
-
throw new
|
|
535
|
+
throw new Xe(y.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
536
536
|
if (n.tracelog.shopify !== void 0 && typeof n.tracelog.shopify != "boolean")
|
|
537
|
-
throw new
|
|
538
|
-
if (n.tracelog.collectUrl !== void 0) {
|
|
539
|
-
const e = "tracelog.collectUrl must be a non-empty HTTPS URL", { collectUrl: t } = n.tracelog;
|
|
540
|
-
if (typeof t != "string" || t.trim() === "")
|
|
541
|
-
throw new F(e, "config");
|
|
542
|
-
let s;
|
|
543
|
-
try {
|
|
544
|
-
s = new URL(t);
|
|
545
|
-
} catch {
|
|
546
|
-
throw new F(e, "config");
|
|
547
|
-
}
|
|
548
|
-
if (s.protocol !== "https:")
|
|
549
|
-
throw new F(e, "config");
|
|
550
|
-
}
|
|
537
|
+
throw new Xe("tracelog.shopify must be a boolean", "config");
|
|
551
538
|
}
|
|
552
|
-
},
|
|
539
|
+
}, fs = (n) => (ds(n), {
|
|
553
540
|
...n ?? {},
|
|
554
541
|
sessionTimeout: n?.sessionTimeout ?? 9e5,
|
|
555
542
|
globalMetadata: n?.globalMetadata ?? {},
|
|
@@ -562,18 +549,18 @@ const ss = () => {
|
|
|
562
549
|
sendIntervalMs: n?.sendIntervalMs ?? 1e4,
|
|
563
550
|
flushOnSpaNavigation: n?.flushOnSpaNavigation ?? !1,
|
|
564
551
|
flushOnPageHidden: n?.flushOnPageHidden ?? !0
|
|
565
|
-
}),
|
|
552
|
+
}), we = (n, e = /* @__PURE__ */ new Set()) => {
|
|
566
553
|
if (n == null)
|
|
567
554
|
return !0;
|
|
568
555
|
const t = typeof n;
|
|
569
|
-
return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(n) ? !1 : (e.add(n), Array.isArray(n) ? n.every((s) =>
|
|
570
|
-
},
|
|
556
|
+
return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(n) ? !1 : (e.add(n), Array.isArray(n) ? n.every((s) => we(s, e)) : t === "object" ? Object.values(n).every((s) => we(s, e)) : !1);
|
|
557
|
+
}, gs = (n) => typeof n != "object" || n === null ? !1 : we(n), Ae = (n) => {
|
|
571
558
|
if (typeof n != "object" || n === null || Array.isArray(n)) return;
|
|
572
559
|
const e = {};
|
|
573
560
|
for (const [t, s] of Object.entries(n))
|
|
574
561
|
typeof s == "string" && (e[t] = s);
|
|
575
562
|
return Object.keys(e).length > 0 ? e : void 0;
|
|
576
|
-
},
|
|
563
|
+
}, ms = (n) => typeof n != "string" ? {
|
|
577
564
|
valid: !1,
|
|
578
565
|
error: "Event name must be a string"
|
|
579
566
|
} : n.length === 0 ? {
|
|
@@ -589,8 +576,8 @@ const ss = () => {
|
|
|
589
576
|
valid: !1,
|
|
590
577
|
error: "Event name cannot be a reserved word"
|
|
591
578
|
} : { valid: !0 }, Je = (n, e, t) => {
|
|
592
|
-
const s =
|
|
593
|
-
if (!
|
|
579
|
+
const s = ls(e), r = `${t} "${n}" metadata error`;
|
|
580
|
+
if (!gs(s))
|
|
594
581
|
return {
|
|
595
582
|
valid: !1,
|
|
596
583
|
error: `${r}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -638,7 +625,7 @@ const ss = () => {
|
|
|
638
625
|
valid: !0,
|
|
639
626
|
sanitizedMetadata: s
|
|
640
627
|
};
|
|
641
|
-
},
|
|
628
|
+
}, ps = (n, e, t) => {
|
|
642
629
|
if (Array.isArray(e)) {
|
|
643
630
|
const s = [], r = `${t} "${n}" metadata error`;
|
|
644
631
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -662,15 +649,15 @@ const ss = () => {
|
|
|
662
649
|
};
|
|
663
650
|
}
|
|
664
651
|
return Je(n, e, t);
|
|
665
|
-
},
|
|
666
|
-
const t =
|
|
652
|
+
}, Ss = (n, e) => {
|
|
653
|
+
const t = ms(n);
|
|
667
654
|
if (!t.valid)
|
|
668
655
|
return a("error", "Event name validation failed", {
|
|
669
656
|
data: { eventName: n, error: t.error }
|
|
670
657
|
}), t;
|
|
671
658
|
if (!e)
|
|
672
659
|
return { valid: !0 };
|
|
673
|
-
const s =
|
|
660
|
+
const s = ps(n, e, "customEvent");
|
|
674
661
|
return s.valid || a("error", "Event metadata validation failed", {
|
|
675
662
|
data: {
|
|
676
663
|
eventName: n,
|
|
@@ -678,7 +665,7 @@ const ss = () => {
|
|
|
678
665
|
}
|
|
679
666
|
}), s;
|
|
680
667
|
};
|
|
681
|
-
class
|
|
668
|
+
class Es {
|
|
682
669
|
listeners = /* @__PURE__ */ new Map();
|
|
683
670
|
/**
|
|
684
671
|
* Subscribes to an event channel
|
|
@@ -795,15 +782,15 @@ class ms {
|
|
|
795
782
|
this.listeners.clear();
|
|
796
783
|
}
|
|
797
784
|
}
|
|
798
|
-
const
|
|
799
|
-
function
|
|
800
|
-
return n.replace(
|
|
785
|
+
const vs = /https?:\/\/\S+/g, Ts = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, _s = /0x[0-9a-fA-F]{4,}/g, ys = /(?<!\d)\d{4,}(?!\d)/g, Is = /(['"])[^'"]{20,}\1/g;
|
|
786
|
+
function ws(n) {
|
|
787
|
+
return n.replace(vs, "[URL]").replace(Ts, "[ID]").replace(_s, "[ADDR]").replace(ys, "[N]").replace(Is, "$1[VAR]$1").toLowerCase().trim();
|
|
801
788
|
}
|
|
802
789
|
function Ze(n) {
|
|
803
790
|
const e = n.search(/[?#]/);
|
|
804
791
|
return e === -1 ? n : n.slice(0, e);
|
|
805
792
|
}
|
|
806
|
-
function
|
|
793
|
+
function As(n, e) {
|
|
807
794
|
const t = Ze((n ?? "").trim());
|
|
808
795
|
if (!t) return "";
|
|
809
796
|
let s;
|
|
@@ -816,35 +803,42 @@ function ys(n, e) {
|
|
|
816
803
|
const r = Ze((e ?? "").trim());
|
|
817
804
|
return r && t === r ? s.origin : t;
|
|
818
805
|
}
|
|
819
|
-
function
|
|
820
|
-
const e =
|
|
806
|
+
function bs(n) {
|
|
807
|
+
const e = ws(n.message), t = As(n.filename, n.page_url), s = n.line == null ? "" : String(n.line);
|
|
821
808
|
return `${e}|${t}|${s}`;
|
|
822
809
|
}
|
|
823
|
-
const
|
|
810
|
+
const ge = { config: {} };
|
|
824
811
|
class T {
|
|
825
812
|
/**
|
|
826
813
|
* Retrieves a value from global state.
|
|
827
814
|
*/
|
|
828
815
|
get(e) {
|
|
829
|
-
return
|
|
816
|
+
return ge[e];
|
|
830
817
|
}
|
|
831
818
|
/**
|
|
832
819
|
* Sets a value in global state.
|
|
833
820
|
*/
|
|
834
821
|
set(e, t) {
|
|
835
|
-
|
|
822
|
+
ge[e] = t;
|
|
836
823
|
}
|
|
837
824
|
/**
|
|
838
825
|
* Returns an immutable snapshot of the entire global state.
|
|
839
826
|
*/
|
|
840
827
|
getState() {
|
|
841
|
-
return { ...
|
|
828
|
+
return { ...ge };
|
|
842
829
|
}
|
|
843
830
|
}
|
|
844
|
-
class
|
|
831
|
+
class Ls extends T {
|
|
845
832
|
storeManager;
|
|
846
833
|
apiUrl;
|
|
847
834
|
lastPermanentErrorLog = null;
|
|
835
|
+
/**
|
|
836
|
+
* In-memory fallback for the beacon throttle when localStorage is
|
|
837
|
+
* unavailable. The primary throttle state lives in localStorage (see
|
|
838
|
+
* {@link HEALTH_BEACON_KEY}) so it survives MPA navigations and is shared
|
|
839
|
+
* across tabs.
|
|
840
|
+
*/
|
|
841
|
+
lastBeaconAt = {};
|
|
848
842
|
recoveryInProgress = !1;
|
|
849
843
|
lastMetadataTimestamp = 0;
|
|
850
844
|
pendingControllers = /* @__PURE__ */ new Set();
|
|
@@ -886,7 +880,7 @@ class ws extends T {
|
|
|
886
880
|
* cases so the migration is one-shot per browser.
|
|
887
881
|
*/
|
|
888
882
|
migrateLegacyV2Keys() {
|
|
889
|
-
const e = this.get("userId") || "anonymous", t = `${
|
|
883
|
+
const e = this.get("userId") || "anonymous", t = `${ce(e)}:saas`, s = `${ce(e)}:custom`, r = `${le(e)}:saas`, i = `${le(e)}:custom`;
|
|
890
884
|
try {
|
|
891
885
|
const o = this.storeManager.getItem(t);
|
|
892
886
|
if (o) {
|
|
@@ -932,11 +926,11 @@ class ws extends T {
|
|
|
932
926
|
}
|
|
933
927
|
getQueueStorageKey() {
|
|
934
928
|
const e = this.get("userId") || "anonymous";
|
|
935
|
-
return
|
|
929
|
+
return ce(e);
|
|
936
930
|
}
|
|
937
931
|
getRateLimitStorageKey() {
|
|
938
932
|
const e = this.get("userId") || "anonymous";
|
|
939
|
-
return
|
|
933
|
+
return le(e);
|
|
940
934
|
}
|
|
941
935
|
getActiveRateLimitKey() {
|
|
942
936
|
return this.rateLimitStorageKeyAtArm ?? this.getRateLimitStorageKey();
|
|
@@ -1004,7 +998,7 @@ class ws extends T {
|
|
|
1004
998
|
const t = this.ensureBatchMetadata(e), s = this.getPersistedData(), r = typeof s?.recoveryFailures == "number" && Number.isFinite(s.recoveryFailures) ? s.recoveryFailures : 0;
|
|
1005
999
|
return this.persistEventsWithFailureCount(t, r, !0), !1;
|
|
1006
1000
|
}
|
|
1007
|
-
return this.apiUrl.includes(
|
|
1001
|
+
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);
|
|
1008
1002
|
}
|
|
1009
1003
|
/**
|
|
1010
1004
|
* Sends events asynchronously using `fetch()` with retry, circuit breaker, and 429 cooldown.
|
|
@@ -1016,7 +1010,7 @@ class ws extends T {
|
|
|
1016
1010
|
const r = await this.send(s);
|
|
1017
1011
|
return r ? (this.clearPersistedEvents(), t?.onSuccess?.(s.events.length, s.events, s)) : (this.persistEvents(s), t?.onFailure?.()), r;
|
|
1018
1012
|
} catch (r) {
|
|
1019
|
-
return r instanceof
|
|
1013
|
+
return r instanceof C ? (this.logPermanentError("Permanent error, not retrying", r), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(s), t?.onFailure?.(), !1);
|
|
1020
1014
|
}
|
|
1021
1015
|
}
|
|
1022
1016
|
/**
|
|
@@ -1054,7 +1048,7 @@ class ws extends T {
|
|
|
1054
1048
|
}
|
|
1055
1049
|
await this.send(t) ? (this.clearPersistedEvents(), e?.onSuccess?.(r.events.length, r.events, t)) : (this.persistEventsWithFailureCount(t, s + 1, !0), e?.onFailure?.());
|
|
1056
1050
|
} catch (r) {
|
|
1057
|
-
if (r instanceof
|
|
1051
|
+
if (r instanceof C) {
|
|
1058
1052
|
this.logPermanentError("Permanent error during recovery, clearing persisted events", r), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1059
1053
|
return;
|
|
1060
1054
|
}
|
|
@@ -1075,9 +1069,9 @@ class ws extends T {
|
|
|
1075
1069
|
}
|
|
1076
1070
|
async send(e) {
|
|
1077
1071
|
const t = this.ensureBatchMetadata(e, e._metadata?.idempotency_token);
|
|
1078
|
-
if (this.apiUrl.includes(
|
|
1072
|
+
if (this.apiUrl.includes(M.Fail))
|
|
1079
1073
|
return a("debug", "Fail mode: simulating network failure", { data: { events: t.events.length } }), !1;
|
|
1080
|
-
if (this.apiUrl.includes(
|
|
1074
|
+
if (this.apiUrl.includes(M.Localhost))
|
|
1081
1075
|
return a("debug", "Success mode: simulating successful send", { data: { events: t.events.length } }), !0;
|
|
1082
1076
|
if (this.isRateLimited())
|
|
1083
1077
|
return a("debug", "Rate-limit cooldown active, skipping send", {
|
|
@@ -1105,15 +1099,15 @@ class ws extends T {
|
|
|
1105
1099
|
}), this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, !0) : !1;
|
|
1106
1100
|
} catch (l) {
|
|
1107
1101
|
const u = c === 3;
|
|
1108
|
-
if (l instanceof
|
|
1109
|
-
throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l;
|
|
1110
|
-
if (l instanceof
|
|
1102
|
+
if (l instanceof C)
|
|
1103
|
+
throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l.statusCode === 403 && this.emitHealthBeacon("events_blocked", l.message), l;
|
|
1104
|
+
if (l instanceof J) {
|
|
1111
1105
|
this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, i = !1, o = !0, this.armRateLimitCooldown(Date.now() + 6e4), a("warn", "Rate limited, skipping retries", {
|
|
1112
1106
|
data: { events: e.events.length, attempt: c, cooldownMs: 6e4 }
|
|
1113
1107
|
});
|
|
1114
1108
|
break;
|
|
1115
1109
|
}
|
|
1116
|
-
if (l instanceof
|
|
1110
|
+
if (l instanceof Z || (i = !1), l instanceof TypeError || (o = !0), a(
|
|
1117
1111
|
u ? "error" : "warn",
|
|
1118
1112
|
`Send attempt ${c} failed${u ? " (all retries exhausted)" : ", will retry"}`,
|
|
1119
1113
|
{
|
|
@@ -1159,13 +1153,13 @@ class ws extends T {
|
|
|
1159
1153
|
if (!o.ok) {
|
|
1160
1154
|
if (o.status >= 400 && o.status < 500 && o.status !== 408 && o.status !== 429) {
|
|
1161
1155
|
const l = await this.readTraceLogErrorCode(o), u = l ? `HTTP ${o.status}: ${o.statusText} (${l})` : `HTTP ${o.status}: ${o.statusText}`;
|
|
1162
|
-
throw new
|
|
1156
|
+
throw new C(u, o.status, l);
|
|
1163
1157
|
}
|
|
1164
|
-
throw o.status === 429 ? new
|
|
1158
|
+
throw o.status === 429 ? new J(`HTTP 429: ${o.statusText}`) : new Error(`HTTP ${o.status}: ${o.statusText}`);
|
|
1165
1159
|
}
|
|
1166
1160
|
return o;
|
|
1167
1161
|
} catch (o) {
|
|
1168
|
-
throw o instanceof
|
|
1162
|
+
throw o instanceof C ? o : r ? new Z("Request timed out") : o;
|
|
1169
1163
|
} finally {
|
|
1170
1164
|
clearTimeout(i), this.pendingControllers.delete(s);
|
|
1171
1165
|
}
|
|
@@ -1173,7 +1167,7 @@ class ws extends T {
|
|
|
1173
1167
|
async readTraceLogErrorCode(e) {
|
|
1174
1168
|
try {
|
|
1175
1169
|
const t = await e.clone().json();
|
|
1176
|
-
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <=
|
|
1170
|
+
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <= Kt)
|
|
1177
1171
|
return t.code;
|
|
1178
1172
|
} catch {
|
|
1179
1173
|
}
|
|
@@ -1200,7 +1194,7 @@ class ws extends T {
|
|
|
1200
1194
|
idempotency_token: e._metadata?.idempotency_token ?? this.computeContentToken(e),
|
|
1201
1195
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1202
1196
|
timestamp: t,
|
|
1203
|
-
client_version:
|
|
1197
|
+
client_version: Zt
|
|
1204
1198
|
}
|
|
1205
1199
|
};
|
|
1206
1200
|
return {
|
|
@@ -1296,8 +1290,72 @@ class ws extends T {
|
|
|
1296
1290
|
data: { status: t.statusCode, code: t.responseCode, message: t.message }
|
|
1297
1291
|
}), this.lastPermanentErrorLog = { key: r, timestamp: s });
|
|
1298
1292
|
}
|
|
1293
|
+
/**
|
|
1294
|
+
* Emits a low-frequency, deduplicated diagnostic "health beacon" to the gate-bypassing
|
|
1295
|
+
* `/client-error` endpoint. Best-effort and silent: never blocks, never throws, never logs to the
|
|
1296
|
+
* host page. Opt out via `integrations.tracelog.healthBeacon: false`.
|
|
1297
|
+
*/
|
|
1298
|
+
emitHealthBeacon(e, t) {
|
|
1299
|
+
try {
|
|
1300
|
+
const s = this.get("config")?.integrations?.tracelog;
|
|
1301
|
+
if (!s?.projectId || s.healthBeacon === !1) return;
|
|
1302
|
+
const r = this.resolveBeaconUrl();
|
|
1303
|
+
if (!r || !this.markBeaconEmitted(e)) return;
|
|
1304
|
+
const i = typeof window < "u" && window.location ? window.location.origin : "", o = JSON.stringify({
|
|
1305
|
+
projectId: s.projectId,
|
|
1306
|
+
reason: e,
|
|
1307
|
+
origin: i,
|
|
1308
|
+
...t ? { lastError: t.slice(0, Qt) } : {}
|
|
1309
|
+
});
|
|
1310
|
+
this.postBeacon(r, o);
|
|
1311
|
+
} catch {
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Throttle gate: returns `true` and records the emit timestamp when the
|
|
1316
|
+
* beacon may fire, `false` when still inside {@link HEALTH_BEACON_THROTTLE_MS}.
|
|
1317
|
+
*
|
|
1318
|
+
* State lives in localStorage so the window survives MPA navigations and is
|
|
1319
|
+
* shared across tabs; the in-memory map covers storage-disabled browsers.
|
|
1320
|
+
* The timestamp is deliberately recorded BEFORE the send attempt: if both
|
|
1321
|
+
* transports fail, waiting out the window is fine for a diagnostic signal
|
|
1322
|
+
* and avoids turning transport failures into retry bursts.
|
|
1323
|
+
*/
|
|
1324
|
+
markBeaconEmitted(e) {
|
|
1325
|
+
const t = Date.now(), s = It(e);
|
|
1326
|
+
let r = this.lastBeaconAt[e] ?? 0;
|
|
1327
|
+
try {
|
|
1328
|
+
const i = Number(this.storeManager.getItem(s));
|
|
1329
|
+
Number.isFinite(i) && i > r && (r = i);
|
|
1330
|
+
} catch {
|
|
1331
|
+
}
|
|
1332
|
+
if (t - r < zt) return !1;
|
|
1333
|
+
this.lastBeaconAt[e] = t;
|
|
1334
|
+
try {
|
|
1335
|
+
this.storeManager.setItem(s, String(t));
|
|
1336
|
+
} catch {
|
|
1337
|
+
}
|
|
1338
|
+
return !0;
|
|
1339
|
+
}
|
|
1340
|
+
/** The collect URL the lib already derived, with the path swapped to the diagnostics route. */
|
|
1341
|
+
resolveBeaconUrl() {
|
|
1342
|
+
return this.apiUrl.includes(M.Localhost) || this.apiUrl.includes(M.Fail) || !/\/collect$/.test(this.apiUrl) ? null : this.apiUrl.replace(/\/collect$/, "/client-error");
|
|
1343
|
+
}
|
|
1344
|
+
postBeacon(e, t) {
|
|
1345
|
+
if (this.isSendBeaconAvailable()) {
|
|
1346
|
+
const s = new Blob([t], { type: "application/json" });
|
|
1347
|
+
if (navigator.sendBeacon(e, s)) return;
|
|
1348
|
+
}
|
|
1349
|
+
typeof fetch == "function" && fetch(e, {
|
|
1350
|
+
method: "POST",
|
|
1351
|
+
body: t,
|
|
1352
|
+
keepalive: !0,
|
|
1353
|
+
headers: { "Content-Type": "application/json" }
|
|
1354
|
+
}).catch(() => {
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1299
1357
|
}
|
|
1300
|
-
class
|
|
1358
|
+
class Ms extends T {
|
|
1301
1359
|
bootTime;
|
|
1302
1360
|
bootTimestamp;
|
|
1303
1361
|
hasPerformanceNow;
|
|
@@ -1331,8 +1389,8 @@ class As extends T {
|
|
|
1331
1389
|
} : { valid: !0 };
|
|
1332
1390
|
}
|
|
1333
1391
|
}
|
|
1334
|
-
const
|
|
1335
|
-
class
|
|
1392
|
+
const Cs = new Set(Object.values(d));
|
|
1393
|
+
class Rs extends T {
|
|
1336
1394
|
dataSenders;
|
|
1337
1395
|
emitter;
|
|
1338
1396
|
timeManager;
|
|
@@ -1364,9 +1422,9 @@ class bs extends T {
|
|
|
1364
1422
|
* @param emitter - Optional event emitter for local event consumption
|
|
1365
1423
|
*/
|
|
1366
1424
|
constructor(e, t = null) {
|
|
1367
|
-
super(), this.emitter = t, this.timeManager = new
|
|
1425
|
+
super(), this.emitter = t, this.timeManager = new Ms(), this.dataSenders = [];
|
|
1368
1426
|
const s = this.get("collectApiUrls");
|
|
1369
|
-
s?.saas && this.dataSenders.push(new
|
|
1427
|
+
s?.saas && this.dataSenders.push(new Ls(e, s.saas)), this.saveSessionCountsDebounced = this.debounce((r) => {
|
|
1370
1428
|
this.saveSessionCounts(r);
|
|
1371
1429
|
}, 500), this.cleanupExpiredSessionCounts();
|
|
1372
1430
|
}
|
|
@@ -1484,7 +1542,7 @@ class bs extends T {
|
|
|
1484
1542
|
a("error", "Event type is required - event will be ignored");
|
|
1485
1543
|
return;
|
|
1486
1544
|
}
|
|
1487
|
-
if (!
|
|
1545
|
+
if (!Cs.has(e)) {
|
|
1488
1546
|
a("error", "Invalid event type - event will be ignored", {
|
|
1489
1547
|
data: { type: e }
|
|
1490
1548
|
});
|
|
@@ -1527,12 +1585,12 @@ class bs extends T {
|
|
|
1527
1585
|
}
|
|
1528
1586
|
const _ = this.getTypeLimitForEvent(S);
|
|
1529
1587
|
if (_) {
|
|
1530
|
-
const
|
|
1531
|
-
if (
|
|
1588
|
+
const ae = this.sessionEventCounts[S];
|
|
1589
|
+
if (ae !== void 0 && ae >= _) {
|
|
1532
1590
|
a("warn", "Session event type limit reached", {
|
|
1533
1591
|
data: {
|
|
1534
1592
|
type: S,
|
|
1535
|
-
count:
|
|
1593
|
+
count: ae,
|
|
1536
1594
|
limit: _
|
|
1537
1595
|
}
|
|
1538
1596
|
});
|
|
@@ -1545,7 +1603,7 @@ class bs extends T {
|
|
|
1545
1603
|
if (!this.checkPerEventRateLimit(o.name, _))
|
|
1546
1604
|
return;
|
|
1547
1605
|
}
|
|
1548
|
-
const St = S === d.SESSION_START, Et = t || this.get("pageUrl"),
|
|
1606
|
+
const St = S === d.SESSION_START, Et = t || this.get("pageUrl"), j = this.buildEventPayload({
|
|
1549
1607
|
type: S,
|
|
1550
1608
|
page_url: Et,
|
|
1551
1609
|
from_page_url: s,
|
|
@@ -1556,7 +1614,7 @@ class bs extends T {
|
|
|
1556
1614
|
error_data: l,
|
|
1557
1615
|
page_view: u
|
|
1558
1616
|
});
|
|
1559
|
-
if (
|
|
1617
|
+
if (j && !(!p && !this.shouldSample())) {
|
|
1560
1618
|
if (St) {
|
|
1561
1619
|
const _ = this.get("sessionId");
|
|
1562
1620
|
if (!_) {
|
|
@@ -1571,18 +1629,18 @@ class bs extends T {
|
|
|
1571
1629
|
}
|
|
1572
1630
|
this.set("hasStartSession", !0);
|
|
1573
1631
|
}
|
|
1574
|
-
if (!this.isDuplicateEvent(
|
|
1575
|
-
if (this.get("mode") ===
|
|
1632
|
+
if (!this.isDuplicateEvent(j)) {
|
|
1633
|
+
if (this.get("mode") === ee.QA && S === d.CUSTOM && o) {
|
|
1576
1634
|
a("info", `Custom Event: ${o.name}`, {
|
|
1577
1635
|
visibility: "qa",
|
|
1578
1636
|
data: {
|
|
1579
1637
|
name: o.name,
|
|
1580
1638
|
...o.metadata && { metadata: o.metadata }
|
|
1581
1639
|
}
|
|
1582
|
-
}), this.emitEvent(
|
|
1640
|
+
}), this.emitEvent(j);
|
|
1583
1641
|
return;
|
|
1584
1642
|
}
|
|
1585
|
-
if (this.addToQueue(
|
|
1643
|
+
if (this.addToQueue(j), !p) {
|
|
1586
1644
|
this.sessionEventCounts.total++, this.sessionEventCounts[S] !== void 0 && this.sessionEventCounts[S]++;
|
|
1587
1645
|
const _ = this.get("sessionId");
|
|
1588
1646
|
_ && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(_);
|
|
@@ -2040,7 +2098,7 @@ class bs extends T {
|
|
|
2040
2098
|
});
|
|
2041
2099
|
const c = this.get("sessionReferrer"), l = this.get("sessionUtm"), u = this.get("sessionClickIds");
|
|
2042
2100
|
return { ...{
|
|
2043
|
-
id:
|
|
2101
|
+
id: is(),
|
|
2044
2102
|
type: e.type,
|
|
2045
2103
|
page_url: r,
|
|
2046
2104
|
timestamp: i,
|
|
@@ -2148,11 +2206,11 @@ class bs extends T {
|
|
|
2148
2206
|
emitEvent(e) {
|
|
2149
2207
|
if (this.emitter) {
|
|
2150
2208
|
const { _session_id: t, ...s } = e;
|
|
2151
|
-
this.emitter.emit(
|
|
2209
|
+
this.emitter.emit(U.EVENT, s);
|
|
2152
2210
|
}
|
|
2153
2211
|
}
|
|
2154
2212
|
emitEventsQueue(e) {
|
|
2155
|
-
this.emitter && this.emitter.emit(
|
|
2213
|
+
this.emitter && this.emitter.emit(U.QUEUE, e);
|
|
2156
2214
|
}
|
|
2157
2215
|
/**
|
|
2158
2216
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2227,13 +2285,13 @@ class bs extends T {
|
|
|
2227
2285
|
loadSessionCounts(e) {
|
|
2228
2286
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2229
2287
|
return this.getInitialCounts();
|
|
2230
|
-
const t = this.get("userId") || "anonymous", s =
|
|
2288
|
+
const t = this.get("userId") || "anonymous", s = Ve(t, e);
|
|
2231
2289
|
try {
|
|
2232
2290
|
const r = localStorage.getItem(s);
|
|
2233
2291
|
if (!r)
|
|
2234
2292
|
return this.getInitialCounts();
|
|
2235
2293
|
const i = JSON.parse(r);
|
|
2236
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2294
|
+
return i._timestamp && Date.now() - i._timestamp > He ? (a("debug", "Session counts expired, clearing", {
|
|
2237
2295
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2238
2296
|
}), localStorage.removeItem(s), this.getInitialCounts()) : typeof i.total == "number" && typeof i[d.CLICK] == "number" && typeof i[d.PAGE_VIEW] == "number" && typeof i[d.CUSTOM] == "number" && typeof i[d.SCROLL] == "number" ? {
|
|
2239
2297
|
total: i.total,
|
|
@@ -2277,7 +2335,7 @@ class bs extends T {
|
|
|
2277
2335
|
cleanupExpiredSessionCounts() {
|
|
2278
2336
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2279
2337
|
try {
|
|
2280
|
-
const e = localStorage.getItem(
|
|
2338
|
+
const e = localStorage.getItem(xe);
|
|
2281
2339
|
if (e) {
|
|
2282
2340
|
const i = Date.now() - parseInt(e, 10);
|
|
2283
2341
|
if (i < Be) {
|
|
@@ -2295,14 +2353,14 @@ class bs extends T {
|
|
|
2295
2353
|
const c = localStorage.getItem(o);
|
|
2296
2354
|
if (c) {
|
|
2297
2355
|
const l = JSON.parse(c);
|
|
2298
|
-
l._timestamp && Date.now() - l._timestamp >
|
|
2356
|
+
l._timestamp && Date.now() - l._timestamp > He && r.push(o);
|
|
2299
2357
|
}
|
|
2300
2358
|
} catch {
|
|
2301
2359
|
}
|
|
2302
2360
|
}
|
|
2303
2361
|
r.forEach((i) => {
|
|
2304
2362
|
localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2305
|
-
}), r.length > 0 && a("info", `Cleaned up ${r.length} expired session counts entries`), localStorage.setItem(
|
|
2363
|
+
}), r.length > 0 && a("info", `Cleaned up ${r.length} expired session counts entries`), localStorage.setItem(xe, Date.now().toString());
|
|
2306
2364
|
} catch (e) {
|
|
2307
2365
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2308
2366
|
}
|
|
@@ -2336,7 +2394,7 @@ class bs extends T {
|
|
|
2336
2394
|
* @internal
|
|
2337
2395
|
*/
|
|
2338
2396
|
saveSessionCounts(e) {
|
|
2339
|
-
const t = this.get("userId") || "anonymous", s =
|
|
2397
|
+
const t = this.get("userId") || "anonymous", s = Ve(t, e);
|
|
2340
2398
|
try {
|
|
2341
2399
|
const r = {
|
|
2342
2400
|
...this.sessionEventCounts,
|
|
@@ -2352,7 +2410,7 @@ class bs extends T {
|
|
|
2352
2410
|
}
|
|
2353
2411
|
}
|
|
2354
2412
|
}
|
|
2355
|
-
class
|
|
2413
|
+
class Ns {
|
|
2356
2414
|
/**
|
|
2357
2415
|
* Gets or creates a unique user ID.
|
|
2358
2416
|
*
|
|
@@ -2370,15 +2428,15 @@ class Ms {
|
|
|
2370
2428
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2371
2429
|
*/
|
|
2372
2430
|
static getId(e) {
|
|
2373
|
-
const t = e.getItem(
|
|
2431
|
+
const t = e.getItem(Se);
|
|
2374
2432
|
if (t)
|
|
2375
2433
|
return t;
|
|
2376
2434
|
const s = at();
|
|
2377
|
-
return e.setItem(
|
|
2435
|
+
return e.setItem(Se, s), s;
|
|
2378
2436
|
}
|
|
2379
2437
|
}
|
|
2380
|
-
const
|
|
2381
|
-
class
|
|
2438
|
+
const Os = /^\d{13}-[a-z0-9]{9}$/;
|
|
2439
|
+
class Ps extends T {
|
|
2382
2440
|
storageManager;
|
|
2383
2441
|
eventManager;
|
|
2384
2442
|
projectId;
|
|
@@ -2405,7 +2463,7 @@ class Rs extends T {
|
|
|
2405
2463
|
return;
|
|
2406
2464
|
}
|
|
2407
2465
|
const e = this.getProjectId();
|
|
2408
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2466
|
+
this.broadcastChannel = new BroadcastChannel(At(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2409
2467
|
const { action: s, sessionId: r, timestamp: i, projectId: o } = t.data ?? {};
|
|
2410
2468
|
if (o === e)
|
|
2411
2469
|
if (s === "session_start" && r && typeof i == "number" && i > Date.now() - 5e3) {
|
|
@@ -2430,7 +2488,7 @@ class Rs extends T {
|
|
|
2430
2488
|
const e = this.loadStoredSession();
|
|
2431
2489
|
if (!e)
|
|
2432
2490
|
return null;
|
|
2433
|
-
if (!
|
|
2491
|
+
if (!Os.test(e.id))
|
|
2434
2492
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2435
2493
|
data: { sessionId: e.id }
|
|
2436
2494
|
}), this.clearStoredSession(), null;
|
|
@@ -2476,7 +2534,7 @@ class Rs extends T {
|
|
|
2476
2534
|
this.storageManager.setItem(t, s), this.storageManager.setSessionItem(t, s);
|
|
2477
2535
|
}
|
|
2478
2536
|
getSessionStorageKey() {
|
|
2479
|
-
return
|
|
2537
|
+
return wt(this.getProjectId());
|
|
2480
2538
|
}
|
|
2481
2539
|
getProjectId() {
|
|
2482
2540
|
return this.projectId;
|
|
@@ -2549,9 +2607,9 @@ class Rs extends T {
|
|
|
2549
2607
|
let s, r, i;
|
|
2550
2608
|
if (e) {
|
|
2551
2609
|
const o = this.loadStoredSession();
|
|
2552
|
-
s = o?.referrer ??
|
|
2610
|
+
s = o?.referrer ?? he(), r = o?.utm ?? fe(), i = o?.clickIds ?? de();
|
|
2553
2611
|
} else
|
|
2554
|
-
s =
|
|
2612
|
+
s = he(), r = fe(), i = de();
|
|
2555
2613
|
a("debug", "Session tracking initialized", {
|
|
2556
2614
|
data: {
|
|
2557
2615
|
sessionId: t,
|
|
@@ -2623,7 +2681,7 @@ class Rs extends T {
|
|
|
2623
2681
|
*/
|
|
2624
2682
|
renewSession() {
|
|
2625
2683
|
this.needsRenewal = !1;
|
|
2626
|
-
const e = this.generateSessionId(), t =
|
|
2684
|
+
const e = this.generateSessionId(), t = he(), s = fe(), r = de();
|
|
2627
2685
|
a("debug", "Renewing session after timeout", {
|
|
2628
2686
|
data: { newSessionId: e }
|
|
2629
2687
|
}), 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({
|
|
@@ -2753,7 +2811,7 @@ class Rs extends T {
|
|
|
2753
2811
|
this.prerenderActivationHandler && (document.removeEventListener("prerenderingchange", this.prerenderActivationHandler), this.prerenderActivationHandler = null);
|
|
2754
2812
|
}
|
|
2755
2813
|
}
|
|
2756
|
-
class
|
|
2814
|
+
class ks extends T {
|
|
2757
2815
|
eventManager;
|
|
2758
2816
|
storageManager;
|
|
2759
2817
|
sessionManager = null;
|
|
@@ -2788,7 +2846,7 @@ class Ns extends T {
|
|
|
2788
2846
|
}
|
|
2789
2847
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
2790
2848
|
try {
|
|
2791
|
-
this.sessionManager = new
|
|
2849
|
+
this.sessionManager = new Ps(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
2792
2850
|
} catch (s) {
|
|
2793
2851
|
if (this.sessionManager) {
|
|
2794
2852
|
try {
|
|
@@ -2841,7 +2899,7 @@ class Ns extends T {
|
|
|
2841
2899
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
2842
2900
|
}
|
|
2843
2901
|
}
|
|
2844
|
-
class
|
|
2902
|
+
class Ds extends T {
|
|
2845
2903
|
eventManager;
|
|
2846
2904
|
onTrack;
|
|
2847
2905
|
originalPushState;
|
|
@@ -2881,7 +2939,7 @@ class Os extends T {
|
|
|
2881
2939
|
};
|
|
2882
2940
|
}
|
|
2883
2941
|
trackCurrentPage = () => {
|
|
2884
|
-
const e = window.location.href, t =
|
|
2942
|
+
const e = window.location.href, t = ye(e, this.get("config").sensitiveQueryParams);
|
|
2885
2943
|
if (this.get("pageUrl") === t)
|
|
2886
2944
|
return;
|
|
2887
2945
|
const s = Date.now(), r = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -2899,7 +2957,7 @@ class Os extends T {
|
|
|
2899
2957
|
}), this.get("config").flushOnSpaNavigation === !0 && this.eventManager.flushImmediately();
|
|
2900
2958
|
};
|
|
2901
2959
|
trackInitialPageView() {
|
|
2902
|
-
const e =
|
|
2960
|
+
const e = ye(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
2903
2961
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
2904
2962
|
type: d.PAGE_VIEW,
|
|
2905
2963
|
page_url: e,
|
|
@@ -2915,7 +2973,7 @@ class Os extends T {
|
|
|
2915
2973
|
};
|
|
2916
2974
|
}
|
|
2917
2975
|
}
|
|
2918
|
-
class
|
|
2976
|
+
class Us extends T {
|
|
2919
2977
|
eventManager;
|
|
2920
2978
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
2921
2979
|
clickHandler;
|
|
@@ -2983,7 +3041,7 @@ class Ps extends T {
|
|
|
2983
3041
|
this.clickHandler && (window.removeEventListener("click", this.clickHandler, !0), this.clickHandler = void 0), this.lastClickTimes.clear(), this.lastPruneTime = 0;
|
|
2984
3042
|
}
|
|
2985
3043
|
shouldIgnoreElement(e) {
|
|
2986
|
-
return e.hasAttribute(`${
|
|
3044
|
+
return e.hasAttribute(`${b}-ignore`) ? !0 : e.closest(`[${b}-ignore]`) !== null;
|
|
2987
3045
|
}
|
|
2988
3046
|
/**
|
|
2989
3047
|
* Checks per-element click throttling to prevent double-clicks and rapid spam
|
|
@@ -3034,8 +3092,8 @@ class Ps extends T {
|
|
|
3034
3092
|
const t = e.getAttribute("data-testid");
|
|
3035
3093
|
if (t)
|
|
3036
3094
|
return `[data-testid="${t}"]`;
|
|
3037
|
-
const s = e.getAttribute(`${
|
|
3038
|
-
return s ? `[${
|
|
3095
|
+
const s = e.getAttribute(`${b}-name`);
|
|
3096
|
+
return s ? `[${b}-name="${s}"]` : this.getElementPath(e);
|
|
3039
3097
|
}
|
|
3040
3098
|
/**
|
|
3041
3099
|
* Generates a DOM path for an element (e.g., "body>div>button")
|
|
@@ -3054,7 +3112,7 @@ class Ps extends T {
|
|
|
3054
3112
|
return t.join(">") || "unknown";
|
|
3055
3113
|
}
|
|
3056
3114
|
findTrackingElement(e) {
|
|
3057
|
-
return e.hasAttribute(`${
|
|
3115
|
+
return e.hasAttribute(`${b}-name`) ? e : e.closest(`[${b}-name]`);
|
|
3058
3116
|
}
|
|
3059
3117
|
getRelevantClickElement(e) {
|
|
3060
3118
|
for (const t of vt)
|
|
@@ -3075,7 +3133,7 @@ class Ps extends T {
|
|
|
3075
3133
|
return typeof t != "number" || typeof s != "number" || !Number.isFinite(t) || !Number.isFinite(s) || t === 0 && s === 0 && !e.isTrusted ? null : { x: t, y: s };
|
|
3076
3134
|
}
|
|
3077
3135
|
extractTrackingData(e) {
|
|
3078
|
-
const t = e.getAttribute(`${
|
|
3136
|
+
const t = e.getAttribute(`${b}-name`), s = e.getAttribute(`${b}-value`);
|
|
3079
3137
|
if (t)
|
|
3080
3138
|
return {
|
|
3081
3139
|
element: e,
|
|
@@ -3100,7 +3158,7 @@ class Ps extends T {
|
|
|
3100
3158
|
if (!s && !r)
|
|
3101
3159
|
return "";
|
|
3102
3160
|
let i = "";
|
|
3103
|
-
return s && s.length <= 255 ? i = s : r.length <= 255 ? i = r : i = r.slice(0, 252) + "...",
|
|
3161
|
+
return s && s.length <= 255 ? i = s : r.length <= 255 ? i = r : i = r.slice(0, 252) + "...", Y(i);
|
|
3104
3162
|
}
|
|
3105
3163
|
createCustomEventData(e) {
|
|
3106
3164
|
return {
|
|
@@ -3109,7 +3167,7 @@ class Ps extends T {
|
|
|
3109
3167
|
};
|
|
3110
3168
|
}
|
|
3111
3169
|
}
|
|
3112
|
-
class
|
|
3170
|
+
class Fs extends T {
|
|
3113
3171
|
eventManager;
|
|
3114
3172
|
containers = [];
|
|
3115
3173
|
limitWarningLogged = !1;
|
|
@@ -3235,7 +3293,7 @@ class ks extends T {
|
|
|
3235
3293
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
3236
3294
|
}
|
|
3237
3295
|
getScrollDirection(e, t) {
|
|
3238
|
-
return e > t ?
|
|
3296
|
+
return e > t ? Ee.DOWN : Ee.UP;
|
|
3239
3297
|
}
|
|
3240
3298
|
calculateScrollDepth(e, t, s) {
|
|
3241
3299
|
if (t <= s)
|
|
@@ -3264,8 +3322,8 @@ class ks extends T {
|
|
|
3264
3322
|
return s && r;
|
|
3265
3323
|
}
|
|
3266
3324
|
}
|
|
3267
|
-
const
|
|
3268
|
-
class
|
|
3325
|
+
const Vs = "tracelog_session_id", Hs = "tracelog_user_id";
|
|
3326
|
+
class xs extends T {
|
|
3269
3327
|
visibilityHandler = null;
|
|
3270
3328
|
pageshowHandler = null;
|
|
3271
3329
|
lastSyncedKey = null;
|
|
@@ -3286,8 +3344,8 @@ class Fs extends T {
|
|
|
3286
3344
|
r !== this.lastSyncedKey && (this.lastSyncedKey = r, this.postCartUpdate(e, s));
|
|
3287
3345
|
}
|
|
3288
3346
|
postCartUpdate(e, t) {
|
|
3289
|
-
const s = { [
|
|
3290
|
-
t.length > 0 && (s[
|
|
3347
|
+
const s = { [Vs]: e };
|
|
3348
|
+
t.length > 0 && (s[Hs] = t);
|
|
3291
3349
|
try {
|
|
3292
3350
|
fetch("/cart/update.js", {
|
|
3293
3351
|
method: "POST",
|
|
@@ -3324,7 +3382,7 @@ class Fs extends T {
|
|
|
3324
3382
|
this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.pageshowHandler && (window.removeEventListener("pageshow", this.pageshowHandler), this.pageshowHandler = null);
|
|
3325
3383
|
}
|
|
3326
3384
|
}
|
|
3327
|
-
class
|
|
3385
|
+
class Bs {
|
|
3328
3386
|
storage;
|
|
3329
3387
|
sessionStorageRef;
|
|
3330
3388
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -3437,7 +3495,7 @@ class Vs {
|
|
|
3437
3495
|
this.fallbackSessionStorage.delete(e);
|
|
3438
3496
|
}
|
|
3439
3497
|
}
|
|
3440
|
-
class
|
|
3498
|
+
class $s extends T {
|
|
3441
3499
|
eventManager;
|
|
3442
3500
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
3443
3501
|
navigationHistory = [];
|
|
@@ -3447,7 +3505,7 @@ class Hs extends T {
|
|
|
3447
3505
|
navigationCounter = 0;
|
|
3448
3506
|
// Counter for handling simultaneous navigations edge case
|
|
3449
3507
|
constructor(e) {
|
|
3450
|
-
super(), this.eventManager = e, this.vitalThresholds = Qe(
|
|
3508
|
+
super(), this.eventManager = e, this.vitalThresholds = Qe(_e);
|
|
3451
3509
|
}
|
|
3452
3510
|
/**
|
|
3453
3511
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -3463,7 +3521,7 @@ class Hs extends T {
|
|
|
3463
3521
|
* @returns Promise that resolves when tracking is initialized
|
|
3464
3522
|
*/
|
|
3465
3523
|
async startTracking() {
|
|
3466
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
3524
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? _e;
|
|
3467
3525
|
this.vitalThresholds = Qe(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals();
|
|
3468
3526
|
}
|
|
3469
3527
|
/**
|
|
@@ -3534,7 +3592,7 @@ class Hs extends T {
|
|
|
3534
3592
|
}
|
|
3535
3593
|
async initWebVitals() {
|
|
3536
3594
|
try {
|
|
3537
|
-
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() =>
|
|
3595
|
+
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() => mn), o = (c) => (l) => {
|
|
3538
3596
|
const u = Number(l.value.toFixed(2));
|
|
3539
3597
|
this.sendVital({ type: c, value: u });
|
|
3540
3598
|
};
|
|
@@ -3564,7 +3622,7 @@ class Hs extends T {
|
|
|
3564
3622
|
return;
|
|
3565
3623
|
if (s)
|
|
3566
3624
|
s.add(e.type);
|
|
3567
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
3625
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > qt) {
|
|
3568
3626
|
const i = this.navigationHistory.shift();
|
|
3569
3627
|
i && this.reportedByNav.delete(i);
|
|
3570
3628
|
}
|
|
@@ -3655,7 +3713,7 @@ class Hs extends T {
|
|
|
3655
3713
|
return !(typeof s == "number" && t <= s);
|
|
3656
3714
|
}
|
|
3657
3715
|
}
|
|
3658
|
-
class
|
|
3716
|
+
class se extends T {
|
|
3659
3717
|
eventManager;
|
|
3660
3718
|
emitter;
|
|
3661
3719
|
recentErrors = /* @__PURE__ */ new Map();
|
|
@@ -3682,7 +3740,7 @@ class ne extends T {
|
|
|
3682
3740
|
this.resetPageviewCounter();
|
|
3683
3741
|
}, window.addEventListener("pagehide", this.pagehideHandler, { passive: !0 }), this.emitter && (this.pageviewResetListener = (e) => {
|
|
3684
3742
|
(e.type === d.SESSION_START || e.type === d.PAGE_VIEW) && this.resetPageviewCounter();
|
|
3685
|
-
}, this.emitter.on(
|
|
3743
|
+
}, this.emitter.on(U.EVENT, this.pageviewResetListener));
|
|
3686
3744
|
}
|
|
3687
3745
|
/**
|
|
3688
3746
|
* Stops tracking errors and cleans up resources.
|
|
@@ -3693,7 +3751,7 @@ class ne extends T {
|
|
|
3693
3751
|
* - Resets burst detection counters
|
|
3694
3752
|
*/
|
|
3695
3753
|
stopTracking() {
|
|
3696
|
-
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(
|
|
3754
|
+
window.removeEventListener("error", this.handleError), window.removeEventListener("unhandledrejection", this.handleRejection), this.pagehideHandler && (window.removeEventListener("pagehide", this.pagehideHandler), this.pagehideHandler = null), this.emitter && this.pageviewResetListener && (this.emitter.off(U.EVENT, this.pageviewResetListener), this.pageviewResetListener = null), this.recentErrors.clear(), this.pageviewSignatureCounts.clear(), this.errorBurstCounter = 0, this.burstWindowStart = 0, this.burstBackoffUntil = 0;
|
|
3697
3755
|
}
|
|
3698
3756
|
/**
|
|
3699
3757
|
* Clears the per-pageview signature counter.
|
|
@@ -3712,7 +3770,7 @@ class ne extends T {
|
|
|
3712
3770
|
const e = Date.now();
|
|
3713
3771
|
if (e < this.burstBackoffUntil)
|
|
3714
3772
|
return !1;
|
|
3715
|
-
if (e - this.burstWindowStart > $t && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter >
|
|
3773
|
+
if (e - this.burstWindowStart > $t && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > Xt)
|
|
3716
3774
|
return this.burstBackoffUntil = e + Ke, a("debug", "Error burst detected - entering cooldown", {
|
|
3717
3775
|
data: {
|
|
3718
3776
|
errorsInWindow: this.errorBurstCounter,
|
|
@@ -3729,8 +3787,8 @@ class ne extends T {
|
|
|
3729
3787
|
* later signature that recycles the same map key after a counter reset.
|
|
3730
3788
|
*/
|
|
3731
3789
|
shouldThrottleBySignature(e) {
|
|
3732
|
-
const t =
|
|
3733
|
-
if (s >=
|
|
3790
|
+
const t = bs(e), s = this.pageviewSignatureCounts.get(t) ?? 0;
|
|
3791
|
+
if (s >= jt)
|
|
3734
3792
|
return a("debug", "Error throttled (pageview cap)", {
|
|
3735
3793
|
data: { signature: t, count: s }
|
|
3736
3794
|
}), !0;
|
|
@@ -3741,7 +3799,7 @@ class ne extends T {
|
|
|
3741
3799
|
if (!this.shouldSample())
|
|
3742
3800
|
return;
|
|
3743
3801
|
const t = this.sanitize(e.message || "Unknown error");
|
|
3744
|
-
if (this.shouldSuppressError(
|
|
3802
|
+
if (this.shouldSuppressError(V.JS_ERROR, t) || this.shouldThrottleBySignature({
|
|
3745
3803
|
message: t,
|
|
3746
3804
|
filename: e.filename,
|
|
3747
3805
|
line: e.lineno,
|
|
@@ -3756,7 +3814,7 @@ class ne extends T {
|
|
|
3756
3814
|
this.eventManager.track({
|
|
3757
3815
|
type: d.ERROR,
|
|
3758
3816
|
error_data: {
|
|
3759
|
-
type:
|
|
3817
|
+
type: V.JS_ERROR,
|
|
3760
3818
|
message: t,
|
|
3761
3819
|
...r !== void 0 && { name: r },
|
|
3762
3820
|
...e.filename !== "" && { filename: e.filename },
|
|
@@ -3770,13 +3828,13 @@ class ne extends T {
|
|
|
3770
3828
|
if (!this.shouldSample())
|
|
3771
3829
|
return;
|
|
3772
3830
|
const t = this.extractRejectionMessage(e.reason), s = this.sanitize(t);
|
|
3773
|
-
if (this.shouldSuppressError(
|
|
3831
|
+
if (this.shouldSuppressError(V.PROMISE_REJECTION, s) || this.shouldThrottleBySignature({ message: s }))
|
|
3774
3832
|
return;
|
|
3775
3833
|
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;
|
|
3776
3834
|
this.eventManager.track({
|
|
3777
3835
|
type: d.ERROR,
|
|
3778
3836
|
error_data: {
|
|
3779
|
-
type:
|
|
3837
|
+
type: V.PROMISE_REJECTION,
|
|
3780
3838
|
message: s,
|
|
3781
3839
|
...i !== void 0 && { name: i },
|
|
3782
3840
|
...r !== void 0 && { stack: r }
|
|
@@ -3797,41 +3855,41 @@ class ne extends T {
|
|
|
3797
3855
|
}
|
|
3798
3856
|
}
|
|
3799
3857
|
sanitize(e) {
|
|
3800
|
-
const t = e.length >
|
|
3801
|
-
return
|
|
3858
|
+
const t = e.length > je ? e.slice(0, je) + "..." : e;
|
|
3859
|
+
return Y(t);
|
|
3802
3860
|
}
|
|
3803
3861
|
shouldSuppressError(e, t) {
|
|
3804
3862
|
const s = Date.now(), r = `${e}:${t}`, i = this.recentErrors.get(r);
|
|
3805
|
-
return i !== void 0 && s - i <
|
|
3863
|
+
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));
|
|
3806
3864
|
}
|
|
3807
3865
|
static TRUNCATION_SUFFIX = `
|
|
3808
3866
|
...truncated`;
|
|
3809
3867
|
truncateStack(e) {
|
|
3810
|
-
if (e.length <=
|
|
3811
|
-
const t =
|
|
3812
|
-
return
|
|
3868
|
+
if (e.length <= Ge) return Y(e);
|
|
3869
|
+
const t = Ge - se.TRUNCATION_SUFFIX.length, s = e.slice(0, t) + se.TRUNCATION_SUFFIX;
|
|
3870
|
+
return Y(s);
|
|
3813
3871
|
}
|
|
3814
3872
|
pruneOldErrors() {
|
|
3815
3873
|
const e = Date.now();
|
|
3816
3874
|
for (const [r, i] of this.recentErrors.entries())
|
|
3817
|
-
e - i >
|
|
3818
|
-
if (this.recentErrors.size <=
|
|
3875
|
+
e - i > We && this.recentErrors.delete(r);
|
|
3876
|
+
if (this.recentErrors.size <= Q)
|
|
3819
3877
|
return;
|
|
3820
|
-
const t = Array.from(this.recentErrors.entries()).sort((r, i) => r[1] - i[1]), s = this.recentErrors.size -
|
|
3878
|
+
const t = Array.from(this.recentErrors.entries()).sort((r, i) => r[1] - i[1]), s = this.recentErrors.size - Q;
|
|
3821
3879
|
for (let r = 0; r < s; r += 1) {
|
|
3822
3880
|
const i = t[r];
|
|
3823
3881
|
i && this.recentErrors.delete(i[0]);
|
|
3824
3882
|
}
|
|
3825
3883
|
}
|
|
3826
3884
|
}
|
|
3827
|
-
class
|
|
3885
|
+
class Xs extends T {
|
|
3828
3886
|
isInitialized = !1;
|
|
3829
3887
|
suppressNextScrollTimer = null;
|
|
3830
3888
|
pageUnloadHandler = null;
|
|
3831
3889
|
pageShowHandler = null;
|
|
3832
3890
|
visibilityFlushHandler = null;
|
|
3833
3891
|
prerenderActivationHandler = null;
|
|
3834
|
-
emitter = new
|
|
3892
|
+
emitter = new Es();
|
|
3835
3893
|
managers = {};
|
|
3836
3894
|
handlers = {};
|
|
3837
3895
|
integrationInstances = {};
|
|
@@ -3846,9 +3904,9 @@ class xs extends T {
|
|
|
3846
3904
|
async init(e = {}) {
|
|
3847
3905
|
if (this.isInitialized)
|
|
3848
3906
|
return { sessionId: this.get("sessionId") ?? "" };
|
|
3849
|
-
this.managers.storage = new
|
|
3907
|
+
this.managers.storage = new Bs();
|
|
3850
3908
|
try {
|
|
3851
|
-
return this.setupState(e), this.managers.event = new
|
|
3909
|
+
return this.setupState(e), this.managers.event = new Rs(this.managers.storage, this.emitter), this.loadPersistedIdentity(), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((t) => {
|
|
3852
3910
|
a("warn", "Failed to recover persisted events", { error: t });
|
|
3853
3911
|
}), this.isInitialized = !0, { sessionId: this.get("sessionId") ?? "" };
|
|
3854
3912
|
} catch (t) {
|
|
@@ -3869,9 +3927,9 @@ class xs extends T {
|
|
|
3869
3927
|
}
|
|
3870
3928
|
let r = t;
|
|
3871
3929
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
3872
|
-
const { valid: i, error: o, sanitizedMetadata: c } =
|
|
3930
|
+
const { valid: i, error: o, sanitizedMetadata: c } = Ss(e, r);
|
|
3873
3931
|
if (!i) {
|
|
3874
|
-
if (this.get("mode") ===
|
|
3932
|
+
if (this.get("mode") === ee.QA)
|
|
3875
3933
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${o}`);
|
|
3876
3934
|
a("warn", `Custom event "${e}" dropped: ${o}`);
|
|
3877
3935
|
return;
|
|
@@ -3908,14 +3966,14 @@ class xs extends T {
|
|
|
3908
3966
|
}
|
|
3909
3967
|
setupState(e = {}) {
|
|
3910
3968
|
this.set("config", e);
|
|
3911
|
-
const t =
|
|
3969
|
+
const t = Ns.getId(this.managers.storage);
|
|
3912
3970
|
this.set("userId", t);
|
|
3913
|
-
const s =
|
|
3971
|
+
const s = cs(e);
|
|
3914
3972
|
this.set("collectApiUrls", s);
|
|
3915
|
-
const r =
|
|
3973
|
+
const r = xt();
|
|
3916
3974
|
this.set("device", r);
|
|
3917
|
-
const i =
|
|
3918
|
-
this.set("pageUrl", i),
|
|
3975
|
+
const i = ye(window.location.href, e.sensitiveQueryParams);
|
|
3976
|
+
this.set("pageUrl", i), ss() && this.set("mode", ee.QA);
|
|
3919
3977
|
}
|
|
3920
3978
|
/**
|
|
3921
3979
|
* @internal Used by api.ts for configuration access
|
|
@@ -3970,7 +4028,7 @@ class xs extends T {
|
|
|
3970
4028
|
a("warn", "identify() userId exceeds 256 characters", { data: { length: e.trim().length } });
|
|
3971
4029
|
return;
|
|
3972
4030
|
}
|
|
3973
|
-
const s = e.trim(), r =
|
|
4031
|
+
const s = e.trim(), r = Ae(t), i = {
|
|
3974
4032
|
userId: s,
|
|
3975
4033
|
...r ? { traits: r } : {}
|
|
3976
4034
|
};
|
|
@@ -3994,7 +4052,7 @@ class xs extends T {
|
|
|
3994
4052
|
async resetIdentity() {
|
|
3995
4053
|
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();
|
|
3996
4054
|
const e = at();
|
|
3997
|
-
this.managers.storage.setItem(
|
|
4055
|
+
this.managers.storage.setItem(Se, e), this.set("userId", e), this.set("hasStartSession", !1), this.set("sessionId", null), this.handlers.session?.stopTracking(), this.handlers.session?.startTracking(), a("debug", "Identity reset, new UUID generated");
|
|
3998
4056
|
}
|
|
3999
4057
|
/**
|
|
4000
4058
|
* Returns the project ID used for identity storage scoping.
|
|
@@ -4007,7 +4065,7 @@ class xs extends T {
|
|
|
4007
4065
|
*/
|
|
4008
4066
|
persistIdentity(e) {
|
|
4009
4067
|
try {
|
|
4010
|
-
const t = this.getProjectId(), s =
|
|
4068
|
+
const t = this.getProjectId(), s = ue(t);
|
|
4011
4069
|
this.managers.storage.setItem(s, JSON.stringify(e));
|
|
4012
4070
|
} catch {
|
|
4013
4071
|
a("debug", "Failed to persist identity to localStorage");
|
|
@@ -4018,12 +4076,12 @@ class xs extends T {
|
|
|
4018
4076
|
* Also migrates pending identity (set before init) to the project-scoped key.
|
|
4019
4077
|
*/
|
|
4020
4078
|
loadPersistedIdentity() {
|
|
4021
|
-
const e = this.managers.storage, t = this.getProjectId(), s =
|
|
4079
|
+
const e = this.managers.storage, t = this.getProjectId(), s = ue(t);
|
|
4022
4080
|
try {
|
|
4023
|
-
const r = e.getItem(
|
|
4081
|
+
const r = e.getItem(P);
|
|
4024
4082
|
if (r) {
|
|
4025
4083
|
const i = JSON.parse(r);
|
|
4026
|
-
if (e.removeItem(
|
|
4084
|
+
if (e.removeItem(P), !this.isValidIdentityData(i)) {
|
|
4027
4085
|
a("debug", "Invalid pending identity in localStorage, discarded");
|
|
4028
4086
|
return;
|
|
4029
4087
|
}
|
|
@@ -4032,7 +4090,7 @@ class xs extends T {
|
|
|
4032
4090
|
return;
|
|
4033
4091
|
}
|
|
4034
4092
|
} catch {
|
|
4035
|
-
e.removeItem(
|
|
4093
|
+
e.removeItem(P);
|
|
4036
4094
|
}
|
|
4037
4095
|
try {
|
|
4038
4096
|
const r = e.getItem(s);
|
|
@@ -4066,7 +4124,7 @@ class xs extends T {
|
|
|
4066
4124
|
* localStorage values.
|
|
4067
4125
|
*/
|
|
4068
4126
|
normalizePersistedIdentity(e) {
|
|
4069
|
-
const t =
|
|
4127
|
+
const t = Ae(e.traits);
|
|
4070
4128
|
return {
|
|
4071
4129
|
userId: e.userId.trim(),
|
|
4072
4130
|
...t ? { traits: t } : {}
|
|
@@ -4078,7 +4136,7 @@ class xs extends T {
|
|
|
4078
4136
|
clearPersistedIdentity() {
|
|
4079
4137
|
try {
|
|
4080
4138
|
const e = this.managers.storage, t = this.getProjectId();
|
|
4081
|
-
e.removeItem(
|
|
4139
|
+
e.removeItem(ue(t)), e.removeItem(P);
|
|
4082
4140
|
} catch {
|
|
4083
4141
|
a("debug", "Failed to clear persisted identity");
|
|
4084
4142
|
}
|
|
@@ -4096,7 +4154,7 @@ class xs extends T {
|
|
|
4096
4154
|
}
|
|
4097
4155
|
initializeHandlers() {
|
|
4098
4156
|
const e = this.get("config");
|
|
4099
|
-
this.handlers.session = new
|
|
4157
|
+
this.handlers.session = new ks(
|
|
4100
4158
|
this.managers.storage,
|
|
4101
4159
|
this.managers.event
|
|
4102
4160
|
), this.handlers.session.startTracking();
|
|
@@ -4105,13 +4163,13 @@ class xs extends T {
|
|
|
4105
4163
|
this.set("suppressNextScroll", !1);
|
|
4106
4164
|
}, 500);
|
|
4107
4165
|
};
|
|
4108
|
-
this.handlers.pageView = new
|
|
4166
|
+
this.handlers.pageView = new Ds(this.managers.event, t), this.handlers.click = new Us(this.managers.event), this.handlers.scroll = new Fs(this.managers.event), this.handlers.performance = new $s(this.managers.event), this.handlers.error = new se(this.managers.event, this.emitter);
|
|
4109
4167
|
const s = () => {
|
|
4110
4168
|
if (this.handlers.pageView?.startTracking(), this.handlers.click?.startTracking(), this.handlers.scroll?.startTracking(), this.handlers.performance?.startTracking().catch((r) => {
|
|
4111
4169
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4112
4170
|
}), this.handlers.error?.startTracking(), e.integrations?.tracelog?.shopify) {
|
|
4113
|
-
const r = new
|
|
4114
|
-
r.activate(), this.integrationInstances.shopifyCartLinker = r, this.emitter.on(
|
|
4171
|
+
const r = new xs();
|
|
4172
|
+
r.activate(), this.integrationInstances.shopifyCartLinker = r, this.emitter.on(U.EVENT, (i) => {
|
|
4115
4173
|
i.type === d.SESSION_START && r.onSessionChange();
|
|
4116
4174
|
});
|
|
4117
4175
|
}
|
|
@@ -4121,15 +4179,15 @@ class xs extends T {
|
|
|
4121
4179
|
}, document.addEventListener("prerenderingchange", this.prerenderActivationHandler, { once: !0 })) : s();
|
|
4122
4180
|
}
|
|
4123
4181
|
}
|
|
4124
|
-
const
|
|
4125
|
-
let f = null,
|
|
4126
|
-
const
|
|
4182
|
+
const N = [];
|
|
4183
|
+
let f = null, D = !1, A = !1, R = null;
|
|
4184
|
+
const js = async (n) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (A = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : f ? { sessionId: f.getSessionId() ?? "" } : (D && R || (D = !0, R = (async () => {
|
|
4127
4185
|
try {
|
|
4128
|
-
const e =
|
|
4186
|
+
const e = fs(n ?? {}), t = new Xs();
|
|
4129
4187
|
try {
|
|
4130
|
-
|
|
4188
|
+
N.forEach(({ event: o, callback: c }) => {
|
|
4131
4189
|
t.on(o, c);
|
|
4132
|
-
}),
|
|
4190
|
+
}), N.length = 0;
|
|
4133
4191
|
const s = t.init(e), r = new Promise((o, c) => {
|
|
4134
4192
|
setTimeout(() => {
|
|
4135
4193
|
c(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
@@ -4147,9 +4205,9 @@ const $s = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4147
4205
|
} catch (e) {
|
|
4148
4206
|
throw f = null, e;
|
|
4149
4207
|
} finally {
|
|
4150
|
-
|
|
4208
|
+
D = !1, R = null;
|
|
4151
4209
|
}
|
|
4152
|
-
})()),
|
|
4210
|
+
})()), R)), Gs = (n, e, t) => {
|
|
4153
4211
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4154
4212
|
if (!f)
|
|
4155
4213
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4157,24 +4215,24 @@ const $s = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4157
4215
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4158
4216
|
f.sendCustomEvent(n, e, t);
|
|
4159
4217
|
}
|
|
4160
|
-
},
|
|
4218
|
+
}, Ws = (n, e) => {
|
|
4161
4219
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4162
|
-
if (!f ||
|
|
4163
|
-
|
|
4220
|
+
if (!f || D) {
|
|
4221
|
+
N.push({ event: n, callback: e });
|
|
4164
4222
|
return;
|
|
4165
4223
|
}
|
|
4166
4224
|
f.on(n, e);
|
|
4167
4225
|
}
|
|
4168
|
-
},
|
|
4226
|
+
}, Ks = (n, e) => {
|
|
4169
4227
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4170
4228
|
if (!f) {
|
|
4171
|
-
const t =
|
|
4172
|
-
t !== -1 &&
|
|
4229
|
+
const t = N.findIndex((s) => s.event === n && s.callback === e);
|
|
4230
|
+
t !== -1 && N.splice(t, 1);
|
|
4173
4231
|
return;
|
|
4174
4232
|
}
|
|
4175
4233
|
f.off(n, e);
|
|
4176
4234
|
}
|
|
4177
|
-
},
|
|
4235
|
+
}, zs = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, Qs = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getSessionId(), Ys = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getUserId(), qs = () => {
|
|
4178
4236
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4179
4237
|
if (A)
|
|
4180
4238
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -4184,12 +4242,12 @@ const $s = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4184
4242
|
}
|
|
4185
4243
|
A = !0;
|
|
4186
4244
|
try {
|
|
4187
|
-
f.destroy(), f = null,
|
|
4245
|
+
f.destroy(), f = null, D = !1, R = null, N.length = 0, A = !1;
|
|
4188
4246
|
} catch (n) {
|
|
4189
|
-
f = null,
|
|
4247
|
+
f = null, D = !1, R = null, N.length = 0, A = !1, a("warn", "Error during destroy, forced cleanup completed", { error: n });
|
|
4190
4248
|
}
|
|
4191
4249
|
}
|
|
4192
|
-
},
|
|
4250
|
+
}, Js = (n, e) => {
|
|
4193
4251
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4194
4252
|
if (!n || typeof n != "string" || n.trim().length === 0) {
|
|
4195
4253
|
a("warn", "identify() called with invalid userId");
|
|
@@ -4208,20 +4266,20 @@ const $s = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4208
4266
|
return;
|
|
4209
4267
|
}
|
|
4210
4268
|
try {
|
|
4211
|
-
const t =
|
|
4269
|
+
const t = Ae(e), s = {
|
|
4212
4270
|
userId: n.trim(),
|
|
4213
4271
|
...t ? { traits: t } : {}
|
|
4214
4272
|
};
|
|
4215
|
-
localStorage.setItem(
|
|
4273
|
+
localStorage.setItem(P, JSON.stringify(s)), a("debug", "Identity persisted pre-init (will be applied on init)");
|
|
4216
4274
|
} catch {
|
|
4217
4275
|
a("debug", "Failed to persist pre-init identity");
|
|
4218
4276
|
}
|
|
4219
4277
|
}
|
|
4220
|
-
},
|
|
4278
|
+
}, Zs = async () => {
|
|
4221
4279
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4222
4280
|
if (!f) {
|
|
4223
4281
|
try {
|
|
4224
|
-
localStorage.removeItem(
|
|
4282
|
+
localStorage.removeItem(P);
|
|
4225
4283
|
} catch {
|
|
4226
4284
|
}
|
|
4227
4285
|
return;
|
|
@@ -4230,32 +4288,32 @@ const $s = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4230
4288
|
throw new Error("[TraceLog] Cannot reset identity while TraceLog is being destroyed");
|
|
4231
4289
|
await f.resetIdentity();
|
|
4232
4290
|
}
|
|
4233
|
-
},
|
|
4234
|
-
init:
|
|
4235
|
-
event:
|
|
4236
|
-
on:
|
|
4237
|
-
off:
|
|
4238
|
-
isInitialized:
|
|
4239
|
-
getSessionId:
|
|
4240
|
-
getUserId:
|
|
4241
|
-
destroy:
|
|
4242
|
-
identify:
|
|
4243
|
-
resetIdentity:
|
|
4291
|
+
}, Ln = {
|
|
4292
|
+
init: js,
|
|
4293
|
+
event: Gs,
|
|
4294
|
+
on: Ws,
|
|
4295
|
+
off: Ks,
|
|
4296
|
+
isInitialized: zs,
|
|
4297
|
+
getSessionId: Qs,
|
|
4298
|
+
getUserId: Ys,
|
|
4299
|
+
destroy: qs,
|
|
4300
|
+
identify: Js,
|
|
4301
|
+
resetIdentity: Zs
|
|
4244
4302
|
};
|
|
4245
|
-
var be,
|
|
4303
|
+
var be, L, x, ct, ne, lt = -1, O = function(n) {
|
|
4246
4304
|
addEventListener("pageshow", (function(e) {
|
|
4247
4305
|
e.persisted && (lt = e.timeStamp, n(e));
|
|
4248
4306
|
}), !0);
|
|
4249
|
-
},
|
|
4307
|
+
}, Pe = function() {
|
|
4250
4308
|
var n = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4251
4309
|
if (n && n.responseStart > 0 && n.responseStart < performance.now()) return n;
|
|
4252
|
-
},
|
|
4253
|
-
var n =
|
|
4310
|
+
}, ie = function() {
|
|
4311
|
+
var n = Pe();
|
|
4254
4312
|
return n && n.activationStart || 0;
|
|
4255
4313
|
}, E = function(n, e) {
|
|
4256
|
-
var t =
|
|
4257
|
-
return lt >= 0 ? s = "back-forward-cache" : t && (document.prerendering ||
|
|
4258
|
-
},
|
|
4314
|
+
var t = Pe(), s = "navigate";
|
|
4315
|
+
return lt >= 0 ? s = "back-forward-cache" : t && (document.prerendering || ie() > 0 ? s = "prerender" : document.wasDiscarded ? s = "restore" : t.type && (s = t.type.replace(/_/g, "-"))), { name: n, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: s };
|
|
4316
|
+
}, F = function(n, e, t) {
|
|
4259
4317
|
try {
|
|
4260
4318
|
if (PerformanceObserver.supportedEntryTypes.includes(n)) {
|
|
4261
4319
|
var s = new PerformanceObserver((function(r) {
|
|
@@ -4274,56 +4332,56 @@ var be, b, $, ct, re, lt = -1, N = function(n) {
|
|
|
4274
4332
|
return c > l[1] ? "poor" : c > l[0] ? "needs-improvement" : "good";
|
|
4275
4333
|
})(e.value, t), n(e));
|
|
4276
4334
|
};
|
|
4277
|
-
},
|
|
4335
|
+
}, ke = function(n) {
|
|
4278
4336
|
requestAnimationFrame((function() {
|
|
4279
4337
|
return requestAnimationFrame((function() {
|
|
4280
4338
|
return n();
|
|
4281
4339
|
}));
|
|
4282
4340
|
}));
|
|
4283
|
-
},
|
|
4341
|
+
}, $ = function(n) {
|
|
4284
4342
|
document.addEventListener("visibilitychange", (function() {
|
|
4285
4343
|
document.visibilityState === "hidden" && n();
|
|
4286
4344
|
}));
|
|
4287
|
-
},
|
|
4345
|
+
}, oe = function(n) {
|
|
4288
4346
|
var e = !1;
|
|
4289
4347
|
return function() {
|
|
4290
4348
|
e || (n(), e = !0);
|
|
4291
4349
|
};
|
|
4292
|
-
},
|
|
4350
|
+
}, k = -1, et = function() {
|
|
4293
4351
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4294
|
-
},
|
|
4295
|
-
document.visibilityState === "hidden" &&
|
|
4352
|
+
}, re = function(n) {
|
|
4353
|
+
document.visibilityState === "hidden" && k > -1 && (k = n.type === "visibilitychange" ? n.timeStamp : 0, en());
|
|
4296
4354
|
}, tt = function() {
|
|
4297
|
-
addEventListener("visibilitychange",
|
|
4298
|
-
},
|
|
4299
|
-
removeEventListener("visibilitychange",
|
|
4300
|
-
},
|
|
4301
|
-
return
|
|
4355
|
+
addEventListener("visibilitychange", re, !0), addEventListener("prerenderingchange", re, !0);
|
|
4356
|
+
}, en = function() {
|
|
4357
|
+
removeEventListener("visibilitychange", re, !0), removeEventListener("prerenderingchange", re, !0);
|
|
4358
|
+
}, De = function() {
|
|
4359
|
+
return k < 0 && (k = et(), tt(), O((function() {
|
|
4302
4360
|
setTimeout((function() {
|
|
4303
|
-
|
|
4361
|
+
k = et(), tt();
|
|
4304
4362
|
}), 0);
|
|
4305
4363
|
}))), { get firstHiddenTime() {
|
|
4306
|
-
return
|
|
4364
|
+
return k;
|
|
4307
4365
|
} };
|
|
4308
|
-
},
|
|
4366
|
+
}, X = function(n) {
|
|
4309
4367
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4310
4368
|
return n();
|
|
4311
4369
|
}), !0) : n();
|
|
4312
|
-
},
|
|
4313
|
-
e = e || {},
|
|
4314
|
-
var t, s =
|
|
4370
|
+
}, Le = [1800, 3e3], ut = function(n, e) {
|
|
4371
|
+
e = e || {}, X((function() {
|
|
4372
|
+
var t, s = De(), r = E("FCP"), i = F("paint", (function(o) {
|
|
4315
4373
|
o.forEach((function(c) {
|
|
4316
|
-
c.name === "first-contentful-paint" && (i.disconnect(), c.startTime < s.firstHiddenTime && (r.value = Math.max(c.startTime -
|
|
4374
|
+
c.name === "first-contentful-paint" && (i.disconnect(), c.startTime < s.firstHiddenTime && (r.value = Math.max(c.startTime - ie(), 0), r.entries.push(c), t(!0)));
|
|
4317
4375
|
}));
|
|
4318
4376
|
}));
|
|
4319
|
-
i && (t = v(n, r,
|
|
4320
|
-
r = E("FCP"), t = v(n, r,
|
|
4377
|
+
i && (t = v(n, r, Le, e.reportAllChanges), O((function(o) {
|
|
4378
|
+
r = E("FCP"), t = v(n, r, Le, e.reportAllChanges), ke((function() {
|
|
4321
4379
|
r.value = performance.now() - o.timeStamp, t(!0);
|
|
4322
4380
|
}));
|
|
4323
4381
|
})));
|
|
4324
4382
|
}));
|
|
4325
|
-
},
|
|
4326
|
-
e = e || {}, ut(
|
|
4383
|
+
}, Me = [0.1, 0.25], tn = function(n, e) {
|
|
4384
|
+
e = e || {}, ut(oe((function() {
|
|
4327
4385
|
var t, s = E("CLS", 0), r = 0, i = [], o = function(l) {
|
|
4328
4386
|
l.forEach((function(u) {
|
|
4329
4387
|
if (!u.hadRecentInput) {
|
|
@@ -4331,112 +4389,112 @@ var be, b, $, ct, re, lt = -1, N = function(n) {
|
|
|
4331
4389
|
r && u.startTime - p.startTime < 1e3 && u.startTime - h.startTime < 5e3 ? (r += u.value, i.push(u)) : (r = u.value, i = [u]);
|
|
4332
4390
|
}
|
|
4333
4391
|
})), r > s.value && (s.value = r, s.entries = i, t());
|
|
4334
|
-
}, c =
|
|
4335
|
-
c && (t = v(n, s,
|
|
4392
|
+
}, c = F("layout-shift", o);
|
|
4393
|
+
c && (t = v(n, s, Me, e.reportAllChanges), $((function() {
|
|
4336
4394
|
o(c.takeRecords()), t(!0);
|
|
4337
|
-
})),
|
|
4338
|
-
r = 0, s = E("CLS", 0), t = v(n, s,
|
|
4395
|
+
})), O((function() {
|
|
4396
|
+
r = 0, s = E("CLS", 0), t = v(n, s, Me, e.reportAllChanges), ke((function() {
|
|
4339
4397
|
return t();
|
|
4340
4398
|
}));
|
|
4341
4399
|
})), setTimeout(t, 0));
|
|
4342
4400
|
})));
|
|
4343
|
-
}, dt = 0,
|
|
4401
|
+
}, dt = 0, me = 1 / 0, K = 0, sn = function(n) {
|
|
4344
4402
|
n.forEach((function(e) {
|
|
4345
|
-
e.interactionId && (
|
|
4403
|
+
e.interactionId && (me = Math.min(me, e.interactionId), K = Math.max(K, e.interactionId), dt = K ? (K - me) / 7 + 1 : 0);
|
|
4346
4404
|
}));
|
|
4347
4405
|
}, ht = function() {
|
|
4348
4406
|
return be ? dt : performance.interactionCount || 0;
|
|
4349
|
-
},
|
|
4350
|
-
"interactionCount" in performance || be || (be =
|
|
4351
|
-
}, I = [],
|
|
4407
|
+
}, nn = function() {
|
|
4408
|
+
"interactionCount" in performance || be || (be = F("event", sn, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4409
|
+
}, I = [], q = /* @__PURE__ */ new Map(), ft = 0, rn = function() {
|
|
4352
4410
|
var n = Math.min(I.length - 1, Math.floor((ht() - ft) / 50));
|
|
4353
4411
|
return I[n];
|
|
4354
|
-
},
|
|
4355
|
-
if (
|
|
4412
|
+
}, on = [], an = function(n) {
|
|
4413
|
+
if (on.forEach((function(r) {
|
|
4356
4414
|
return r(n);
|
|
4357
4415
|
})), n.interactionId || n.entryType === "first-input") {
|
|
4358
|
-
var e = I[I.length - 1], t =
|
|
4416
|
+
var e = I[I.length - 1], t = q.get(n.interactionId);
|
|
4359
4417
|
if (t || I.length < 10 || n.duration > e.latency) {
|
|
4360
4418
|
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);
|
|
4361
4419
|
else {
|
|
4362
4420
|
var s = { id: n.interactionId, latency: n.duration, entries: [n] };
|
|
4363
|
-
|
|
4421
|
+
q.set(s.id, s), I.push(s);
|
|
4364
4422
|
}
|
|
4365
4423
|
I.sort((function(r, i) {
|
|
4366
4424
|
return i.latency - r.latency;
|
|
4367
4425
|
})), I.length > 10 && I.splice(10).forEach((function(r) {
|
|
4368
|
-
return
|
|
4426
|
+
return q.delete(r.id);
|
|
4369
4427
|
}));
|
|
4370
4428
|
}
|
|
4371
4429
|
}
|
|
4372
4430
|
}, gt = function(n) {
|
|
4373
4431
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4374
|
-
return n =
|
|
4375
|
-
},
|
|
4376
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
4432
|
+
return n = oe(n), document.visibilityState === "hidden" ? n() : (t = e(n), $(n)), t;
|
|
4433
|
+
}, Ce = [200, 500], cn = function(n, e) {
|
|
4434
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, X((function() {
|
|
4377
4435
|
var t;
|
|
4378
|
-
|
|
4436
|
+
nn();
|
|
4379
4437
|
var s, r = E("INP"), i = function(c) {
|
|
4380
4438
|
gt((function() {
|
|
4381
|
-
c.forEach(
|
|
4382
|
-
var l =
|
|
4439
|
+
c.forEach(an);
|
|
4440
|
+
var l = rn();
|
|
4383
4441
|
l && l.latency !== r.value && (r.value = l.latency, r.entries = l.entries, s());
|
|
4384
4442
|
}));
|
|
4385
|
-
}, o =
|
|
4386
|
-
s = v(n, r,
|
|
4443
|
+
}, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4444
|
+
s = v(n, r, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), $((function() {
|
|
4387
4445
|
i(o.takeRecords()), s(!0);
|
|
4388
|
-
})),
|
|
4389
|
-
ft = ht(), I.length = 0,
|
|
4446
|
+
})), O((function() {
|
|
4447
|
+
ft = ht(), I.length = 0, q.clear(), r = E("INP"), s = v(n, r, Ce, e.reportAllChanges);
|
|
4390
4448
|
})));
|
|
4391
4449
|
})));
|
|
4392
|
-
},
|
|
4393
|
-
e = e || {},
|
|
4394
|
-
var t, s =
|
|
4450
|
+
}, Re = [2500, 4e3], pe = {}, ln = function(n, e) {
|
|
4451
|
+
e = e || {}, X((function() {
|
|
4452
|
+
var t, s = De(), r = E("LCP"), i = function(l) {
|
|
4395
4453
|
e.reportAllChanges || (l = l.slice(-1)), l.forEach((function(u) {
|
|
4396
|
-
u.startTime < s.firstHiddenTime && (r.value = Math.max(u.startTime -
|
|
4454
|
+
u.startTime < s.firstHiddenTime && (r.value = Math.max(u.startTime - ie(), 0), r.entries = [u], t());
|
|
4397
4455
|
}));
|
|
4398
|
-
}, o =
|
|
4456
|
+
}, o = F("largest-contentful-paint", i);
|
|
4399
4457
|
if (o) {
|
|
4400
|
-
t = v(n, r,
|
|
4401
|
-
var c =
|
|
4402
|
-
|
|
4458
|
+
t = v(n, r, Re, e.reportAllChanges);
|
|
4459
|
+
var c = oe((function() {
|
|
4460
|
+
pe[r.id] || (i(o.takeRecords()), o.disconnect(), pe[r.id] = !0, t(!0));
|
|
4403
4461
|
}));
|
|
4404
4462
|
["keydown", "click"].forEach((function(l) {
|
|
4405
4463
|
addEventListener(l, (function() {
|
|
4406
4464
|
return gt(c);
|
|
4407
4465
|
}), { once: !0, capture: !0 });
|
|
4408
|
-
})),
|
|
4409
|
-
r = E("LCP"), t = v(n, r,
|
|
4410
|
-
r.value = performance.now() - l.timeStamp,
|
|
4466
|
+
})), $(c), O((function(l) {
|
|
4467
|
+
r = E("LCP"), t = v(n, r, Re, e.reportAllChanges), ke((function() {
|
|
4468
|
+
r.value = performance.now() - l.timeStamp, pe[r.id] = !0, t(!0);
|
|
4411
4469
|
}));
|
|
4412
4470
|
}));
|
|
4413
4471
|
}
|
|
4414
4472
|
}));
|
|
4415
|
-
},
|
|
4416
|
-
document.prerendering ?
|
|
4473
|
+
}, Ne = [800, 1800], un = function n(e) {
|
|
4474
|
+
document.prerendering ? X((function() {
|
|
4417
4475
|
return n(e);
|
|
4418
4476
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4419
4477
|
return n(e);
|
|
4420
4478
|
}), !0) : setTimeout(e, 0);
|
|
4421
|
-
},
|
|
4479
|
+
}, dn = function(n, e) {
|
|
4422
4480
|
e = e || {};
|
|
4423
|
-
var t = E("TTFB"), s = v(n, t,
|
|
4424
|
-
|
|
4425
|
-
var r =
|
|
4426
|
-
r && (t.value = Math.max(r.responseStart -
|
|
4427
|
-
t = E("TTFB", 0), (s = v(n, t,
|
|
4481
|
+
var t = E("TTFB"), s = v(n, t, Ne, e.reportAllChanges);
|
|
4482
|
+
un((function() {
|
|
4483
|
+
var r = Pe();
|
|
4484
|
+
r && (t.value = Math.max(r.responseStart - ie(), 0), t.entries = [r], s(!0), O((function() {
|
|
4485
|
+
t = E("TTFB", 0), (s = v(n, t, Ne, e.reportAllChanges))(!0);
|
|
4428
4486
|
})));
|
|
4429
4487
|
}));
|
|
4430
|
-
},
|
|
4431
|
-
|
|
4488
|
+
}, H = { passive: !0, capture: !0 }, hn = /* @__PURE__ */ new Date(), st = function(n, e) {
|
|
4489
|
+
L || (L = e, x = n, ct = /* @__PURE__ */ new Date(), pt(removeEventListener), mt());
|
|
4432
4490
|
}, mt = function() {
|
|
4433
|
-
if (
|
|
4434
|
-
var n = { entryType: "first-input", name:
|
|
4435
|
-
|
|
4491
|
+
if (x >= 0 && x < ct - hn) {
|
|
4492
|
+
var n = { entryType: "first-input", name: L.type, target: L.target, cancelable: L.cancelable, startTime: L.timeStamp, processingStart: L.timeStamp + x };
|
|
4493
|
+
ne.forEach((function(e) {
|
|
4436
4494
|
e(n);
|
|
4437
|
-
})),
|
|
4495
|
+
})), ne = [];
|
|
4438
4496
|
}
|
|
4439
|
-
},
|
|
4497
|
+
}, fn = function(n) {
|
|
4440
4498
|
if (n.cancelable) {
|
|
4441
4499
|
var e = (n.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - n.timeStamp;
|
|
4442
4500
|
n.type == "pointerdown" ? (function(t, s) {
|
|
@@ -4445,76 +4503,76 @@ var be, b, $, ct, re, lt = -1, N = function(n) {
|
|
|
4445
4503
|
}, i = function() {
|
|
4446
4504
|
o();
|
|
4447
4505
|
}, o = function() {
|
|
4448
|
-
removeEventListener("pointerup", r,
|
|
4506
|
+
removeEventListener("pointerup", r, H), removeEventListener("pointercancel", i, H);
|
|
4449
4507
|
};
|
|
4450
|
-
addEventListener("pointerup", r,
|
|
4508
|
+
addEventListener("pointerup", r, H), addEventListener("pointercancel", i, H);
|
|
4451
4509
|
})(e, n) : st(e, n);
|
|
4452
4510
|
}
|
|
4453
4511
|
}, pt = function(n) {
|
|
4454
4512
|
["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
|
|
4455
|
-
return n(e,
|
|
4513
|
+
return n(e, fn, H);
|
|
4456
4514
|
}));
|
|
4457
|
-
},
|
|
4458
|
-
e = e || {},
|
|
4459
|
-
var t, s =
|
|
4515
|
+
}, Oe = [100, 300], gn = function(n, e) {
|
|
4516
|
+
e = e || {}, X((function() {
|
|
4517
|
+
var t, s = De(), r = E("FID"), i = function(l) {
|
|
4460
4518
|
l.startTime < s.firstHiddenTime && (r.value = l.processingStart - l.startTime, r.entries.push(l), t(!0));
|
|
4461
4519
|
}, o = function(l) {
|
|
4462
4520
|
l.forEach(i);
|
|
4463
|
-
}, c =
|
|
4464
|
-
t = v(n, r,
|
|
4521
|
+
}, c = F("first-input", o);
|
|
4522
|
+
t = v(n, r, Oe, e.reportAllChanges), c && ($(oe((function() {
|
|
4465
4523
|
o(c.takeRecords()), c.disconnect();
|
|
4466
|
-
}))),
|
|
4524
|
+
}))), O((function() {
|
|
4467
4525
|
var l;
|
|
4468
|
-
r = E("FID"), t = v(n, r,
|
|
4526
|
+
r = E("FID"), t = v(n, r, Oe, e.reportAllChanges), ne = [], x = -1, L = null, pt(addEventListener), l = i, ne.push(l), mt();
|
|
4469
4527
|
})));
|
|
4470
4528
|
}));
|
|
4471
4529
|
};
|
|
4472
|
-
const
|
|
4530
|
+
const mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4473
4531
|
__proto__: null,
|
|
4474
|
-
CLSThresholds:
|
|
4475
|
-
FCPThresholds:
|
|
4476
|
-
FIDThresholds:
|
|
4477
|
-
INPThresholds:
|
|
4478
|
-
LCPThresholds:
|
|
4479
|
-
TTFBThresholds:
|
|
4480
|
-
onCLS:
|
|
4532
|
+
CLSThresholds: Me,
|
|
4533
|
+
FCPThresholds: Le,
|
|
4534
|
+
FIDThresholds: Oe,
|
|
4535
|
+
INPThresholds: Ce,
|
|
4536
|
+
LCPThresholds: Re,
|
|
4537
|
+
TTFBThresholds: Ne,
|
|
4538
|
+
onCLS: tn,
|
|
4481
4539
|
onFCP: ut,
|
|
4482
|
-
onFID:
|
|
4483
|
-
onINP:
|
|
4484
|
-
onLCP:
|
|
4485
|
-
onTTFB:
|
|
4540
|
+
onFID: gn,
|
|
4541
|
+
onINP: cn,
|
|
4542
|
+
onLCP: ln,
|
|
4543
|
+
onTTFB: dn
|
|
4486
4544
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4487
4545
|
export {
|
|
4488
4546
|
m as AppConfigValidationError,
|
|
4489
|
-
|
|
4490
|
-
|
|
4547
|
+
pn as DEFAULT_SESSION_TIMEOUT,
|
|
4548
|
+
_e as DEFAULT_WEB_VITALS_MODE,
|
|
4491
4549
|
w as DeviceType,
|
|
4492
|
-
|
|
4493
|
-
|
|
4550
|
+
U as EmitterEvent,
|
|
4551
|
+
V as ErrorType,
|
|
4494
4552
|
d as EventType,
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4553
|
+
An as InitializationTimeoutError,
|
|
4554
|
+
Xe as IntegrationValidationError,
|
|
4555
|
+
wn as MAX_ARRAY_LENGTH,
|
|
4556
|
+
Tn as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
4557
|
+
vn as MAX_CUSTOM_EVENT_KEYS,
|
|
4558
|
+
Sn as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
4559
|
+
En as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
4560
|
+
_n as MAX_NESTED_OBJECT_KEYS,
|
|
4561
|
+
yn as MAX_STRING_LENGTH,
|
|
4562
|
+
In as MAX_STRING_LENGTH_IN_ARRAY,
|
|
4563
|
+
ee as Mode,
|
|
4564
|
+
us as PII_PATTERNS,
|
|
4565
|
+
C as PermanentError,
|
|
4566
|
+
J as RateLimitError,
|
|
4567
|
+
$e as SamplingRateValidationError,
|
|
4568
|
+
Ee as ScrollDirection,
|
|
4569
|
+
bt as SessionTimeoutValidationError,
|
|
4570
|
+
M as SpecialApiUrl,
|
|
4571
|
+
Z as TimeoutError,
|
|
4514
4572
|
B as TraceLogValidationError,
|
|
4515
|
-
|
|
4573
|
+
bn as WEB_VITALS_GOOD_THRESHOLDS,
|
|
4516
4574
|
ze as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
4517
|
-
|
|
4575
|
+
Yt as WEB_VITALS_POOR_THRESHOLDS,
|
|
4518
4576
|
Qe as getWebVitalsThresholds,
|
|
4519
|
-
|
|
4577
|
+
Ln as tracelog
|
|
4520
4578
|
};
|