@utk09/ui-observability 0.8.0 → 0.9.1
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/CHANGELOG.md +95 -0
- package/README.md +75 -48
- package/dist/batch-DEK4bv9N.js +31 -0
- package/dist/batch-DEK4bv9N.js.map +1 -0
- package/dist/batch-DEVFs28i.cjs +2 -0
- package/dist/batch-DEVFs28i.cjs.map +1 -0
- package/dist/bus/bus.d.ts +46 -12
- package/dist/bus/links.d.ts +6 -3
- package/dist/bus-DNFvTkif.cjs +2 -0
- package/dist/bus-DNFvTkif.cjs.map +1 -0
- package/dist/{bus-DPDrlUBY.js → bus-HVQ8E72V.js} +128 -71
- package/dist/bus-HVQ8E72V.js.map +1 -0
- package/dist/capture/interactions.d.ts +7 -6
- package/dist/capture/network.d.ts +23 -9
- package/dist/capture/types.d.ts +3 -3
- package/dist/console-C9Y639mn.js +82 -0
- package/dist/console-C9Y639mn.js.map +1 -0
- package/dist/console-DssDxq1B.cjs +2 -0
- package/dist/console-DssDxq1B.cjs.map +1 -0
- package/dist/constants-N99w84xy.js +117 -0
- package/dist/constants-N99w84xy.js.map +1 -0
- package/dist/constants-X86IDwkC.cjs +2 -0
- package/dist/constants-X86IDwkC.cjs.map +1 -0
- package/dist/constants.d.ts +36 -18
- package/dist/core/diagnostics.d.ts +2 -2
- package/dist/core/drops.d.ts +29 -0
- package/dist/core/hold-buffer.d.ts +27 -0
- package/dist/core/journey.d.ts +16 -4
- package/dist/core/logger.d.ts +6 -2
- package/dist/core/pipeline.d.ts +20 -16
- package/dist/core/record.d.ts +11 -6
- package/dist/core/remote-sampling.d.ts +1 -1
- package/dist/core/runtime.d.ts +87 -23
- package/dist/core/sender.d.ts +19 -11
- package/dist/deadline-5_PecIl5.js +26 -0
- package/dist/deadline-5_PecIl5.js.map +1 -0
- package/dist/deadline-XSnm95pg.cjs +2 -0
- package/dist/deadline-XSnm95pg.cjs.map +1 -0
- package/dist/error-like-Ywo5uRHo.js +19 -0
- package/dist/error-like-Ywo5uRHo.js.map +1 -0
- package/dist/error-like-gGRx2s36.cjs +2 -0
- package/dist/error-like-gGRx2s36.cjs.map +1 -0
- package/dist/errors-BTWuVnHZ.cjs +3 -0
- package/dist/errors-BTWuVnHZ.cjs.map +1 -0
- package/dist/{errors-Dnc-X4Ec.js → errors-CQusIGWJ.js} +39 -20
- package/dist/errors-CQusIGWJ.js.map +1 -0
- package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
- package/dist/global-scope-dp2jADRl.js.map +1 -1
- package/dist/identity-B1GDS1Tb.cjs +2 -0
- package/dist/identity-B1GDS1Tb.cjs.map +1 -0
- package/dist/identity-D4DPjTM9.js +88 -0
- package/dist/identity-D4DPjTM9.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.js +720 -446
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-uD4oaRMc.js → indexeddb-storage-B8SGUzSV.js} +88 -59
- package/dist/indexeddb-storage-B8SGUzSV.js.map +1 -0
- package/dist/indexeddb-storage-ukzC82dm.cjs +2 -0
- package/dist/indexeddb-storage-ukzC82dm.cjs.map +1 -0
- package/dist/interactions-CcxrVzpg.cjs +2 -0
- package/dist/interactions-CcxrVzpg.cjs.map +1 -0
- package/dist/{interactions-igKTAJvj.js → interactions-CnjfQgw3.js} +22 -19
- package/dist/interactions-CnjfQgw3.js.map +1 -0
- package/dist/journey-DjvDzHyp.js +163 -0
- package/dist/journey-DjvDzHyp.js.map +1 -0
- package/dist/journey-DxlfdFJV.cjs +2 -0
- package/dist/journey-DxlfdFJV.cjs.map +1 -0
- package/dist/{library-request-Br_T09Bn.cjs → library-request-BZ1ekVtl.cjs} +2 -2
- package/dist/{library-request-Br_T09Bn.cjs.map → library-request-BZ1ekVtl.cjs.map} +1 -1
- package/dist/{library-request-Dt0fXhcn.js → library-request-C8kc5YWv.js} +2 -2
- package/dist/{library-request-Dt0fXhcn.js.map → library-request-C8kc5YWv.js.map} +1 -1
- package/dist/{long-frames-DahhqM6u.cjs → long-frames-BGik_Yhy.cjs} +2 -2
- package/dist/{long-frames-DahhqM6u.cjs.map → long-frames-BGik_Yhy.cjs.map} +1 -1
- package/dist/{long-frames-6pnjWSSR.js → long-frames-CZk3XOkH.js} +3 -3
- package/dist/{long-frames-6pnjWSSR.js.map → long-frames-CZk3XOkH.js.map} +1 -1
- package/dist/models/batch.d.ts +15 -1
- package/dist/models/bus.d.ts +7 -4
- package/dist/models/config.d.ts +189 -12
- package/dist/models/drop.d.ts +39 -0
- package/dist/models/log-record.d.ts +12 -6
- package/dist/models/storage.d.ts +15 -3
- package/dist/network-51iicpLl.js +174 -0
- package/dist/network-51iicpLl.js.map +1 -0
- package/dist/network-jBbjyAJP.cjs +2 -0
- package/dist/network-jBbjyAJP.cjs.map +1 -0
- package/dist/patch-BX8KrPCT.cjs +2 -0
- package/dist/patch-BX8KrPCT.cjs.map +1 -0
- package/dist/patch-CCWfuEY7.js +9 -0
- package/dist/patch-CCWfuEY7.js.map +1 -0
- package/dist/platform-Cjts-8k8.js +48 -0
- package/dist/platform-Cjts-8k8.js.map +1 -0
- package/dist/{platform-D_XkVIF6.cjs → platform-DW3GFIUE.cjs} +2 -2
- package/dist/platform-DW3GFIUE.cjs.map +1 -0
- package/dist/{remote-rules-rJJZKVG8.cjs → remote-rules-ByS34k4e.cjs} +2 -2
- package/dist/remote-rules-ByS34k4e.cjs.map +1 -0
- package/dist/{remote-rules-5UA23alm.js → remote-rules-M-XZ1xbe.js} +14 -14
- package/dist/remote-rules-M-XZ1xbe.js.map +1 -0
- package/dist/sampling-BN3Oi6SV.js +63 -0
- package/dist/sampling-BN3Oi6SV.js.map +1 -0
- package/dist/sampling-b2ck5X98.cjs +2 -0
- package/dist/sampling-b2ck5X98.cjs.map +1 -0
- package/dist/sanitize-DKp5MRsa.cjs +2 -0
- package/dist/sanitize-DKp5MRsa.cjs.map +1 -0
- package/dist/sanitize-Dwj9JCkI.js +123 -0
- package/dist/sanitize-Dwj9JCkI.js.map +1 -0
- package/dist/{sender-G6v4Uqi4.js → sender-BBY0IcUo.js} +439 -322
- package/dist/sender-BBY0IcUo.js.map +1 -0
- package/dist/sender-BXoAZKum.cjs +3 -0
- package/dist/sender-BXoAZKum.cjs.map +1 -0
- package/dist/storage/emergency-queue.d.ts +5 -2
- package/dist/storage/eviction.d.ts +40 -0
- package/dist/storage/factory.d.ts +1 -1
- package/dist/storage/idb-driver.d.ts +7 -1
- package/dist/storage/indexeddb-storage.d.ts +13 -5
- package/dist/storage/local-storage.d.ts +27 -4
- package/dist/storage/memory-storage.d.ts +10 -3
- package/dist/{storm-BtzgLOCX.cjs → storm-CKuaBp7i.cjs} +2 -2
- package/dist/{storm-BtzgLOCX.cjs.map → storm-CKuaBp7i.cjs.map} +1 -1
- package/dist/{storm-DJkEZP_8.js → storm-DhtL2eVr.js} +2 -2
- package/dist/{storm-DJkEZP_8.js.map → storm-DhtL2eVr.js.map} +1 -1
- package/dist/transport/compression.d.ts +1 -1
- package/dist/transport/exit-flush.d.ts +27 -17
- package/dist/transport/http-transport.d.ts +61 -7
- package/dist/transport/retry-engine.d.ts +12 -8
- package/dist/transport/status-transport.d.ts +8 -3
- package/dist/utils/console.d.ts +5 -2
- package/dist/utils/error-like.d.ts +25 -0
- package/dist/utils/global-scope.d.ts +1 -1
- package/dist/utils/identity.d.ts +1 -1
- package/dist/utils/library-console.d.ts +1 -1
- package/dist/utils/library-request.d.ts +1 -1
- package/dist/utils/patch.d.ts +9 -0
- package/dist/utils/platform.d.ts +3 -3
- package/dist/utils/sequence.d.ts +0 -5
- package/dist/utils/timer.d.ts +1 -1
- package/dist/utils/tracing.d.ts +3 -3
- package/dist/utils/unref.d.ts +2 -2
- package/dist/{web-vitals-DHZ0yA_H.js → web-vitals-Bflr5jSA.js} +4 -2
- package/dist/web-vitals-Bflr5jSA.js.map +1 -0
- package/dist/web-vitals-DFuoTQbZ.cjs +2 -0
- package/dist/web-vitals-DFuoTQbZ.cjs.map +1 -0
- package/package.json +2 -2
- package/dist/bus-CUXRY0JR.cjs +0 -2
- package/dist/bus-CUXRY0JR.cjs.map +0 -1
- package/dist/bus-DPDrlUBY.js.map +0 -1
- package/dist/console-CNljJict.js +0 -81
- package/dist/console-CNljJict.js.map +0 -1
- package/dist/console-PKzc-FmR.cjs +0 -2
- package/dist/console-PKzc-FmR.cjs.map +0 -1
- package/dist/constants-B28fDv2F.cjs +0 -2
- package/dist/constants-B28fDv2F.cjs.map +0 -1
- package/dist/constants-Bu49bm39.js +0 -93
- package/dist/constants-Bu49bm39.js.map +0 -1
- package/dist/errors-C78ZTjet.cjs +0 -3
- package/dist/errors-C78ZTjet.cjs.map +0 -1
- package/dist/errors-Dnc-X4Ec.js.map +0 -1
- package/dist/indexeddb-storage-D0p3iMD0.cjs +0 -2
- package/dist/indexeddb-storage-D0p3iMD0.cjs.map +0 -1
- package/dist/indexeddb-storage-uD4oaRMc.js.map +0 -1
- package/dist/interactions-CsE2y_fQ.cjs +0 -2
- package/dist/interactions-CsE2y_fQ.cjs.map +0 -1
- package/dist/interactions-igKTAJvj.js.map +0 -1
- package/dist/network-CZ0aFUsy.cjs +0 -2
- package/dist/network-CZ0aFUsy.cjs.map +0 -1
- package/dist/network-aSNbwpue.js +0 -112
- package/dist/network-aSNbwpue.js.map +0 -1
- package/dist/platform-BwbMRwHm.js +0 -48
- package/dist/platform-BwbMRwHm.js.map +0 -1
- package/dist/platform-D_XkVIF6.cjs.map +0 -1
- package/dist/remote-rules-5UA23alm.js.map +0 -1
- package/dist/remote-rules-rJJZKVG8.cjs.map +0 -1
- package/dist/sampling-E4x92Nn2.cjs +0 -2
- package/dist/sampling-E4x92Nn2.cjs.map +0 -1
- package/dist/sampling-J1eahbfT.js +0 -160
- package/dist/sampling-J1eahbfT.js.map +0 -1
- package/dist/sanitize-BMhh8ghJ.cjs +0 -2
- package/dist/sanitize-BMhh8ghJ.cjs.map +0 -1
- package/dist/sanitize-UJ-4Lb0n.js +0 -114
- package/dist/sanitize-UJ-4Lb0n.js.map +0 -1
- package/dist/sender-B6ufz26f.cjs +0 -3
- package/dist/sender-B6ufz26f.cjs.map +0 -1
- package/dist/sender-G6v4Uqi4.js.map +0 -1
- package/dist/unref-16maCyKA.js +0 -8
- package/dist/unref-16maCyKA.js.map +0 -1
- package/dist/unref-CU9Nyz_9.cjs +0 -2
- package/dist/unref-CU9Nyz_9.cjs.map +0 -1
- package/dist/web-vitals-B2FYsEAU.cjs +0 -2
- package/dist/web-vitals-B2FYsEAU.cjs.map +0 -1
- package/dist/web-vitals-DHZ0yA_H.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-B1GDS1Tb.cjs","names":["SESSION_ID_KEY","TAB_ID_KEY","require_constants","BROWSER_STORES","memoryStores","wrap","map","key","value","localStore","sessionStore","randomHex","bytes","byteLength","i","b","newId","diagnostics","safeRead","store","stores","safeWrite","resolveIdentity","contextId","now","sessionId","rawSession","parsed","session","tabId","persistTabId","SessionTouch"],"sources":["../src/utils/identity.ts"],"sourcesContent":["// src/utils/identity.ts\n//\n// Makes and keeps the session, tab, and context correlation identifiers. In a\n// sandboxed iframe and in private mode, Storage throws instead of returning null.\n// An unguarded read breaks the library at import.\n\nimport {\n BYTE_VALUE_COUNT,\n ID_BYTE_LENGTH,\n SESSION_ID_KEY,\n SESSION_IDLE_MS,\n SESSION_TOUCH_MS,\n TAB_ID_KEY,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\n\n/** Correlation identifiers attached to log records across session, tab, and realm scopes. */\nexport interface Identity {\n /** Origin-wide user session identifier surviving across tabs until idle expiration. */\n sessionId: string;\n /** Browser tab or desktop window identifier surviving document reloads. */\n tabId: string;\n /** Unique execution realm identifier regenerated on every document load. */\n contextId: string;\n}\n\n/** The three Storage methods that identity and journey code use. */\nexport interface KeyValueStore {\n /**\n * Reads one value.\n * @param key Storage key.\n * @returns Stored value, or null.\n */\n getItem(key: string): string | null;\n /**\n * Writes one value.\n * @param key Storage key.\n * @param value Value to write.\n */\n setItem(key: string, value: string): void;\n /**\n * Removes one value.\n * @param key Storage key.\n */\n removeItem(key: string): void;\n}\n\n/** Stores for identity and journey keys. A getter can throw in a sandboxed frame. */\nexport interface IdentityStores {\n /** Store that lasts across tabs and reloads. */\n local(): KeyValueStore;\n /** Store that lasts for one tab. */\n session(): KeyValueStore;\n}\n\n/** Stores that write to the browser. The `identity: \"storage\"` option uses them. */\nexport const BROWSER_STORES: IdentityStores = {\n local: () => localStorage,\n session: () => sessionStorage,\n};\n\n/**\n * Creates stores that keep values in memory only. The `identity: \"memory\"` option uses them.\n * @returns Stores that write nothing to the browser.\n */\nexport function memoryStores(): IdentityStores {\n const wrap = (map: Map<string, string>): KeyValueStore => ({\n getItem: (key) => map.get(key) ?? null,\n setItem: (key, value) => {\n map.set(key, value);\n },\n removeItem: (key) => {\n map.delete(key);\n },\n });\n\n const localStore = wrap(new Map());\n const sessionStore = wrap(new Map());\n\n return { local: () => localStore, session: () => sessionStore };\n}\n\n/**\n * Generates a random lowercase hexadecimal string of the specified byte length.\n * It uses crypto.getRandomValues when it is available. If not, it uses Math.random.\n * @param byteLength Number of random bytes to generate.\n * @returns Hexadecimal string of length byteLength * 2.\n */\nexport function randomHex(byteLength: number): string {\n const bytes = new Uint8Array(byteLength);\n if (typeof crypto !== \"undefined\" && typeof crypto.getRandomValues === \"function\") {\n crypto.getRandomValues(bytes);\n } else {\n for (let i = 0; i < byteLength; i++) {\n bytes[i] = Math.floor(Math.random() * BYTE_VALUE_COUNT);\n }\n }\n return Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\n/**\n * Generates a unique identifier string using crypto.randomUUID or randomHex fallback.\n * @param diagnostics Diagnostics reporter. It counts a blocked crypto.randomUUID call.\n * @returns UUID or random hex identifier.\n */\nexport function newId(diagnostics: Diagnostics): string {\n try {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n } catch {\n // A sandbox can block crypto.randomUUID with a SecurityError. The method exists,\n // but the call throws. Count the fault. A report on each id is noise.\n diagnostics.count(\"platform.api_blocked\");\n }\n return randomHex(ID_BYTE_LENGTH);\n}\n\n/**\n * Reads a value from the local or session store. Reports a storage error to diagnostics.\n * @param stores Identity stores.\n * @param store Storage target (\"local\" or \"session\").\n * @param key Storage key.\n * @param diagnostics Diagnostics reporter.\n * @returns Stored string value or null if unreadable or absent.\n */\nfunction safeRead(\n stores: IdentityStores,\n store: \"local\" | \"session\",\n key: string,\n diagnostics: Diagnostics,\n): string | null {\n return (\n diagnostics.guard(\"storage.unavailable\", `The library could not read ${store}Storage.`, () =>\n stores[store]().getItem(key),\n ) ?? null\n );\n}\n\n/**\n * Writes a key-value pair to the local or session store. Reports a storage error to diagnostics.\n * @param stores Identity stores.\n * @param store Storage target (\"local\" or \"session\").\n * @param key Storage key.\n * @param value String value to store.\n * @param diagnostics Diagnostics reporter.\n */\nfunction safeWrite(\n stores: IdentityStores,\n store: \"local\" | \"session\",\n key: string,\n value: string,\n diagnostics: Diagnostics,\n): void {\n diagnostics.guard(\n \"storage.unavailable\",\n `The library could not write to ${store}Storage.`,\n () => {\n stores[store]().setItem(key, value);\n },\n );\n}\n\n/**\n * Resolves or initializes session, tab, and context identifiers for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n * @returns Populated Identity object.\n */\nexport function resolveIdentity(\n diagnostics: Diagnostics,\n stores: IdentityStores = BROWSER_STORES,\n): Identity {\n const contextId = newId(diagnostics);\n const now = Date.now();\n\n let sessionId = newId(diagnostics);\n const rawSession = safeRead(stores, \"local\", SESSION_ID_KEY, diagnostics);\n if (rawSession) {\n try {\n const parsed = JSON.parse(rawSession) as {\n id?: string;\n lastSeenAt?: number;\n };\n if (parsed.id && now - (parsed.lastSeenAt ?? 0) < SESSION_IDLE_MS) {\n sessionId = parsed.id;\n }\n } catch {\n diagnostics.report(\n \"storage.degraded\",\n \"The session record is not valid JSON. The library starts a new session.\",\n );\n }\n }\n const session = JSON.stringify({ id: sessionId, lastSeenAt: now });\n safeWrite(stores, \"local\", SESSION_ID_KEY, session, diagnostics);\n\n let tabId = safeRead(stores, \"session\", TAB_ID_KEY, diagnostics) ?? \"\";\n if (!tabId) {\n tabId = newId(diagnostics);\n safeWrite(stores, \"session\", TAB_ID_KEY, tabId, diagnostics);\n }\n\n return { sessionId, tabId, contextId };\n}\n\n/**\n * Writes a new tab id to the session store.\n * @param tabId New tab identifier.\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n */\nexport function persistTabId(\n tabId: string,\n diagnostics: Diagnostics,\n stores: IdentityStores,\n): void {\n safeWrite(stores, \"session\", TAB_ID_KEY, tabId, diagnostics);\n}\n\n/**\n * Writes the last-seen timestamp of the session. `SESSION_TOUCH_MS` sets the throttle.\n * The instance keeps the throttle state, not the module. Two runtimes in one document\n * must not block the session writes of each other.\n */\nexport class SessionTouch {\n /** Epoch milliseconds of the last write this instance made. */\n private lastTouchAt = 0;\n\n /**\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n */\n constructor(\n private diagnostics: Diagnostics,\n private readonly stores: IdentityStores = BROWSER_STORES,\n ) {}\n\n /**\n * Writes the session activity time to the local store. It writes one time in each throttle window.\n * @param sessionId Active session identifier.\n */\n touch(sessionId: string): void {\n const now = Date.now();\n\n if (now - this.lastTouchAt < SESSION_TOUCH_MS) {\n return;\n }\n\n this.lastTouchAt = now;\n const session = JSON.stringify({ id: sessionId, lastSeenAt: now });\n safeWrite(this.stores, \"local\", SESSION_ID_KEY, session, this.diagnostics);\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Qt as e, ln as t } from "./constants-N99w84xy.js";
|
|
2
|
+
//#region src/utils/identity.ts
|
|
3
|
+
var n = {
|
|
4
|
+
local: () => localStorage,
|
|
5
|
+
session: () => sessionStorage
|
|
6
|
+
};
|
|
7
|
+
function r() {
|
|
8
|
+
let e = (e) => ({
|
|
9
|
+
getItem: (t) => e.get(t) ?? null,
|
|
10
|
+
setItem: (t, n) => {
|
|
11
|
+
e.set(t, n);
|
|
12
|
+
},
|
|
13
|
+
removeItem: (t) => {
|
|
14
|
+
e.delete(t);
|
|
15
|
+
}
|
|
16
|
+
}), t = e(/* @__PURE__ */ new Map()), n = e(/* @__PURE__ */ new Map());
|
|
17
|
+
return {
|
|
18
|
+
local: () => t,
|
|
19
|
+
session: () => n
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function i(e) {
|
|
23
|
+
let t = new Uint8Array(e);
|
|
24
|
+
if (typeof crypto < "u" && typeof crypto.getRandomValues == "function") crypto.getRandomValues(t);
|
|
25
|
+
else for (let n = 0; n < e; n++) t[n] = Math.floor(Math.random() * 256);
|
|
26
|
+
return Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
27
|
+
}
|
|
28
|
+
function a(e) {
|
|
29
|
+
try {
|
|
30
|
+
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
31
|
+
} catch {
|
|
32
|
+
e.count("platform.api_blocked");
|
|
33
|
+
}
|
|
34
|
+
return i(16);
|
|
35
|
+
}
|
|
36
|
+
function o(e, t, n, r) {
|
|
37
|
+
return r.guard("storage.unavailable", `The library could not read ${t}Storage.`, () => e[t]().getItem(n)) ?? null;
|
|
38
|
+
}
|
|
39
|
+
function s(e, t, n, r, i) {
|
|
40
|
+
i.guard("storage.unavailable", `The library could not write to ${t}Storage.`, () => {
|
|
41
|
+
e[t]().setItem(n, r);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function c(r, i = n) {
|
|
45
|
+
let c = a(r), l = Date.now(), u = a(r), d = o(i, "local", e, r);
|
|
46
|
+
if (d) try {
|
|
47
|
+
let e = JSON.parse(d);
|
|
48
|
+
e.id && l - (e.lastSeenAt ?? 0) < 18e5 && (u = e.id);
|
|
49
|
+
} catch {
|
|
50
|
+
r.report("storage.degraded", "The session record is not valid JSON. The library starts a new session.");
|
|
51
|
+
}
|
|
52
|
+
let f = JSON.stringify({
|
|
53
|
+
id: u,
|
|
54
|
+
lastSeenAt: l
|
|
55
|
+
});
|
|
56
|
+
s(i, "local", e, f, r);
|
|
57
|
+
let p = o(i, "session", "ui-observability.tab", r) ?? "";
|
|
58
|
+
return p || (p = a(r), s(i, "session", t, p, r)), {
|
|
59
|
+
sessionId: u,
|
|
60
|
+
tabId: p,
|
|
61
|
+
contextId: c
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function l(e, n, r) {
|
|
65
|
+
s(r, "session", t, e, n);
|
|
66
|
+
}
|
|
67
|
+
var u = class {
|
|
68
|
+
diagnostics;
|
|
69
|
+
stores;
|
|
70
|
+
lastTouchAt = 0;
|
|
71
|
+
constructor(e, t = n) {
|
|
72
|
+
this.diagnostics = e, this.stores = t;
|
|
73
|
+
}
|
|
74
|
+
touch(t) {
|
|
75
|
+
let n = Date.now();
|
|
76
|
+
if (n - this.lastTouchAt < 6e4) return;
|
|
77
|
+
this.lastTouchAt = n;
|
|
78
|
+
let r = JSON.stringify({
|
|
79
|
+
id: t,
|
|
80
|
+
lastSeenAt: n
|
|
81
|
+
});
|
|
82
|
+
s(this.stores, "local", e, r, this.diagnostics);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
export { l as a, a as i, u as n, i as o, r, c as s, n as t };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=identity-D4DPjTM9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-D4DPjTM9.js","names":["SESSION_ID_KEY","TAB_ID_KEY","BROWSER_STORES","memoryStores","wrap","map","key","value","localStore","sessionStore","randomHex","bytes","byteLength","i","b","newId","safeRead","diagnostics","store","stores","safeWrite","resolveIdentity","contextId","now","sessionId","rawSession","parsed","session","tabId","persistTabId","SessionTouch"],"sources":["../src/utils/identity.ts"],"sourcesContent":["// src/utils/identity.ts\n//\n// Makes and keeps the session, tab, and context correlation identifiers. In a\n// sandboxed iframe and in private mode, Storage throws instead of returning null.\n// An unguarded read breaks the library at import.\n\nimport {\n BYTE_VALUE_COUNT,\n ID_BYTE_LENGTH,\n SESSION_ID_KEY,\n SESSION_IDLE_MS,\n SESSION_TOUCH_MS,\n TAB_ID_KEY,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\n\n/** Correlation identifiers attached to log records across session, tab, and realm scopes. */\nexport interface Identity {\n /** Origin-wide user session identifier surviving across tabs until idle expiration. */\n sessionId: string;\n /** Browser tab or desktop window identifier surviving document reloads. */\n tabId: string;\n /** Unique execution realm identifier regenerated on every document load. */\n contextId: string;\n}\n\n/** The three Storage methods that identity and journey code use. */\nexport interface KeyValueStore {\n /**\n * Reads one value.\n * @param key Storage key.\n * @returns Stored value, or null.\n */\n getItem(key: string): string | null;\n /**\n * Writes one value.\n * @param key Storage key.\n * @param value Value to write.\n */\n setItem(key: string, value: string): void;\n /**\n * Removes one value.\n * @param key Storage key.\n */\n removeItem(key: string): void;\n}\n\n/** Stores for identity and journey keys. A getter can throw in a sandboxed frame. */\nexport interface IdentityStores {\n /** Store that lasts across tabs and reloads. */\n local(): KeyValueStore;\n /** Store that lasts for one tab. */\n session(): KeyValueStore;\n}\n\n/** Stores that write to the browser. The `identity: \"storage\"` option uses them. */\nexport const BROWSER_STORES: IdentityStores = {\n local: () => localStorage,\n session: () => sessionStorage,\n};\n\n/**\n * Creates stores that keep values in memory only. The `identity: \"memory\"` option uses them.\n * @returns Stores that write nothing to the browser.\n */\nexport function memoryStores(): IdentityStores {\n const wrap = (map: Map<string, string>): KeyValueStore => ({\n getItem: (key) => map.get(key) ?? null,\n setItem: (key, value) => {\n map.set(key, value);\n },\n removeItem: (key) => {\n map.delete(key);\n },\n });\n\n const localStore = wrap(new Map());\n const sessionStore = wrap(new Map());\n\n return { local: () => localStore, session: () => sessionStore };\n}\n\n/**\n * Generates a random lowercase hexadecimal string of the specified byte length.\n * It uses crypto.getRandomValues when it is available. If not, it uses Math.random.\n * @param byteLength Number of random bytes to generate.\n * @returns Hexadecimal string of length byteLength * 2.\n */\nexport function randomHex(byteLength: number): string {\n const bytes = new Uint8Array(byteLength);\n if (typeof crypto !== \"undefined\" && typeof crypto.getRandomValues === \"function\") {\n crypto.getRandomValues(bytes);\n } else {\n for (let i = 0; i < byteLength; i++) {\n bytes[i] = Math.floor(Math.random() * BYTE_VALUE_COUNT);\n }\n }\n return Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\n/**\n * Generates a unique identifier string using crypto.randomUUID or randomHex fallback.\n * @param diagnostics Diagnostics reporter. It counts a blocked crypto.randomUUID call.\n * @returns UUID or random hex identifier.\n */\nexport function newId(diagnostics: Diagnostics): string {\n try {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n } catch {\n // A sandbox can block crypto.randomUUID with a SecurityError. The method exists,\n // but the call throws. Count the fault. A report on each id is noise.\n diagnostics.count(\"platform.api_blocked\");\n }\n return randomHex(ID_BYTE_LENGTH);\n}\n\n/**\n * Reads a value from the local or session store. Reports a storage error to diagnostics.\n * @param stores Identity stores.\n * @param store Storage target (\"local\" or \"session\").\n * @param key Storage key.\n * @param diagnostics Diagnostics reporter.\n * @returns Stored string value or null if unreadable or absent.\n */\nfunction safeRead(\n stores: IdentityStores,\n store: \"local\" | \"session\",\n key: string,\n diagnostics: Diagnostics,\n): string | null {\n return (\n diagnostics.guard(\"storage.unavailable\", `The library could not read ${store}Storage.`, () =>\n stores[store]().getItem(key),\n ) ?? null\n );\n}\n\n/**\n * Writes a key-value pair to the local or session store. Reports a storage error to diagnostics.\n * @param stores Identity stores.\n * @param store Storage target (\"local\" or \"session\").\n * @param key Storage key.\n * @param value String value to store.\n * @param diagnostics Diagnostics reporter.\n */\nfunction safeWrite(\n stores: IdentityStores,\n store: \"local\" | \"session\",\n key: string,\n value: string,\n diagnostics: Diagnostics,\n): void {\n diagnostics.guard(\n \"storage.unavailable\",\n `The library could not write to ${store}Storage.`,\n () => {\n stores[store]().setItem(key, value);\n },\n );\n}\n\n/**\n * Resolves or initializes session, tab, and context identifiers for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n * @returns Populated Identity object.\n */\nexport function resolveIdentity(\n diagnostics: Diagnostics,\n stores: IdentityStores = BROWSER_STORES,\n): Identity {\n const contextId = newId(diagnostics);\n const now = Date.now();\n\n let sessionId = newId(diagnostics);\n const rawSession = safeRead(stores, \"local\", SESSION_ID_KEY, diagnostics);\n if (rawSession) {\n try {\n const parsed = JSON.parse(rawSession) as {\n id?: string;\n lastSeenAt?: number;\n };\n if (parsed.id && now - (parsed.lastSeenAt ?? 0) < SESSION_IDLE_MS) {\n sessionId = parsed.id;\n }\n } catch {\n diagnostics.report(\n \"storage.degraded\",\n \"The session record is not valid JSON. The library starts a new session.\",\n );\n }\n }\n const session = JSON.stringify({ id: sessionId, lastSeenAt: now });\n safeWrite(stores, \"local\", SESSION_ID_KEY, session, diagnostics);\n\n let tabId = safeRead(stores, \"session\", TAB_ID_KEY, diagnostics) ?? \"\";\n if (!tabId) {\n tabId = newId(diagnostics);\n safeWrite(stores, \"session\", TAB_ID_KEY, tabId, diagnostics);\n }\n\n return { sessionId, tabId, contextId };\n}\n\n/**\n * Writes a new tab id to the session store.\n * @param tabId New tab identifier.\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n */\nexport function persistTabId(\n tabId: string,\n diagnostics: Diagnostics,\n stores: IdentityStores,\n): void {\n safeWrite(stores, \"session\", TAB_ID_KEY, tabId, diagnostics);\n}\n\n/**\n * Writes the last-seen timestamp of the session. `SESSION_TOUCH_MS` sets the throttle.\n * The instance keeps the throttle state, not the module. Two runtimes in one document\n * must not block the session writes of each other.\n */\nexport class SessionTouch {\n /** Epoch milliseconds of the last write this instance made. */\n private lastTouchAt = 0;\n\n /**\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n */\n constructor(\n private diagnostics: Diagnostics,\n private readonly stores: IdentityStores = BROWSER_STORES,\n ) {}\n\n /**\n * Writes the session activity time to the local store. It writes one time in each throttle window.\n * @param sessionId Active session identifier.\n */\n touch(sessionId: string): void {\n const now = Date.now();\n\n if (now - this.lastTouchAt < SESSION_TOUCH_MS) {\n return;\n }\n\n this.lastTouchAt = now;\n const session = JSON.stringify({ id: sessionId, lastSeenAt: now });\n safeWrite(this.stores, \"local\", SESSION_ID_KEY, session, this.diagnostics);\n }\n}\n"],"mappings":"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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-B28fDv2F.cjs"),t=require("./sampling-E4x92Nn2.cjs"),n=require("./sanitize-BMhh8ghJ.cjs"),r=require("./platform-D_XkVIF6.cjs"),i=require("./unref-CU9Nyz_9.cjs");function a(t){return Math.round((performance.now()-t)*e.F)/e.F}function o(e,t,n,r,i){e.logMetric(`${t}.duration`,a(n),`ms`,`histogram`,{status:r,...i})}function s(e,t,n,r,i){e.error(`${t} failed`,r,{"action.duration_ms":a(n),status:`FAILURE`,...i})}function c(e,t,n,r){let i=performance.now();try{let a=n();return o(e,t,i,`SUCCESS`,r),a}catch(n){throw s(e,t,i,n,r),n}}async function l(e,t,n,r){let i=performance.now();try{let a=await n();return o(e,t,i,`SUCCESS`,r),a}catch(n){throw s(e,t,i,n,r),n}}function u(e,t){if(e instanceof Error)return e;let n=t.guard(`record.sanitize_failed`,`The library could not convert the error reason to text.`,()=>String(e));return Error(n??typeof e)}function d(e){if(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Error)return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}var f=class t{bind;namespace;options;constructor(e,t,n={}){this.bind=e,this.namespace=t,this.options=n}child(e,n={}){return new t(this.bind,`${this.namespace}.${e}`,{scopedContext:{...this.options.scopedContext,...n.scopedContext}})}trace=(e,t)=>{this.write(`TRACE`,`system`,e,t)};debug=(e,t)=>{this.write(`DEBUG`,`system`,e,t)};info=(e,t)=>{this.write(`INFO`,`system`,e,t)};warn=(e,t)=>{this.write(`WARN`,`system`,e,t)};error=(e,t,n)=>{this.writeError(`ERROR`,e,t,n)};fatal=(e,t,n)=>{this.writeError(`FATAL`,e,t,n)};logAction=(e,t)=>{this.write(`INFO`,`action`,e,t)};logEvent=(e,t)=>{this.write(`INFO`,`event`,e,t)};logMetric=(t,n,r=e.M,i=`gauge`,a)=>{this.write(`INFO`,`metric`,t,{"metric.name":t,"metric.value":n,"metric.unit":r,"metric.type":i,...a})};timeSync=(e,t,n)=>c(this,e,t,n);timeAsync=(e,t,n)=>l(this,e,t,n);write(e,t,n,r){let i=this.bind();if(i.isDestroyed())return;if(!i.builder.isEnabled(e)){this.mirrors(i,e)&&this.print(i,e,n,r,void 0,null);return}let{record:a,dropped:o}=i.builder.build({level:e,type:t,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:r});t!==`metric`&&o!==`redact`&&i.breadcrumbs.push({t:Date.now(),category:t===`action`?`action`:t===`event`?`event`:`log`,message:n}),this.print(i,e,n,r,void 0,a),i.emit(a)}writeError(e,t,n,r){let i=this.bind();if(i.isDestroyed())return;let a=i.builder.isEnabled(e);if(!a&&!this.mirrors(i,e))return;let o=r===void 0&&d(n),s=o?n:r,c=o||n===void 0?void 0:u(n,i.diagnostics);if(!a){this.print(i,e,t,s,c,null);return}let{record:l}=i.builder.build({level:e,type:`system`,body:t,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...s,...c?{"error.type":c.name,"error.message":c.message,"error.stack_trace":c.stack}:{},breadcrumbs:i.breadcrumbs.snapshot()}});this.print(i,e,t,s,c,l),i.emit(l)}print(e,t,n,r,i,a){e.config.redact?a?e.console.write(this.namespace,t,a.body,a.attributes):e.console.write(this.namespace,t,n,void 0,i):e.console.write(this.namespace,t,n,r,i)}mirrors(e,t){return e.config.enabled&&e.console.accepts(t)}},p={TRACE:`debug`,DEBUG:`debug`,INFO:`info`,WARN:`warn`,ERROR:`error`,FATAL:`error`},m=class{settings;diagnostics;constructor(e,t){this.settings=e,this.diagnostics=t}update(e){this.settings=e}accepts(t){return this.settings.level!==null&&e.at[t]>=e.at[this.settings.level]}write(t,r,i,a,o){if(!this.accepts(r)||typeof console>`u`||n.a())return;let s=`%c[%s]%c[${r}]%c`,{styles:c}=this.settings,l=p[r];this.diagnostics.guard(`handler.threw`,`The library could not print to console.${l}.`,()=>{let u=[];o!==void 0&&u.push(o),a!==void 0&&u.push(n.n(a,e.Ct,this.diagnostics)),n.o(()=>{console[l](s,c.namespace,t,c[r],``,i,...u)})})}},h=class{value=0;next(){return++this.value}reset(){this.value=0}},g=/^[0-9a-f]{32}$/,_=/^[0-9a-f]{16}$/,v=/[1-9a-f]/;function y(e){return g.test(e.traceId)&&v.test(e.traceId)&&_.test(e.spanId)&&v.test(e.spanId)}function b(){return t.d(16)}function x(){return t.d(8)}function S(){return{traceId:b(),spanId:x(),traceFlags:1,startedAt:Date.now()}}function C(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags}}var w=class{diagnostics;maxAgeMs;load;ambient=S();otel;constructor(t,n=e.fn,r){this.diagnostics=t,this.maxAgeMs=n,this.load=r}async loadOtel(){if(this.load)try{this.otel=await this.load()}catch(e){this.diagnostics.report(`trace.otel_failed`,`The library could not load @opentelemetry/api. Records use the trace ids of the library.`,void 0,e)}}resolve(){let e=this.activeSpanContext();return e===void 0?(Date.now()-this.ambient.startedAt>this.maxAgeMs&&this.rotate(`maxAge`),C(this.ambient)):e}activeSpanContext(){let e=this.otel;if(e)return this.diagnostics.guard(`trace.otel_failed`,`The library could not read the active OpenTelemetry span.`,()=>{let t=e.trace.getActiveSpan();if(t===void 0)return;let n=t.spanContext();if(y(n))return{traceId:n.traceId,spanId:n.spanId,traceFlags:n.traceFlags}})}rotate(e){return this.ambient=S(),C(this.ambient)}headers(){let t={},n=this.otel;if(n&&this.diagnostics.guard(`trace.otel_failed`,`The library could not add the OpenTelemetry headers.`,()=>{n.propagation.inject(n.context.active(),t)}),!t.traceparent){let n=this.resolve(),r=(n.traceFlags&255).toString(16).padStart(2,`0`);t[e.dn]=`00-${n.traceId}-${n.spanId}-${r}`}return t}},T=class{buffer;pointer=0;filled=!1;capacity;constructor(e){this.capacity=Math.max(e,1),this.buffer=Array(this.capacity)}push(e){this.buffer[this.pointer]=e,this.pointer=(this.pointer+1)%this.capacity,this.pointer===0&&(this.filled=!0)}snapshot(){return(this.filled?[...this.buffer.slice(this.pointer),...this.buffer.slice(0,this.pointer)]:this.buffer.slice(0,this.pointer)).filter(e=>e!==void 0)}clear(){this.buffer=Array(this.capacity),this.pointer=0,this.filled=!1}};function E(e){return typeof e!=`object`||!e?!1:typeof Reflect.get(e,`serialize`)==`function`}function D(t,n,r){return t===void 0?n??`otlp`:t===`otlp`||t===`ecs`||E(t)?t:(r.report(`config.invalid`,`serializer must be "${e.qt}", "ecs" or an implementation. The library uses "${e.qt}".`),e.qt)}var O=new Set(Object.keys(e.D));function k(e,t){let n={},r=Object.entries(e??{});for(let[e,i]of r)O.has(e)?typeof i==`string`?n[e]=i:t.report(`config.invalid`,`console.styles.${e} must be a string. The library keeps the style in force.`):t.report(`config.invalid`,`The library ignores the unknown console.styles key "${e}". Check the spelling.`);return n}function A(t,n,r){return t===void 0?n:t===!1?{level:null,styles:n.styles}:t===!0?{level:e.E,styles:n.styles}:typeof t==`string`?{level:t,styles:n.styles}:typeof t!=`object`||!t?(r.report(`config.invalid`,`console must be a boolean, a level or an object. The console settings in force stay.`),n):{level:t.level??n.level??`DEBUG`,styles:{...n.styles,...k(t.styles,r)}}}function j(t,n,r){let i=r??e.j,a={...i,...t,endpoint:t.endpoint===void 0?i.endpoint:t.endpoint,serializer:D(t.serializer,r?.serializer,n),console:A(t.console,i.console,n),sampling:{...i.sampling,...t.sampling,rates:{...i.sampling.rates,...t.sampling?.rates}},bus:{...i.bus,...t.bus},capture:{...i.capture,...t.capture}};if(a.transport!==void 0&&typeof a.transport!=`function`&&(n.report(`config.invalid`,`transport must be a function. The library ignores the value.`),a.transport=i.transport),a.transportOnExit!==void 0&&typeof a.transportOnExit!=`function`&&(n.report(`config.invalid`,`transportOnExit must be a function. The library ignores the value.`),a.transportOnExit=i.transportOnExit),a.endpoint===``)a.transport===void 0&&n.report(`config.invalid`,`endpoint is missing. The library drops each record. Set endpoint: null for console-only mode.`);else if(a.endpoint!==null)try{new URL(a.endpoint)}catch(e){n.report(`config.invalid`,`endpoint is not a valid absolute URL: ${a.endpoint}.`,void 0,e)}a.serviceName||=(n.report(`config.invalid`,`serviceName is missing. Every record reports service.name as '${e.gn}'.`),e.gn);let o=a.sampling.defaultRate;(typeof o!=`number`||o<0||o>1)&&(n.report(`config.invalid`,`sampling.defaultRate must be 0..1. The value is ${String(o)}. The library uses 1.`),a.sampling.defaultRate=1);let s=a.sampling.remoteMaxRate;(typeof s!=`number`||!(s>=0&&s<=1))&&(n.report(`config.invalid`,`sampling.remoteMaxRate must be 0..1. The value is ${String(s)}. The library uses 1.`),a.sampling.remoteMaxRate=1);let c=Object.entries(a.sampling.rates);for(let[e,t]of c)(typeof t!=`number`||t<0||t>1)&&(n.report(`config.invalid`,`sampling.rates["${e}"] must be 0..1. The value is ${String(t)}. The library uses 1.`),a.sampling.rates[e]=1);return a.capture.ignoreUrls=a.capture.ignoreUrls.filter(e=>e!==r?.endpoint),a.endpoint&&!a.capture.ignoreUrls.includes(a.endpoint)&&(a.capture.ignoreUrls=[...a.capture.ignoreUrls,a.endpoint]),M(t,n),a}function M(t,n){let r=new Set([...Object.keys(e.j),...e.mn]);for(let e of Object.keys(t))r.has(e)||n.report(`config.invalid`,`The library ignores the unknown config key "${e}". Check the spelling.`);for(let r of e.T){let i=t[r];if(typeof i!=`object`||!i)continue;let a=new Set([...Object.keys(e.j[r]),...e.hn[r]]);for(let e of Object.keys(i))a.has(e)||n.report(`config.invalid`,`The library ignores the unknown config key "${r}.${e}". Check the spelling.`)}}function N(t,n){for(let r of Object.keys(n))e.T.includes(r)||Object.assign(t,{[r]:n[r]});for(let r of e.T)Object.assign(t[r],n[r])}var P=class{map=new Map;set(e,t){this.map.set(e,t)}setMany(e){for(let[t,n]of Object.entries(e))this.map.set(t,n)}get(e){return this.map.get(e)}remove(e){this.map.delete(e)}clear(){this.map.clear()}getAll(){return Object.fromEntries(this.map)}},ee=class{handler;throttleMs;counters=new Map;lastEmitted=new Map;constructor(t,n=e.N){this.handler=t,this.throttleMs=n}setHandler(e){this.handler=e}count(e,t=1){let n=(this.counters.get(e)??0)+t;return this.counters.set(e,n),n}report(t,r,i,a){let o=this.count(t),s=Date.now();if(s-(this.lastEmitted.get(t)??0)<this.throttleMs)return;this.lastEmitted.set(t,s);let c={code:t,message:r,detail:i,cause:a,at:s,count:o},{handler:l}=this;if(l)try{n.o(()=>{l(c)})}catch(t){this.count(`handler.threw`),typeof console<`u`&&n.o(()=>{console.warn(`${e.st} The onDiagnostic handler threw an error.`,t)})}}guard(e,t,n){try{return n()}catch(n){this.report(e,t,void 0,n);return}}async guardAsync(e,t,n){try{return await n()}catch(n){this.report(e,t,void 0,n);return}}snapshot(){return Object.fromEntries(this.counters)}reset(){this.counters.clear(),this.lastEmitted.clear()}},te={maxAgeMs:e.nt,endOnOwnerClose:!1,urlParam:e.it};function F(e,t){let n=Reflect.get(e,t);return typeof n==`string`&&n!==``?n:void 0}function I(e,t){let n=Reflect.get(e,t);return typeof n==`number`&&Number.isFinite(n)?n:void 0}function L(e){if(typeof e!=`object`||!e)return null;let t=F(e,`id`),n=F(e,`name`),r=I(e,`startedAt`);return t===void 0||n===void 0||r===void 0?null:{id:t,name:n,startedAt:r,parentId:F(e,`parentId`),ownerContextId:F(e,`ownerContextId`)??``}}function R(e){if(typeof e!=`object`||!e)return null;let t=F(e,`i`),n=F(e,`n`);return t===void 0||n===void 0?null:{id:t,name:n,startedAt:I(e,`s`)??Date.now(),parentId:void 0,ownerContextId:``}}function z(t){let n=JSON.stringify({i:t.id,n:t.name.slice(0,64),s:t.startedAt}),r=new TextEncoder().encode(n),i=``;for(let e of r)i+=String.fromCharCode(e);return btoa(i).replace(e.g,`-`).replace(e._,`_`).replace(e.h,``)}var B=class{options;diagnostics;contextId;onLocalChange;stores;journey=null;expiryTimer=null;constructor(e,n,r,i,a=t.o){this.options=e,this.diagnostics=n,this.contextId=r,this.onLocalChange=i,this.stores=a}current(){return this.journey}async bootstrap(){let t=this.readUrlToken();if(t&&this.adopt(t,`url`))return;let n=this.diagnostics.guard(`storage.unavailable`,`The library could not read the persisted journey.`,()=>this.stores.session().getItem(e.rt));if(n&&this.restore(n))return;let r=await this.readOpenFinToken();r!==null&&this.adopt(r,`openfin.customData`)}start(e,n={}){let r={id:n.id??t.l(this.diagnostics),name:e,startedAt:Date.now(),parentId:n.parent?this.journey?.id:void 0,ownerContextId:this.contextId};return this.setJourney(r),this.onLocalChange(r),r}end(){this.journey!==null&&(this.setJourney(null),this.onLocalChange(null))}applyRemote(e){let t=this.journey;(e===null||t===null||e.id!==t.id)&&this.setJourney(e)}getToken(){let e=this.journey;if(e===null)return;let t=z(e);if(t.length>256)this.diagnostics.report(`journey.token_too_large`,`The journey token is larger than the size limit. The library does not issue it.`,{length:t.length});else return t}adopt(e,t,n=!1){let r=this.decodeToken(e);return r===null?!1:Date.now()-r.startedAt>this.options.maxAgeMs?(this.diagnostics.report(`journey.expired`,`The library discarded a seeded journey older than maxAgeMs.`,{source:t,name:r.name}),!1):(this.setJourney(r),this.diagnostics.report(`journey.adopted`,`The library adopted the journey "${r.name}".`,{source:t,journeyId:r.id}),n&&this.onLocalChange(r),!0)}ownerClosed(e){this.options.endOnOwnerClose&&this.journey?.ownerContextId===e&&this.end()}destroy(){this.clearTimer()}restore(e){let t=L(this.diagnostics.guard(`storage.degraded`,`The library could not parse the persisted journey.`,()=>JSON.parse(e)));return t===null?!1:Date.now()-t.startedAt>this.options.maxAgeMs?(this.diagnostics.report(`journey.expired`,`The library discarded a persisted journey older than maxAgeMs.`,{name:t.name}),this.clearStored(),!1):(this.setJourney(t),this.diagnostics.report(`journey.adopted`,`The library resumed the journey "${t.name}".`,{source:`sessionStorage`,journeyId:t.id}),!0)}decodeToken(t){return this.diagnostics.guard(`config.invalid`,`The library could not decode a seeded journey token.`,()=>{let n=t.replace(e.p,`+`).replace(e.m,`/`),r=(4-n.length%4)%4,i=`=`.repeat(r),a=Uint8Array.from(atob(n+i),e=>e.charCodeAt(0));return R(JSON.parse(new TextDecoder().decode(a)))})??null}setJourney(t){if(this.journey=t,this.clearTimer(),this.diagnostics.guard(`storage.unavailable`,`The library could not save the journey.`,()=>{t===null?this.stores.session().removeItem(e.rt):this.stores.session().setItem(e.rt,JSON.stringify(t))}),t===null)return;let n=Math.max(this.options.maxAgeMs-(Date.now()-t.startedAt),0),r=setTimeout(()=>{this.diagnostics.report(`journey.expired`,`The journey "${t.name}" reached maxAgeMs. The library ended it.`,{journeyId:t.id}),this.journey=null,this.expiryTimer=null,this.clearStored()},n);this.expiryTimer=r,i.t(r)}clearStored(){this.diagnostics.guard(`storage.unavailable`,`The library could not clear the persisted journey.`,()=>{this.stores.session().removeItem(e.rt)})}clearTimer(){this.expiryTimer!==null&&(clearTimeout(this.expiryTimer),this.expiryTimer=null)}readUrlToken(){return this.diagnostics.guard(`config.invalid`,`The library could not read the journey token from the URL.`,()=>typeof location>`u`?null:new URL(location.href).searchParams.get(this.options.urlParam))??null}async readOpenFinToken(){let n=globalThis.fin?.me,r=n?.getOptions;if(r===void 0)return null;let i=(await this.diagnostics.guardAsync(`openfin.unavailable`,`The library could not read fin.me.getOptions().`,()=>t.a(r.call(n),e.vt)))?.customData?.[e._t];return typeof i==`string`?i:null}};function V(e){return e}var H=class{deps;resourceCache=null;constructor(e){this.deps=e}invalidateResource(){this.resourceCache=null}isEnabled(t){let{config:n}=this.deps;if(!n.enabled)return!1;let r=this.deps.remote.sampling?.minLevel()??n.minLevel;return e.at[t]>=e.at[r]}build(i){let{config:a,diagnostics:o,tracing:s,journey:c,sequence:l,limits:u,remote:d}=this.deps;if(!this.isEnabled(i.level))return o.count(`record.dropped_by_level`),{record:null,dropped:`level`};let f=s.resolve(),p=c.current();if(!t.r({level:i.level,type:i.type,namespace:i.namespace,journeyId:p?.id??``,traceId:f.traceId},a,d.sampling?.current()??null))return o.count(`record.dropped_by_sampling`),{record:null,dropped:`sampling`};let m=l.next(),h=r.t(o),g=a.capture.fullUrls?h:r.r(h),_,v=0;try{let e=n.r(this.deps.context.getAll(),u,o),t=n.r(i.scoped??{},u,o),r=n.r(i.payload??{},u,o);v=e.bytes+t.bytes+r.bytes,_={...V(e.value),...V(t.value),...V(r.value)}}catch(t){o.report(`record.sanitize_failed`,`The library could not sanitize the attributes.`,void 0,t),_={[e.d]:!0}}_[e.l]=i.type,_[e.c]=m,_[e.n]=i.namespace,_[e.u]=g,p&&(_[e.a]=p.id,_[e.o]=p.name,p.parentId!==void 0&&(_[e.s]=p.parentId));let y=n.i(i.body,u.maxBodyChars);y!==i.body&&o.count(`record.truncated`);let b={timeUnixNano:t.m(),traceId:f.traceId,spanId:f.spanId,traceFlags:f.traceFlags,severityNumber:e.Zt[i.level],severityText:i.level,body:y,attributes:_,resource:this.resource()},x=a.redact;if(x){let e=o.guard(`record.sanitize_failed`,`The redact hook threw an error.`,()=>x(b));if(e===null)return o.count(`record.dropped_by_redact`),{record:null,dropped:`redact`};if(e!==void 0&&e!==b){if(t.p(e)){let t=n.r(e.attributes,u,o);b={...e,attributes:V(t.value)},v=t.bytes}else o.report(`record.sanitize_failed`,`The redact hook returned a value that is not a record. The library keeps the original record.`)}}if(v>u.maxRecordBytes){o.report(`record.truncated`,`The attributes are larger than the size limit. The library dropped them.`,{bytes:v,body:b.body});let t={[e.l]:i.type,[e.c]:m,[e.n]:i.namespace,[e.u]:g,[e.i]:!0,[e.r]:v};p&&(t[e.a]=p.id,t[e.o]=p.name),b.attributes=t}return{record:b}}resource(){if(this.resourceCache)return this.resourceCache;let{config:t,identity:n,platform:r}=this.deps;return this.resourceCache={[e.Pt]:t.serviceName,[e.Ft]:t.serviceVersion,[e.At]:t.environment,[e.zt]:e.ln,[e.Bt]:e.un,[e.Rt]:e.cn,[e.jt]:r.platform,[e.It]:n.sessionId,[e.Lt]:n.tabId,[e.kt]:n.contextId,[e.Ot]:r.userAgent,...r.openfinUuid===void 0?{}:{[e.Nt]:r.openfinUuid},...r.openfinName===void 0?{}:{[e.Mt]:r.openfinName}},this.resourceCache}},U={errors:async()=>(await Promise.resolve().then(()=>require("./errors-C78ZTjet.cjs"))).ErrorCapture,network:async()=>(await Promise.resolve().then(()=>require("./network-CZ0aFUsy.cjs"))).NetworkCapture,interactions:async()=>(await Promise.resolve().then(()=>require("./interactions-CsE2y_fQ.cjs"))).InteractionCapture,webVitals:async()=>(await Promise.resolve().then(()=>require("./web-vitals-B2FYsEAU.cjs"))).WebVitalsCapture,longFrames:async()=>(await Promise.resolve().then(()=>require("./long-frames-DahhqM6u.cjs"))).LongFrameCapture,console:async()=>(await Promise.resolve().then(()=>require("./console-PKzc-FmR.cjs"))).ConsoleCapture},W=Symbol.for(e.Wt),G=Symbol.for(e.Gt),K=class n{diagnostics;config;platform;identity;stores;identityBuiltAs;sessionTouch;context=new P;breadcrumbs;tracing;sequence=new h;journey;builder;remote={sampling:null};console;bus=null;busBuilt;busLoad;storageBuiltAs;sender;senderLoad;pendingRecords=[];captures=[];captureGeneration=0;captureOnce={webVitals:!1,navigationTiming:!1,longFrames:!1};bootBuffer=[];forwardBuffer=[];forwardScheduled=!1;roleResolved=!1;started=Promise.resolve();ready=!1;destroyed=!1;lastGapAt=0;constructor(n){this.diagnostics=new ee(n.onDiagnostic),this.platform=r.n(this.diagnostics),this.config=j(n,this.diagnostics),this.identityBuiltAs=this.config.identity,this.stores=this.identityBuiltAs===`memory`?t.c():t.o,this.identity=t.f(this.diagnostics,this.stores),this.sessionTouch=new t.s(this.diagnostics,this.stores),this.breadcrumbs=new T(50),this.tracing=new w(this.diagnostics,void 0,this.config.otelLoader),this.tracing.loadOtel(),this.console=new m(this.config.console,this.diagnostics),this.journey=new B(te,this.diagnostics,this.identity.contextId,e=>{this.bus?.broadcastJourney(e)},this.stores),this.builder=new H({remote:this.remote,config:this.config,limits:e.Ct,diagnostics:this.diagnostics,context:this.context,journey:this.journey,tracing:this.tracing,sequence:this.sequence,identity:this.identity,platform:this.platform})}busAccept=(e,t)=>{this.destroyed||this.ensureBus().then(n=>{n&&!this.destroyed&&this.diagnostics.guard(`bus.send_failed`,`The bus could not accept a direct message from a child frame.`,()=>{n.acceptDirect(e,t)})})};static current(){return globalThis[W]??null}static stopped(){return globalThis[G]??null}isDestroyed(){return this.destroyed}static configure(e){let t=n.current();if(t&&!t.destroyed)return t.reconfigure(e),t;let r=new n(e);return globalThis[W]=r,Reflect.deleteProperty(globalThis,G),r.init(),r}reconfigure(e){let t=this.keepDestination(e);N(this.config,j(t,this.diagnostics,this.config)),this.diagnostics.setHandler(this.config.onDiagnostic),this.builder.invalidateResource(),this.console.update(this.config.console),this.keepBuiltStorage(),this.keepBuiltIdentity(),this.installCaptures(),this.roleResolved&&this.syncSender(),this.diagnostics.report(`config.reconfigured`,`A later configure() call updated the runtime.`)}keepBuiltStorage(){let e=this.storageBuiltAs;e!==void 0&&this.config.storage!==e&&(this.diagnostics.report(`config.invalid`,`storage cannot change after startup. It stays ${e}.`,{requested:this.config.storage}),this.config.storage=e)}keepDestination(e){if(this.senderLoad===void 0)return e;let t=e;return`transport`in e&&e.transport===void 0!=(this.config.transport===void 0)&&(this.diagnostics.report(`config.invalid`,`You cannot add or remove transport after the delivery stack loads. The transport in force stays.`),t={...t},delete t.transport),(t.endpoint===null||t.endpoint===``)&&this.config.transport===void 0&&(this.diagnostics.report(`config.invalid`,`You cannot remove the endpoint after the delivery stack loads. The endpoint in force stays.`),t={...t,endpoint:void 0}),t}keepBuiltIdentity(){let e=this.identityBuiltAs;this.config.identity!==e&&(this.diagnostics.report(`config.invalid`,`identity cannot change after startup. It stays ${e}.`,{requested:this.config.identity}),this.config.identity=e)}async init(){let e=this.installCaptures();this.started=this.boot(),await this.started,await e}async boot(){try{let e=this.journey.bootstrap();this.config.bus.mode!==`off`&&await this.ensureBus(),this.roleResolved=!0,await this.syncSender(),await e}catch(e){this.diagnostics.report(`pipeline.crashed`,`Startup failed. The runtime continues with reduced function.`,void 0,e)}finally{this.ready=!0,this.releaseBootBuffer()}}ensureBus(){return this.busLoad??=this.startBus(),this.busLoad}constructBus(){return this.busBuilt??=this.buildBus(),this.busBuilt}async startBus(){let e=await this.constructBus();if(!e)return null;try{return await e.start(),e}catch(e){return this.diagnostics.report(`pipeline.crashed`,`The bus did not start. This context sends its own records.`,void 0,e),null}}async buildBus(){try{let{Bus:e}=await Promise.resolve().then(()=>require("./bus-CUXRY0JR.cjs"));if(this.destroyed)return null;let t=new e(this.config,this.diagnostics,this.platform,this.identity.contextId,this.identity.tabId,{onRecords:e=>{this.ingestForwarded(e)},onJourney:e=>{this.journey.applyRemote(e)},onJourneyRequest:()=>this.journey.current(),onTabConflict:()=>{this.regenerateTabId()},remote:this.remote});return this.bus=t,t}catch(e){return this.diagnostics.report(`pipeline.crashed`,`The bus did not load. This context sends its own records.`,void 0,e),null}}role(){return this.bus?.getRole()??`sender`}syncSender(){return!(this.config.endpoint||this.config.transport!==void 0)||this.role()!==`sender`?Promise.resolve():this.loadSender()}loadSender(){return this.senderLoad??=this.buildSender(),this.senderLoad}async buildSender(){this.storageBuiltAs=this.config.storage;try{let{Sender:e}=await Promise.resolve().then(()=>require("./sender-B6ufz26f.cjs")),t=this.destroyed?null:await e.create({config:this.config,diagnostics:this.diagnostics,onGap:this.reportGap,remote:this.remote});if(!t||this.destroyed){await t?.destroy();return}this.sender=t}catch(e){this.senderLoad=void 0,this.diagnostics.report(`pipeline.crashed`,`The delivery stack did not load. The library does not send records.`,{held:this.pendingRecords.length},e)}let e=this.pendingRecords;this.pendingRecords=[];for(let t of e)this.sender?.push(t)}async installCaptures(){let t=++this.captureGeneration,n=this.config.capture,r=[];(n.errors||n.rejections||n.resourceErrors)&&r.push(`errors`),(n.fetch||n.xhr)&&r.push(`network`),(n.interactions||n.navigation)&&r.push(`interactions`),n.webVitals&&r.push(`webVitals`),n.longFrames&&r.push(`longFrames`),(Array.isArray(n.console)?n.console.length>0:n.console)&&r.push(`console`);let i=await Promise.all(r.map(e=>this.loadCapture(e)));if(t!==this.captureGeneration||this.destroyed)return;this.uninstallCaptures();let a={config:this.config,diagnostics:this.diagnostics,breadcrumbs:this.breadcrumbs,tracing:this.tracing,logger:new f(()=>this,e.C),once:this.captureOnce};for(let e of i)e&&this.captures.push(new e(a));for(let e of this.captures)this.diagnostics.guard(`capture.install_failed`,`The library could not install the ${e.name} capture.`,()=>{e.install()})}uninstallCaptures(){for(let e of this.captures)this.diagnostics.guard(`capture.install_failed`,`The library could not uninstall the ${e.name} capture.`,()=>{e.uninstall()});this.captures.length=0}loadCapture(e){return this.diagnostics.guardAsync(`capture.install_failed`,`The library could not load the ${e} capture.`,U[e])}registerWorker(e){this.destroyed||this.constructBus().then(t=>{t&&!this.destroyed&&(this.diagnostics.guard(`bus.send_failed`,`The library could not register the worker.`,()=>{t.attachWorker(e)}),this.ensureBus())})}async destroy(){if(this.destroyed)return;this.destroyed=!0,this.uninstallCaptures();let e=this.sender?.destroy();this.journey.destroy(),this.bus?.destroy(),this.forwardBuffer=[],this.pendingRecords=[],await e,await this.senderLoad,n.current()===this&&(Reflect.deleteProperty(globalThis,W),globalThis[G]=this)}emit(e){e&&!this.destroyed&&(this.sessionTouch.touch(this.identity.sessionId),this.ready?this.route(e):this.pushCapped(this.bootBuffer,e))}route(e){this.role()===`forwarder`?this.forward(e):this.deliver(e)}deliver(e){this.sender?this.sender.push(e):this.senderLoad&&this.pushCapped(this.pendingRecords,e)}pushCapped(e,t){e.length>=500&&(e.shift(),this.diagnostics.count(`record.dropped_boot_buffer_full`)),e.push(t)}forward(e){this.forwardBuffer.push(e),!this.forwardScheduled&&(this.forwardScheduled=!0,queueMicrotask(()=>{this.forwardScheduled=!1;let e=this.forwardBuffer;this.forwardBuffer=[],e.length>0&&this.bus?.sendRecords(e)}))}ingestForwarded(e){if(!Array.isArray(e))this.diagnostics.count(`record.dropped_malformed`);else for(let n of e)t.p(n)?t.n(n,this.config,this.remote.sampling?.current()??null)?this.deliver(n):this.diagnostics.count(`record.dropped_by_sampling`):this.diagnostics.count(`record.dropped_malformed`)}releaseBootBuffer(){let e=this.bootBuffer;this.bootBuffer=[];let t=this.journey.current();for(let n of e)t&&!n.attributes[`journey.id`]&&(n.attributes[`journey.id`]=t.id,n.attributes[`journey.name`]=t.name),this.route(n)}reportGap=t=>{let n=Date.now();n-this.lastGapAt<6e4||(this.lastGapAt=n,new f(()=>this,e.tn).warn(`stored records were dropped before delivery`,{"gap.batches":t.batches,"gap.records":t.records,"gap.reason":t.reason}))};regenerateTabId(){let e=t.l(this.diagnostics);this.diagnostics.report(`bus.role_resolved`,`Another context uses this tab id. A duplicated tab is the usual cause. The library makes a new tab id.`,{was:this.identity.tabId,now:e}),this.identity.tabId=e,t.u(e,this.diagnostics,this.stores),this.builder.invalidateResource()}async queueDepth(){return await this.senderLoad,await this.sender?.queueDepth()??0}async flush(){if(this.ready||await this.started,this.role()===`forwarder`){let e=this.forwardBuffer;this.forwardBuffer=[],e.length>0&&this.bus?.sendRecords(e)}else await this.senderLoad,await this.sender?.flush()}};function q(){let e=[],t=[],n={status:200};return{transport:r=>(e.push(r),n.status>=200&&n.status<300&&t.push(r),Promise.resolve({...n})),records:()=>t.flatMap(e=>[...e.records]),batches:()=>[...e],clear:()=>{e.length=0,t.length=0},respondWith:(e,t)=>{n=t===void 0?{status:e}:{status:e,retryAfterMs:t}}}}var J=new Map;function Y(){return(K.current()??K.stopped())||K.configure({})}function X(e){K.configure(e)}function Z(e,t){if(t)return new f(Y,e,t);let n=J.get(e);return n||(n=new f(Y,e),J.set(e,n)),n}function Q(){return Z(`app`)}function ne(e,t){Q().trace(e,t)}function re(e,t){Q().debug(e,t)}function ie(e,t){Q().info(e,t)}function ae(e,t){Q().warn(e,t)}function oe(e,t,n){Q().error(e,t,n)}function se(e,t){Q().logAction(e,t)}function ce(e,t){Q().logEvent(e,t)}function le(e,t,n,r,i){Q().logMetric(e,t,n,r,i)}function ue(e,t,n){return Q().timeSync(e,t,n)}function de(e,t,n){return Q().timeAsync(e,t,n)}function fe(e,t){Y().context.set(e,t)}function pe(e){Y().context.setMany(e)}function me(e){Y().context.remove(e)}function he(e,t){return Y().journey.start(e,t)}function ge(){Y().journey.end()}function _e(){return Y().journey.current()}function ve(){return Y().journey.getToken()}function ye(e){return Y().journey.adopt(e,`manual`,!0)}function be(e){Y().registerWorker(e)}function $(){Y().tracing.rotate(`explicit`)}function xe(){return Y().tracing.headers()}function Se(){return Y().flush()}function Ce(){return Y().queueDepth()}function we(){return Y().diagnostics.snapshot()}async function Te(){await K.current()?.destroy()}exports.OneLogger=f,exports.adoptJourney=ye,exports.configure=X,exports.createMemoryTransport=q,exports.currentJourney=_e,exports.debug=re,exports.endJourney=ge,exports.error=oe,exports.flush=Se,exports.getDiagnosticCounters=we,exports.getJourneyToken=ve,exports.getLogger=Z,exports.getQueueDepth=Ce,exports.getTraceHeaders=xe,exports.info=ie,exports.logAction=se,exports.logEvent=ce,exports.logMetric=le,exports.registerWorker=be,exports.removeContext=me,exports.setContext=fe,exports.setContextMap=pe,exports.shutdown=Te,exports.startJourney=he,exports.startTrace=$,exports.timeAsync=de,exports.timeSync=ue,exports.trace=ne,exports.warn=ae;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-X86IDwkC.cjs"),t=require("./error-like-gGRx2s36.cjs"),n=require("./sampling-b2ck5X98.cjs"),r=require("./sanitize-DKp5MRsa.cjs"),i=require("./identity-B1GDS1Tb.cjs"),a=require("./platform-DW3GFIUE.cjs"),o=require("./batch-DEVFs28i.cjs"),s=require("./library-request-BZ1ekVtl.cjs"),c=require("./journey-DxlfdFJV.cjs");function l(t){return Math.round((performance.now()-t)*e.R)/e.R}function u(e,t,n,r,i){e.logMetric(`${t}.duration`,n,`ms`,`histogram`,{status:r,...i})}function d(e,t,n,r,i){let a=l(n);e.error(`${t} failed`,r,{"action.duration_ms":a,status:`FAILURE`,...i}),u(e,t,a,`FAILURE`,i)}function f(e,t,n,r){let i=performance.now();try{let a=n();return u(e,t,l(i),`SUCCESS`,r),a}catch(n){throw d(e,t,i,n,r),n}}async function p(e,t,n,r){let i=performance.now();try{let a=await n();return u(e,t,l(i),`SUCCESS`,r),a}catch(n){throw d(e,t,i,n,r),n}}var m=[e.E,e.rn];function h(e,n){let r=n.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>{if(!(e instanceof Error)&&!t.r(e))return;let n=Error(e.message);return n.name=e.name,n.stack=e.stack,n});if(r)return r;let i=n.guard(`record.sanitize_failed`,`The library could not convert the error reason to text.`,()=>String(e));return Error(i??typeof e)}function g(e,t,n){return n.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>e instanceof Error?e:t)??t}function _(e,n){if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||typeof e==`symbol`)return e;if(typeof e==`object`&&e)return n.guard(`record.sanitize_failed`,`The library could not read the properties of the error reason.`,()=>{let n=e,r=t.r(e),i={},a=0;for(let e of Object.keys(n)){let o=n[e];(!r||!t.t.has(e))&&t.n(o)&&(i[e]=o,a++)}return a===0?void 0:i})}function v(e){if(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Error)return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function y(e){return m.some(t=>e===t||e.startsWith(`${t}.`))?`system`:`log`}function b(e,t){return e===void 0?{}:t.guard(`record.sanitize_failed`,`The library could not read the payload.`,()=>({...e}))??{"uiobs.sanitize_failed":!0}}var x=class t{bind;namespace;options;levelType;constructor(e,t,n={}){this.bind=e,this.namespace=t,this.options=n,this.levelType=y(t)}child(e,n={}){return new t(this.bind,`${this.namespace}.${e}`,{scopedContext:{...this.options.scopedContext,...n.scopedContext}})}trace=(e,t)=>{this.write(`TRACE`,this.levelType,e,t)};debug=(e,t)=>{this.write(`DEBUG`,this.levelType,e,t)};info=(e,t)=>{this.write(`INFO`,this.levelType,e,t)};warn=(e,t)=>{this.write(`WARN`,this.levelType,e,t)};error=(e,t,n)=>{this.writeError(`ERROR`,e,t,n)};fatal=(e,t,n)=>{this.writeError(`FATAL`,e,t,n)};logAction=(e,t)=>{this.write(`INFO`,`action`,e,t)};logEvent=(e,t)=>{this.write(`INFO`,`event`,e,t)};logMetric=(t,n,r=e.F,i=`gauge`,a)=>{if(!Number.isFinite(n)){this.bind().diagnostics.report(`record.dropped_malformed`,`The metric value is not a finite number. The library dropped the metric.`,{"metric.name":t});return}let o={...b(a,this.bind().diagnostics),"metric.name":t,"metric.value":n,"metric.unit":r,"metric.type":i};this.write(`INFO`,`metric`,t,o,!0)};timeSync=(e,t,n)=>f(this,e,t,n);timeAsync=(e,t,n)=>p(this,e,t,n);write(e,t,n,r,i=!1){let a=this.bind();if(a.isDestroyed())return;if(!a.builder.isEnabled(e,t)){this.mirrors(a,e)&&this.print(a,e,n,r,void 0,null);return}let{record:o,dropped:s}=a.builder.build({level:e,type:t,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:i?r:b(r,a.diagnostics)}),c=o?o.body:s===`sampling`?n:void 0;t!==`metric`&&c!==void 0&&a.breadcrumbs.push({t:Date.now(),category:t===`action`?`action`:t===`event`?`event`:`log`,message:c}),this.print(a,e,n,r,void 0,o,s),a.emit(o)}writeError(t,n,r,i){let a=this.bind();if(a.isDestroyed())return;let o=a.builder.isEnabled(t);if(!o&&!this.mirrors(a,t))return;let s=i===void 0&&(a.diagnostics.guard(`record.sanitize_failed`,`The library could not read the error slot.`,()=>v(r))??!1),c=s?r:i,l=s?void 0:r,u=l===void 0?void 0:h(l,a.diagnostics),d=u===void 0?void 0:g(l,u,a.diagnostics);if(!o){this.print(a,t,n,c,d,null);return}let f=u?_(l,a.diagnostics):void 0,{record:p,dropped:m}=a.builder.build({level:t,type:this.levelType,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...b(c,a.diagnostics),...u?{"error.type":u.name,"error.message":u.message,"error.stack_trace":u.stack}:{},...f===void 0?{}:{[e.o]:f},[e.a]:a.breadcrumbs.snapshot()}});this.print(a,t,n,c,d,p,m),a.emit(p)}print(e,t,n,r,i,a,o){e.config.redact?a?e.console.write(this.namespace,t,a.body,a.attributes):o!==`redact`&&o!==`malformed`&&e.console.write(this.namespace,t,n,void 0,i):e.console.write(this.namespace,t,n,r,i)}mirrors(e,t){return e.config.enabled&&e.console.accepts(t)}},ee={TRACE:`debug`,DEBUG:`debug`,INFO:`info`,WARN:`warn`,ERROR:`error`,FATAL:`error`},te=class{settings;diagnostics;limits;constructor(t,n,r=e.Et){this.settings=t,this.diagnostics=n,this.limits=r}update(e){this.settings=e}accepts(t){return this.settings.level===null||!Object.hasOwn(e.lt,this.settings.level)?!1:e.lt[t]>=e.lt[this.settings.level]}write(e,t,n,i,a){if(!this.accepts(t)||typeof console>`u`||r.a())return;let o=`%c[%s]%c[${t}]%c`,{styles:s}=this.settings,c=ee[t];this.diagnostics.guard(`handler.threw`,`The library could not print to console.${c}.`,()=>{let l=[];a!==void 0&&l.push(a),i!==void 0&&l.push(r.n(i,this.limits,this.diagnostics)),r.o(()=>{console[c](o,s.namespace,e,s[t],``,n,...l)})})}},ne=class{value=0;next(){return++this.value}},re=/^[0-9a-f]{32}$/,ie=/^[0-9a-f]{16}$/,S=/[1-9a-f]/;function ae(e){return re.test(e.traceId)&&S.test(e.traceId)&&ie.test(e.spanId)&&S.test(e.spanId)}function oe(){return i.o(16)}function se(){return i.o(8)}function C(){return{traceId:oe(),spanId:se(),traceFlags:1,startedAt:Date.now()}}function w(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags}}var ce=class{diagnostics;maxAgeMs;load;ambient=C();otel;constructor(t,n=e.mn,r){this.diagnostics=t,this.maxAgeMs=n,this.load=r}async loadOtel(){if(this.load)try{this.otel=await this.load()}catch(e){this.diagnostics.report(`trace.otel_failed`,`The library could not load @opentelemetry/api. Records use the trace ids of the library.`,void 0,e)}}resolve(){let e=this.activeSpanContext();return e===void 0?(Date.now()-this.ambient.startedAt>this.maxAgeMs&&this.rotate(`maxAge`),w(this.ambient)):e}activeSpanContext(){let e=this.otel;if(e)return this.diagnostics.guard(`trace.otel_failed`,`The library could not read the active OpenTelemetry span.`,()=>{let t=e.trace.getActiveSpan();if(t===void 0)return;let n=t.spanContext();if(ae(n))return{traceId:n.traceId,spanId:n.spanId,traceFlags:n.traceFlags}})}rotate(e){return this.ambient=C(),w(this.ambient)}headers(){let t={},n=this.otel;if(n&&this.diagnostics.guard(`trace.otel_failed`,`The library could not add the OpenTelemetry headers.`,()=>{n.propagation.inject(n.context.active(),t)}),!t.traceparent){let n=this.resolve(),r=(n.traceFlags&255).toString(16).padStart(2,`0`);t[e.pn]=`00-${n.traceId}-${n.spanId}-${r}`}return t}},le=class{buffer;pointer=0;filled=!1;capacity;constructor(e){this.capacity=Math.max(e,1),this.buffer=Array(this.capacity)}push(e){this.buffer[this.pointer]=e,this.pointer=(this.pointer+1)%this.capacity,this.pointer===0&&(this.filled=!0)}snapshot(){return(this.filled?[...this.buffer.slice(this.pointer),...this.buffer.slice(0,this.pointer)]:this.buffer.slice(0,this.pointer)).filter(e=>e!==void 0)}clear(){this.buffer=Array(this.capacity),this.pointer=0,this.filled=!1}},T=Object.keys(e.lt),ue=[`gzip`,`none`],de=[`omit`,`same-origin`,`include`],fe=[`auto`,`indexeddb`,`localstorage`,`memory`,`none`],pe=[`storage`,`memory`],me=[`auto`,`sender`,`forwarder`,`off`],he=[`auto`,`provider`,`client`],ge=[`auto`,`context`,`tab`,`origin`],E=[`error`,`warn`,`info`,`log`],_e=[`limited`,`until-delivered`],ve={logFlushIntervalMs:[100,6e4],logBatchSize:[1,1e3],metricFlushIntervalMs:[100,6e4],metricBatchSize:[1,1e3]},ye={maxBatches:[1,5e3],maxAgeMs:[6e4,6048e5],maxAttempts:[1,20]},be={maxBodyChars:[256,65536],maxAttributeChars:[256,65536],maxAttributeCount:[1,1024],maxStackChars:[256,65536],maxDepth:[1,16],maxArrayLength:[1,1e4],maxNodes:[100,1e5],maxRecordBytes:[1024,e.x]},xe=[6e4,864e5],Se=[`errors`,`rejections`,`resourceErrors`,`fetch`,`xhr`,`interactions`,`navigation`,`webVitals`,`longFrames`,`fullUrls`],Ce=`null`,D=`a level name: ${k(T)}`,O=`true, false or a list of ${k(E)}`,we=`a list of strings and RegExp patterns`,Te=`a list of origin URLs such as "https://api.example" and RegExp patterns`,Ee=`a list of origin URLs such as "https://app.example". For a sandboxed frame, set bus.mode: "sender" in the frame`,De=`a list of strings`;function k(e){let t=e.map(e=>`"${e}"`);return`${t.slice(0,-1).join(`, `)} or ${t[t.length-1]}`}function A(e){return typeof e==`string`?`"${e}"`:typeof e==`function`?`a function`:typeof e==`object`&&e?`an object`:String(e)}function j(e,t,n,r,i){e.report(`config.invalid`,`${t} must be ${n}. The value is ${A(r)}. The library keeps ${i}.`)}function M(e,t,n,r,i){if(t===void 0)return r;let a=n.find(e=>e===t);return a===void 0?(j(i,e,k(n),t,`"${r}"`),r):a}function N(e,t,n,r){return t===void 0?n:typeof t==`boolean`?t:(j(r,e,`true or false`,t,String(n)),n)}function Oe(e,t,n,r){return t===void 0?n:typeof t==`number`&&Number.isFinite(t)&&t>=0?t:(j(r,e,`a finite number of 0 or more`,t,String(n)),n)}function P(e,t,n,r,i){if(t===void 0)return r;let[a,o]=n;return typeof t==`number`&&Number.isInteger(t)&&t>=a&&t<=o?t:(j(i,e,`an integer from ${String(a)} to ${String(o)}`,t,String(r)),r)}function F(e,t,n,r,i){let a=t??{},o=Object.keys(r);return Object.fromEntries(o.map(t=>[t,P(`${e}.${t}`,a[t],r[t],n[t],i)]))}function I(e){if(typeof e!=`string`)return;let t=e.toUpperCase();return T.find(e=>e===t)}function ke(e,t,n,r){if(t===void 0)return n;let i=I(t);return i===void 0?(j(r,e,D,t,`"${n}"`),n):i}function L(e,t,n,r,i,a){if(t===void 0)return n;if(!Array.isArray(t))return j(a,e,r,t,`the list in force`),n;let o=[],s=t;for(let t of s){let n=i(t);n===void 0?a.report(`config.invalid`,`The library ignores the ${e} entry ${A(t)}. ${e} must be ${r}.`):o.push(n)}return o}function Ae(e){return typeof e==`string`?e:void 0}function je(e){return typeof e==`string`||e instanceof RegExp?e:void 0}function Me(e){return E.find(t=>t===e)}function R(e){if(typeof e==`string`)try{let{origin:t}=new URL(e);return t===Ce?void 0:t}catch{return}}function Ne(e){return e instanceof RegExp?e:R(e)}function Pe(e){return typeof e!=`object`||!e||Array.isArray(e)?!1:Object.values(e).every(e=>typeof e==`string`)}function Fe(e,t,n){if(e!==void 0)return typeof e==`function`||Pe(e)?e:(j(n,`headers`,`an object of strings or a function`,e,`the headers in force`),t)}function Ie(e){return typeof e!=`object`||!e?!1:typeof Reflect.get(e,`serialize`)==`function`}function Le(t,n,r){return t===void 0?n??`otlp`:t===`otlp`||t===`ecs`||Ie(t)?t:(r.report(`config.invalid`,`serializer must be "${e.Xt}", "ecs" or an implementation. The library uses "${e.Xt}".`),e.Xt)}var Re=new Set(Object.keys(e.A));function ze(e,t){let n={},r=Object.entries(e??{});for(let[e,i]of r)Re.has(e)?typeof i==`string`?n[e]=i:t.report(`config.invalid`,`console.styles.${e} must be a string. The library keeps the style in force.`):t.report(`config.invalid`,`The library ignores the unknown console.styles key "${e}". Check the spelling.`);return n}function Be(e,t,n){if(e===void 0)return t??`DEBUG`;let r=I(e);return r===void 0?(j(n,`console.level`,D,e,`the console level in force`),t):r}function Ve(t,n,r){if(t===void 0)return n;if(t===!1)return{level:null,styles:n.styles};if(t===!0)return{level:e.k,styles:n.styles};if(typeof t==`string`){let e=I(t);return e===void 0?(j(r,`console`,D,t,`the console level in force`),n):{level:e,styles:n.styles}}return typeof t!=`object`||!t?(r.report(`config.invalid`,`console must be a boolean, a level or an object. The console settings in force stay.`),n):{level:Be(t.level,n.level,r),styles:{...n.styles,...ze(t.styles,r)}}}function He(e,t,n){let r=e??{};return{...t,...r,rates:{...t.rates,...r.rates},alwaysSampleTypes:L(`sampling.alwaysSampleTypes`,r.alwaysSampleTypes,t.alwaysSampleTypes,De,Ae,n),remote:N(`sampling.remote`,r.remote,t.remote,n)}}function Ue(e,t,n){let r=e??{};return{mode:M(`bus.mode`,r.mode,me,t.mode,n),trustedOrigins:L(`bus.trustedOrigins`,r.trustedOrigins,t.trustedOrigins,Ee,R,n),openFinRole:M(`bus.openFinRole`,r.openFinRole,he,t.openFinRole,n)}}function We(e,t,n){let r=e??{};return{scope:M(`journey.scope`,r.scope,ge,t.scope,n),maxAgeMs:P(`journey.maxAgeMs`,r.maxAgeMs,xe,t.maxAgeMs,n)}}function Ge(e,t,n){let r=e??{};return{mode:M(`retention.mode`,r.mode,_e,t.mode,n),...F(`retention`,r,t,ye,n)}}function Ke(e,t,n){return e===void 0?t:typeof e==`boolean`?e:Array.isArray(e)?L(`capture.console`,e,[],O,Me,n):(j(n,`capture.console`,O,e,`the value in force`),t)}function qe(e,t,n){let r=e??{},i={...t,...r,console:Ke(r.console,t.console,n),longFrameThresholdMs:Oe(`capture.longFrameThresholdMs`,r.longFrameThresholdMs,t.longFrameThresholdMs,n),ignoreUrls:L(`capture.ignoreUrls`,r.ignoreUrls,t.ignoreUrls,we,je,n),propagateTraceHeaderTo:L(`capture.propagateTraceHeaderTo`,r.propagateTraceHeaderTo,t.propagateTraceHeaderTo,Te,Ne,n)};for(let e of Se)i[e]=N(`capture.${e}`,r[e],t[e],n);return i}function z(t,n,r){let i=r??e.P,a={...i,...t,endpoint:t.endpoint===void 0?i.endpoint:t.endpoint,enabled:N(`enabled`,t.enabled,i.enabled,n),minLevel:ke(`minLevel`,t.minLevel,i.minLevel,n),compression:M(`compression`,t.compression,ue,i.compression,n),credentials:M(`credentials`,t.credentials,de,i.credentials,n),headers:`headers`in t?Fe(t.headers,i.headers,n):i.headers,storage:M(`storage`,t.storage,fe,i.storage,n),identity:M(`identity`,t.identity,pe,i.identity,n),serializer:Le(t.serializer,r?.serializer,n),console:Ve(t.console,i.console,n),sampling:He(t.sampling,i.sampling,n),bus:Ue(t.bus,i.bus,n),batching:F(`batching`,t.batching,i.batching,ve,n),retention:Ge(t.retention,i.retention,n),limits:F(`limits`,t.limits,i.limits,be,n),journey:We(t.journey,i.journey,n),capture:qe(t.capture,i.capture,n)};if(a.transport!==void 0&&typeof a.transport!=`function`&&(n.report(`config.invalid`,`transport must be a function. The library ignores the value.`),a.transport=i.transport),a.onDrop!==void 0&&typeof a.onDrop!=`function`&&(n.report(`config.invalid`,`onDrop must be a function. The library ignores the value.`),a.onDrop=i.onDrop),a.transportOnExit!==void 0&&typeof a.transportOnExit!=`function`&&(n.report(`config.invalid`,`transportOnExit must be a function. The library ignores the value.`),a.transportOnExit=i.transportOnExit),a.endpoint===``)a.transport===void 0&&n.report(`config.invalid`,`endpoint is missing. The library drops each record. Set endpoint: null for console-only mode.`);else if(a.endpoint!==null)try{new URL(a.endpoint)}catch(e){n.report(`config.invalid`,`endpoint is not a valid absolute URL: ${a.endpoint}.`,void 0,e)}a.serviceName||=(n.report(`config.invalid`,`serviceName is missing. Every record reports service.name as '${e.vn}'.`),e.vn);let o=a.sampling.defaultRate;(typeof o!=`number`||o<0||o>1)&&(n.report(`config.invalid`,`sampling.defaultRate must be 0..1. The value is ${String(o)}. The library uses 1.`),a.sampling.defaultRate=1);let s=a.sampling.remoteMaxRate;(typeof s!=`number`||!(s>=0&&s<=1))&&(n.report(`config.invalid`,`sampling.remoteMaxRate must be 0..1. The value is ${String(s)}. The library uses 1.`),a.sampling.remoteMaxRate=1);let c=Object.entries(a.sampling.rates);for(let[e,t]of c)(typeof t!=`number`||t<0||t>1)&&(n.report(`config.invalid`,`sampling.rates["${e}"] must be 0..1. The value is ${String(t)}. The library uses 1.`),a.sampling.rates[e]=1);return a.capture.ignoreUrls=a.capture.ignoreUrls.filter(e=>e!==r?.endpoint),a.endpoint&&!a.capture.ignoreUrls.includes(a.endpoint)&&(a.capture.ignoreUrls=[...a.capture.ignoreUrls,a.endpoint]),Je(t,n),a}function Je(t,n){let r=new Set([...Object.keys(e.P),...e.gn]);for(let e of Object.keys(t))r.has(e)||n.report(`config.invalid`,`The library ignores the unknown config key "${e}". Check the spelling.`);for(let r of e.O){let i=t[r];if(typeof i!=`object`||!i)continue;let a=new Set([...Object.keys(e.P[r]),...e._n[r]]);for(let e of Object.keys(i))a.has(e)||n.report(`config.invalid`,`The library ignores the unknown config key "${r}.${e}". Check the spelling.`)}}function Ye(t,n){for(let r of Object.keys(n))e.O.includes(r)||Object.assign(t,{[r]:n[r]});for(let r of e.O)Object.assign(t[r],n[r])}var Xe=class{map=new Map;set(e,t){this.map.set(e,t)}setMany(e){for(let[t,n]of Object.entries(e))this.map.set(t,n)}get(e){return this.map.get(e)}remove(e){this.map.delete(e)}clear(){this.map.clear()}getAll(){return Object.fromEntries(this.map)}},Ze=class{handler;throttleMs;counters=new Map;lastEmitted=new Map;constructor(t,n=e.I){this.handler=t,this.throttleMs=n}setHandler(e){this.handler=e}count(e,t=1){let n=(this.counters.get(e)??0)+t;return this.counters.set(e,n),n}report(t,n,i,a){let o=this.count(t),s=Date.now();if(s-(this.lastEmitted.get(t)??0)<this.throttleMs)return;this.lastEmitted.set(t,s);let c={code:t,message:n,detail:i,cause:a,at:s,count:o},{handler:l}=this;if(l)try{r.o(()=>{l(c)})}catch(t){this.count(`handler.threw`),typeof console<`u`&&r.o(()=>{console.warn(`${e.dt} The onDiagnostic handler threw an error.`,t)})}}guard(e,t,n){try{return n()}catch(n){this.report(e,t,void 0,n);return}}async guardAsync(e,t,n){try{return await n()}catch(n){this.report(e,t,void 0,n);return}}snapshot(){return Object.fromEntries(this.counters)}reset(){this.counters.clear(),this.lastEmitted.clear()}};function B(e,t){e.length<20&&!e.includes(t)&&e.push(t)}var Qe=class{config;diagnostics;pending=new Map;scheduled=!1;reporting=!1;constructor(e,t){this.config=e,this.diagnostics=t}add(t,n,r=[]){if(!this.config.onDrop||this.reporting||n.length===0&&r.length===0)return;let i=this.pending.get(t);i||(i={reason:t,records:0,batchIds:[],journeyIds:[],actions:[]},this.pending.set(t,i)),i.records+=n.length;for(let e of r)B(i.batchIds,e);for(let t of n){let n=o.t(t,e.s);typeof n==`string`&&B(i.journeyIds,n);let r=o.n(t)?t.body:void 0;typeof r==`string`&&B(i.actions,r)}this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.flush()}))}flush(){this.scheduled=!1;let e=[...this.pending.values()];this.pending.clear();let t=this.config.onDrop;if(t){this.reporting=!0;for(let n of e)this.diagnostics.guard(`handler.threw`,`The onDrop hook threw an error.`,()=>{s.n(()=>{r.o(()=>{t(n)})})});this.reporting=!1}}},V=class{onDrop;held=[];actions=0;constructor(e){this.onDrop=e}get records(){return this.held}get length(){return this.held.length}push(e){let t=o.n(e);if((t?this.actions:this.held.length-this.actions)<(t?2e3:500))this.actions+=+!!t;else{let e=this.held.findIndex(e=>o.n(e)===t),[n]=this.held.splice(e,1);this.onDrop(n)}this.held.push(e)}take(){let e=this.held;return this.held=[],this.actions=0,e}},$e=`error.`,et=[e.f,e.s,e.c];function H(e){return e}var tt=class{deps;resourceCache=null;constructor(e){this.deps=e}invalidateResource(){this.resourceCache=null}isEnabled(t,n){let{config:r}=this.deps;if(!r.enabled)return!1;if(n!==void 0&&e.ct.includes(n))return!0;let i=this.deps.remote.sampling?.minLevel()??r.minLevel;return e.lt[t]>=e.lt[i]}build(t){let{config:i,diagnostics:o,tracing:s,journey:c,sequence:l,limits:u,remote:d}=this.deps;if(!this.isEnabled(t.level,t.type))return o.count(`record.dropped_by_level`),{record:null,dropped:`level`};let f=s.resolve(),p=c.current();if(!n.r({level:t.level,type:t.type,namespace:t.namespace,journeyId:p?.id??``,traceId:f.traceId},i,d.sampling?.current()??null))return o.count(`record.dropped_by_sampling`),{record:null,dropped:`sampling`};let m=l.next(),h=a.t(o),g=i.capture.fullUrls?h:a.r(h),_,v=0;try{let e=r.r(this.deps.context.getAll(),u,o),n=r.r(t.scoped??{},u,o),i=r.r(t.payload??{},u,o);v=e.bytes+n.bytes+i.bytes,_={...H(e.value),...H(n.value),...H(i.value)}}catch(t){o.report(`record.sanitize_failed`,`The library could not sanitize the attributes.`,void 0,t),_={[e.p]:!0}}_[e.d]=t.type,_[e.u]=m,_[e.n]=t.namespace,_[e.f]=g,p&&(_[e.s]=p.id,_[e.c]=p.name,p.parentId!==void 0&&(_[e.l]=p.parentId));let y=r.i(t.body,u.maxBodyChars);y!==t.body&&o.count(`record.truncated`);let b={timeUnixNano:n.o(),traceId:f.traceId,spanId:f.spanId,traceFlags:f.traceFlags,severityNumber:e.en[t.level],severityText:t.level,body:y,attributes:_,resource:this.resource()},x=i.redact;if(x){let t;try{t=x(b)}catch(e){return o.report(`record.dropped_by_redact`,`The redact hook threw an error. The library dropped the record.`,void 0,e),{record:null,dropped:`redact`}}if(t===null)return o.count(`record.dropped_by_redact`),{record:null,dropped:`redact`};let i=t??b;if(!n.a(i))return i===b?(o.report(`record.dropped_malformed`,`The redact hook changed the record to a shape that is not a record. The library dropped it.`),{record:null,dropped:`malformed`}):(o.report(`record.dropped_by_redact`,`The redact hook returned a value that is not a record. The library dropped the record.`),{record:null,dropped:`redact`});if(n.i(i.severityText)){if(i!==b){let e=r.r(i.attributes,u,o);b={...i,attributes:H(e.value)},v=e.bytes}b.severityNumber=e.en[b.severityText]}else return o.report(`record.dropped_malformed`,`The redact hook set a severityText that is not a log level. The library dropped the record.`),{record:null,dropped:`malformed`}}if(v>u.maxRecordBytes){o.report(`record.truncated`,`The attributes are larger than the size limit. The library dropped the caller attributes.`,{bytes:v,body:b.body});let n={[e.d]:t.type,[e.u]:m,[e.n]:t.namespace,[e.i]:!0,[e.r]:v};for(let e of et)e in b.attributes&&(n[e]=b.attributes[e]);for(let[e,t]of Object.entries(b.attributes))e.startsWith($e)&&(n[e]=t);let i=r.r(n,u,o).bytes;i>u.maxRecordBytes&&`error.data`in n&&(Reflect.deleteProperty(n,e.o),i=r.r(n,u,o).bytes);let a=b.attributes[e.a];if(a!==void 0){let t=r.r(a,u,o).bytes;i+t<=u.maxRecordBytes&&(n[e.a]=a)}b.attributes=n}return{record:b}}resource(){if(this.resourceCache)return this.resourceCache;let{config:t,identity:n,platform:r}=this.deps;return this.resourceCache={[e.Lt]:t.serviceName,[e.Rt]:t.serviceVersion,[e.Nt]:t.environment,[e.Ht]:e.dn,[e.Ut]:e.fn,[e.Vt]:e.un,[e.Pt]:r.platform,[e.zt]:n.sessionId,[e.Bt]:n.tabId,[e.Mt]:n.contextId,[e.jt]:r.userAgent,...r.openfinUuid===void 0?{}:{[e.It]:r.openfinUuid},...r.openfinName===void 0?{}:{[e.Ft]:r.openfinName}},this.resourceCache}},nt={errors:async()=>(await Promise.resolve().then(()=>require("./errors-BTWuVnHZ.cjs"))).ErrorCapture,network:async()=>(await Promise.resolve().then(()=>require("./network-jBbjyAJP.cjs"))).NetworkCapture,interactions:async()=>(await Promise.resolve().then(()=>require("./interactions-CcxrVzpg.cjs"))).InteractionCapture,webVitals:async()=>(await Promise.resolve().then(()=>require("./web-vitals-DFuoTQbZ.cjs"))).WebVitalsCapture,longFrames:async()=>(await Promise.resolve().then(()=>require("./long-frames-BGik_Yhy.cjs"))).LongFrameCapture,console:async()=>(await Promise.resolve().then(()=>require("./console-DssDxq1B.cjs"))).ConsoleCapture},U=Symbol.for(e.qt),W=Symbol.for(e.Jt),rt=[`batching`,`retention`];function G(e){return JSON.stringify({...e,webVitalsLoader:e.webVitalsLoader!==void 0,ignoreUrls:e.ignoreUrls.map(String),propagateTraceHeaderTo:e.propagateTraceHeaderTo.map(String)})}function K(e){return{...e,endpoint:null,transport:void 0,transportOnExit:void 0,bus:{...e.bus,mode:`off`}}}function q(t){return t.sdkVersion===e.fn}var J=class t{degraded;static local=null;sdkVersion=e.fn;diagnostics;config;platform;identity;stores;identityBuiltAs;sessionTouch;context=new Xe;breadcrumbs;tracing;sequence=new ne;journey;builder;remote={sampling:null};console;drops;bus=null;busBuilt;busLoad;storageBuiltAs;sender;senderLoad;pendingRecords=new V(e=>{this.dropHeld(e)});captures=[];captureGeneration=0;captureOnce={webVitals:!1,navigationTiming:!1,longFrames:!1};bootBuffer=new V(e=>{this.dropHeld(e)});forwardBuffer=[];forwardScheduled=!1;roleResolved=!1;started=Promise.resolve();ready=!1;destroyed=!1;lastGapAt=0;limits;journeyOptions;tunablesLocked=!0;constructor(e,t=!1){this.degraded=t,this.diagnostics=new Ze(e.onDiagnostic),this.platform=a.n(this.diagnostics),this.config=z(e,this.diagnostics),this.identityBuiltAs=this.config.identity,this.stores=this.identityBuiltAs===`memory`?i.r():i.t,this.identity=i.s(this.diagnostics,this.stores),this.sessionTouch=new i.n(this.diagnostics,this.stores),this.breadcrumbs=new le(50),this.tracing=new ce(this.diagnostics,void 0,this.config.otelLoader),this.tracing.loadOtel(),this.limits={...this.config.limits},this.console=new te(this.config.console,this.diagnostics,this.limits),this.drops=new Qe(this.config,this.diagnostics),this.journeyOptions={...c.t,maxAgeMs:this.config.journey.maxAgeMs},this.journey=new c.n(this.journeyOptions,this.diagnostics,this.identity.contextId,e=>{this.bus?.broadcastJourney(e)},this.stores),this.builder=new tt({remote:this.remote,config:this.config,limits:this.limits,diagnostics:this.diagnostics,context:this.context,journey:this.journey,tracing:this.tracing,sequence:this.sequence,identity:this.identity,platform:this.platform})}busAccept=(e,t)=>{this.destroyed||this.ensureBus().then(n=>{n&&!this.destroyed&&this.diagnostics.guard(`bus.send_failed`,`The bus could not accept a direct message from a child frame.`,()=>{n.acceptDirect(e,t)})})};static pinned(){return globalThis[U]??null}static current(){let e=t.local;if(e)return e.destroyed?null:e;let n=t.pinned();return n&&q(n)?n:null}static stopped(){let e=t.local;if(e?.destroyed)return e;let n=globalThis[W];return n&&q(n)?n:null}isDestroyed(){return this.destroyed}static configure(e,n=!1){let r=t.local;if(r&&!r.destroyed)return r.reconfigure(K(e)),r;t.local=null;let i=t.pinned();if(i){if(!q(i))return t.startDegraded(e,i.sdkVersion);if(!i.destroyed)return i.reconfigure(e),i}let a=new t(e);return a.tunablesLocked=!n,globalThis[U]=a,Reflect.deleteProperty(globalThis,W),a.init(),a}static startDegraded(n,r){let i=new t(K(n),!0);t.local=i;let a=typeof r==`string`?r:`before 0.9.0`;return i.diagnostics.report(`runtime.version_mismatch`,`Another copy of the library, version ${a}, owns the page runtime. This copy, version ${e.fn}, runs in console-only mode and installs no capture. Load one version of the library on the page.`,{found:a,own:e.fn}),i.init(),i}reconfigure(e){let t=this.keepDestination(e),n=G(this.config.capture),r=z(t,this.diagnostics,this.config);this.keepStartupTunables(r),Ye(this.config,r),this.diagnostics.setHandler(this.config.onDiagnostic),this.builder.invalidateResource(),this.console.update(this.config.console),this.keepBuiltStorage(),this.keepBuiltIdentity(),G(this.config.capture)!==n&&this.installCaptures(),this.roleResolved&&this.syncSender(),this.diagnostics.report(`config.reconfigured`,`A later configure() call updated the runtime.`)}keepStartupTunables(e){if(this.senderLoad!==void 0&&this.keepSections(e,rt),!this.tunablesLocked){this.tunablesLocked=!0,Object.assign(this.limits,e.limits),this.journeyOptions.maxAgeMs=e.journey.maxAgeMs;return}this.keepSections(e,[`limits`]);let{maxAgeMs:t}=this.config.journey;e.journey.maxAgeMs!==t&&(this.diagnostics.report(`config.invalid`,`journey.maxAgeMs cannot change after startup. It stays ${String(t)}.`,{requested:e.journey.maxAgeMs}),e.journey.maxAgeMs=t)}keepSections(e,t){for(let n of t)JSON.stringify(e[n])!==JSON.stringify(this.config[n])&&(this.diagnostics.report(`config.invalid`,`${n} cannot change after startup. The values in force stay.`,{requested:e[n]}),Object.assign(e,{[n]:this.config[n]}))}keepBuiltStorage(){let e=this.storageBuiltAs;e!==void 0&&this.config.storage!==e&&(this.diagnostics.report(`config.invalid`,`storage cannot change after startup. It stays ${e}.`,{requested:this.config.storage}),this.config.storage=e)}keepDestination(e){if(this.senderLoad===void 0)return e;let t=e;return`transport`in e&&e.transport===void 0!=(this.config.transport===void 0)&&(this.diagnostics.report(`config.invalid`,`You cannot add or remove transport after the delivery stack loads. The transport in force stays.`),t={...t},delete t.transport),(t.endpoint===null||t.endpoint===``)&&this.config.transport===void 0&&(this.diagnostics.report(`config.invalid`,`You cannot remove the endpoint after the delivery stack loads. The endpoint in force stays.`),t={...t,endpoint:void 0}),t}keepBuiltIdentity(){let e=this.identityBuiltAs;this.config.identity!==e&&(this.diagnostics.report(`config.invalid`,`identity cannot change after startup. It stays ${e}.`,{requested:this.config.identity}),this.config.identity=e)}async init(){let e=this.installCaptures();this.started=this.boot(),await this.started,await e}async boot(){try{let e=this.journey.bootstrap();this.config.bus.mode!==`off`&&await this.ensureBus(),this.roleResolved=!0,await this.syncSender(),await e}catch(e){this.diagnostics.report(`pipeline.crashed`,`Startup failed. The runtime continues with reduced function.`,void 0,e)}finally{this.ready=!0,this.releaseBootBuffer()}}ensureBus(){return this.busLoad??=this.startBus(),this.busLoad}constructBus(){return this.busBuilt??=this.buildBus(),this.busBuilt}async startBus(){let e=await this.constructBus();if(!e)return null;try{return await e.start(),e}catch(e){return this.diagnostics.report(`pipeline.crashed`,`The bus did not start. This context sends its own records.`,void 0,e),null}}async buildBus(){try{let{Bus:e}=await Promise.resolve().then(()=>require("./bus-DNFvTkif.cjs"));if(this.destroyed)return null;let t=new e(this.config,this.diagnostics,this.platform,this.identity.contextId,this.identity.tabId,{onRecords:e=>{this.ingestForwarded(e)},onJourney:e=>{this.journey.applyRemote(e)},onJourneyRequest:()=>this.journey.current(),onTabConflict:()=>{this.regenerateTabId()},remote:this.remote});return this.bus=t,t}catch(e){return this.diagnostics.report(`pipeline.crashed`,`The bus did not load. This context sends its own records.`,void 0,e),null}}role(){return this.bus?.getRole()??`sender`}syncSender(){return!this.hasDestination()||this.role()!==`sender`?Promise.resolve():this.loadSender()}hasDestination(){return!!this.config.endpoint||this.config.transport!==void 0}loadSender(){return this.senderLoad??=this.buildSender(),this.senderLoad}async buildSender(){this.storageBuiltAs=this.config.storage;try{let{Sender:e}=await Promise.resolve().then(()=>require("./sender-BXoAZKum.cjs")),t=this.destroyed?null:await e.create({config:this.config,diagnostics:this.diagnostics,onGap:this.reportGap,onLoss:this.reportLoss,remote:this.remote});if(!t||this.destroyed){await t?.destroy();return}this.sender=t}catch(e){this.senderLoad=void 0,this.diagnostics.report(`pipeline.crashed`,`The delivery stack did not load. The library does not send records.`,{held:this.pendingRecords.length},e),this.drops.add(`load_failed`,this.pendingRecords.records)}for(let e of this.pendingRecords.take())this.sender?.push(e)}async installCaptures(){if(this.degraded)return;let t=++this.captureGeneration,n=this.config.capture,r=[];(n.errors||n.rejections||n.resourceErrors)&&r.push(`errors`),(n.fetch||n.xhr)&&r.push(`network`),(n.interactions||n.navigation)&&r.push(`interactions`),n.webVitals&&r.push(`webVitals`),n.longFrames&&r.push(`longFrames`),(Array.isArray(n.console)?n.console.length>0:n.console)&&r.push(`console`);let i=await Promise.all(r.map(e=>this.loadCapture(e)));if(t!==this.captureGeneration||this.destroyed)return;this.uninstallCaptures();let a={config:this.config,diagnostics:this.diagnostics,breadcrumbs:this.breadcrumbs,tracing:this.tracing,logger:new x(()=>this,e.E),once:this.captureOnce};for(let e of i)e&&this.captures.push(new e(a));for(let e of this.captures)this.diagnostics.guard(`capture.install_failed`,`The library could not install the ${e.name} capture.`,()=>{e.install()})}uninstallCaptures(){for(let e of this.captures)this.diagnostics.guard(`capture.install_failed`,`The library could not uninstall the ${e.name} capture.`,()=>{e.uninstall()});this.captures.length=0}loadCapture(e){return this.diagnostics.guardAsync(`capture.install_failed`,`The library could not load the ${e} capture.`,nt[e])}registerWorker(e){this.destroyed||this.constructBus().then(t=>{t&&!this.destroyed&&(this.diagnostics.guard(`bus.send_failed`,`The library could not register the worker.`,()=>{t.attachWorker(e)}),this.ensureBus())})}async destroy(){if(this.destroyed)return;this.destroyed=!0,this.uninstallCaptures();let e=this.sender?.destroy();this.journey.destroy(),this.sendForwarded(),this.bus?.destroy(),this.drops.add(`load_failed`,this.pendingRecords.take()),await e,await this.senderLoad,t.pinned()===this&&(Reflect.deleteProperty(globalThis,U),globalThis[W]=this)}emit(e){e&&!this.destroyed&&(this.sessionTouch.touch(this.identity.sessionId),this.ready?this.route(e):this.bootBuffer.push(e))}route(e){this.role()===`forwarder`?this.forward(e):this.deliver(e)}deliver(e){this.sender?this.sender.push(e):this.senderLoad?this.pendingRecords.push(e):(this.diagnostics.count(`record.dropped_no_destination`),this.hasDestination()&&this.drops.add(`load_failed`,[e]))}dropHeld(e){this.diagnostics.count(`record.dropped_boot_buffer_full`),this.drops.add(`buffer_full`,[e])}forward(e){this.forwardBuffer.push(e),!this.forwardScheduled&&(this.forwardScheduled=!0,queueMicrotask(()=>{this.forwardScheduled=!1,this.sendForwarded()}))}sendForwarded(){let e=this.forwardBuffer;this.forwardBuffer=[],e.length>0&&this.bus?.sendRecords(e)}ingestForwarded(e){if(!Array.isArray(e))this.diagnostics.count(`record.dropped_malformed`);else for(let t of e)n.a(t)?n.n(t,this.config,this.remote.sampling?.current()??null)?this.deliver(t):this.diagnostics.count(`record.dropped_by_sampling`):this.diagnostics.count(`record.dropped_malformed`)}releaseBootBuffer(){let e=this.bootBuffer.take(),t=this.journey.current();for(let n of e)t&&!n.attributes[`journey.id`]&&(n.attributes[`journey.id`]=t.id,n.attributes[`journey.name`]=t.name),this.route(n)}reportLoss=(e,t,n)=>{this.drops.add(e,t,n)};reportGap=(t,n)=>{this.drops.add(t.reason,n.flatMap(e=>e.records),n.map(e=>e.id));let r=Date.now();r-this.lastGapAt<6e4||(this.lastGapAt=r,new x(()=>this,e.rn).warn(`stored records were dropped before delivery`,{"gap.batches":t.batches,"gap.records":t.records,"gap.reason":t.reason}))};regenerateTabId(){let e=i.i(this.diagnostics);this.diagnostics.report(`bus.role_resolved`,`Another context uses this tab id. A duplicated tab is the usual cause. The library makes a new tab id.`,{was:this.identity.tabId,now:e}),this.identity.tabId=e,i.a(e,this.diagnostics,this.stores),this.builder.invalidateResource()}async queueDepth(){return await this.senderLoad,await this.sender?.queueDepth()??0}async flush(){this.ready||await this.started,this.role()===`forwarder`?this.sendForwarded():(await this.senderLoad,await this.sender?.flush())}};function it(){let e=[],t=[],n={status:200};return{transport:r=>(e.push(r),n.status>=200&&n.status<300&&t.push(r),Promise.resolve({...n})),records:()=>t.flatMap(e=>[...e.records]),batches:()=>[...e],clear:()=>{e.length=0,t.length=0},respondWith:(e,t)=>{n=t===void 0?{status:e}:{status:e,retryAfterMs:t}}}}var Y=new Map;function X(){return(J.current()??J.stopped())||J.configure({},!0)}function at(e){J.configure(e)}function Z(e,t){if(t)return new x(X,e,t);let n=Y.get(e);return n||(n=new x(X,e),Y.set(e,n)),n}function Q(){return Z(`app`)}function ot(e,t){Q().trace(e,t)}function st(e,t){Q().debug(e,t)}function ct(e,t){Q().info(e,t)}function lt(e,t){Q().warn(e,t)}function ut(e,t,n){Q().error(e,t,n)}function dt(e,t,n){Q().fatal(e,t,n)}function ft(e,t){Q().logAction(e,t)}function pt(e,t){Q().logEvent(e,t)}function mt(e,t,n,r,i){Q().logMetric(e,t,n,r,i)}function ht(e,t,n){return Q().timeSync(e,t,n)}function gt(e,t,n){return Q().timeAsync(e,t,n)}function _t(e,t){X().context.set(e,t)}function vt(e){X().context.setMany(e)}function yt(e){X().context.remove(e)}function $(e,t){return X().journey.start(e,t)}function bt(){X().journey.end()}function xt(){return X().journey.current()}function St(){return X().journey.getToken()}function Ct(e){return X().journey.adopt(e,`manual`,!0)}function wt(e){X().registerWorker(e)}function Tt(){X().tracing.rotate(`explicit`)}function Et(){return X().tracing.headers()}function Dt(){return X().flush()}function Ot(){return X().queueDepth()}function kt(){return X().diagnostics.snapshot()}async function At(){await J.current()?.destroy()}exports.OneLogger=x,exports.adoptJourney=Ct,exports.configure=at,exports.createMemoryTransport=it,exports.currentJourney=xt,exports.debug=st,exports.endJourney=bt,exports.error=ut,exports.fatal=dt,exports.flush=Dt,exports.getDiagnosticCounters=kt,exports.getJourneyToken=St,exports.getLogger=Z,exports.getQueueDepth=Ot,exports.getTraceHeaders=Et,exports.info=ct,exports.logAction=ft,exports.logEvent=pt,exports.logMetric=mt,exports.registerWorker=wt,exports.removeContext=yt,exports.setContext=_t,exports.setContextMap=vt,exports.shutdown=At,exports.startJourney=$,exports.startTrace=Tt,exports.timeAsync=gt,exports.timeSync=ht,exports.trace=ot,exports.warn=lt;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|