@tracelog/lib 2.8.3-rc.103.6 → 2.8.4-rc.104.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/tracelog.esm.js +182 -162
- 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 +2 -1
- package/dist/public-api.d.ts +2 -1
- package/dist/public-api.js +2 -2
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
const hr = 9e5;
|
|
2
|
+
const fr = 120, mr = 49152, gr = 100, Er = 500, pr = 200;
|
|
3
|
+
const Sr = 1e3, Tr = 500, Ir = 1e3;
|
|
4
4
|
const b = "data-tlog", bt = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
@@ -82,10 +82,11 @@ const E = {
|
|
|
82
82
|
], S = "tlog", X = `${S}:qa_mode`, Te = `${S}:uid`, rt = "tlog_mode", Ue = "qa", Fe = "qa_off", Ct = (r) => r ? `${S}:${r}:queue` : `${S}:queue`, Rt = (r) => r ? `${S}:${r}:rate_limit` : `${S}:rate_limit`, Nt = (r) => r ? `${S}:${r}:session` : `${S}:session`, Ot = (r) => r ? `${S}:${r}:broadcast` : `${S}:broadcast`, He = (r, e) => `${S}:${r}:session_counts:${e}`, xe = 10080 * 60 * 1e3, $e = `${S}:session_counts_last_cleanup`, Be = 3600 * 1e3, fe = (r) => r ? `${S}:${r}:identity` : `${S}:identity`, U = `${S}:pending_identity`;
|
|
83
83
|
var $ = /* @__PURE__ */ ((r) => (r.Localhost = "localhost:8080", r.Fail = "localhost:9999", r))($ || {}), A = /* @__PURE__ */ ((r) => (r.Mobile = "mobile", r.Tablet = "tablet", r.Desktop = "desktop", r.Unknown = "unknown", r))(A || {}), se = /* @__PURE__ */ ((r) => (r.EVENT = "event", r.QUEUE = "queue", r))(se || {});
|
|
84
84
|
class O extends Error {
|
|
85
|
-
constructor(e, t) {
|
|
86
|
-
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, O);
|
|
85
|
+
constructor(e, t, s) {
|
|
86
|
+
super(e), this.statusCode = t, this.responseCode = s, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, O);
|
|
87
87
|
}
|
|
88
88
|
statusCode;
|
|
89
|
+
responseCode;
|
|
89
90
|
}
|
|
90
91
|
class re extends Error {
|
|
91
92
|
constructor(e) {
|
|
@@ -98,7 +99,7 @@ class ie extends Error {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
var u = /* @__PURE__ */ ((r) => (r.PAGE_VIEW = "page_view", r.CLICK = "click", r.SCROLL = "scroll", r.SESSION_START = "session_start", r.CUSTOM = "custom", r.WEB_VITALS = "web_vitals", r.ERROR = "error", r.VIEWPORT_VISIBLE = "viewport_visible", r))(u || {}), Z = /* @__PURE__ */ ((r) => (r.UP = "up", r.DOWN = "down", r))(Z || {}), B = /* @__PURE__ */ ((r) => (r.JS_ERROR = "js_error", r.PROMISE_REJECTION = "promise_rejection", r))(B || {}), ne = /* @__PURE__ */ ((r) => (r.QA = "qa", r))(ne || {});
|
|
101
|
-
const
|
|
102
|
+
const vr = (r) => r.type === u.SCROLL && "scroll_data" in r && r.scroll_data.is_primary === !0, _r = (r) => r.type === u.SCROLL && "scroll_data" in r && r.scroll_data.is_primary === !1;
|
|
102
103
|
class j extends Error {
|
|
103
104
|
constructor(e, t, s) {
|
|
104
105
|
super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
@@ -126,7 +127,7 @@ class N extends j {
|
|
|
126
127
|
super(e, "INTEGRATION_INVALID", t);
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
class
|
|
130
|
+
class yr extends j {
|
|
130
131
|
constructor(e, t, s = "runtime") {
|
|
131
132
|
super(e, "INITIALIZATION_TIMEOUT", s), this.timeoutMs = t;
|
|
132
133
|
}
|
|
@@ -253,7 +254,7 @@ const xt = () => {
|
|
|
253
254
|
/:\/\/[^:/]+:([^@]+)@/gi,
|
|
254
255
|
// Sensitive URL query parameters (token=, password=, auth=, secret=, api_key=, etc.)
|
|
255
256
|
/[?&](token|password|passwd|auth|secret|secret_key|private_key|auth_key|api_key|apikey|access_token)=[^&\s]+/gi
|
|
256
|
-
], Xe = 500, Ge = 2e3, je = 5e3, ee = 50, Gt = ee * 2, lt = 1, jt = 1e3, zt = 10, ze = 5e3, Kt = 6e4,
|
|
257
|
+
], Xe = 500, Ge = 2e3, je = 5e3, ee = 50, Gt = ee * 2, lt = 1, jt = 1e3, zt = 10, ze = 5e3, Kt = 6e4, Qt = 64, wr = {
|
|
257
258
|
LCP: 2500,
|
|
258
259
|
// Good: ≤ 2.5s
|
|
259
260
|
FCP: 1800,
|
|
@@ -277,7 +278,7 @@ const xt = () => {
|
|
|
277
278
|
TTFB: 800,
|
|
278
279
|
// Needs improvement: > 800ms
|
|
279
280
|
LONG_TASK: 50
|
|
280
|
-
},
|
|
281
|
+
}, Yt = {
|
|
281
282
|
LCP: 4e3,
|
|
282
283
|
// Poor: > 4s
|
|
283
284
|
FCP: 3e3,
|
|
@@ -297,11 +298,11 @@ const xt = () => {
|
|
|
297
298
|
case "needs-improvement":
|
|
298
299
|
return Ke;
|
|
299
300
|
case "poor":
|
|
300
|
-
return
|
|
301
|
+
return Yt;
|
|
301
302
|
default:
|
|
302
303
|
return Ke;
|
|
303
304
|
}
|
|
304
|
-
},
|
|
305
|
+
}, qt = 1e3, Jt = 50, Zt = "2.8.4", es = Zt, ct = () => typeof window < "u" && typeof sessionStorage < "u", ts = () => {
|
|
305
306
|
try {
|
|
306
307
|
const r = new URLSearchParams(window.location.search);
|
|
307
308
|
r.delete(rt);
|
|
@@ -309,7 +310,7 @@ const xt = () => {
|
|
|
309
310
|
window.history.replaceState({}, "", t);
|
|
310
311
|
} catch {
|
|
311
312
|
}
|
|
312
|
-
},
|
|
313
|
+
}, ss = () => {
|
|
313
314
|
if (!ct())
|
|
314
315
|
return !1;
|
|
315
316
|
try {
|
|
@@ -321,11 +322,11 @@ const xt = () => {
|
|
|
321
322
|
})) : e === Fe && (s = !1, sessionStorage.setItem(X, "false"), a("info", "QA Mode DISABLED", {
|
|
322
323
|
visibility: "qa",
|
|
323
324
|
style: nt
|
|
324
|
-
})), (e === Ue || e === Fe) &&
|
|
325
|
+
})), (e === Ue || e === Fe) && ts(), s ?? t === "true";
|
|
325
326
|
} catch {
|
|
326
327
|
return !1;
|
|
327
328
|
}
|
|
328
|
-
},
|
|
329
|
+
}, rs = (r) => {
|
|
329
330
|
if (ct())
|
|
330
331
|
try {
|
|
331
332
|
sessionStorage.setItem(X, r ? "true" : "false"), a("info", r ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
@@ -335,7 +336,7 @@ const xt = () => {
|
|
|
335
336
|
} catch {
|
|
336
337
|
a("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
337
338
|
}
|
|
338
|
-
},
|
|
339
|
+
}, is = [
|
|
339
340
|
"co.uk",
|
|
340
341
|
"org.uk",
|
|
341
342
|
"com.au",
|
|
@@ -352,14 +353,14 @@ const xt = () => {
|
|
|
352
353
|
if (e.length <= 2)
|
|
353
354
|
return r.toLowerCase();
|
|
354
355
|
const t = e.slice(-2).join(".");
|
|
355
|
-
return
|
|
356
|
-
},
|
|
356
|
+
return is.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
357
|
+
}, ns = (r, e) => r === e ? !0 : Ye(r) === Ye(e), me = () => {
|
|
357
358
|
const r = document.referrer;
|
|
358
359
|
if (!r)
|
|
359
360
|
return "Direct";
|
|
360
361
|
try {
|
|
361
362
|
const e = new URL(r).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
|
|
362
|
-
return
|
|
363
|
+
return ns(e, t) ? "Direct" : r;
|
|
363
364
|
} catch (e) {
|
|
364
365
|
return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: r } }), r;
|
|
365
366
|
}
|
|
@@ -377,7 +378,7 @@ const xt = () => {
|
|
|
377
378
|
return (r === "x" ? e : e & 3 | 8).toString(16);
|
|
378
379
|
});
|
|
379
380
|
let Y = 0, q = 0;
|
|
380
|
-
const
|
|
381
|
+
const os = () => {
|
|
381
382
|
let r = Date.now();
|
|
382
383
|
r < q && (r = q), r === q ? Y = (Y + 1) % 1e3 : Y = 0, q = r;
|
|
383
384
|
const e = Y.toString().padStart(3, "0");
|
|
@@ -397,7 +398,7 @@ const ns = () => {
|
|
|
397
398
|
} catch {
|
|
398
399
|
return !1;
|
|
399
400
|
}
|
|
400
|
-
},
|
|
401
|
+
}, as = (r) => {
|
|
401
402
|
try {
|
|
402
403
|
const t = new URL(window.location.href).hostname;
|
|
403
404
|
if (!t || typeof t != "string")
|
|
@@ -421,9 +422,9 @@ const ns = () => {
|
|
|
421
422
|
} catch (e) {
|
|
422
423
|
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
423
424
|
}
|
|
424
|
-
},
|
|
425
|
+
}, ls = (r) => {
|
|
425
426
|
const e = {};
|
|
426
|
-
r.integrations?.tracelog?.projectId && (e.saas =
|
|
427
|
+
r.integrations?.tracelog?.projectId && (e.saas = as(r.integrations.tracelog.projectId));
|
|
427
428
|
const t = r.integrations?.custom?.collectApiUrl;
|
|
428
429
|
if (t) {
|
|
429
430
|
const s = r.integrations?.custom?.allowHttp ?? !1;
|
|
@@ -486,7 +487,7 @@ const ns = () => {
|
|
|
486
487
|
return t;
|
|
487
488
|
}
|
|
488
489
|
return null;
|
|
489
|
-
},
|
|
490
|
+
}, cs = (r) => {
|
|
490
491
|
if (typeof r != "object" || r === null)
|
|
491
492
|
return {};
|
|
492
493
|
try {
|
|
@@ -496,7 +497,7 @@ const ns = () => {
|
|
|
496
497
|
const t = e instanceof Error ? e.message : String(e);
|
|
497
498
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
498
499
|
}
|
|
499
|
-
},
|
|
500
|
+
}, ds = (r) => {
|
|
500
501
|
if (r !== void 0 && (r === null || typeof r != "object"))
|
|
501
502
|
throw new m("Configuration must be an object", "config");
|
|
502
503
|
if (r) {
|
|
@@ -504,7 +505,7 @@ const ns = () => {
|
|
|
504
505
|
throw new Pt(E.INVALID_SESSION_TIMEOUT, "config");
|
|
505
506
|
if (r.globalMetadata !== void 0 && (typeof r.globalMetadata != "object" || r.globalMetadata === null))
|
|
506
507
|
throw new m(E.INVALID_GLOBAL_METADATA, "config");
|
|
507
|
-
if (r.integrations &&
|
|
508
|
+
if (r.integrations && hs(r.integrations), r.sensitiveQueryParams !== void 0) {
|
|
508
509
|
if (!Array.isArray(r.sensitiveQueryParams))
|
|
509
510
|
throw new m(E.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
510
511
|
for (const e of r.sensitiveQueryParams)
|
|
@@ -536,7 +537,7 @@ const ns = () => {
|
|
|
536
537
|
throw new m(E.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
|
|
537
538
|
if (r.sendIntervalMs !== void 0 && (!Number.isFinite(r.sendIntervalMs) || r.sendIntervalMs < 1e3 || r.sendIntervalMs > 6e4))
|
|
538
539
|
throw new m(E.INVALID_SEND_INTERVAL, "config");
|
|
539
|
-
if (r.viewport !== void 0 &&
|
|
540
|
+
if (r.viewport !== void 0 && us(r.viewport), r.webVitalsMode !== void 0) {
|
|
540
541
|
if (typeof r.webVitalsMode != "string")
|
|
541
542
|
throw new m(
|
|
542
543
|
`Invalid webVitalsMode type: ${typeof r.webVitalsMode}. Must be a string`,
|
|
@@ -567,7 +568,7 @@ const ns = () => {
|
|
|
567
568
|
}
|
|
568
569
|
}
|
|
569
570
|
}
|
|
570
|
-
},
|
|
571
|
+
}, us = (r) => {
|
|
571
572
|
if (typeof r != "object" || r === null)
|
|
572
573
|
throw new m(E.INVALID_VIEWPORT_CONFIG, "config");
|
|
573
574
|
if (!r.elements || !Array.isArray(r.elements))
|
|
@@ -597,7 +598,7 @@ const ns = () => {
|
|
|
597
598
|
throw new m(E.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
598
599
|
if (r.maxTrackedElements !== void 0 && (typeof r.maxTrackedElements != "number" || r.maxTrackedElements <= 0))
|
|
599
600
|
throw new m(E.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
600
|
-
},
|
|
601
|
+
}, hs = (r) => {
|
|
601
602
|
if (r) {
|
|
602
603
|
if (r.tracelog && (!r.tracelog.projectId || typeof r.tracelog.projectId != "string" || r.tracelog.projectId.trim() === ""))
|
|
603
604
|
throw new N(E.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
@@ -620,8 +621,8 @@ const ns = () => {
|
|
|
620
621
|
if (r.tracelog?.shopify !== void 0 && typeof r.tracelog.shopify != "boolean")
|
|
621
622
|
throw new N("tracelog.shopify must be a boolean", "config");
|
|
622
623
|
}
|
|
623
|
-
},
|
|
624
|
-
|
|
624
|
+
}, fs = (r) => {
|
|
625
|
+
ds(r);
|
|
625
626
|
const e = {
|
|
626
627
|
...r ?? {},
|
|
627
628
|
sessionTimeout: r?.sessionTimeout ?? 9e5,
|
|
@@ -649,13 +650,13 @@ const ns = () => {
|
|
|
649
650
|
return !0;
|
|
650
651
|
const t = typeof r;
|
|
651
652
|
return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(r) ? !1 : (e.add(r), Array.isArray(r) ? r.every((s) => be(s, e)) : t === "object" ? Object.values(r).every((s) => be(s, e)) : !1);
|
|
652
|
-
},
|
|
653
|
+
}, ms = (r) => typeof r != "object" || r === null ? !1 : be(r), ht = (r) => {
|
|
653
654
|
if (typeof r != "object" || r === null || Array.isArray(r)) return;
|
|
654
655
|
const e = {};
|
|
655
656
|
for (const [t, s] of Object.entries(r))
|
|
656
657
|
typeof s == "string" && (e[t] = s);
|
|
657
658
|
return Object.keys(e).length > 0 ? e : void 0;
|
|
658
|
-
},
|
|
659
|
+
}, gs = (r) => typeof r != "string" ? {
|
|
659
660
|
valid: !1,
|
|
660
661
|
error: "Event name must be a string"
|
|
661
662
|
} : r.length === 0 ? {
|
|
@@ -671,8 +672,8 @@ const ns = () => {
|
|
|
671
672
|
valid: !1,
|
|
672
673
|
error: "Event name cannot be a reserved word"
|
|
673
674
|
} : { valid: !0 }, Je = (r, e, t) => {
|
|
674
|
-
const s =
|
|
675
|
-
if (!
|
|
675
|
+
const s = cs(e), i = t && t === "customEvent" ? `${t} "${r}" metadata error` : `${r} metadata error`;
|
|
676
|
+
if (!ms(s))
|
|
676
677
|
return {
|
|
677
678
|
valid: !1,
|
|
678
679
|
error: `${i}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -744,8 +745,8 @@ const ns = () => {
|
|
|
744
745
|
};
|
|
745
746
|
}
|
|
746
747
|
return Je(r, e, t);
|
|
747
|
-
},
|
|
748
|
-
const t =
|
|
748
|
+
}, Es = (r, e) => {
|
|
749
|
+
const t = gs(r);
|
|
749
750
|
if (!t.valid)
|
|
750
751
|
return a("error", "Event name validation failed", {
|
|
751
752
|
data: { eventName: r, error: t.error }
|
|
@@ -760,7 +761,7 @@ const ns = () => {
|
|
|
760
761
|
}
|
|
761
762
|
}), s;
|
|
762
763
|
};
|
|
763
|
-
class
|
|
764
|
+
class ps {
|
|
764
765
|
listeners = /* @__PURE__ */ new Map();
|
|
765
766
|
/**
|
|
766
767
|
* Subscribes to an event channel
|
|
@@ -888,7 +889,7 @@ function mt(r, e, t) {
|
|
|
888
889
|
}), r;
|
|
889
890
|
}
|
|
890
891
|
}
|
|
891
|
-
function
|
|
892
|
+
function Ss(r, e, t) {
|
|
892
893
|
return r.map((s) => mt(s, e, t)).filter((s) => s !== null);
|
|
893
894
|
}
|
|
894
895
|
function gt(r, e, t) {
|
|
@@ -1387,7 +1388,7 @@ class Ze extends _ {
|
|
|
1387
1388
|
const t = this.transformers.beforeSend;
|
|
1388
1389
|
if (!t)
|
|
1389
1390
|
return e;
|
|
1390
|
-
const s =
|
|
1391
|
+
const s = Ss(
|
|
1391
1392
|
e.events,
|
|
1392
1393
|
t,
|
|
1393
1394
|
this.integrationId || "SenderManager"
|
|
@@ -1618,8 +1619,13 @@ class Ze extends _ {
|
|
|
1618
1619
|
"Content-Type": "application/json"
|
|
1619
1620
|
}
|
|
1620
1621
|
});
|
|
1621
|
-
if (!l.ok)
|
|
1622
|
-
|
|
1622
|
+
if (!l.ok) {
|
|
1623
|
+
if (l.status >= 400 && l.status < 500 && l.status !== 408 && l.status !== 429) {
|
|
1624
|
+
const d = await this.readTraceLogErrorCode(l), f = d ? `HTTP ${l.status}: ${l.statusText} (${d})` : `HTTP ${l.status}: ${l.statusText}`;
|
|
1625
|
+
throw new O(f, l.status, d);
|
|
1626
|
+
}
|
|
1627
|
+
throw l.status === 429 ? new re(`HTTP 429: ${l.statusText}`) : new Error(`HTTP ${l.status}: ${l.statusText}`);
|
|
1628
|
+
}
|
|
1623
1629
|
return l;
|
|
1624
1630
|
} catch (o) {
|
|
1625
1631
|
throw o instanceof O ? o : i ? new ie("Request timed out") : o;
|
|
@@ -1627,6 +1633,23 @@ class Ze extends _ {
|
|
|
1627
1633
|
clearTimeout(n), this.pendingControllers.delete(s);
|
|
1628
1634
|
}
|
|
1629
1635
|
}
|
|
1636
|
+
/**
|
|
1637
|
+
* Best-effort extraction of an application `code` from a 4xx response body.
|
|
1638
|
+
*
|
|
1639
|
+
* Used purely for logging context (e.g. `PLAN_LIMIT_EXCEEDED`, `PROJECT_READ_ONLY`).
|
|
1640
|
+
* Status alone already determines retry semantics, so this never affects the
|
|
1641
|
+
* retry/persistence decision. Bounded to {@link MAX_RESPONSE_CODE_LENGTH} chars
|
|
1642
|
+
* to keep noisy/untrusted payloads out of logs without coupling the lib to the
|
|
1643
|
+
* API's evolving code catalogue.
|
|
1644
|
+
*/
|
|
1645
|
+
async readTraceLogErrorCode(e) {
|
|
1646
|
+
try {
|
|
1647
|
+
const t = await e.clone().json();
|
|
1648
|
+
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <= Qt)
|
|
1649
|
+
return t.code;
|
|
1650
|
+
} catch {
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1630
1653
|
/**
|
|
1631
1654
|
* Internal synchronous send logic using navigator.sendBeacon() for page unload scenarios.
|
|
1632
1655
|
*
|
|
@@ -1708,7 +1731,7 @@ class Ze extends _ {
|
|
|
1708
1731
|
idempotency_token: e._metadata?.idempotency_token ?? this.computeContentToken(e),
|
|
1709
1732
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1710
1733
|
timestamp: t,
|
|
1711
|
-
client_version:
|
|
1734
|
+
client_version: es
|
|
1712
1735
|
}
|
|
1713
1736
|
};
|
|
1714
1737
|
return {
|
|
@@ -1882,13 +1905,13 @@ class Ze extends _ {
|
|
|
1882
1905
|
return typeof navigator < "u" && typeof navigator.sendBeacon == "function";
|
|
1883
1906
|
}
|
|
1884
1907
|
logPermanentError(e, t) {
|
|
1885
|
-
const s = Date.now()
|
|
1886
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.
|
|
1887
|
-
data: { status: t.statusCode, message: t.message }
|
|
1888
|
-
}), this.lastPermanentErrorLog = {
|
|
1908
|
+
const s = Date.now(), i = `${t.statusCode ?? "unknown"}:${t.responseCode ?? ""}`;
|
|
1909
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== i || s - this.lastPermanentErrorLog.timestamp >= Kt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1910
|
+
data: { status: t.statusCode, code: t.responseCode, message: t.message }
|
|
1911
|
+
}), this.lastPermanentErrorLog = { key: i, timestamp: s });
|
|
1889
1912
|
}
|
|
1890
1913
|
}
|
|
1891
|
-
class
|
|
1914
|
+
class Ts extends _ {
|
|
1892
1915
|
bootTime;
|
|
1893
1916
|
bootTimestamp;
|
|
1894
1917
|
hasPerformanceNow;
|
|
@@ -2037,8 +2060,8 @@ class Ss extends _ {
|
|
|
2037
2060
|
};
|
|
2038
2061
|
}
|
|
2039
2062
|
}
|
|
2040
|
-
const
|
|
2041
|
-
class
|
|
2063
|
+
const Is = new Set(Object.values(u));
|
|
2064
|
+
class vs extends _ {
|
|
2042
2065
|
dataSenders;
|
|
2043
2066
|
emitter;
|
|
2044
2067
|
transformers;
|
|
@@ -2077,7 +2100,7 @@ class Is extends _ {
|
|
|
2077
2100
|
* @param fetchCredentials - Fetch credentials mode for custom backend. @default 'include'
|
|
2078
2101
|
*/
|
|
2079
2102
|
constructor(e, t = null, s = {}, i = {}, n, o = "include") {
|
|
2080
|
-
super(), this.emitter = t, this.transformers = s, this.timeManager = new
|
|
2103
|
+
super(), this.emitter = t, this.transformers = s, this.timeManager = new Ts(), this.dataSenders = [];
|
|
2081
2104
|
const l = this.get("collectApiUrls");
|
|
2082
2105
|
l?.saas && this.dataSenders.push(new Ze(e, "saas", l.saas, s)), l?.custom && this.dataSenders.push(
|
|
2083
2106
|
new Ze(
|
|
@@ -2208,7 +2231,7 @@ class Is extends _ {
|
|
|
2208
2231
|
a("error", "Event type is required - event will be ignored");
|
|
2209
2232
|
return;
|
|
2210
2233
|
}
|
|
2211
|
-
if (!
|
|
2234
|
+
if (!Is.has(e)) {
|
|
2212
2235
|
a("error", "Invalid event type - event will be ignored", {
|
|
2213
2236
|
data: { type: e }
|
|
2214
2237
|
});
|
|
@@ -2594,13 +2617,10 @@ class Is extends _ {
|
|
|
2594
2617
|
const t = this.buildEventsPayload(), s = [...this.eventsQueue], i = s.map((n) => n.id);
|
|
2595
2618
|
if (this.dataSenders.length === 0)
|
|
2596
2619
|
return this.removeProcessedEvents(i), this.clearSendTimeout(), this.emitEventsQueue(t), e ? !0 : Promise.resolve(!0);
|
|
2597
|
-
if (e && this.sendInProgress)
|
|
2598
|
-
|
|
2599
|
-
n.persistForRecovery(t);
|
|
2600
|
-
return a("debug", "Sync flush deferred: async send in progress, events persisted for recovery", {
|
|
2620
|
+
if (e && this.sendInProgress)
|
|
2621
|
+
return a("debug", "Sync flush skipped: async send already in-flight, trusting fetch to deliver", {
|
|
2601
2622
|
data: { eventCount: i.length }
|
|
2602
2623
|
}), !0;
|
|
2603
|
-
}
|
|
2604
2624
|
if (e) {
|
|
2605
2625
|
const o = this.dataSenders.map((l) => l.sendEventsQueueSync(t)).some((l) => l);
|
|
2606
2626
|
return o ? (this.removeProcessedEvents(i), this.clearSendTimeout(), this.emitEventsQueue(t)) : (this.clearSendTimeout(), a("debug", "Sync flush complete failure, events kept in queue for retry", {
|
|
@@ -2685,7 +2705,7 @@ class Is extends _ {
|
|
|
2685
2705
|
});
|
|
2686
2706
|
const n = this.get("sessionReferrer"), o = this.get("sessionUtm");
|
|
2687
2707
|
let l = {
|
|
2688
|
-
id:
|
|
2708
|
+
id: os(),
|
|
2689
2709
|
type: e.type,
|
|
2690
2710
|
page_url: t,
|
|
2691
2711
|
timestamp: s,
|
|
@@ -3005,7 +3025,7 @@ class Is extends _ {
|
|
|
3005
3025
|
}
|
|
3006
3026
|
}
|
|
3007
3027
|
}
|
|
3008
|
-
class
|
|
3028
|
+
class _s {
|
|
3009
3029
|
/**
|
|
3010
3030
|
* Gets or creates a unique user ID.
|
|
3011
3031
|
*
|
|
@@ -3030,8 +3050,8 @@ class vs {
|
|
|
3030
3050
|
return e.setItem(Te, s), s;
|
|
3031
3051
|
}
|
|
3032
3052
|
}
|
|
3033
|
-
const
|
|
3034
|
-
class
|
|
3053
|
+
const ys = /^\d{13}-[a-z0-9]{9}$/;
|
|
3054
|
+
class ws extends _ {
|
|
3035
3055
|
storageManager;
|
|
3036
3056
|
eventManager;
|
|
3037
3057
|
projectId;
|
|
@@ -3077,7 +3097,7 @@ class ys extends _ {
|
|
|
3077
3097
|
const e = this.loadStoredSession();
|
|
3078
3098
|
if (!e)
|
|
3079
3099
|
return null;
|
|
3080
|
-
if (!
|
|
3100
|
+
if (!ys.test(e.id))
|
|
3081
3101
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
3082
3102
|
data: { sessionId: e.id }
|
|
3083
3103
|
}), this.clearStoredSession(), null;
|
|
@@ -3362,7 +3382,7 @@ class ys extends _ {
|
|
|
3362
3382
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
3363
3383
|
}
|
|
3364
3384
|
}
|
|
3365
|
-
class
|
|
3385
|
+
class bs extends _ {
|
|
3366
3386
|
eventManager;
|
|
3367
3387
|
storageManager;
|
|
3368
3388
|
sessionManager = null;
|
|
@@ -3397,7 +3417,7 @@ class ws extends _ {
|
|
|
3397
3417
|
}
|
|
3398
3418
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
3399
3419
|
try {
|
|
3400
|
-
this.sessionManager = new
|
|
3420
|
+
this.sessionManager = new ws(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
3401
3421
|
} catch (s) {
|
|
3402
3422
|
if (this.sessionManager) {
|
|
3403
3423
|
try {
|
|
@@ -3450,7 +3470,7 @@ class ws extends _ {
|
|
|
3450
3470
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
3451
3471
|
}
|
|
3452
3472
|
}
|
|
3453
|
-
class
|
|
3473
|
+
class Ls extends _ {
|
|
3454
3474
|
eventManager;
|
|
3455
3475
|
onTrack;
|
|
3456
3476
|
originalPushState;
|
|
@@ -3526,7 +3546,7 @@ class bs extends _ {
|
|
|
3526
3546
|
};
|
|
3527
3547
|
}
|
|
3528
3548
|
}
|
|
3529
|
-
class
|
|
3549
|
+
class As extends _ {
|
|
3530
3550
|
eventManager;
|
|
3531
3551
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3532
3552
|
clickHandler;
|
|
@@ -3783,7 +3803,7 @@ class Ls extends _ {
|
|
|
3783
3803
|
};
|
|
3784
3804
|
}
|
|
3785
3805
|
}
|
|
3786
|
-
class
|
|
3806
|
+
class Ms extends _ {
|
|
3787
3807
|
eventManager;
|
|
3788
3808
|
containers = [];
|
|
3789
3809
|
limitWarningLogged = !1;
|
|
@@ -4011,7 +4031,7 @@ class As extends _ {
|
|
|
4011
4031
|
e.isPrimary = t;
|
|
4012
4032
|
}
|
|
4013
4033
|
}
|
|
4014
|
-
class
|
|
4034
|
+
class Cs extends _ {
|
|
4015
4035
|
eventManager;
|
|
4016
4036
|
trackedElements = /* @__PURE__ */ new Map();
|
|
4017
4037
|
observer = null;
|
|
@@ -4172,8 +4192,8 @@ class Ms extends _ {
|
|
|
4172
4192
|
});
|
|
4173
4193
|
}
|
|
4174
4194
|
}
|
|
4175
|
-
const
|
|
4176
|
-
class
|
|
4195
|
+
const Rs = "tracelog_session_id";
|
|
4196
|
+
class Ns extends _ {
|
|
4177
4197
|
visibilityHandler = null;
|
|
4178
4198
|
lastSyncedSessionId = null;
|
|
4179
4199
|
activate() {
|
|
@@ -4195,7 +4215,7 @@ class Rs extends _ {
|
|
|
4195
4215
|
fetch("/cart/update.js", {
|
|
4196
4216
|
method: "POST",
|
|
4197
4217
|
headers: { "Content-Type": "application/json" },
|
|
4198
|
-
body: JSON.stringify({ attributes: { [
|
|
4218
|
+
body: JSON.stringify({ attributes: { [Rs]: e } }),
|
|
4199
4219
|
credentials: "same-origin"
|
|
4200
4220
|
}).then((t) => {
|
|
4201
4221
|
t.ok || (this.lastSyncedSessionId = null, a("debug", "Shopify cart attribute update failed", { data: { status: t.status } }));
|
|
@@ -4215,7 +4235,7 @@ class Rs extends _ {
|
|
|
4215
4235
|
this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null);
|
|
4216
4236
|
}
|
|
4217
4237
|
}
|
|
4218
|
-
class
|
|
4238
|
+
class Os {
|
|
4219
4239
|
storage;
|
|
4220
4240
|
sessionStorageRef;
|
|
4221
4241
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -4498,7 +4518,7 @@ class Ns {
|
|
|
4498
4518
|
this.fallbackSessionStorage.delete(e);
|
|
4499
4519
|
}
|
|
4500
4520
|
}
|
|
4501
|
-
class
|
|
4521
|
+
class Ps extends _ {
|
|
4502
4522
|
eventManager;
|
|
4503
4523
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
4504
4524
|
navigationHistory = [];
|
|
@@ -4597,7 +4617,7 @@ class Os extends _ {
|
|
|
4597
4617
|
}
|
|
4598
4618
|
async initWebVitals() {
|
|
4599
4619
|
try {
|
|
4600
|
-
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: i, onINP: n } = await Promise.resolve().then(() =>
|
|
4620
|
+
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: i, onINP: n } = await Promise.resolve().then(() => ur), o = (l) => (c) => {
|
|
4601
4621
|
const d = Number(c.value.toFixed(2));
|
|
4602
4622
|
this.sendVital({ type: l, value: d });
|
|
4603
4623
|
};
|
|
@@ -4624,7 +4644,7 @@ class Os extends _ {
|
|
|
4624
4644
|
const t = e.getEntries();
|
|
4625
4645
|
for (const s of t) {
|
|
4626
4646
|
const i = Number(s.duration.toFixed(2)), n = Date.now();
|
|
4627
|
-
n - this.lastLongTaskSentAt >=
|
|
4647
|
+
n - this.lastLongTaskSentAt >= qt && (this.shouldSendVital("LONG_TASK", i) && this.trackWebVital("LONG_TASK", i), this.lastLongTaskSentAt = n);
|
|
4628
4648
|
}
|
|
4629
4649
|
},
|
|
4630
4650
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4640,7 +4660,7 @@ class Os extends _ {
|
|
|
4640
4660
|
return;
|
|
4641
4661
|
if (s)
|
|
4642
4662
|
s.add(e.type);
|
|
4643
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4663
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Jt) {
|
|
4644
4664
|
const n = this.navigationHistory.shift();
|
|
4645
4665
|
n && this.reportedByNav.delete(n);
|
|
4646
4666
|
}
|
|
@@ -4861,11 +4881,11 @@ class ae extends _ {
|
|
|
4861
4881
|
}
|
|
4862
4882
|
}
|
|
4863
4883
|
}
|
|
4864
|
-
class
|
|
4884
|
+
class Ds extends _ {
|
|
4865
4885
|
isInitialized = !1;
|
|
4866
4886
|
suppressNextScrollTimer = null;
|
|
4867
4887
|
pageUnloadHandler = null;
|
|
4868
|
-
emitter = new
|
|
4888
|
+
emitter = new ps();
|
|
4869
4889
|
transformers = {};
|
|
4870
4890
|
customHeadersProvider;
|
|
4871
4891
|
managers = {};
|
|
@@ -4884,11 +4904,11 @@ class Ps extends _ {
|
|
|
4884
4904
|
async init(e = {}) {
|
|
4885
4905
|
if (this.isInitialized)
|
|
4886
4906
|
return { sessionId: this.get("sessionId") ?? "" };
|
|
4887
|
-
this.managers.storage = new
|
|
4907
|
+
this.managers.storage = new Os();
|
|
4888
4908
|
try {
|
|
4889
4909
|
this.setupState(e);
|
|
4890
4910
|
const t = e.integrations?.custom?.headers ?? {}, s = e.integrations?.custom?.fetchCredentials ?? "include";
|
|
4891
|
-
return this.managers.event = new
|
|
4911
|
+
return this.managers.event = new vs(
|
|
4892
4912
|
this.managers.storage,
|
|
4893
4913
|
this.emitter,
|
|
4894
4914
|
this.transformers,
|
|
@@ -4918,7 +4938,7 @@ class Ps extends _ {
|
|
|
4918
4938
|
}
|
|
4919
4939
|
let s = t;
|
|
4920
4940
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (s = Object.assign({}, t));
|
|
4921
|
-
const { valid: i, error: n, sanitizedMetadata: o } =
|
|
4941
|
+
const { valid: i, error: n, sanitizedMetadata: o } = Es(e, s);
|
|
4922
4942
|
if (!i) {
|
|
4923
4943
|
if (this.get("mode") === ne.QA)
|
|
4924
4944
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${n}`);
|
|
@@ -4988,14 +5008,14 @@ class Ps extends _ {
|
|
|
4988
5008
|
}
|
|
4989
5009
|
setupState(e = {}) {
|
|
4990
5010
|
this.set("config", e);
|
|
4991
|
-
const t =
|
|
5011
|
+
const t = _s.getId(this.managers.storage);
|
|
4992
5012
|
this.set("userId", t);
|
|
4993
|
-
const s =
|
|
5013
|
+
const s = ls(e);
|
|
4994
5014
|
this.set("collectApiUrls", s);
|
|
4995
5015
|
const i = Xt();
|
|
4996
5016
|
this.set("device", i);
|
|
4997
5017
|
const n = ye(window.location.href, e.sensitiveQueryParams);
|
|
4998
|
-
this.set("pageUrl", n),
|
|
5018
|
+
this.set("pageUrl", n), ss() && this.set("mode", ne.QA);
|
|
4999
5019
|
}
|
|
5000
5020
|
/**
|
|
5001
5021
|
* Returns the current configuration object.
|
|
@@ -5222,7 +5242,7 @@ class Ps extends _ {
|
|
|
5222
5242
|
}
|
|
5223
5243
|
initializeHandlers() {
|
|
5224
5244
|
const e = this.get("config");
|
|
5225
|
-
this.handlers.session = new
|
|
5245
|
+
this.handlers.session = new bs(
|
|
5226
5246
|
this.managers.storage,
|
|
5227
5247
|
this.managers.event
|
|
5228
5248
|
), this.handlers.session.startTracking();
|
|
@@ -5231,10 +5251,10 @@ class Ps extends _ {
|
|
|
5231
5251
|
this.set("suppressNextScroll", !1);
|
|
5232
5252
|
}, 500);
|
|
5233
5253
|
};
|
|
5234
|
-
if (this.handlers.pageView = new
|
|
5254
|
+
if (this.handlers.pageView = new Ls(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new As(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new Ms(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new Ps(this.managers.event), this.handlers.performance.startTracking().catch((s) => {
|
|
5235
5255
|
a("warn", "Failed to start performance tracking", { error: s });
|
|
5236
|
-
}), this.handlers.error = new ae(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new
|
|
5237
|
-
const s = new
|
|
5256
|
+
}), this.handlers.error = new ae(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new Cs(this.managers.event), this.handlers.viewport.startTracking()), e.integrations?.tracelog?.shopify) {
|
|
5257
|
+
const s = new Ns();
|
|
5238
5258
|
s.activate(), this.integrationInstances.shopifyCartLinker = s, this.emitter.on(se.EVENT, (i) => {
|
|
5239
5259
|
i.type === u.SESSION_START && s.onSessionChange();
|
|
5240
5260
|
});
|
|
@@ -5243,9 +5263,9 @@ class Ps extends _ {
|
|
|
5243
5263
|
}
|
|
5244
5264
|
const k = [], M = [];
|
|
5245
5265
|
let D = null, h = null, R = !1, T = !1, P = null;
|
|
5246
|
-
const
|
|
5266
|
+
const ks = async (r) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (T = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : h ? { sessionId: h.getSessionId() ?? "" } : (R && P || (R = !0, P = (async () => {
|
|
5247
5267
|
try {
|
|
5248
|
-
const e =
|
|
5268
|
+
const e = fs(r ?? {}), t = new Ds();
|
|
5249
5269
|
try {
|
|
5250
5270
|
k.forEach(({ event: o, callback: l }) => {
|
|
5251
5271
|
t.on(o, l);
|
|
@@ -5271,7 +5291,7 @@ const Ds = async (r) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
5271
5291
|
} finally {
|
|
5272
5292
|
R = !1, P = null;
|
|
5273
5293
|
}
|
|
5274
|
-
})()), P)),
|
|
5294
|
+
})()), P)), Vs = (r, e) => {
|
|
5275
5295
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5276
5296
|
if (!h)
|
|
5277
5297
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -5279,7 +5299,7 @@ const Ds = async (r) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
5279
5299
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
5280
5300
|
h.sendCustomEvent(r, e);
|
|
5281
5301
|
}
|
|
5282
|
-
},
|
|
5302
|
+
}, Us = (r, e) => {
|
|
5283
5303
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5284
5304
|
if (!h || R) {
|
|
5285
5305
|
k.push({ event: r, callback: e });
|
|
@@ -5287,7 +5307,7 @@ const Ds = async (r) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
5287
5307
|
}
|
|
5288
5308
|
h.on(r, e);
|
|
5289
5309
|
}
|
|
5290
|
-
},
|
|
5310
|
+
}, Fs = (r, e) => {
|
|
5291
5311
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5292
5312
|
if (!h) {
|
|
5293
5313
|
const t = k.findIndex((s) => s.event === r && s.callback === e);
|
|
@@ -5297,7 +5317,7 @@ const Ds = async (r) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
5297
5317
|
h.off(r, e);
|
|
5298
5318
|
}
|
|
5299
5319
|
};
|
|
5300
|
-
function
|
|
5320
|
+
function Hs(r, e) {
|
|
5301
5321
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5302
5322
|
if (typeof e != "function")
|
|
5303
5323
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
@@ -5311,7 +5331,7 @@ function Fs(r, e) {
|
|
|
5311
5331
|
r === "beforeSend" ? h.setTransformer("beforeSend", e) : h.setTransformer("beforeBatch", e);
|
|
5312
5332
|
}
|
|
5313
5333
|
}
|
|
5314
|
-
const
|
|
5334
|
+
const xs = (r) => {
|
|
5315
5335
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5316
5336
|
if (!h) {
|
|
5317
5337
|
const e = M.findIndex((t) => t.hook === r);
|
|
@@ -5322,7 +5342,7 @@ const Hs = (r) => {
|
|
|
5322
5342
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
5323
5343
|
h.removeTransformer(r);
|
|
5324
5344
|
}
|
|
5325
|
-
},
|
|
5345
|
+
}, $s = (r) => {
|
|
5326
5346
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5327
5347
|
if (typeof r != "function")
|
|
5328
5348
|
throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof r}`);
|
|
@@ -5334,7 +5354,7 @@ const Hs = (r) => {
|
|
|
5334
5354
|
throw new Error("[TraceLog] Cannot set custom headers while TraceLog is being destroyed");
|
|
5335
5355
|
h.setCustomHeaders(r);
|
|
5336
5356
|
}
|
|
5337
|
-
},
|
|
5357
|
+
}, Bs = () => {
|
|
5338
5358
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5339
5359
|
if (!h) {
|
|
5340
5360
|
D = null;
|
|
@@ -5344,7 +5364,7 @@ const Hs = (r) => {
|
|
|
5344
5364
|
throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
|
|
5345
5365
|
h.removeCustomHeaders();
|
|
5346
5366
|
}
|
|
5347
|
-
},
|
|
5367
|
+
}, Ws = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, Xs = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getSessionId(), Gs = () => {
|
|
5348
5368
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5349
5369
|
if (T)
|
|
5350
5370
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -5359,9 +5379,9 @@ const Hs = (r) => {
|
|
|
5359
5379
|
h = null, R = !1, P = null, k.length = 0, M.length = 0, D = null, T = !1, a("warn", "Error during destroy, forced cleanup completed", { error: r });
|
|
5360
5380
|
}
|
|
5361
5381
|
}
|
|
5362
|
-
}, Gs = (r) => {
|
|
5363
|
-
typeof window > "u" || typeof document > "u" || ss(r);
|
|
5364
5382
|
}, js = (r) => {
|
|
5383
|
+
typeof window > "u" || typeof document > "u" || rs(r);
|
|
5384
|
+
}, zs = (r) => {
|
|
5365
5385
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5366
5386
|
if (!h)
|
|
5367
5387
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -5369,7 +5389,7 @@ const Hs = (r) => {
|
|
|
5369
5389
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
5370
5390
|
h.updateGlobalMetadata(r);
|
|
5371
5391
|
}
|
|
5372
|
-
},
|
|
5392
|
+
}, Ks = (r) => {
|
|
5373
5393
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5374
5394
|
if (!h)
|
|
5375
5395
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -5377,7 +5397,7 @@ const Hs = (r) => {
|
|
|
5377
5397
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
5378
5398
|
h.mergeGlobalMetadata(r);
|
|
5379
5399
|
}
|
|
5380
|
-
},
|
|
5400
|
+
}, Qs = (r, e) => {
|
|
5381
5401
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5382
5402
|
if (!r || typeof r != "string" || r.trim().length === 0) {
|
|
5383
5403
|
a("warn", "identify() called with invalid userId");
|
|
@@ -5405,7 +5425,7 @@ const Hs = (r) => {
|
|
|
5405
5425
|
a("debug", "Failed to persist pre-init identity");
|
|
5406
5426
|
}
|
|
5407
5427
|
}
|
|
5408
|
-
},
|
|
5428
|
+
}, Ys = async () => {
|
|
5409
5429
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5410
5430
|
if (!h) {
|
|
5411
5431
|
try {
|
|
@@ -5418,23 +5438,23 @@ const Hs = (r) => {
|
|
|
5418
5438
|
throw new Error("[TraceLog] Cannot reset identity while TraceLog is being destroyed");
|
|
5419
5439
|
await h.resetIdentity();
|
|
5420
5440
|
}
|
|
5421
|
-
},
|
|
5422
|
-
init:
|
|
5423
|
-
event:
|
|
5424
|
-
on:
|
|
5425
|
-
off:
|
|
5426
|
-
setTransformer:
|
|
5427
|
-
removeTransformer:
|
|
5428
|
-
setCustomHeaders:
|
|
5429
|
-
removeCustomHeaders:
|
|
5430
|
-
isInitialized:
|
|
5431
|
-
getSessionId:
|
|
5432
|
-
destroy:
|
|
5433
|
-
setQaMode:
|
|
5434
|
-
updateGlobalMetadata:
|
|
5435
|
-
mergeGlobalMetadata:
|
|
5436
|
-
identify:
|
|
5437
|
-
resetIdentity:
|
|
5441
|
+
}, br = {
|
|
5442
|
+
init: ks,
|
|
5443
|
+
event: Vs,
|
|
5444
|
+
on: Us,
|
|
5445
|
+
off: Fs,
|
|
5446
|
+
setTransformer: Hs,
|
|
5447
|
+
removeTransformer: xs,
|
|
5448
|
+
setCustomHeaders: $s,
|
|
5449
|
+
removeCustomHeaders: Bs,
|
|
5450
|
+
isInitialized: Ws,
|
|
5451
|
+
getSessionId: Xs,
|
|
5452
|
+
destroy: Gs,
|
|
5453
|
+
setQaMode: js,
|
|
5454
|
+
updateGlobalMetadata: zs,
|
|
5455
|
+
mergeGlobalMetadata: Ks,
|
|
5456
|
+
identify: Qs,
|
|
5457
|
+
resetIdentity: Ys
|
|
5438
5458
|
};
|
|
5439
5459
|
var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
5440
5460
|
addEventListener("pageshow", (function(e) {
|
|
@@ -5486,10 +5506,10 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5486
5506
|
}, F = -1, et = function() {
|
|
5487
5507
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
5488
5508
|
}, ce = function(r) {
|
|
5489
|
-
document.visibilityState === "hidden" && F > -1 && (F = r.type === "visibilitychange" ? r.timeStamp : 0,
|
|
5509
|
+
document.visibilityState === "hidden" && F > -1 && (F = r.type === "visibilitychange" ? r.timeStamp : 0, qs());
|
|
5490
5510
|
}, tt = function() {
|
|
5491
5511
|
addEventListener("visibilitychange", ce, !0), addEventListener("prerenderingchange", ce, !0);
|
|
5492
|
-
},
|
|
5512
|
+
}, qs = function() {
|
|
5493
5513
|
removeEventListener("visibilitychange", ce, !0), removeEventListener("prerenderingchange", ce, !0);
|
|
5494
5514
|
}, ke = function() {
|
|
5495
5515
|
return F < 0 && (F = et(), tt(), V((function() {
|
|
@@ -5516,7 +5536,7 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5516
5536
|
}));
|
|
5517
5537
|
})));
|
|
5518
5538
|
}));
|
|
5519
|
-
}, Me = [0.1, 0.25],
|
|
5539
|
+
}, Me = [0.1, 0.25], Js = function(r, e) {
|
|
5520
5540
|
e = e || {}, St(ue((function() {
|
|
5521
5541
|
var t, s = y("CLS", 0), i = 0, n = [], o = function(c) {
|
|
5522
5542
|
c.forEach((function(d) {
|
|
@@ -5534,19 +5554,19 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5534
5554
|
}));
|
|
5535
5555
|
})), setTimeout(t, 0));
|
|
5536
5556
|
})));
|
|
5537
|
-
}, Tt = 0, pe = 1 / 0, J = 0,
|
|
5557
|
+
}, Tt = 0, pe = 1 / 0, J = 0, Zs = function(r) {
|
|
5538
5558
|
r.forEach((function(e) {
|
|
5539
5559
|
e.interactionId && (pe = Math.min(pe, e.interactionId), J = Math.max(J, e.interactionId), Tt = J ? (J - pe) / 7 + 1 : 0);
|
|
5540
5560
|
}));
|
|
5541
5561
|
}, It = function() {
|
|
5542
5562
|
return Le ? Tt : performance.interactionCount || 0;
|
|
5543
|
-
},
|
|
5544
|
-
"interactionCount" in performance || Le || (Le = H("event",
|
|
5545
|
-
}, L = [], te = /* @__PURE__ */ new Map(), vt = 0,
|
|
5563
|
+
}, er = function() {
|
|
5564
|
+
"interactionCount" in performance || Le || (Le = H("event", Zs, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
5565
|
+
}, L = [], te = /* @__PURE__ */ new Map(), vt = 0, tr = function() {
|
|
5546
5566
|
var r = Math.min(L.length - 1, Math.floor((It() - vt) / 50));
|
|
5547
5567
|
return L[r];
|
|
5548
|
-
},
|
|
5549
|
-
if (
|
|
5568
|
+
}, sr = [], rr = function(r) {
|
|
5569
|
+
if (sr.forEach((function(i) {
|
|
5550
5570
|
return i(r);
|
|
5551
5571
|
})), r.interactionId || r.entryType === "first-input") {
|
|
5552
5572
|
var e = L[L.length - 1], t = te.get(r.interactionId);
|
|
@@ -5566,14 +5586,14 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5566
5586
|
}, _t = function(r) {
|
|
5567
5587
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
5568
5588
|
return r = ue(r), document.visibilityState === "hidden" ? r() : (t = e(r), z(r)), t;
|
|
5569
|
-
}, Ce = [200, 500],
|
|
5589
|
+
}, Ce = [200, 500], ir = function(r, e) {
|
|
5570
5590
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, K((function() {
|
|
5571
5591
|
var t;
|
|
5572
|
-
|
|
5592
|
+
er();
|
|
5573
5593
|
var s, i = y("INP"), n = function(l) {
|
|
5574
5594
|
_t((function() {
|
|
5575
|
-
l.forEach(
|
|
5576
|
-
var c =
|
|
5595
|
+
l.forEach(rr);
|
|
5596
|
+
var c = tr();
|
|
5577
5597
|
c && c.latency !== i.value && (i.value = c.latency, i.entries = c.entries, s());
|
|
5578
5598
|
}));
|
|
5579
5599
|
}, o = H("event", n, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
@@ -5583,7 +5603,7 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5583
5603
|
vt = It(), L.length = 0, te.clear(), i = y("INP"), s = w(r, i, Ce, e.reportAllChanges);
|
|
5584
5604
|
})));
|
|
5585
5605
|
})));
|
|
5586
|
-
}, Re = [2500, 4e3], Se = {},
|
|
5606
|
+
}, Re = [2500, 4e3], Se = {}, nr = function(r, e) {
|
|
5587
5607
|
e = e || {}, K((function() {
|
|
5588
5608
|
var t, s = ke(), i = y("LCP"), n = function(c) {
|
|
5589
5609
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(d) {
|
|
@@ -5606,31 +5626,31 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5606
5626
|
}));
|
|
5607
5627
|
}
|
|
5608
5628
|
}));
|
|
5609
|
-
}, Ne = [800, 1800],
|
|
5629
|
+
}, Ne = [800, 1800], or = function r(e) {
|
|
5610
5630
|
document.prerendering ? K((function() {
|
|
5611
5631
|
return r(e);
|
|
5612
5632
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
5613
5633
|
return r(e);
|
|
5614
5634
|
}), !0) : setTimeout(e, 0);
|
|
5615
|
-
},
|
|
5635
|
+
}, ar = function(r, e) {
|
|
5616
5636
|
e = e || {};
|
|
5617
5637
|
var t = y("TTFB"), s = w(r, t, Ne, e.reportAllChanges);
|
|
5618
|
-
|
|
5638
|
+
or((function() {
|
|
5619
5639
|
var i = Pe();
|
|
5620
5640
|
i && (t.value = Math.max(i.responseStart - de(), 0), t.entries = [i], s(!0), V((function() {
|
|
5621
5641
|
t = y("TTFB", 0), (s = w(r, t, Ne, e.reportAllChanges))(!0);
|
|
5622
5642
|
})));
|
|
5623
5643
|
}));
|
|
5624
|
-
}, W = { passive: !0, capture: !0 },
|
|
5644
|
+
}, W = { passive: !0, capture: !0 }, lr = /* @__PURE__ */ new Date(), st = function(r, e) {
|
|
5625
5645
|
C || (C = e, G = r, Et = /* @__PURE__ */ new Date(), wt(removeEventListener), yt());
|
|
5626
5646
|
}, yt = function() {
|
|
5627
|
-
if (G >= 0 && G < Et -
|
|
5647
|
+
if (G >= 0 && G < Et - lr) {
|
|
5628
5648
|
var r = { entryType: "first-input", name: C.type, target: C.target, cancelable: C.cancelable, startTime: C.timeStamp, processingStart: C.timeStamp + G };
|
|
5629
5649
|
le.forEach((function(e) {
|
|
5630
5650
|
e(r);
|
|
5631
5651
|
})), le = [];
|
|
5632
5652
|
}
|
|
5633
|
-
},
|
|
5653
|
+
}, cr = function(r) {
|
|
5634
5654
|
if (r.cancelable) {
|
|
5635
5655
|
var e = (r.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - r.timeStamp;
|
|
5636
5656
|
r.type == "pointerdown" ? (function(t, s) {
|
|
@@ -5646,9 +5666,9 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5646
5666
|
}
|
|
5647
5667
|
}, wt = function(r) {
|
|
5648
5668
|
["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
|
|
5649
|
-
return r(e,
|
|
5669
|
+
return r(e, cr, W);
|
|
5650
5670
|
}));
|
|
5651
|
-
}, Oe = [100, 300],
|
|
5671
|
+
}, Oe = [100, 300], dr = function(r, e) {
|
|
5652
5672
|
e = e || {}, K((function() {
|
|
5653
5673
|
var t, s = ke(), i = y("FID"), n = function(c) {
|
|
5654
5674
|
c.startTime < s.firstHiddenTime && (i.value = c.processingStart - c.startTime, i.entries.push(c), t(!0));
|
|
@@ -5663,7 +5683,7 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5663
5683
|
})));
|
|
5664
5684
|
}));
|
|
5665
5685
|
};
|
|
5666
|
-
const
|
|
5686
|
+
const ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5667
5687
|
__proto__: null,
|
|
5668
5688
|
CLSThresholds: Me,
|
|
5669
5689
|
FCPThresholds: Ae,
|
|
@@ -5671,31 +5691,31 @@ const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5671
5691
|
INPThresholds: Ce,
|
|
5672
5692
|
LCPThresholds: Re,
|
|
5673
5693
|
TTFBThresholds: Ne,
|
|
5674
|
-
onCLS:
|
|
5694
|
+
onCLS: Js,
|
|
5675
5695
|
onFCP: St,
|
|
5676
|
-
onFID:
|
|
5677
|
-
onINP:
|
|
5678
|
-
onLCP:
|
|
5679
|
-
onTTFB:
|
|
5696
|
+
onFID: dr,
|
|
5697
|
+
onINP: ir,
|
|
5698
|
+
onLCP: nr,
|
|
5699
|
+
onTTFB: ar
|
|
5680
5700
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5681
5701
|
export {
|
|
5682
5702
|
m as AppConfigValidationError,
|
|
5683
|
-
|
|
5703
|
+
hr as DEFAULT_SESSION_TIMEOUT,
|
|
5684
5704
|
_e as DEFAULT_WEB_VITALS_MODE,
|
|
5685
5705
|
A as DeviceType,
|
|
5686
5706
|
se as EmitterEvent,
|
|
5687
5707
|
B as ErrorType,
|
|
5688
5708
|
u as EventType,
|
|
5689
|
-
|
|
5709
|
+
yr as InitializationTimeoutError,
|
|
5690
5710
|
N as IntegrationValidationError,
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5711
|
+
Ir as MAX_ARRAY_LENGTH,
|
|
5712
|
+
Er as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
5713
|
+
gr as MAX_CUSTOM_EVENT_KEYS,
|
|
5714
|
+
fr as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
5715
|
+
mr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
5716
|
+
pr as MAX_NESTED_OBJECT_KEYS,
|
|
5717
|
+
Sr as MAX_STRING_LENGTH,
|
|
5718
|
+
Tr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
5699
5719
|
ne as Mode,
|
|
5700
5720
|
at as PII_PATTERNS,
|
|
5701
5721
|
O as PermanentError,
|
|
@@ -5706,11 +5726,11 @@ export {
|
|
|
5706
5726
|
$ as SpecialApiUrl,
|
|
5707
5727
|
ie as TimeoutError,
|
|
5708
5728
|
j as TraceLogValidationError,
|
|
5709
|
-
|
|
5729
|
+
wr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5710
5730
|
Ke as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5711
|
-
|
|
5731
|
+
Yt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5712
5732
|
Qe as getWebVitalsThresholds,
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5733
|
+
vr as isPrimaryScrollEvent,
|
|
5734
|
+
_r as isSecondaryScrollEvent,
|
|
5735
|
+
br as tracelog
|
|
5716
5736
|
};
|