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