@tracelog/lib 2.8.4 → 2.8.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 +185 -177
- 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) {
|
|
@@ -1197,21 +1198,6 @@ class Ze extends _ {
|
|
|
1197
1198
|
}
|
|
1198
1199
|
), !0) : this.sendQueueSyncInternal(e);
|
|
1199
1200
|
}
|
|
1200
|
-
/**
|
|
1201
|
-
* Persists events to localStorage for recovery without sending.
|
|
1202
|
-
*
|
|
1203
|
-
* Used when an async send is already in-flight to avoid sending the same
|
|
1204
|
-
* events through two paths (fetch + sendBeacon) with different idempotency tokens.
|
|
1205
|
-
* `ensureBatchMetadata()` assigns a stable token before persisting.
|
|
1206
|
-
* On next page load, `recoverPersistedEvents()` sends with the persisted token.
|
|
1207
|
-
*
|
|
1208
|
-
* @param body - Event queue to persist
|
|
1209
|
-
*/
|
|
1210
|
-
persistForRecovery(e) {
|
|
1211
|
-
if (this.shouldSkipSend()) return;
|
|
1212
|
-
const t = this.ensureBatchMetadata(e);
|
|
1213
|
-
this.persistEventsWithFailureCount(t, 0, !0);
|
|
1214
|
-
}
|
|
1215
1201
|
/**
|
|
1216
1202
|
* Sends events asynchronously using `fetch()` API with automatic persistence on failure.
|
|
1217
1203
|
*
|
|
@@ -1387,7 +1373,7 @@ class Ze extends _ {
|
|
|
1387
1373
|
const t = this.transformers.beforeSend;
|
|
1388
1374
|
if (!t)
|
|
1389
1375
|
return e;
|
|
1390
|
-
const s =
|
|
1376
|
+
const s = Ss(
|
|
1391
1377
|
e.events,
|
|
1392
1378
|
t,
|
|
1393
1379
|
this.integrationId || "SenderManager"
|
|
@@ -1618,8 +1604,13 @@ class Ze extends _ {
|
|
|
1618
1604
|
"Content-Type": "application/json"
|
|
1619
1605
|
}
|
|
1620
1606
|
});
|
|
1621
|
-
if (!l.ok)
|
|
1622
|
-
|
|
1607
|
+
if (!l.ok) {
|
|
1608
|
+
if (l.status >= 400 && l.status < 500 && l.status !== 408 && l.status !== 429) {
|
|
1609
|
+
const d = await this.readTraceLogErrorCode(l), f = d ? `HTTP ${l.status}: ${l.statusText} (${d})` : `HTTP ${l.status}: ${l.statusText}`;
|
|
1610
|
+
throw new O(f, l.status, d);
|
|
1611
|
+
}
|
|
1612
|
+
throw l.status === 429 ? new re(`HTTP 429: ${l.statusText}`) : new Error(`HTTP ${l.status}: ${l.statusText}`);
|
|
1613
|
+
}
|
|
1623
1614
|
return l;
|
|
1624
1615
|
} catch (o) {
|
|
1625
1616
|
throw o instanceof O ? o : i ? new ie("Request timed out") : o;
|
|
@@ -1627,6 +1618,26 @@ class Ze extends _ {
|
|
|
1627
1618
|
clearTimeout(n), this.pendingControllers.delete(s);
|
|
1628
1619
|
}
|
|
1629
1620
|
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Best-effort extraction of an application `code` from a 4xx response body.
|
|
1623
|
+
*
|
|
1624
|
+
* Used purely for logging context (e.g. `PLAN_LIMIT_EXCEEDED`, `PROJECT_READ_ONLY`).
|
|
1625
|
+
* Status alone already determines retry semantics, so this never affects the
|
|
1626
|
+
* retry/persistence decision. Bounded to {@link MAX_RESPONSE_CODE_LENGTH} chars
|
|
1627
|
+
* to keep noisy/untrusted payloads out of logs without coupling the lib to the
|
|
1628
|
+
* API's evolving code catalogue.
|
|
1629
|
+
*
|
|
1630
|
+
* Only string `code` values are accepted — numeric or object codes are
|
|
1631
|
+
* intentionally dropped to keep the log shape stable.
|
|
1632
|
+
*/
|
|
1633
|
+
async readTraceLogErrorCode(e) {
|
|
1634
|
+
try {
|
|
1635
|
+
const t = await e.clone().json();
|
|
1636
|
+
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <= Qt)
|
|
1637
|
+
return t.code;
|
|
1638
|
+
} catch {
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1630
1641
|
/**
|
|
1631
1642
|
* Internal synchronous send logic using navigator.sendBeacon() for page unload scenarios.
|
|
1632
1643
|
*
|
|
@@ -1708,7 +1719,7 @@ class Ze extends _ {
|
|
|
1708
1719
|
idempotency_token: e._metadata?.idempotency_token ?? this.computeContentToken(e),
|
|
1709
1720
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1710
1721
|
timestamp: t,
|
|
1711
|
-
client_version:
|
|
1722
|
+
client_version: es
|
|
1712
1723
|
}
|
|
1713
1724
|
};
|
|
1714
1725
|
return {
|
|
@@ -1882,13 +1893,13 @@ class Ze extends _ {
|
|
|
1882
1893
|
return typeof navigator < "u" && typeof navigator.sendBeacon == "function";
|
|
1883
1894
|
}
|
|
1884
1895
|
logPermanentError(e, t) {
|
|
1885
|
-
const s = Date.now()
|
|
1886
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.
|
|
1887
|
-
data: { status: t.statusCode, message: t.message }
|
|
1888
|
-
}), this.lastPermanentErrorLog = {
|
|
1896
|
+
const s = Date.now(), i = `${t.statusCode ?? "unknown"}:${t.responseCode ?? ""}`;
|
|
1897
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== i || s - this.lastPermanentErrorLog.timestamp >= Kt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1898
|
+
data: { status: t.statusCode, code: t.responseCode, message: t.message }
|
|
1899
|
+
}), this.lastPermanentErrorLog = { key: i, timestamp: s });
|
|
1889
1900
|
}
|
|
1890
1901
|
}
|
|
1891
|
-
class
|
|
1902
|
+
class Ts extends _ {
|
|
1892
1903
|
bootTime;
|
|
1893
1904
|
bootTimestamp;
|
|
1894
1905
|
hasPerformanceNow;
|
|
@@ -2037,8 +2048,8 @@ class Ss extends _ {
|
|
|
2037
2048
|
};
|
|
2038
2049
|
}
|
|
2039
2050
|
}
|
|
2040
|
-
const
|
|
2041
|
-
class
|
|
2051
|
+
const Is = new Set(Object.values(u));
|
|
2052
|
+
class vs extends _ {
|
|
2042
2053
|
dataSenders;
|
|
2043
2054
|
emitter;
|
|
2044
2055
|
transformers;
|
|
@@ -2077,7 +2088,7 @@ class Is extends _ {
|
|
|
2077
2088
|
* @param fetchCredentials - Fetch credentials mode for custom backend. @default 'include'
|
|
2078
2089
|
*/
|
|
2079
2090
|
constructor(e, t = null, s = {}, i = {}, n, o = "include") {
|
|
2080
|
-
super(), this.emitter = t, this.transformers = s, this.timeManager = new
|
|
2091
|
+
super(), this.emitter = t, this.transformers = s, this.timeManager = new Ts(), this.dataSenders = [];
|
|
2081
2092
|
const l = this.get("collectApiUrls");
|
|
2082
2093
|
l?.saas && this.dataSenders.push(new Ze(e, "saas", l.saas, s)), l?.custom && this.dataSenders.push(
|
|
2083
2094
|
new Ze(
|
|
@@ -2208,7 +2219,7 @@ class Is extends _ {
|
|
|
2208
2219
|
a("error", "Event type is required - event will be ignored");
|
|
2209
2220
|
return;
|
|
2210
2221
|
}
|
|
2211
|
-
if (!
|
|
2222
|
+
if (!Is.has(e)) {
|
|
2212
2223
|
a("error", "Invalid event type - event will be ignored", {
|
|
2213
2224
|
data: { type: e }
|
|
2214
2225
|
});
|
|
@@ -2594,13 +2605,10 @@ class Is extends _ {
|
|
|
2594
2605
|
const t = this.buildEventsPayload(), s = [...this.eventsQueue], i = s.map((n) => n.id);
|
|
2595
2606
|
if (this.dataSenders.length === 0)
|
|
2596
2607
|
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", {
|
|
2608
|
+
if (e && this.sendInProgress)
|
|
2609
|
+
return a("debug", "Sync flush skipped: async send already in-flight, trusting fetch to deliver", {
|
|
2601
2610
|
data: { eventCount: i.length }
|
|
2602
2611
|
}), !0;
|
|
2603
|
-
}
|
|
2604
2612
|
if (e) {
|
|
2605
2613
|
const o = this.dataSenders.map((l) => l.sendEventsQueueSync(t)).some((l) => l);
|
|
2606
2614
|
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 +2693,7 @@ class Is extends _ {
|
|
|
2685
2693
|
});
|
|
2686
2694
|
const n = this.get("sessionReferrer"), o = this.get("sessionUtm");
|
|
2687
2695
|
let l = {
|
|
2688
|
-
id:
|
|
2696
|
+
id: os(),
|
|
2689
2697
|
type: e.type,
|
|
2690
2698
|
page_url: t,
|
|
2691
2699
|
timestamp: s,
|
|
@@ -3005,7 +3013,7 @@ class Is extends _ {
|
|
|
3005
3013
|
}
|
|
3006
3014
|
}
|
|
3007
3015
|
}
|
|
3008
|
-
class
|
|
3016
|
+
class _s {
|
|
3009
3017
|
/**
|
|
3010
3018
|
* Gets or creates a unique user ID.
|
|
3011
3019
|
*
|
|
@@ -3030,8 +3038,8 @@ class vs {
|
|
|
3030
3038
|
return e.setItem(Te, s), s;
|
|
3031
3039
|
}
|
|
3032
3040
|
}
|
|
3033
|
-
const
|
|
3034
|
-
class
|
|
3041
|
+
const ys = /^\d{13}-[a-z0-9]{9}$/;
|
|
3042
|
+
class ws extends _ {
|
|
3035
3043
|
storageManager;
|
|
3036
3044
|
eventManager;
|
|
3037
3045
|
projectId;
|
|
@@ -3077,7 +3085,7 @@ class ys extends _ {
|
|
|
3077
3085
|
const e = this.loadStoredSession();
|
|
3078
3086
|
if (!e)
|
|
3079
3087
|
return null;
|
|
3080
|
-
if (!
|
|
3088
|
+
if (!ys.test(e.id))
|
|
3081
3089
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
3082
3090
|
data: { sessionId: e.id }
|
|
3083
3091
|
}), this.clearStoredSession(), null;
|
|
@@ -3362,7 +3370,7 @@ class ys extends _ {
|
|
|
3362
3370
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
3363
3371
|
}
|
|
3364
3372
|
}
|
|
3365
|
-
class
|
|
3373
|
+
class bs extends _ {
|
|
3366
3374
|
eventManager;
|
|
3367
3375
|
storageManager;
|
|
3368
3376
|
sessionManager = null;
|
|
@@ -3397,7 +3405,7 @@ class ws extends _ {
|
|
|
3397
3405
|
}
|
|
3398
3406
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
3399
3407
|
try {
|
|
3400
|
-
this.sessionManager = new
|
|
3408
|
+
this.sessionManager = new ws(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
3401
3409
|
} catch (s) {
|
|
3402
3410
|
if (this.sessionManager) {
|
|
3403
3411
|
try {
|
|
@@ -3450,7 +3458,7 @@ class ws extends _ {
|
|
|
3450
3458
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
3451
3459
|
}
|
|
3452
3460
|
}
|
|
3453
|
-
class
|
|
3461
|
+
class Ls extends _ {
|
|
3454
3462
|
eventManager;
|
|
3455
3463
|
onTrack;
|
|
3456
3464
|
originalPushState;
|
|
@@ -3526,7 +3534,7 @@ class bs extends _ {
|
|
|
3526
3534
|
};
|
|
3527
3535
|
}
|
|
3528
3536
|
}
|
|
3529
|
-
class
|
|
3537
|
+
class As extends _ {
|
|
3530
3538
|
eventManager;
|
|
3531
3539
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3532
3540
|
clickHandler;
|
|
@@ -3783,7 +3791,7 @@ class Ls extends _ {
|
|
|
3783
3791
|
};
|
|
3784
3792
|
}
|
|
3785
3793
|
}
|
|
3786
|
-
class
|
|
3794
|
+
class Ms extends _ {
|
|
3787
3795
|
eventManager;
|
|
3788
3796
|
containers = [];
|
|
3789
3797
|
limitWarningLogged = !1;
|
|
@@ -4011,7 +4019,7 @@ class As extends _ {
|
|
|
4011
4019
|
e.isPrimary = t;
|
|
4012
4020
|
}
|
|
4013
4021
|
}
|
|
4014
|
-
class
|
|
4022
|
+
class Cs extends _ {
|
|
4015
4023
|
eventManager;
|
|
4016
4024
|
trackedElements = /* @__PURE__ */ new Map();
|
|
4017
4025
|
observer = null;
|
|
@@ -4172,8 +4180,8 @@ class Ms extends _ {
|
|
|
4172
4180
|
});
|
|
4173
4181
|
}
|
|
4174
4182
|
}
|
|
4175
|
-
const
|
|
4176
|
-
class
|
|
4183
|
+
const Rs = "tracelog_session_id";
|
|
4184
|
+
class Ns extends _ {
|
|
4177
4185
|
visibilityHandler = null;
|
|
4178
4186
|
lastSyncedSessionId = null;
|
|
4179
4187
|
activate() {
|
|
@@ -4195,7 +4203,7 @@ class Rs extends _ {
|
|
|
4195
4203
|
fetch("/cart/update.js", {
|
|
4196
4204
|
method: "POST",
|
|
4197
4205
|
headers: { "Content-Type": "application/json" },
|
|
4198
|
-
body: JSON.stringify({ attributes: { [
|
|
4206
|
+
body: JSON.stringify({ attributes: { [Rs]: e } }),
|
|
4199
4207
|
credentials: "same-origin"
|
|
4200
4208
|
}).then((t) => {
|
|
4201
4209
|
t.ok || (this.lastSyncedSessionId = null, a("debug", "Shopify cart attribute update failed", { data: { status: t.status } }));
|
|
@@ -4215,7 +4223,7 @@ class Rs extends _ {
|
|
|
4215
4223
|
this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null);
|
|
4216
4224
|
}
|
|
4217
4225
|
}
|
|
4218
|
-
class
|
|
4226
|
+
class Os {
|
|
4219
4227
|
storage;
|
|
4220
4228
|
sessionStorageRef;
|
|
4221
4229
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -4498,7 +4506,7 @@ class Ns {
|
|
|
4498
4506
|
this.fallbackSessionStorage.delete(e);
|
|
4499
4507
|
}
|
|
4500
4508
|
}
|
|
4501
|
-
class
|
|
4509
|
+
class Ps extends _ {
|
|
4502
4510
|
eventManager;
|
|
4503
4511
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
4504
4512
|
navigationHistory = [];
|
|
@@ -4597,7 +4605,7 @@ class Os extends _ {
|
|
|
4597
4605
|
}
|
|
4598
4606
|
async initWebVitals() {
|
|
4599
4607
|
try {
|
|
4600
|
-
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: i, onINP: n } = await Promise.resolve().then(() =>
|
|
4608
|
+
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: i, onINP: n } = await Promise.resolve().then(() => ur), o = (l) => (c) => {
|
|
4601
4609
|
const d = Number(c.value.toFixed(2));
|
|
4602
4610
|
this.sendVital({ type: l, value: d });
|
|
4603
4611
|
};
|
|
@@ -4624,7 +4632,7 @@ class Os extends _ {
|
|
|
4624
4632
|
const t = e.getEntries();
|
|
4625
4633
|
for (const s of t) {
|
|
4626
4634
|
const i = Number(s.duration.toFixed(2)), n = Date.now();
|
|
4627
|
-
n - this.lastLongTaskSentAt >=
|
|
4635
|
+
n - this.lastLongTaskSentAt >= qt && (this.shouldSendVital("LONG_TASK", i) && this.trackWebVital("LONG_TASK", i), this.lastLongTaskSentAt = n);
|
|
4628
4636
|
}
|
|
4629
4637
|
},
|
|
4630
4638
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4640,7 +4648,7 @@ class Os extends _ {
|
|
|
4640
4648
|
return;
|
|
4641
4649
|
if (s)
|
|
4642
4650
|
s.add(e.type);
|
|
4643
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4651
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Jt) {
|
|
4644
4652
|
const n = this.navigationHistory.shift();
|
|
4645
4653
|
n && this.reportedByNav.delete(n);
|
|
4646
4654
|
}
|
|
@@ -4861,11 +4869,11 @@ class ae extends _ {
|
|
|
4861
4869
|
}
|
|
4862
4870
|
}
|
|
4863
4871
|
}
|
|
4864
|
-
class
|
|
4872
|
+
class Ds extends _ {
|
|
4865
4873
|
isInitialized = !1;
|
|
4866
4874
|
suppressNextScrollTimer = null;
|
|
4867
4875
|
pageUnloadHandler = null;
|
|
4868
|
-
emitter = new
|
|
4876
|
+
emitter = new ps();
|
|
4869
4877
|
transformers = {};
|
|
4870
4878
|
customHeadersProvider;
|
|
4871
4879
|
managers = {};
|
|
@@ -4884,11 +4892,11 @@ class Ps extends _ {
|
|
|
4884
4892
|
async init(e = {}) {
|
|
4885
4893
|
if (this.isInitialized)
|
|
4886
4894
|
return { sessionId: this.get("sessionId") ?? "" };
|
|
4887
|
-
this.managers.storage = new
|
|
4895
|
+
this.managers.storage = new Os();
|
|
4888
4896
|
try {
|
|
4889
4897
|
this.setupState(e);
|
|
4890
4898
|
const t = e.integrations?.custom?.headers ?? {}, s = e.integrations?.custom?.fetchCredentials ?? "include";
|
|
4891
|
-
return this.managers.event = new
|
|
4899
|
+
return this.managers.event = new vs(
|
|
4892
4900
|
this.managers.storage,
|
|
4893
4901
|
this.emitter,
|
|
4894
4902
|
this.transformers,
|
|
@@ -4918,7 +4926,7 @@ class Ps extends _ {
|
|
|
4918
4926
|
}
|
|
4919
4927
|
let s = t;
|
|
4920
4928
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (s = Object.assign({}, t));
|
|
4921
|
-
const { valid: i, error: n, sanitizedMetadata: o } =
|
|
4929
|
+
const { valid: i, error: n, sanitizedMetadata: o } = Es(e, s);
|
|
4922
4930
|
if (!i) {
|
|
4923
4931
|
if (this.get("mode") === ne.QA)
|
|
4924
4932
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${n}`);
|
|
@@ -4988,14 +4996,14 @@ class Ps extends _ {
|
|
|
4988
4996
|
}
|
|
4989
4997
|
setupState(e = {}) {
|
|
4990
4998
|
this.set("config", e);
|
|
4991
|
-
const t =
|
|
4999
|
+
const t = _s.getId(this.managers.storage);
|
|
4992
5000
|
this.set("userId", t);
|
|
4993
|
-
const s =
|
|
5001
|
+
const s = ls(e);
|
|
4994
5002
|
this.set("collectApiUrls", s);
|
|
4995
5003
|
const i = Xt();
|
|
4996
5004
|
this.set("device", i);
|
|
4997
5005
|
const n = ye(window.location.href, e.sensitiveQueryParams);
|
|
4998
|
-
this.set("pageUrl", n),
|
|
5006
|
+
this.set("pageUrl", n), ss() && this.set("mode", ne.QA);
|
|
4999
5007
|
}
|
|
5000
5008
|
/**
|
|
5001
5009
|
* Returns the current configuration object.
|
|
@@ -5222,7 +5230,7 @@ class Ps extends _ {
|
|
|
5222
5230
|
}
|
|
5223
5231
|
initializeHandlers() {
|
|
5224
5232
|
const e = this.get("config");
|
|
5225
|
-
this.handlers.session = new
|
|
5233
|
+
this.handlers.session = new bs(
|
|
5226
5234
|
this.managers.storage,
|
|
5227
5235
|
this.managers.event
|
|
5228
5236
|
), this.handlers.session.startTracking();
|
|
@@ -5231,10 +5239,10 @@ class Ps extends _ {
|
|
|
5231
5239
|
this.set("suppressNextScroll", !1);
|
|
5232
5240
|
}, 500);
|
|
5233
5241
|
};
|
|
5234
|
-
if (this.handlers.pageView = new
|
|
5242
|
+
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
5243
|
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
|
|
5244
|
+
}), 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) {
|
|
5245
|
+
const s = new Ns();
|
|
5238
5246
|
s.activate(), this.integrationInstances.shopifyCartLinker = s, this.emitter.on(se.EVENT, (i) => {
|
|
5239
5247
|
i.type === u.SESSION_START && s.onSessionChange();
|
|
5240
5248
|
});
|
|
@@ -5243,9 +5251,9 @@ class Ps extends _ {
|
|
|
5243
5251
|
}
|
|
5244
5252
|
const k = [], M = [];
|
|
5245
5253
|
let D = null, h = null, R = !1, T = !1, P = null;
|
|
5246
|
-
const
|
|
5254
|
+
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
5255
|
try {
|
|
5248
|
-
const e =
|
|
5256
|
+
const e = fs(r ?? {}), t = new Ds();
|
|
5249
5257
|
try {
|
|
5250
5258
|
k.forEach(({ event: o, callback: l }) => {
|
|
5251
5259
|
t.on(o, l);
|
|
@@ -5271,7 +5279,7 @@ const Ds = async (r) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
5271
5279
|
} finally {
|
|
5272
5280
|
R = !1, P = null;
|
|
5273
5281
|
}
|
|
5274
|
-
})()), P)),
|
|
5282
|
+
})()), P)), Vs = (r, e) => {
|
|
5275
5283
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5276
5284
|
if (!h)
|
|
5277
5285
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -5279,7 +5287,7 @@ const Ds = async (r) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
5279
5287
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
5280
5288
|
h.sendCustomEvent(r, e);
|
|
5281
5289
|
}
|
|
5282
|
-
},
|
|
5290
|
+
}, Us = (r, e) => {
|
|
5283
5291
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5284
5292
|
if (!h || R) {
|
|
5285
5293
|
k.push({ event: r, callback: e });
|
|
@@ -5287,7 +5295,7 @@ const Ds = async (r) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
5287
5295
|
}
|
|
5288
5296
|
h.on(r, e);
|
|
5289
5297
|
}
|
|
5290
|
-
},
|
|
5298
|
+
}, Fs = (r, e) => {
|
|
5291
5299
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5292
5300
|
if (!h) {
|
|
5293
5301
|
const t = k.findIndex((s) => s.event === r && s.callback === e);
|
|
@@ -5297,7 +5305,7 @@ const Ds = async (r) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
5297
5305
|
h.off(r, e);
|
|
5298
5306
|
}
|
|
5299
5307
|
};
|
|
5300
|
-
function
|
|
5308
|
+
function Hs(r, e) {
|
|
5301
5309
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5302
5310
|
if (typeof e != "function")
|
|
5303
5311
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
@@ -5311,7 +5319,7 @@ function Fs(r, e) {
|
|
|
5311
5319
|
r === "beforeSend" ? h.setTransformer("beforeSend", e) : h.setTransformer("beforeBatch", e);
|
|
5312
5320
|
}
|
|
5313
5321
|
}
|
|
5314
|
-
const
|
|
5322
|
+
const xs = (r) => {
|
|
5315
5323
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5316
5324
|
if (!h) {
|
|
5317
5325
|
const e = M.findIndex((t) => t.hook === r);
|
|
@@ -5322,7 +5330,7 @@ const Hs = (r) => {
|
|
|
5322
5330
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
5323
5331
|
h.removeTransformer(r);
|
|
5324
5332
|
}
|
|
5325
|
-
},
|
|
5333
|
+
}, $s = (r) => {
|
|
5326
5334
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5327
5335
|
if (typeof r != "function")
|
|
5328
5336
|
throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof r}`);
|
|
@@ -5334,7 +5342,7 @@ const Hs = (r) => {
|
|
|
5334
5342
|
throw new Error("[TraceLog] Cannot set custom headers while TraceLog is being destroyed");
|
|
5335
5343
|
h.setCustomHeaders(r);
|
|
5336
5344
|
}
|
|
5337
|
-
},
|
|
5345
|
+
}, Bs = () => {
|
|
5338
5346
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5339
5347
|
if (!h) {
|
|
5340
5348
|
D = null;
|
|
@@ -5344,7 +5352,7 @@ const Hs = (r) => {
|
|
|
5344
5352
|
throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
|
|
5345
5353
|
h.removeCustomHeaders();
|
|
5346
5354
|
}
|
|
5347
|
-
},
|
|
5355
|
+
}, Ws = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, Xs = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getSessionId(), Gs = () => {
|
|
5348
5356
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5349
5357
|
if (T)
|
|
5350
5358
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -5359,9 +5367,9 @@ const Hs = (r) => {
|
|
|
5359
5367
|
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
5368
|
}
|
|
5361
5369
|
}
|
|
5362
|
-
}, Gs = (r) => {
|
|
5363
|
-
typeof window > "u" || typeof document > "u" || ss(r);
|
|
5364
5370
|
}, js = (r) => {
|
|
5371
|
+
typeof window > "u" || typeof document > "u" || rs(r);
|
|
5372
|
+
}, zs = (r) => {
|
|
5365
5373
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5366
5374
|
if (!h)
|
|
5367
5375
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -5369,7 +5377,7 @@ const Hs = (r) => {
|
|
|
5369
5377
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
5370
5378
|
h.updateGlobalMetadata(r);
|
|
5371
5379
|
}
|
|
5372
|
-
},
|
|
5380
|
+
}, Ks = (r) => {
|
|
5373
5381
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5374
5382
|
if (!h)
|
|
5375
5383
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -5377,7 +5385,7 @@ const Hs = (r) => {
|
|
|
5377
5385
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
5378
5386
|
h.mergeGlobalMetadata(r);
|
|
5379
5387
|
}
|
|
5380
|
-
},
|
|
5388
|
+
}, Qs = (r, e) => {
|
|
5381
5389
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5382
5390
|
if (!r || typeof r != "string" || r.trim().length === 0) {
|
|
5383
5391
|
a("warn", "identify() called with invalid userId");
|
|
@@ -5405,7 +5413,7 @@ const Hs = (r) => {
|
|
|
5405
5413
|
a("debug", "Failed to persist pre-init identity");
|
|
5406
5414
|
}
|
|
5407
5415
|
}
|
|
5408
|
-
},
|
|
5416
|
+
}, Ys = async () => {
|
|
5409
5417
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5410
5418
|
if (!h) {
|
|
5411
5419
|
try {
|
|
@@ -5418,23 +5426,23 @@ const Hs = (r) => {
|
|
|
5418
5426
|
throw new Error("[TraceLog] Cannot reset identity while TraceLog is being destroyed");
|
|
5419
5427
|
await h.resetIdentity();
|
|
5420
5428
|
}
|
|
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:
|
|
5429
|
+
}, br = {
|
|
5430
|
+
init: ks,
|
|
5431
|
+
event: Vs,
|
|
5432
|
+
on: Us,
|
|
5433
|
+
off: Fs,
|
|
5434
|
+
setTransformer: Hs,
|
|
5435
|
+
removeTransformer: xs,
|
|
5436
|
+
setCustomHeaders: $s,
|
|
5437
|
+
removeCustomHeaders: Bs,
|
|
5438
|
+
isInitialized: Ws,
|
|
5439
|
+
getSessionId: Xs,
|
|
5440
|
+
destroy: Gs,
|
|
5441
|
+
setQaMode: js,
|
|
5442
|
+
updateGlobalMetadata: zs,
|
|
5443
|
+
mergeGlobalMetadata: Ks,
|
|
5444
|
+
identify: Qs,
|
|
5445
|
+
resetIdentity: Ys
|
|
5438
5446
|
};
|
|
5439
5447
|
var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
5440
5448
|
addEventListener("pageshow", (function(e) {
|
|
@@ -5486,10 +5494,10 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5486
5494
|
}, F = -1, et = function() {
|
|
5487
5495
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
5488
5496
|
}, ce = function(r) {
|
|
5489
|
-
document.visibilityState === "hidden" && F > -1 && (F = r.type === "visibilitychange" ? r.timeStamp : 0,
|
|
5497
|
+
document.visibilityState === "hidden" && F > -1 && (F = r.type === "visibilitychange" ? r.timeStamp : 0, qs());
|
|
5490
5498
|
}, tt = function() {
|
|
5491
5499
|
addEventListener("visibilitychange", ce, !0), addEventListener("prerenderingchange", ce, !0);
|
|
5492
|
-
},
|
|
5500
|
+
}, qs = function() {
|
|
5493
5501
|
removeEventListener("visibilitychange", ce, !0), removeEventListener("prerenderingchange", ce, !0);
|
|
5494
5502
|
}, ke = function() {
|
|
5495
5503
|
return F < 0 && (F = et(), tt(), V((function() {
|
|
@@ -5516,7 +5524,7 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5516
5524
|
}));
|
|
5517
5525
|
})));
|
|
5518
5526
|
}));
|
|
5519
|
-
}, Me = [0.1, 0.25],
|
|
5527
|
+
}, Me = [0.1, 0.25], Js = function(r, e) {
|
|
5520
5528
|
e = e || {}, St(ue((function() {
|
|
5521
5529
|
var t, s = y("CLS", 0), i = 0, n = [], o = function(c) {
|
|
5522
5530
|
c.forEach((function(d) {
|
|
@@ -5534,19 +5542,19 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5534
5542
|
}));
|
|
5535
5543
|
})), setTimeout(t, 0));
|
|
5536
5544
|
})));
|
|
5537
|
-
}, Tt = 0, pe = 1 / 0, J = 0,
|
|
5545
|
+
}, Tt = 0, pe = 1 / 0, J = 0, Zs = function(r) {
|
|
5538
5546
|
r.forEach((function(e) {
|
|
5539
5547
|
e.interactionId && (pe = Math.min(pe, e.interactionId), J = Math.max(J, e.interactionId), Tt = J ? (J - pe) / 7 + 1 : 0);
|
|
5540
5548
|
}));
|
|
5541
5549
|
}, It = function() {
|
|
5542
5550
|
return Le ? Tt : performance.interactionCount || 0;
|
|
5543
|
-
},
|
|
5544
|
-
"interactionCount" in performance || Le || (Le = H("event",
|
|
5545
|
-
}, L = [], te = /* @__PURE__ */ new Map(), vt = 0,
|
|
5551
|
+
}, er = function() {
|
|
5552
|
+
"interactionCount" in performance || Le || (Le = H("event", Zs, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
5553
|
+
}, L = [], te = /* @__PURE__ */ new Map(), vt = 0, tr = function() {
|
|
5546
5554
|
var r = Math.min(L.length - 1, Math.floor((It() - vt) / 50));
|
|
5547
5555
|
return L[r];
|
|
5548
|
-
},
|
|
5549
|
-
if (
|
|
5556
|
+
}, sr = [], rr = function(r) {
|
|
5557
|
+
if (sr.forEach((function(i) {
|
|
5550
5558
|
return i(r);
|
|
5551
5559
|
})), r.interactionId || r.entryType === "first-input") {
|
|
5552
5560
|
var e = L[L.length - 1], t = te.get(r.interactionId);
|
|
@@ -5566,14 +5574,14 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5566
5574
|
}, _t = function(r) {
|
|
5567
5575
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
5568
5576
|
return r = ue(r), document.visibilityState === "hidden" ? r() : (t = e(r), z(r)), t;
|
|
5569
|
-
}, Ce = [200, 500],
|
|
5577
|
+
}, Ce = [200, 500], ir = function(r, e) {
|
|
5570
5578
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, K((function() {
|
|
5571
5579
|
var t;
|
|
5572
|
-
|
|
5580
|
+
er();
|
|
5573
5581
|
var s, i = y("INP"), n = function(l) {
|
|
5574
5582
|
_t((function() {
|
|
5575
|
-
l.forEach(
|
|
5576
|
-
var c =
|
|
5583
|
+
l.forEach(rr);
|
|
5584
|
+
var c = tr();
|
|
5577
5585
|
c && c.latency !== i.value && (i.value = c.latency, i.entries = c.entries, s());
|
|
5578
5586
|
}));
|
|
5579
5587
|
}, o = H("event", n, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
@@ -5583,7 +5591,7 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5583
5591
|
vt = It(), L.length = 0, te.clear(), i = y("INP"), s = w(r, i, Ce, e.reportAllChanges);
|
|
5584
5592
|
})));
|
|
5585
5593
|
})));
|
|
5586
|
-
}, Re = [2500, 4e3], Se = {},
|
|
5594
|
+
}, Re = [2500, 4e3], Se = {}, nr = function(r, e) {
|
|
5587
5595
|
e = e || {}, K((function() {
|
|
5588
5596
|
var t, s = ke(), i = y("LCP"), n = function(c) {
|
|
5589
5597
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(d) {
|
|
@@ -5606,31 +5614,31 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5606
5614
|
}));
|
|
5607
5615
|
}
|
|
5608
5616
|
}));
|
|
5609
|
-
}, Ne = [800, 1800],
|
|
5617
|
+
}, Ne = [800, 1800], or = function r(e) {
|
|
5610
5618
|
document.prerendering ? K((function() {
|
|
5611
5619
|
return r(e);
|
|
5612
5620
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
5613
5621
|
return r(e);
|
|
5614
5622
|
}), !0) : setTimeout(e, 0);
|
|
5615
|
-
},
|
|
5623
|
+
}, ar = function(r, e) {
|
|
5616
5624
|
e = e || {};
|
|
5617
5625
|
var t = y("TTFB"), s = w(r, t, Ne, e.reportAllChanges);
|
|
5618
|
-
|
|
5626
|
+
or((function() {
|
|
5619
5627
|
var i = Pe();
|
|
5620
5628
|
i && (t.value = Math.max(i.responseStart - de(), 0), t.entries = [i], s(!0), V((function() {
|
|
5621
5629
|
t = y("TTFB", 0), (s = w(r, t, Ne, e.reportAllChanges))(!0);
|
|
5622
5630
|
})));
|
|
5623
5631
|
}));
|
|
5624
|
-
}, W = { passive: !0, capture: !0 },
|
|
5632
|
+
}, W = { passive: !0, capture: !0 }, lr = /* @__PURE__ */ new Date(), st = function(r, e) {
|
|
5625
5633
|
C || (C = e, G = r, Et = /* @__PURE__ */ new Date(), wt(removeEventListener), yt());
|
|
5626
5634
|
}, yt = function() {
|
|
5627
|
-
if (G >= 0 && G < Et -
|
|
5635
|
+
if (G >= 0 && G < Et - lr) {
|
|
5628
5636
|
var r = { entryType: "first-input", name: C.type, target: C.target, cancelable: C.cancelable, startTime: C.timeStamp, processingStart: C.timeStamp + G };
|
|
5629
5637
|
le.forEach((function(e) {
|
|
5630
5638
|
e(r);
|
|
5631
5639
|
})), le = [];
|
|
5632
5640
|
}
|
|
5633
|
-
},
|
|
5641
|
+
}, cr = function(r) {
|
|
5634
5642
|
if (r.cancelable) {
|
|
5635
5643
|
var e = (r.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - r.timeStamp;
|
|
5636
5644
|
r.type == "pointerdown" ? (function(t, s) {
|
|
@@ -5646,9 +5654,9 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5646
5654
|
}
|
|
5647
5655
|
}, wt = function(r) {
|
|
5648
5656
|
["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
|
|
5649
|
-
return r(e,
|
|
5657
|
+
return r(e, cr, W);
|
|
5650
5658
|
}));
|
|
5651
|
-
}, Oe = [100, 300],
|
|
5659
|
+
}, Oe = [100, 300], dr = function(r, e) {
|
|
5652
5660
|
e = e || {}, K((function() {
|
|
5653
5661
|
var t, s = ke(), i = y("FID"), n = function(c) {
|
|
5654
5662
|
c.startTime < s.firstHiddenTime && (i.value = c.processingStart - c.startTime, i.entries.push(c), t(!0));
|
|
@@ -5663,7 +5671,7 @@ var Le, C, G, Et, le, pt = -1, V = function(r) {
|
|
|
5663
5671
|
})));
|
|
5664
5672
|
}));
|
|
5665
5673
|
};
|
|
5666
|
-
const
|
|
5674
|
+
const ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5667
5675
|
__proto__: null,
|
|
5668
5676
|
CLSThresholds: Me,
|
|
5669
5677
|
FCPThresholds: Ae,
|
|
@@ -5671,31 +5679,31 @@ const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5671
5679
|
INPThresholds: Ce,
|
|
5672
5680
|
LCPThresholds: Re,
|
|
5673
5681
|
TTFBThresholds: Ne,
|
|
5674
|
-
onCLS:
|
|
5682
|
+
onCLS: Js,
|
|
5675
5683
|
onFCP: St,
|
|
5676
|
-
onFID:
|
|
5677
|
-
onINP:
|
|
5678
|
-
onLCP:
|
|
5679
|
-
onTTFB:
|
|
5684
|
+
onFID: dr,
|
|
5685
|
+
onINP: ir,
|
|
5686
|
+
onLCP: nr,
|
|
5687
|
+
onTTFB: ar
|
|
5680
5688
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5681
5689
|
export {
|
|
5682
5690
|
m as AppConfigValidationError,
|
|
5683
|
-
|
|
5691
|
+
hr as DEFAULT_SESSION_TIMEOUT,
|
|
5684
5692
|
_e as DEFAULT_WEB_VITALS_MODE,
|
|
5685
5693
|
A as DeviceType,
|
|
5686
5694
|
se as EmitterEvent,
|
|
5687
5695
|
B as ErrorType,
|
|
5688
5696
|
u as EventType,
|
|
5689
|
-
|
|
5697
|
+
yr as InitializationTimeoutError,
|
|
5690
5698
|
N as IntegrationValidationError,
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
+
Ir as MAX_ARRAY_LENGTH,
|
|
5700
|
+
Er as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
5701
|
+
gr as MAX_CUSTOM_EVENT_KEYS,
|
|
5702
|
+
fr as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
5703
|
+
mr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
5704
|
+
pr as MAX_NESTED_OBJECT_KEYS,
|
|
5705
|
+
Sr as MAX_STRING_LENGTH,
|
|
5706
|
+
Tr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
5699
5707
|
ne as Mode,
|
|
5700
5708
|
at as PII_PATTERNS,
|
|
5701
5709
|
O as PermanentError,
|
|
@@ -5706,11 +5714,11 @@ export {
|
|
|
5706
5714
|
$ as SpecialApiUrl,
|
|
5707
5715
|
ie as TimeoutError,
|
|
5708
5716
|
j as TraceLogValidationError,
|
|
5709
|
-
|
|
5717
|
+
wr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5710
5718
|
Ke as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5711
|
-
|
|
5719
|
+
Yt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5712
5720
|
Qe as getWebVitalsThresholds,
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5721
|
+
vr as isPrimaryScrollEvent,
|
|
5722
|
+
_r as isSecondaryScrollEvent,
|
|
5723
|
+
br as tracelog
|
|
5716
5724
|
};
|