@utk09/ui-observability 0.7.0 → 0.8.0
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 +20 -1
- package/README.md +122 -0
- package/dist/bus/bus.d.ts +30 -0
- package/dist/bus-CUXRY0JR.cjs +2 -0
- package/dist/bus-CUXRY0JR.cjs.map +1 -0
- package/dist/{bus-DfAbg_pg.js → bus-DPDrlUBY.js} +96 -50
- package/dist/bus-DPDrlUBY.js.map +1 -0
- package/dist/capture/console.d.ts +37 -0
- package/dist/capture/errors.d.ts +2 -4
- package/dist/capture/long-frames.d.ts +31 -0
- package/dist/capture/storm.d.ts +17 -0
- package/dist/capture/types.d.ts +2 -0
- package/dist/console-CNljJict.js +81 -0
- package/dist/console-CNljJict.js.map +1 -0
- package/dist/console-PKzc-FmR.cjs +2 -0
- package/dist/console-PKzc-FmR.cjs.map +1 -0
- package/dist/constants-B28fDv2F.cjs +2 -0
- package/dist/constants-B28fDv2F.cjs.map +1 -0
- package/dist/constants-Bu49bm39.js +93 -0
- package/dist/constants-Bu49bm39.js.map +1 -0
- package/dist/constants.d.ts +32 -2
- package/dist/core/breadcrumbs.d.ts +1 -1
- package/dist/core/pipeline.d.ts +2 -2
- package/dist/core/record.d.ts +3 -0
- package/dist/core/remote-rules.d.ts +17 -0
- package/dist/core/remote-sampling.d.ts +65 -0
- package/dist/core/runtime.d.ts +10 -4
- package/dist/core/sampling.d.ts +5 -2
- package/dist/core/sender.d.ts +3 -0
- package/dist/errors-C78ZTjet.cjs +3 -0
- package/dist/errors-C78ZTjet.cjs.map +1 -0
- package/dist/{errors-4MQyjZVj.js → errors-Dnc-X4Ec.js} +19 -20
- package/dist/errors-Dnc-X4Ec.js.map +1 -0
- package/dist/global-scope-BN-Io_yv.cjs +2 -0
- package/dist/global-scope-BN-Io_yv.cjs.map +1 -0
- package/dist/global-scope-dp2jADRl.js +19 -0
- package/dist/global-scope-dp2jADRl.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +287 -242
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-D0p3iMD0.cjs +2 -0
- package/dist/{indexeddb-storage-CcEJlq2l.cjs.map → indexeddb-storage-D0p3iMD0.cjs.map} +1 -1
- package/dist/{indexeddb-storage-0LtUALBg.js → indexeddb-storage-uD4oaRMc.js} +10 -10
- package/dist/{indexeddb-storage-0LtUALBg.js.map → indexeddb-storage-uD4oaRMc.js.map} +1 -1
- package/dist/{interactions-BMNPQ3WH.cjs → interactions-CsE2y_fQ.cjs} +2 -2
- package/dist/{interactions-BMNPQ3WH.cjs.map → interactions-CsE2y_fQ.cjs.map} +1 -1
- package/dist/{interactions-BaCmoGLB.js → interactions-igKTAJvj.js} +2 -2
- package/dist/{interactions-BaCmoGLB.js.map → interactions-igKTAJvj.js.map} +1 -1
- package/dist/library-request-Br_T09Bn.cjs +2 -0
- package/dist/library-request-Br_T09Bn.cjs.map +1 -0
- package/dist/library-request-Dt0fXhcn.js +14 -0
- package/dist/library-request-Dt0fXhcn.js.map +1 -0
- package/dist/long-frames-6pnjWSSR.js +65 -0
- package/dist/long-frames-6pnjWSSR.js.map +1 -0
- package/dist/long-frames-DahhqM6u.cjs +2 -0
- package/dist/long-frames-DahhqM6u.cjs.map +1 -0
- package/dist/models/bus.d.ts +16 -0
- package/dist/models/config.d.ts +90 -0
- package/dist/network-CZ0aFUsy.cjs +2 -0
- package/dist/network-CZ0aFUsy.cjs.map +1 -0
- package/dist/{network-jQ2t8rU4.js → network-aSNbwpue.js} +16 -15
- package/dist/network-aSNbwpue.js.map +1 -0
- package/dist/{platform-YuByH8A5.js → platform-BwbMRwHm.js} +7 -7
- package/dist/{platform-YuByH8A5.js.map → platform-BwbMRwHm.js.map} +1 -1
- package/dist/{platform-ByQllE_W.cjs → platform-D_XkVIF6.cjs} +2 -2
- package/dist/{platform-ByQllE_W.cjs.map → platform-D_XkVIF6.cjs.map} +1 -1
- package/dist/remote-rules-5UA23alm.js +86 -0
- package/dist/remote-rules-5UA23alm.js.map +1 -0
- package/dist/remote-rules-rJJZKVG8.cjs +2 -0
- package/dist/remote-rules-rJJZKVG8.cjs.map +1 -0
- package/dist/sampling-E4x92Nn2.cjs +2 -0
- package/dist/sampling-E4x92Nn2.cjs.map +1 -0
- package/dist/sampling-J1eahbfT.js +160 -0
- package/dist/sampling-J1eahbfT.js.map +1 -0
- package/dist/sanitize-BMhh8ghJ.cjs +2 -0
- package/dist/sanitize-BMhh8ghJ.cjs.map +1 -0
- package/dist/sanitize-UJ-4Lb0n.js +114 -0
- package/dist/sanitize-UJ-4Lb0n.js.map +1 -0
- package/dist/sender-B6ufz26f.cjs +3 -0
- package/dist/sender-B6ufz26f.cjs.map +1 -0
- package/dist/{sender-BIob8eZz.js → sender-G6v4Uqi4.js} +304 -219
- package/dist/sender-G6v4Uqi4.js.map +1 -0
- package/dist/storm-BtzgLOCX.cjs +2 -0
- package/dist/storm-BtzgLOCX.cjs.map +1 -0
- package/dist/storm-DJkEZP_8.js +10 -0
- package/dist/storm-DJkEZP_8.js.map +1 -0
- package/dist/transport/custom-transport.d.ts +20 -0
- package/dist/transport/errors.d.ts +2 -1
- package/dist/transport/exit-flush.d.ts +15 -0
- package/dist/transport/http-transport.d.ts +2 -24
- package/dist/transport/memory-transport.d.ts +30 -0
- package/dist/transport/retry-engine.d.ts +2 -2
- package/dist/transport/serializers/select.d.ts +12 -1
- package/dist/transport/status-transport.d.ts +72 -0
- package/dist/utils/deadline.d.ts +7 -0
- package/dist/utils/global-scope.d.ts +20 -0
- package/dist/utils/library-console.d.ts +11 -0
- package/dist/utils/library-request.d.ts +12 -0
- package/package.json +1 -1
- package/dist/bus-DeZzr2bx.cjs +0 -2
- package/dist/bus-DeZzr2bx.cjs.map +0 -1
- package/dist/bus-DfAbg_pg.js.map +0 -1
- package/dist/constants-C8nZQBmQ.js +0 -86
- package/dist/constants-C8nZQBmQ.js.map +0 -1
- package/dist/constants-IBL_jd5R.cjs +0 -2
- package/dist/constants-IBL_jd5R.cjs.map +0 -1
- package/dist/errors-4MQyjZVj.js.map +0 -1
- package/dist/errors-CUdShXe7.cjs +0 -3
- package/dist/errors-CUdShXe7.cjs.map +0 -1
- package/dist/indexeddb-storage-CcEJlq2l.cjs +0 -2
- package/dist/network-DBNvxCE3.cjs +0 -2
- package/dist/network-DBNvxCE3.cjs.map +0 -1
- package/dist/network-jQ2t8rU4.js.map +0 -1
- package/dist/sampling-CbYySsZ1.js +0 -251
- package/dist/sampling-CbYySsZ1.js.map +0 -1
- package/dist/sampling-Cs50xsZl.cjs +0 -2
- package/dist/sampling-Cs50xsZl.cjs.map +0 -1
- package/dist/sender-BIob8eZz.js.map +0 -1
- package/dist/sender-iOjzcueM.cjs +0 -3
- package/dist/sender-iOjzcueM.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-CNljJict.js","names":["isLibraryConsole","truncate","runAsLibraryConsole","allowInWindow","METHODS","DEFAULT_METHODS","makeWrapper","args","original","target","ConsoleCapture","ctx","method","wrapper","value","errorAt","arg","textAt","error","message","diagnostics","used","rest","index","attrs","logger"],"sources":["../src/capture/console.ts"],"sourcesContent":["// src/capture/console.ts\n//\n// Records the app's own console calls. Third-party code often reports a fault only to the console.\n\nimport { CONSOLE_BREADCRUMB_MAX_CHARS, ERROR_STORM_MAX_PER_WINDOW } from \"../constants\";\nimport type { CapturedConsoleMethod } from \"../models/config\";\nimport { isLibraryConsole, runAsLibraryConsole } from \"../utils/library-console\";\nimport { truncate } from \"../utils/sanitize\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** Methods that the capture accepts. */\nconst METHODS: readonly CapturedConsoleMethod[] = [\"error\", \"warn\", \"info\", \"log\"];\n\n/** Methods that `capture.console: true` wraps. */\nconst DEFAULT_METHODS: readonly CapturedConsoleMethod[] = [\"error\", \"warn\"];\n\n/** Signature of a console method. */\ntype ConsoleFn = (...args: unknown[]) => void;\n\n/** Record function of a wrapper. Uninstall sets it to null. */\ninterface Target {\n /** Records one call, or null after uninstall. */\n record: ((args: unknown[]) => void) | null;\n}\n\n/** Original method, the wrapper that replaced it, and the target of the wrapper. */\ninterface Wrapped {\n /** Method that was in place before the wrap. */\n original: ConsoleFn;\n /** Wrapper of this capture. */\n wrapper: ConsoleFn;\n /** Target of the wrapper. */\n target: Target;\n}\n\n/**\n * Makes a wrapper that calls the original first, then the target.\n * The wrapper does not close over the capture. A wrapper that stays in place keeps no runtime.\n * @param original Method that was in place before the wrap.\n * @param target Target of the wrapper.\n * @returns The wrapper.\n */\nfunction makeWrapper(original: ConsoleFn, target: Target): ConsoleFn {\n return (...args) => {\n // Call the original first. Devtools then shows the same text, also when a record fails.\n Reflect.apply(original, console, args);\n\n // Skip the lines that the library prints.\n if (isLibraryConsole()) {\n return;\n }\n\n target.record?.(args);\n };\n}\n\n/** Wraps the selected console methods. It records each call as a record or a breadcrumb. */\nexport class ConsoleCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"console\";\n\n /** Active wrappers. A wrapper that is not in this map calls only the original. */\n private readonly wrapped = new Map<CapturedConsoleMethod, Wrapped>();\n\n /** Prevents a second wrap on a wrapped method. */\n private installed = false;\n\n /** Rate limit of this capture. Console noise must not use the allowance of the error capture. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /**\n * @param ctx Capture context containing configuration, diagnostics, logger, and breadcrumbs.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Wraps each selected method. */\n install(): void {\n // Guard against a missing console. Some worker realms do not define it.\n if (this.installed || typeof console === \"undefined\") {\n return;\n }\n this.installed = true;\n\n for (const method of this.readMethods()) {\n this.wrap(method);\n }\n }\n\n /** Restores each method that still holds the wrapper of this capture. */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n for (const [method, { original, wrapper, target }] of this.wrapped) {\n target.record = null;\n\n if (console[method] === wrapper) {\n console[method] = original;\n continue;\n }\n\n // A restore here removes the wrapper of the other script. Leave it. The wrapper of this\n // capture then calls only the original.\n this.ctx.diagnostics.report(\n \"capture.install_failed\",\n `Another script wrapped console.${method} after the library. The library leaves that wrapper in place.`,\n );\n }\n\n this.wrapped.clear();\n }\n\n /**\n * Reads the methods from the configuration. It reports a value that is not usable.\n * @returns Methods to wrap, with no duplicates.\n */\n private readMethods(): readonly CapturedConsoleMethod[] {\n const value: unknown = this.ctx.config.capture.console;\n\n if (value === true) {\n return DEFAULT_METHODS;\n }\n\n if (\n Array.isArray(value) &&\n value.every((method: unknown) => METHODS.includes(method as CapturedConsoleMethod))\n ) {\n return [...new Set(value as CapturedConsoleMethod[])];\n }\n\n this.ctx.diagnostics.report(\n \"config.invalid\",\n 'capture.console must be true, false or a list of \"error\", \"warn\", \"info\" and \"log\". The console capture is off.',\n );\n return [];\n }\n\n /**\n * Replaces one console method with a wrapper that calls the original first.\n * @param method Console method to wrap.\n */\n private wrap(method: CapturedConsoleMethod): void {\n // Keep the unbound method. Uninstall must restore the same function, not a bound copy.\n // eslint-disable-next-line @typescript-eslint/unbound-method -- Reflect.apply binds console.\n const original = console[method] as ConsoleFn;\n\n const target: Target = {\n record: (args) => {\n // The scope stops a console call in the record path from a second capture.\n runAsLibraryConsole(() => {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record a console.${method} call.`,\n () => {\n this.record(method, args);\n },\n );\n });\n },\n };\n const wrapper = makeWrapper(original, target);\n\n this.wrapped.set(method, { original, wrapper, target });\n console[method] = wrapper;\n }\n\n /**\n * Records one console call.\n * @param method Console method of the call.\n * @param args Arguments of the call.\n */\n private record(method: CapturedConsoleMethod, args: unknown[]): void {\n const errorAt = args.findIndex((arg) => arg instanceof Error);\n const textAt = args.findIndex((arg) => typeof arg === \"string\");\n const error = args[errorAt] as Error | undefined;\n const message = (args[textAt] as string | undefined) ?? error?.message ?? `console.${method}`;\n\n if (method === \"info\" || method === \"log\") {\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"console\",\n message: truncate(message, CONSOLE_BREADCRUMB_MAX_CHARS),\n data: { \"console.method\": method },\n });\n return;\n }\n\n const { diagnostics, logger } = this.ctx;\n\n if (!allowInWindow(this.window, ERROR_STORM_MAX_PER_WINDOW, diagnostics, \"console records\")) {\n return;\n }\n\n // The record builder sanitizes the arguments. A warn record keeps its Error in the arguments.\n const used = method === \"error\" ? [textAt, errorAt] : [textAt];\n const rest = args.filter((_, index) => !used.includes(index));\n const attrs: Record<string, unknown> = { \"console.method\": method };\n\n if (rest.length > 0) {\n attrs[\"console.args\"] = rest;\n }\n\n if (method === \"warn\") {\n logger.warn(message, attrs);\n return;\n }\n\n logger.error(message, error, { ...attrs, \"error.captured_by\": \"console.error\" });\n }\n}\n"],"mappings":";;;AAYA,IAAMI,IAA4C;CAAC;CAAS;CAAQ;CAAQ;AAAK,GAG3EC,IAAoD,CAAC,SAAS,MAAM;AA4B1E,SAASC,EAAY,GAAqB,GAA2B;CACnE,QAAQ,GAAGC,MAAS;EAKlB,AAHA,QAAQ,MAAMC,GAAU,SAASD,CAAI,GAGjC,GAAiB,KAIrBE,EAAO,SAASF,CAAI;CACtB;AACF;AAGA,IAAaG,IAAb,MAA+C;CAgBhB;CAd7B,OAAgB;CAGhB,0BAA2B,IAAI,IAAoC;CAGnE,YAAoB;CAGpB,SAAuC;EAAE,OAAO;EAAG,OAAO;CAAE;CAK5D,YAAY,GAAsC;EAArB,KAAA,MAAAC;CAAsB;CAGnD,UAAgB;EAEd,IAAI,OAAK,aAAa,OAAO,UAAY,MAGzC;QAAK,YAAY;GAEjB,KAAK,IAAMC,KAAU,KAAK,YAAY,GACpC,KAAK,KAAKA,CAAM;EAHD;CAKnB;CAGA,YAAkB;EAChB,IAAK,KAAK,WAGV;QAAK,YAAY;GAEjB,KAAK,IAAM,CAACA,GAAQ,EAAE,aAAU,YAAS,gBAAa,KAAK,SAGzD,AAFA,EAAO,SAAS,MAEZ,QAAQA,OAAYC,IACtB,QAAQD,KAAUJ,IAMpB,KAAK,IAAI,YAAY,OACnB,0BACA,kCAAkCI,EAAO,8DAC3C;GAGF,KAAK,QAAQ,MAAM;EAlBF;CAmBnB;CAMA,cAAwD;EACtD,IAAME,IAAiB,KAAK,IAAI,OAAO,QAAQ;EAiB/C,OAfIA,MAAU,KACLT,IAIP,MAAM,QAAQS,CAAK,KACnBA,EAAM,OAAO,MAAoBV,EAAQ,SAASQ,CAA+B,CAAC,IAE3E,CAAC,GAAG,IAAI,IAAIE,CAAgC,CAAC,KAGtD,KAAK,IAAI,YAAY,OACnB,kBACA,yHACF,GACO,CAAC;CACV;CAMA,KAAa,GAAqC;EAGhD,IAAMN,IAAW,QAAQI,IAEnBH,IAAiB,EACrB,SAAS,MAAS;GAEhB,QAA0B;IACxB,KAAK,IAAI,YAAY,MACnB,yBACA,0CAA0CG,EAAO,eAC3C;KACJ,KAAK,OAAOA,GAAQL,CAAI;IAC1B,CACF;GACF,CAAC;EACH,EACF,GACMM,IAAUP,EAAYE,GAAUC,CAAM;EAG5C,AADA,KAAK,QAAQ,IAAIG,GAAQ;GAAE;GAAU;GAAS;EAAO,CAAC,GACtD,QAAQA,KAAUC;CACpB;CAOA,OAAe,GAA+B,GAAuB;EACnE,IAAME,IAAUR,EAAK,WAAW,MAAQS,aAAe,KAAK,GACtDC,IAASV,EAAK,WAAW,MAAQ,OAAOS,KAAQ,QAAQ,GACxDE,IAAQX,EAAKQ,IACbI,IAAWZ,EAAKU,MAAkCC,GAAO,WAAW,WAAWN;EAErF,IAAIA,MAAW,UAAUA,MAAW,OAAO;GACzC,KAAK,IAAI,YAAY,KAAK;IACxB,GAAG,KAAK,IAAI;IACZ,UAAU;IACV,SAASX,EAASkB,GAAA,GAAqC;IACvD,MAAM,EAAE,kBAAkBP,EAAO;GACnC,CAAC;GACD;EACF;EAEA,IAAM,EAAE,gBAAa,cAAW,KAAK;EAErC,IAAI,CAACT,EAAc,KAAK,QAAA,IAAoCiB,GAAa,iBAAiB,GACxF;EAIF,IAAMC,IAAOT,MAAW,UAAU,CAACK,GAAQF,CAAO,IAAI,CAACE,CAAM,GACvDK,IAAOf,EAAK,QAAQ,GAAG,MAAU,CAACc,EAAK,SAASE,CAAK,CAAC,GACtDC,IAAiC,EAAE,kBAAkBZ,EAAO;EAMlE,AAJIU,EAAK,SAAS,MAChB,EAAM,kBAAkBA,IAGtBV,MAAW,SACba,EAAO,KAAKN,GAASK,CAAK,IAI5BC,EAAO,MAAMN,GAASD,GAAO;GAAE,GAAGM;GAAO,qBAAqB;EAAgB,CAAC;CACjF;AACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./sanitize-BMhh8ghJ.cjs"),t=require("./storm-BtzgLOCX.cjs");var n=[`error`,`warn`,`info`,`log`],r=[`error`,`warn`];function i(t,n){return(...r)=>{Reflect.apply(t,console,r),!e.a()&&n.record?.(r)}}var a=class{ctx;name=`console`;wrapped=new Map;installed=!1;window={start:0,count:0};constructor(e){this.ctx=e}install(){if(!(this.installed||typeof console>`u`)){this.installed=!0;for(let e of this.readMethods())this.wrap(e)}}uninstall(){if(this.installed){this.installed=!1;for(let[e,{original:t,wrapper:n,target:r}]of this.wrapped)r.record=null,console[e]===n?console[e]=t:this.ctx.diagnostics.report(`capture.install_failed`,`Another script wrapped console.${e} after the library. The library leaves that wrapper in place.`);this.wrapped.clear()}}readMethods(){let e=this.ctx.config.capture.console;return e===!0?r:Array.isArray(e)&&e.every(e=>n.includes(e))?[...new Set(e)]:(this.ctx.diagnostics.report(`config.invalid`,`capture.console must be true, false or a list of "error", "warn", "info" and "log". The console capture is off.`),[])}wrap(t){let n=console[t],r={record:n=>{e.o(()=>{this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record a console.${t} call.`,()=>{this.record(t,n)})})}},a=i(n,r);this.wrapped.set(t,{original:n,wrapper:a,target:r}),console[t]=a}record(n,r){let i=r.findIndex(e=>e instanceof Error),a=r.findIndex(e=>typeof e==`string`),o=r[i],s=r[a]??o?.message??`console.${n}`;if(n===`info`||n===`log`){this.ctx.breadcrumbs.push({t:Date.now(),category:`console`,message:e.i(s,200),data:{"console.method":n}});return}let{diagnostics:c,logger:l}=this.ctx;if(!t.t(this.window,20,c,`console records`))return;let u=n===`error`?[a,i]:[a],d=r.filter((e,t)=>!u.includes(t)),f={"console.method":n};d.length>0&&(f[`console.args`]=d),n===`warn`?l.warn(s,f):l.error(s,o,{...f,"error.captured_by":`console.error`})}};exports.ConsoleCapture=a;
|
|
2
|
+
//# sourceMappingURL=console-PKzc-FmR.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-PKzc-FmR.cjs","names":["isLibraryConsole","truncate","allowInWindow","require_sanitize","require_storm","METHODS","DEFAULT_METHODS","makeWrapper","args","original","target","ConsoleCapture","ctx","method","wrapper","value","errorAt","arg","textAt","error","message","diagnostics","used","rest","index","attrs","logger"],"sources":["../src/capture/console.ts"],"sourcesContent":["// src/capture/console.ts\n//\n// Records the app's own console calls. Third-party code often reports a fault only to the console.\n\nimport { CONSOLE_BREADCRUMB_MAX_CHARS, ERROR_STORM_MAX_PER_WINDOW } from \"../constants\";\nimport type { CapturedConsoleMethod } from \"../models/config\";\nimport { isLibraryConsole, runAsLibraryConsole } from \"../utils/library-console\";\nimport { truncate } from \"../utils/sanitize\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** Methods that the capture accepts. */\nconst METHODS: readonly CapturedConsoleMethod[] = [\"error\", \"warn\", \"info\", \"log\"];\n\n/** Methods that `capture.console: true` wraps. */\nconst DEFAULT_METHODS: readonly CapturedConsoleMethod[] = [\"error\", \"warn\"];\n\n/** Signature of a console method. */\ntype ConsoleFn = (...args: unknown[]) => void;\n\n/** Record function of a wrapper. Uninstall sets it to null. */\ninterface Target {\n /** Records one call, or null after uninstall. */\n record: ((args: unknown[]) => void) | null;\n}\n\n/** Original method, the wrapper that replaced it, and the target of the wrapper. */\ninterface Wrapped {\n /** Method that was in place before the wrap. */\n original: ConsoleFn;\n /** Wrapper of this capture. */\n wrapper: ConsoleFn;\n /** Target of the wrapper. */\n target: Target;\n}\n\n/**\n * Makes a wrapper that calls the original first, then the target.\n * The wrapper does not close over the capture. A wrapper that stays in place keeps no runtime.\n * @param original Method that was in place before the wrap.\n * @param target Target of the wrapper.\n * @returns The wrapper.\n */\nfunction makeWrapper(original: ConsoleFn, target: Target): ConsoleFn {\n return (...args) => {\n // Call the original first. Devtools then shows the same text, also when a record fails.\n Reflect.apply(original, console, args);\n\n // Skip the lines that the library prints.\n if (isLibraryConsole()) {\n return;\n }\n\n target.record?.(args);\n };\n}\n\n/** Wraps the selected console methods. It records each call as a record or a breadcrumb. */\nexport class ConsoleCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"console\";\n\n /** Active wrappers. A wrapper that is not in this map calls only the original. */\n private readonly wrapped = new Map<CapturedConsoleMethod, Wrapped>();\n\n /** Prevents a second wrap on a wrapped method. */\n private installed = false;\n\n /** Rate limit of this capture. Console noise must not use the allowance of the error capture. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /**\n * @param ctx Capture context containing configuration, diagnostics, logger, and breadcrumbs.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Wraps each selected method. */\n install(): void {\n // Guard against a missing console. Some worker realms do not define it.\n if (this.installed || typeof console === \"undefined\") {\n return;\n }\n this.installed = true;\n\n for (const method of this.readMethods()) {\n this.wrap(method);\n }\n }\n\n /** Restores each method that still holds the wrapper of this capture. */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n for (const [method, { original, wrapper, target }] of this.wrapped) {\n target.record = null;\n\n if (console[method] === wrapper) {\n console[method] = original;\n continue;\n }\n\n // A restore here removes the wrapper of the other script. Leave it. The wrapper of this\n // capture then calls only the original.\n this.ctx.diagnostics.report(\n \"capture.install_failed\",\n `Another script wrapped console.${method} after the library. The library leaves that wrapper in place.`,\n );\n }\n\n this.wrapped.clear();\n }\n\n /**\n * Reads the methods from the configuration. It reports a value that is not usable.\n * @returns Methods to wrap, with no duplicates.\n */\n private readMethods(): readonly CapturedConsoleMethod[] {\n const value: unknown = this.ctx.config.capture.console;\n\n if (value === true) {\n return DEFAULT_METHODS;\n }\n\n if (\n Array.isArray(value) &&\n value.every((method: unknown) => METHODS.includes(method as CapturedConsoleMethod))\n ) {\n return [...new Set(value as CapturedConsoleMethod[])];\n }\n\n this.ctx.diagnostics.report(\n \"config.invalid\",\n 'capture.console must be true, false or a list of \"error\", \"warn\", \"info\" and \"log\". The console capture is off.',\n );\n return [];\n }\n\n /**\n * Replaces one console method with a wrapper that calls the original first.\n * @param method Console method to wrap.\n */\n private wrap(method: CapturedConsoleMethod): void {\n // Keep the unbound method. Uninstall must restore the same function, not a bound copy.\n // eslint-disable-next-line @typescript-eslint/unbound-method -- Reflect.apply binds console.\n const original = console[method] as ConsoleFn;\n\n const target: Target = {\n record: (args) => {\n // The scope stops a console call in the record path from a second capture.\n runAsLibraryConsole(() => {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record a console.${method} call.`,\n () => {\n this.record(method, args);\n },\n );\n });\n },\n };\n const wrapper = makeWrapper(original, target);\n\n this.wrapped.set(method, { original, wrapper, target });\n console[method] = wrapper;\n }\n\n /**\n * Records one console call.\n * @param method Console method of the call.\n * @param args Arguments of the call.\n */\n private record(method: CapturedConsoleMethod, args: unknown[]): void {\n const errorAt = args.findIndex((arg) => arg instanceof Error);\n const textAt = args.findIndex((arg) => typeof arg === \"string\");\n const error = args[errorAt] as Error | undefined;\n const message = (args[textAt] as string | undefined) ?? error?.message ?? `console.${method}`;\n\n if (method === \"info\" || method === \"log\") {\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"console\",\n message: truncate(message, CONSOLE_BREADCRUMB_MAX_CHARS),\n data: { \"console.method\": method },\n });\n return;\n }\n\n const { diagnostics, logger } = this.ctx;\n\n if (!allowInWindow(this.window, ERROR_STORM_MAX_PER_WINDOW, diagnostics, \"console records\")) {\n return;\n }\n\n // The record builder sanitizes the arguments. A warn record keeps its Error in the arguments.\n const used = method === \"error\" ? [textAt, errorAt] : [textAt];\n const rest = args.filter((_, index) => !used.includes(index));\n const attrs: Record<string, unknown> = { \"console.method\": method };\n\n if (rest.length > 0) {\n attrs[\"console.args\"] = rest;\n }\n\n if (method === \"warn\") {\n logger.warn(message, attrs);\n return;\n }\n\n logger.error(message, error, { ...attrs, \"error.captured_by\": \"console.error\" });\n }\n}\n"],"mappings":"6EAYA,IAAMK,EAA4C,CAAC,QAAS,OAAQ,OAAQ,KAAK,EAG3EC,EAAoD,CAAC,QAAS,MAAM,EA4B1E,SAASC,EAAY,EAAqB,EAA2B,CACnE,OAAQ,GAAGC,IAAS,CAElB,QAAQ,MAAMC,EAAU,QAASD,CAAI,EAGjCR,GAAAA,EAAiB,GAIrBU,EAAO,SAASF,CAAI,CACtB,CACF,CAGA,IAAaG,EAAb,KAA+C,CAgBhB,IAd7B,KAAgB,UAGhB,QAA2B,IAAI,IAG/B,UAAoB,GAGpB,OAAuC,CAAE,MAAO,EAAG,MAAO,CAAE,EAK5D,YAAY,EAAsC,CAArB,KAAA,IAAAC,CAAsB,CAGnD,SAAgB,CAEd,GAAI,OAAK,WAAa,OAAO,QAAY,KAGzC,MAAK,UAAY,GAEjB,IAAK,IAAMC,KAAU,KAAK,YAAY,EACpC,KAAK,KAAKA,CAAM,CAHD,CAKnB,CAGA,WAAkB,CAChB,GAAK,KAAK,UAGV,MAAK,UAAY,GAEjB,IAAK,GAAM,CAACA,EAAQ,CAAE,WAAU,UAAS,aAAa,KAAK,QACzD,EAAO,OAAS,KAEZ,QAAQA,KAAYC,EACtB,QAAQD,GAAUJ,EAMpB,KAAK,IAAI,YAAY,OACnB,yBACA,kCAAkCI,EAAO,8DAC3C,EAGF,KAAK,QAAQ,MAAM,CAlBF,CAmBnB,CAMA,aAAwD,CACtD,IAAME,EAAiB,KAAK,IAAI,OAAO,QAAQ,QAiB/C,OAfIA,IAAU,GACLT,EAIP,MAAM,QAAQS,CAAK,GACnBA,EAAM,MAAO,GAAoBV,EAAQ,SAASQ,CAA+B,CAAC,EAE3E,CAAC,GAAG,IAAI,IAAIE,CAAgC,CAAC,GAGtD,KAAK,IAAI,YAAY,OACnB,iBACA,iHACF,EACO,CAAC,EACV,CAMA,KAAa,EAAqC,CAGhD,IAAMN,EAAW,QAAQI,GAEnBH,EAAiB,CACrB,OAAS,GAAS,CAEhBP,EAAA,MAA0B,CACxB,KAAK,IAAI,YAAY,MACnB,wBACA,0CAA0CU,EAAO,YAC3C,CACJ,KAAK,OAAOA,EAAQL,CAAI,CAC1B,CACF,CACF,CAAC,CACH,CACF,EACMM,EAAUP,EAAYE,EAAUC,CAAM,EAE5C,KAAK,QAAQ,IAAIG,EAAQ,CAAE,WAAU,UAAS,QAAO,CAAC,EACtD,QAAQA,GAAUC,CACpB,CAOA,OAAe,EAA+B,EAAuB,CACnE,IAAME,EAAUR,EAAK,UAAW,GAAQS,aAAe,KAAK,EACtDC,EAASV,EAAK,UAAW,GAAQ,OAAOS,GAAQ,QAAQ,EACxDE,EAAQX,EAAKQ,GACbI,EAAWZ,EAAKU,IAAkCC,GAAO,SAAW,WAAWN,IAErF,GAAIA,IAAW,QAAUA,IAAW,MAAO,CACzC,KAAK,IAAI,YAAY,KAAK,CACxB,EAAG,KAAK,IAAI,EACZ,SAAU,UACV,QAASZ,EAAAA,EAASmB,EAAA,GAAqC,EACvD,KAAM,CAAE,iBAAkBP,CAAO,CACnC,CAAC,EACD,MACF,CAEA,GAAM,CAAE,cAAa,UAAW,KAAK,IAErC,GAAI,CAACX,EAAAA,EAAc,KAAK,OAAA,GAAoCmB,EAAa,iBAAiB,EACxF,OAIF,IAAMC,EAAOT,IAAW,QAAU,CAACK,EAAQF,CAAO,EAAI,CAACE,CAAM,EACvDK,EAAOf,EAAK,QAAQ,EAAG,IAAU,CAACc,EAAK,SAASE,CAAK,CAAC,EACtDC,EAAiC,CAAE,iBAAkBZ,CAAO,EAE9DU,EAAK,OAAS,IAChB,EAAM,gBAAkBA,GAGtBV,IAAW,OACba,EAAO,KAAKN,EAASK,CAAK,EAI5BC,EAAO,MAAMN,EAASD,EAAO,CAAE,GAAGM,EAAO,oBAAqB,eAAgB,CAAC,CACjF,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var ee=/OpenFin/i,te=/\bwv\b/,e=/\b(iPhone|iPad|iPod)\b/,ne=/\bMacintosh\b/,t=/\bMobile\b/,n={TRACE:1,DEBUG:5,INFO:9,WARN:13,ERROR:17,FATAL:21},r=n,i=`log.type`,a=`log.seq`,o=`app.namespace`,s=`page.url`,c=`url.full`,l=`journey.id`,u=`journey.name`,d=`journey.parent_id`,f=`uiobs.sanitize_failed`,p=`uiobs.attributes_dropped`,m=`uiobs.attributes_bytes`,h=`service.name`,g=`service.version`,_=`deployment.environment`,v=`telemetry.sdk.name`,y=`telemetry.sdk.version`,b=`telemetry.sdk.language`,x=`host.platform`,S=`session.id`,C=`tab.id`,w=`context.id`,T=`browser.user_agent`,E=`openfin.uuid`,D=`openfin.name`,O=`@utk09/ui-observability`,k=`0.8.0`,A=`webjs`,j=`otlp`,M={WARN:`warning`},N=`application/json`,P=`application/x-ndjson`,F=1000000n,I=/^\d+$/,L=`Content-Type`,R=`Content-Encoding`,z=`Retry-After`,B=`X-UiObs-Batch-Id`,V=`X-UiObs-Attempt`,H=`X-UiObs-Sampling`,U=`gzip`,W=1e3,G=6e4,K=`text/plain;charset=UTF-8`,q=`uiobs_batch_id`,J=`uiobs_exit`,Y=`ui-observability.batch.`,X=`ui-observability.emergency.`,Z=`ui-observability.probe`,re=`QuotaExceededError`,ie=`batches`,ae=`createdAt`,oe=`indexeddb`,se=`localstorage`,Q=`memory`,ce=`none`,le=`ui-observability.drain`,ue=`ui-observability.emergency`,de=`ui-observability.journey`,fe=2e3,pe=`uiObsJourney`,me=/\+/g,he=/\//g,ge=/=+$/,_e=/-/g,ve=/_/g,ye=3e5,be=`traceparent`,xe=2166136261,Se=16777619,Ce=4294967295,we=`metric`,Te=`ui-observability/1`,Ee=`ui-observability.runtime`,De=`ui-observability.stopped`,Oe=`ui-observability.request-scope`,ke=`ui-observability.console-scope`,Ae=1e4,$={namespace:`color:#888`,TRACE:`color:#888;font-weight:bold`,DEBUG:`color:#888;font-weight:bold`,INFO:`color:#1e6fd9;font-weight:bold`,WARN:`color:#c77700;font-weight:bold`,ERROR:`color:#d32f2f;font-weight:bold`,FATAL:`color:#d32f2f;font-weight:bold`},je=1e3,Me=6e4,Ne=`uiobs.capture`,Pe=`uiobs.storage`,Fe=`count`,Ie=`unknown-service`,Le=4096,Re=36e5,ze=3e4,Be=[`redact`,`onDiagnostic`,`headers`,`serializer`,`otelLoader`,`transport`,`transportOnExit`],Ve=[`sampling`,`bus`,`capture`],He={sampling:[],bus:[],capture:[`webVitalsLoader`]},Ue={endpoint:``,serviceName:``,serviceVersion:``,environment:``,enabled:!0,minLevel:`INFO`,compression:`gzip`,credentials:`omit`,storage:`auto`,identity:`storage`,sampling:{defaultRate:1,rates:{},alwaysSampleTypes:[`action`],remote:!1,remoteMaxRate:1},bus:{mode:`auto`,trustedOrigins:[],openFinRole:`auto`},capture:{errors:!0,rejections:!0,resourceErrors:!1,fetch:!1,xhr:!1,interactions:!1,navigation:!1,webVitals:!1,longFrames:!1,longFrameThresholdMs:100,console:!1,fullUrls:!1,ignoreUrls:[],propagateTraceHeaderTo:[]},console:{level:null,styles:$}},We=`DEBUG`,Ge=2e3,Ke=1e4,qe=15e3,Je=1024,Ye=`UiObservability`,Xe={maxBatches:500,maxAgeMs:864e5,maxAttempts:5},Ze=1e4,Qe=2e3,$e=6e4,et=3e4,tt=18e5,nt=`__uiobs_journey`,rt=`ui_observability_control`,it=1500,at=5e3,ot={maxBodyChars:4096,maxAttributeChars:8192,maxAttributeCount:128,maxStackChars:8192,maxDepth:6,maxArrayLength:100,maxNodes:1e4,maxRecordBytes:32768};Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,"$t",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"At",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return at}}),Object.defineProperty(exports,"Bt",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"Ct",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"Dt",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return We}}),Object.defineProperty(exports,"Et",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"Ft",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"Gt",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"Ht",{enumerable:!0,get:function(){return et}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"It",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"Jt",{enumerable:!0,get:function(){return 18e5}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"Kt",{enumerable:!0,get:function(){return`Safari/`}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"Lt",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"Mt",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return 1e3}}),Object.defineProperty(exports,"Nt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"Ot",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"Pt",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return 55296}}),Object.defineProperty(exports,"Qt",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"Rt",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"St",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,"Tt",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"Ut",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"Vt",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"Wt",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"Xt",{enumerable:!0,get:function(){return 6e4}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"Yt",{enumerable:!0,get:function(){return`ui-observability.session`}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return 56319}}),Object.defineProperty(exports,"Zt",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"_n",{enumerable:!0,get:function(){return 2048}}),Object.defineProperty(exports,"_t",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"an",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(exports,"bt",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"cn",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"ct",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"dn",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"dt",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"en",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"fn",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"ft",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"gn",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"gt",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"hn",{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,"ht",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"in",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(exports,"jt",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"kt",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"ln",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"lt",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"mn",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"mt",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"nn",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"on",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"ot",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"pn",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"pt",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"qt",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"rn",{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"sn",{enumerable:!0,get:function(){return`ui-observability.tab`}}),Object.defineProperty(exports,"st",{enumerable:!0,get:function(){return`[ui-observability]`}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"tn",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"un",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"ut",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"vn",{enumerable:!0,get:function(){return`AppleWebKit`}}),Object.defineProperty(exports,"vt",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(exports,"wt",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return it}}),Object.defineProperty(exports,"xt",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"yt",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"zt",{enumerable:!0,get:function(){return v}});
|
|
2
|
+
//# sourceMappingURL=constants-B28fDv2F.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-B28fDv2F.cjs","names":["OPENFIN_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","IOS_DEVICE_UA_PATTERN","MACINTOSH_UA_PATTERN","MOBILE_UA_PATTERN","SEVERITY_NUMBER","LEVEL_ORDER","ATTR_LOG_TYPE","ATTR_LOG_SEQ","ATTR_APP_NAMESPACE","ATTR_PAGE_URL","ATTR_URL_FULL","ATTR_JOURNEY_ID","ATTR_JOURNEY_NAME","ATTR_JOURNEY_PARENT_ID","ATTR_SANITIZE_FAILED","ATTR_ATTRIBUTES_DROPPED","ATTR_ATTRIBUTES_BYTES","RESOURCE_SERVICE_NAME","RESOURCE_SERVICE_VERSION","RESOURCE_DEPLOYMENT_ENVIRONMENT","RESOURCE_TELEMETRY_SDK_NAME","RESOURCE_TELEMETRY_SDK_VERSION","RESOURCE_TELEMETRY_SDK_LANGUAGE","RESOURCE_HOST_PLATFORM","RESOURCE_SESSION_ID","RESOURCE_TAB_ID","RESOURCE_CONTEXT_ID","RESOURCE_BROWSER_USER_AGENT","RESOURCE_OPENFIN_UUID","RESOURCE_OPENFIN_NAME","TELEMETRY_SDK_NAME","TELEMETRY_SDK_VERSION","TELEMETRY_SDK_LANGUAGE","SERIALIZER_NAME_OTLP","ECS_LEVEL_NAMES","CONTENT_TYPE_JSON","CONTENT_TYPE_NDJSON","NANOS_PER_MILLI","NANOS_PATTERN","HEADER_CONTENT_TYPE","HEADER_CONTENT_ENCODING","HEADER_RETRY_AFTER","HEADER_BATCH_ID","HEADER_ATTEMPT","HEADER_SAMPLING","ENCODING_GZIP","MILLIS_PER_SECOND","BEACON_LIMIT_BYTES","CONTENT_TYPE_TEXT_PLAIN","QUERY_PARAM_BATCH_ID","QUERY_PARAM_EXIT_REASON","BATCH_STORAGE_KEY_PREFIX","EMERGENCY_STORAGE_KEY_PREFIX","STORAGE_PROBE_KEY","QUOTA_EXCEEDED_ERROR","INDEXEDDB_STORE_NAME","INDEXEDDB_CREATED_AT_INDEX","STORAGE_NAME_INDEXEDDB","STORAGE_NAME_LOCAL","STORAGE_NAME_MEMORY","STORAGE_NAME_NONE","DRAIN_LOCK_NAME","EMERGENCY_LOCK_NAME","JOURNEY_STORAGE_KEY","OPENFIN_OPTIONS_TIMEOUT_MS","OPENFIN_JOURNEY_CUSTOM_DATA_KEY","BASE64_PLUS_PATTERN","BASE64_SLASH_PATTERN","BASE64_PADDING_PATTERN","BASE64URL_DASH_PATTERN","BASE64URL_UNDERSCORE_PATTERN","TRACE_MAX_AGE_MS","TRACEPARENT_HEADER","FNV_OFFSET_BASIS","FNV_PRIME","UINT32_MAX","LOG_TYPE_METRIC","BUS_PROTOCOL","RUNTIME_GLOBAL_KEY","RUNTIME_STOPPED_KEY","LIBRARY_REQUEST_KEY","LIBRARY_CONSOLE_KEY","ERROR_STORM_WINDOW_MS","CONSOLE_DEFAULT_STYLES","DURATION_PRECISION","GAP_REPORT_THROTTLE_MS","CAPTURE_NAMESPACE","STORAGE_NAMESPACE","DEFAULT_METRIC_UNIT","UNKNOWN_SERVICE_NAME","REMOTE_SAMPLING_MAX_CHARS","REMOTE_SAMPLING_MAX_TTL_MS","REMOTE_SAMPLING_POLL_MS","UNDEFAULTED_CONFIG_KEYS","CONFIG_SECTIONS","UNDEFAULTED_SECTION_KEYS","DEFAULT_CONFIG","CONSOLE_DEFAULT_LEVEL","LOG_FLUSH_INTERVAL_MS","METRIC_FLUSH_INTERVAL_MS","REQUEST_TIMEOUT_MS","COMPRESSION_THRESHOLD_BYTES","STORAGE_DB_NAME","STORAGE_LIMITS","STORAGE_DEADLINE_MS","RETRY_BASE_DELAY_MS","RETRY_MAX_DELAY_MS","RETRY_IDLE_DELAY_MS","JOURNEY_MAX_AGE_MS","JOURNEY_URL_PARAM","BUS_CHANNEL_NAME","BUS_HANDSHAKE_TIMEOUT_MS","ERROR_DEDUPE_MS","RECORD_LIMITS"],"sources":["../src/constants.ts"],"sourcesContent":["// src/constants.ts\n//\n// Defines all limits, thresholds, timing windows, storage keys, patterns, and\n// defaults that the library uses.\n\nimport type { ConsoleStyles, ResolvedConfig } from \"./models/config\";\nimport type { LogLevel, LogType } from \"./models/log-record\";\nimport type { StorageLimits } from \"./models/storage\";\n\n// ----------------------------------\n// Library-wide\n// ----------------------------------\n\n/** Prefix on console messages this library writes. */\nexport const LIBRARY_LOG_PREFIX = \"[ui-observability]\";\n\n// ----------------------------------\n// Diagnostics\n// ----------------------------------\n\n/**\n * Throttle window for each diagnostic code, in milliseconds. It limits how often an error\n * loop calls the handler.\n */\nexport const DIAGNOSTIC_THROTTLE_MS = 1000;\n\n// ----------------------------------\n// Identity\n// ----------------------------------\n\n/** `localStorage` key for the session id and its last-seen time. */\nexport const SESSION_ID_KEY = \"ui-observability.session\";\n\n/** `sessionStorage` key for the tab id. */\nexport const TAB_ID_KEY = \"ui-observability.tab\";\n\n/** Session idle timeout, in milliseconds. */\nexport const SESSION_IDLE_MS = 30 * 60 * 1000;\n\n/** Min gap between session last-seen writes, in milliseconds. */\nexport const SESSION_TOUCH_MS = 60_000;\n\n/** Random id length, in bytes, used when `crypto.randomUUID` is unavailable. */\nexport const ID_BYTE_LENGTH = 16;\n\n/** Distinct values in one byte (256). */\nexport const BYTE_VALUE_COUNT = 256;\n\n// ----------------------------------\n// Platform detection\n// ----------------------------------\n\n/** Matches OpenFin's user agent. */\nexport const OPENFIN_UA_PATTERN = /OpenFin/i;\n\n/** Matches Android's webview token (`wv`). */\nexport const ANDROID_WEBVIEW_UA_PATTERN = /\\bwv\\b/;\n\n/** Matches iOS hardware: iPhone, iPad, iPod. */\nexport const IOS_DEVICE_UA_PATTERN = /\\b(iPhone|iPad|iPod)\\b/;\n\n/** Matches desktop macOS in a user agent. */\nexport const MACINTOSH_UA_PATTERN = /\\bMacintosh\\b/;\n\n/** Matches the mobile token. */\nexport const MOBILE_UA_PATTERN = /\\bMobile\\b/;\n\n/** WebKit engine token, present in every WebKit browser including webviews. */\nexport const WEBKIT_UA_TOKEN = \"AppleWebKit\";\n\n/** Safari token sent by real iOS browsers, not in-app webviews. */\nexport const SAFARI_UA_TOKEN = \"Safari/\";\n\n// ----------------------------------\n// Sanitizing and size estimation\n// ----------------------------------\n\n/** First UTF-16 high surrogate code unit. */\nexport const HIGH_SURROGATE_MIN = 0xd800;\n\n/** Last UTF-16 high surrogate code unit. */\nexport const HIGH_SURROGATE_MAX = 0xdbff;\n\n/** Code units below this encode as one UTF-8 byte. */\nexport const UTF8_ONE_BYTE_CEILING = 0x80;\n\n/** Code units below this, and at or above the one-byte ceiling, encode as two UTF-8 bytes. */\nexport const UTF8_TWO_BYTE_CEILING = 0x800;\n\n/** Class names kept in a `describeNode` selector. */\nexport const MAX_NODE_CLASS_NAMES = 3;\n\n/** Byte cost of a null or undefined value. */\nexport const BYTES_PER_NULL = 4;\n\n/** Byte cost of a number (flat estimate). */\nexport const BYTES_PER_NUMBER = 8;\n\n/** Byte cost of a boolean. */\nexport const BYTES_PER_BOOLEAN = 5;\n\n/** Byte cost of an object or array's wrapping braces or brackets. */\nexport const BYTES_PER_CONTAINER = 2;\n\n/** Byte cost of a string's wrapping quotes. */\nexport const BYTES_PER_QUOTED_STRING = 2;\n\n/** Byte cost of one key's punctuation: quotes, colon, comma. */\nexport const BYTES_PER_KEY_OVERHEAD = 4;\n\n// ----------------------------------\n// Record model\n// ----------------------------------\n\n/**\n * Maps each log level to its OpenTelemetry severity number.\n * @see {@link LEVEL_ORDER}\n */\nexport const SEVERITY_NUMBER: Record<LogLevel, number> = {\n TRACE: 1,\n DEBUG: 5,\n INFO: 9,\n WARN: 13,\n ERROR: 17,\n FATAL: 21,\n};\n\n/**\n * Alias for `SEVERITY_NUMBER`, used by the level filter.\n * @see {@link SEVERITY_NUMBER}\n */\nexport const LEVEL_ORDER: Record<LogLevel, number> = SEVERITY_NUMBER;\n\n// ----------------------------------\n// Attribute and resource keys\n// ----------------------------------\n//\n// Attribute and resource key names that records carry in the payload. The names\n// follow OpenTelemetry conventions. The `uiobs.` prefix marks the fields of this library.\n\n/** Record kind attribute key. */\nexport const ATTR_LOG_TYPE = \"log.type\";\n\n/** Record sequence number in its context. It starts at 1. */\nexport const ATTR_LOG_SEQ = \"log.seq\";\n\n/** Logger namespace attribute key. */\nexport const ATTR_APP_NAMESPACE = \"app.namespace\";\n\n/** Document URL when the record was built. */\nexport const ATTR_PAGE_URL = \"page.url\";\n\n/**\n * HTTP request URL attribute key. Network capture sets it. Do not reuse `ATTR_PAGE_URL`.\n * The page URL overwrites the request target under that key.\n * @see {@link ATTR_PAGE_URL}\n */\nexport const ATTR_URL_FULL = \"url.full\";\n\n/** Journey id attribute key. */\nexport const ATTR_JOURNEY_ID = \"journey.id\";\n\n/** Journey name attribute key. */\nexport const ATTR_JOURNEY_NAME = \"journey.name\";\n\n/** Parent journey id, present only on a child journey. */\nexport const ATTR_JOURNEY_PARENT_ID = \"journey.parent_id\";\n\n/** Marks a record whose attributes failed to sanitize. */\nexport const ATTR_SANITIZE_FAILED = \"uiobs.sanitize_failed\";\n\n/**\n * Marks a record when the library drops its attributes because they exceed the byte budget.\n * @see {@link ATTR_ATTRIBUTES_BYTES}\n */\nexport const ATTR_ATTRIBUTES_DROPPED = \"uiobs.attributes_dropped\";\n\n/**\n * Byte size of the dropped attributes.\n * @see {@link ATTR_ATTRIBUTES_DROPPED}\n */\nexport const ATTR_ATTRIBUTES_BYTES = \"uiobs.attributes_bytes\";\n\n/** Application name resource key. */\nexport const RESOURCE_SERVICE_NAME = \"service.name\";\n\n/** Application build version resource key. */\nexport const RESOURCE_SERVICE_VERSION = \"service.version\";\n\n/** Deployment environment resource key. */\nexport const RESOURCE_DEPLOYMENT_ENVIRONMENT = \"deployment.environment\";\n\n/**\n * Producer library name resource key.\n * @see {@link TELEMETRY_SDK_NAME}\n */\nexport const RESOURCE_TELEMETRY_SDK_NAME = \"telemetry.sdk.name\";\n\n/**\n * Producer library version resource key.\n * @see {@link TELEMETRY_SDK_VERSION}\n */\nexport const RESOURCE_TELEMETRY_SDK_VERSION = \"telemetry.sdk.version\";\n\n/**\n * Producer SDK language resource key.\n * @see {@link TELEMETRY_SDK_LANGUAGE}\n */\nexport const RESOURCE_TELEMETRY_SDK_LANGUAGE = \"telemetry.sdk.language\";\n\n/** Host platform resource key: browser, webview, or OpenFin. */\nexport const RESOURCE_HOST_PLATFORM = \"host.platform\";\n\n/** Session id resource key. */\nexport const RESOURCE_SESSION_ID = \"session.id\";\n\n/** Tab id resource key. */\nexport const RESOURCE_TAB_ID = \"tab.id\";\n\n/** Context (realm) id resource key. */\nexport const RESOURCE_CONTEXT_ID = \"context.id\";\n\n/** Raw user agent resource key. */\nexport const RESOURCE_BROWSER_USER_AGENT = \"browser.user_agent\";\n\n/** OpenFin application uuid resource key. */\nexport const RESOURCE_OPENFIN_UUID = \"openfin.uuid\";\n\n/** OpenFin window or view name resource key. */\nexport const RESOURCE_OPENFIN_NAME = \"openfin.name\";\n\n/**\n * Value of `telemetry.sdk.name`.\n * @see {@link RESOURCE_TELEMETRY_SDK_NAME}\n */\nexport const TELEMETRY_SDK_NAME = \"@utk09/ui-observability\";\n\n/**\n * Value of `telemetry.sdk.version`. The code does not read it from package.json.\n * Change it by hand when you change the version in package.json.\n * @see {@link RESOURCE_TELEMETRY_SDK_VERSION}\n */\nexport const TELEMETRY_SDK_VERSION = \"0.8.0\";\n\n/**\n * Value of `telemetry.sdk.language`.\n * @see {@link RESOURCE_TELEMETRY_SDK_LANGUAGE}\n */\nexport const TELEMETRY_SDK_LANGUAGE = \"webjs\";\n\n// ----------------------------------\n// Serializers\n// ----------------------------------\n\n/** OTLP/JSON serializer name. */\nexport const SERIALIZER_NAME_OTLP = \"otlp\";\n\n/** ECS serializer name. */\nexport const SERIALIZER_NAME_ECS = \"ecs\";\n\n/**\n * ECS `log.level` names that differ from the lowercase severity text. ECS spells\n * the warning level in full. All other levels match in lowercase.\n * @see {@link SERIALIZER_NAME_ECS}\n */\nexport const ECS_LEVEL_NAMES: Partial<Record<LogLevel, string>> = { WARN: \"warning\" };\n\n/** Content type for an OTLP/JSON body. */\nexport const CONTENT_TYPE_JSON = \"application/json\";\n\n/** Content type for newline-delimited JSON. */\nexport const CONTENT_TYPE_NDJSON = \"application/x-ndjson\";\n\n/** Nanoseconds per millisecond. */\nexport const NANOS_PER_MILLI = 1000000n;\n\n/**\n * Matches a nanosecond epoch written as decimal digits, e.g. \"1755543600123000000\".\n * @see {@link NANOS_PER_MILLI}\n */\nexport const NANOS_PATTERN = /^\\d+$/;\n\n// ----------------------------------\n// HTTP transport\n// ----------------------------------\n\n/** Content-Type header name. */\nexport const HEADER_CONTENT_TYPE = \"Content-Type\";\n\n/** Content-Encoding header name. */\nexport const HEADER_CONTENT_ENCODING = \"Content-Encoding\";\n\n/** Retry-After header name. */\nexport const HEADER_RETRY_AFTER = \"Retry-After\";\n\n/**\n * Batch deduplication key header name.\n * @see {@link QUERY_PARAM_BATCH_ID}\n */\nexport const HEADER_BATCH_ID = \"X-UiObs-Batch-Id\";\n\n/** Delivery attempt number header name. */\nexport const HEADER_ATTEMPT = \"X-UiObs-Attempt\";\n\n/** Response header that carries sampling rules from the ingest server. */\nexport const HEADER_SAMPLING = \"X-UiObs-Sampling\";\n\n/** Gzip encoding name. */\nexport const ENCODING_GZIP = \"gzip\";\n\n/** Lowest valid HTTP status code. */\nexport const HTTP_STATUS_MIN = 100;\n\n/** Highest valid HTTP status code. */\nexport const HTTP_STATUS_MAX = 599;\n\n/** Lowest HTTP status code that accepts a batch. */\nexport const HTTP_SUCCESS_MIN = 200;\n\n/** Lowest HTTP status code above the success range. */\nexport const HTTP_SUCCESS_END = 300;\n\n/** 401, credentials missing or rejected. */\nexport const HTTP_UNAUTHORIZED = 401;\n\n/** 403, valid credentials but access denied. */\nexport const HTTP_FORBIDDEN = 403;\n\n/** 408, the server closed the connection after a timeout. The transport can retry. */\nexport const HTTP_REQUEST_TIMEOUT = 408;\n\n/** 413, payload too large. The transport must split the batch. */\nexport const HTTP_PAYLOAD_TOO_LARGE = 413;\n\n/** 429, backpressure. */\nexport const HTTP_TOO_MANY_REQUESTS = 429;\n\n/** 500, floor for server-side errors. */\nexport const HTTP_SERVER_ERROR_MIN = 500;\n\n/** 503, temporary unavailability. */\nexport const HTTP_SERVICE_UNAVAILABLE = 503;\n\n/** Milliseconds per second. */\nexport const MILLIS_PER_SECOND = 1000;\n\n// ----------------------------------\n// Exit flush\n// ----------------------------------\n\n/** Max exit payload size, in bytes (`sendBeacon`/`fetch(keepalive)` shared budget). */\nexport const BEACON_LIMIT_BYTES = 60_000;\n\n/** Content type for an exit payload. It is CORS-safelisted and does not cause a preflight. */\nexport const CONTENT_TYPE_TEXT_PLAIN = \"text/plain;charset=UTF-8\";\n\n/**\n * Batch id query param name, for the exit path.\n * @see {@link HEADER_BATCH_ID}\n */\nexport const QUERY_PARAM_BATCH_ID = \"uiobs_batch_id\";\n\n/** Exit reason query param name, for logs only. */\nexport const QUERY_PARAM_EXIT_REASON = \"uiobs_exit\";\n\n// ----------------------------------\n// Storage\n// ----------------------------------\n\n/** localStorage key prefix for a stored batch. */\nexport const BATCH_STORAGE_KEY_PREFIX = \"ui-observability.batch.\";\n\n/** Zero-padded digit width for the creation time in a batch key. */\nexport const BATCH_KEY_TIME_WIDTH = 14;\n\n/** localStorage key prefix for a batch that exit flush stores. */\nexport const EMERGENCY_STORAGE_KEY_PREFIX = \"ui-observability.emergency.\";\n\n/** Max exit batches held at once. */\nexport const EMERGENCY_MAX_ENTRIES = 20;\n\n/** Key used to test whether localStorage accepts writes. */\nexport const STORAGE_PROBE_KEY = \"ui-observability.probe\";\n\n/** Fraction of the store to evict on a quota error (1 in N). */\nexport const QUOTA_EVICTION_DIVISOR = 4;\n\n/** DOMException name for a full store. */\nexport const QUOTA_EXCEEDED_ERROR = \"QuotaExceededError\";\n\n/**\n * Native IndexedDB version. It starts at 11. Dexie, the previous adapter, opened the\n * same database at ten times its declared version. A version below 11 makes open()\n * fail with VersionError for an existing installation. Then no code can read the\n * batches in that database.\n */\nexport const INDEXEDDB_SCHEMA_VERSION = 11;\n\n/** IndexedDB object store that holds batches. Dexie set this name before the library removed it. */\nexport const INDEXEDDB_STORE_NAME = \"batches\";\n\n/** Index on the batch store that orders reads by creation time. */\nexport const INDEXEDDB_CREATED_AT_INDEX = \"createdAt\";\n\n/** IndexedDB adapter/strategy name. */\nexport const STORAGE_NAME_INDEXEDDB = \"indexeddb\";\n\n/** localStorage adapter/strategy name. */\nexport const STORAGE_NAME_LOCAL = \"localstorage\";\n\n/** In-memory adapter/strategy name. */\nexport const STORAGE_NAME_MEMORY = \"memory\";\n\n/** No-op adapter/strategy name. */\nexport const STORAGE_NAME_NONE = \"none\";\n\n// ----------------------------------\n// Retry\n// ----------------------------------\n\n/**\n * Origin-wide lock name a drain runs under.\n * @see {@link EMERGENCY_LOCK_NAME}\n */\nexport const DRAIN_LOCK_NAME = \"ui-observability.drain\";\n\n/**\n * Lock name startup recovery runs under.\n * @see {@link DRAIN_LOCK_NAME}\n */\nexport const EMERGENCY_LOCK_NAME = \"ui-observability.emergency\";\n\n/** Batches sent per drain tick. */\nexport const BATCHES_PER_DRAIN = 20;\n\n// ----------------------------------\n// Journey\n// ----------------------------------\n\n/** `sessionStorage` key for the current journey. */\nexport const JOURNEY_STORAGE_KEY = \"ui-observability.journey\";\n\n/**\n * Max journey name length in a token, in characters.\n * @see {@link JOURNEY_TOKEN_MAX_CHARS}\n */\nexport const JOURNEY_TOKEN_NAME_MAX_CHARS = 64;\n\n/**\n * Max whole-token length, in characters. It rejects an oversized token. It does not\n * validate the token content.\n * @see {@link JOURNEY_TOKEN_NAME_MAX_CHARS}\n */\nexport const JOURNEY_TOKEN_MAX_CHARS = 256;\n\n/**\n * Time to wait for `fin.me.getOptions()`, in milliseconds. After this time, the\n * runtime continues without a seeded journey.\n * @see {@link OPENFIN_JOURNEY_CUSTOM_DATA_KEY}\n */\nexport const OPENFIN_OPTIONS_TIMEOUT_MS = 2000;\n\n/** Key under an OpenFin window's `customData` carrying a seeded journey token. */\nexport const OPENFIN_JOURNEY_CUSTOM_DATA_KEY = \"uiObsJourney\";\n\n/** Matches `+` in standard base64 (`-` in URL-safe). */\nexport const BASE64_PLUS_PATTERN = /\\+/g;\n\n/** Matches `/` in standard base64 (`_` in URL-safe). */\nexport const BASE64_SLASH_PATTERN = /\\//g;\n\n/** Matches trailing `=` padding. */\nexport const BASE64_PADDING_PATTERN = /=+$/;\n\n/** Matches `-` in URL-safe base64 (`+` in standard). */\nexport const BASE64URL_DASH_PATTERN = /-/g;\n\n/** Matches `_` in URL-safe base64 (`/` in standard). */\nexport const BASE64URL_UNDERSCORE_PATTERN = /_/g;\n\n/** Base64 characters per 3-byte group. */\nexport const BASE64_GROUP_CHARS = 4;\n\n// ----------------------------------\n// Tracing\n// ----------------------------------\n\n/** W3C trace id width, in bytes. */\nexport const TRACE_ID_BYTES = 16;\n\n/** W3C span id width, in bytes. */\nexport const SPAN_ID_BYTES = 8;\n\n/** Max ambient trace lifetime with no activity, in milliseconds. */\nexport const TRACE_MAX_AGE_MS = 5 * 60 * 1000;\n\n/** trace-flags value with the sampled bit set. */\nexport const TRACE_FLAGS_SAMPLED = 1;\n\n/** Mask for the one-byte trace-flags field. */\nexport const TRACE_FLAGS_MASK = 0xff;\n\n/**\n * W3C trace context header name\n * @see {@link TRACEPARENT_VERSION}\n */\nexport const TRACEPARENT_HEADER = \"traceparent\";\n\n/** traceparent header version prefix. */\nexport const TRACEPARENT_VERSION = \"00\";\n\n// ----------------------------------\n// Breadcrumbs\n// ----------------------------------\n\n/** Smallest valid breadcrumb buffer capacity. */\nexport const BREADCRUMB_MIN_CAPACITY = 1;\n\n// ----------------------------------\n// Sampling\n// ----------------------------------\n//\n// FNV-1a hash constants. The sampler uses them to change a sampling key into a\n// stable 0-1 fraction.\n\n/** FNV-1a 32-bit offset basis. */\nexport const FNV_OFFSET_BASIS = 0x811c9dc5;\n\n/** FNV-1a 32-bit prime. */\nexport const FNV_PRIME = 0x01000193;\n\n/** Largest 32-bit unsigned value. */\nexport const UINT32_MAX = 0xffffffff;\n\n// ----------------------------------\n// Pipeline\n// ----------------------------------\n\n/** Record kind routed to the metric stream. */\nexport const LOG_TYPE_METRIC: LogType = \"metric\";\n\n// ----------------------------------\n// Bus\n// ----------------------------------\n\n/** Protocol identifier for bus envelopes. The bus drops an envelope with a different version. */\nexport const BUS_PROTOCOL = \"ui-observability/1\";\n\n/** Global window property key used to locate a same-origin runtime instance. */\nexport const RUNTIME_GLOBAL_KEY = \"ui-observability.runtime\";\n\n/** Global key of the runtime that shutdown() stopped. Calls go to it until the next configure(). */\nexport const RUNTIME_STOPPED_KEY = \"ui-observability.stopped\";\n\n/** Global symbol key of the library request scope count. All library copies on a page share it. */\nexport const LIBRARY_REQUEST_KEY = \"ui-observability.request-scope\";\n\n/** Global symbol key of the library console scope count. All library copies on a page share it. */\nexport const LIBRARY_CONSOLE_KEY = \"ui-observability.console-scope\";\n\n// ----------------------------------\n// Capture\n// ----------------------------------\n\n/** Maximum error records captured per throttling window before suppression. */\nexport const ERROR_STORM_MAX_PER_WINDOW = 20;\n\n/** Error rate-limiting window duration in milliseconds. */\nexport const ERROR_STORM_WINDOW_MS = 10_000;\n\n/**\n * Max ERROR and FATAL records that the pipeline admits in each storm window.\n * It is a safety limit for a render loop. It does not shape normal traffic.\n * ERROR and FATAL records skip sampling. A direct logger.error call has no other limit.\n */\nexport const ERROR_CEILING_MAX_PER_WINDOW = 500;\n\n/** Default minimum duration of a long frame that the library records, in milliseconds. */\nexport const LONG_FRAME_THRESHOLD_MS = 100;\n\n/** Maximum long frames recorded in each storm window. A frozen tab cannot flood the pipeline. */\nexport const LONG_FRAME_MAX_PER_WINDOW = 20;\n\n/** Maximum character length of a console breadcrumb message. */\nexport const CONSOLE_BREADCRUMB_MAX_CHARS = 200;\n\n/** Maximum distinct error signatures tracked for deduplication before LRU eviction. */\nexport const MAX_TRACKED_ERROR_SIGNATURES = 200;\n\n/** Maximum character length retained from clicked element text in breadcrumbs. */\nexport const CLICK_TEXT_MAX_CHARS = 50;\n\n/** Maximum character length retained from an aria-label attribute in generated selectors. */\nexport const ARIA_LABEL_MAX_CHARS = 40;\n\n/** Maximum class names included per element in generated CSS selectors. */\nexport const SELECTOR_MAX_CLASSES = 2;\n\n/** Default CSS of the console prefix. The colors are readable on light and dark devtools. */\nexport const CONSOLE_DEFAULT_STYLES: Readonly<Required<ConsoleStyles>> = {\n namespace: \"color:#888\",\n TRACE: \"color:#888;font-weight:bold\",\n DEBUG: \"color:#888;font-weight:bold\",\n INFO: \"color:#1e6fd9;font-weight:bold\",\n WARN: \"color:#c77700;font-weight:bold\",\n ERROR: \"color:#d32f2f;font-weight:bold\",\n FATAL: \"color:#d32f2f;font-weight:bold\",\n};\n\n/** Scaling factor for rounding duration measurements to three decimal places. */\nexport const DURATION_PRECISION = 1000;\n\n// ----------------------------------\n// Runtime\n// ----------------------------------\n\n/** Minimum duration in milliseconds between storage gap warning reports. */\nexport const GAP_REPORT_THROTTLE_MS = 60_000;\n\n/** Default namespace for telemetry records emitted by auto-capture modules. */\nexport const CAPTURE_NAMESPACE = \"uiobs.capture\";\n\n/** Default namespace for telemetry records emitted by storage subsystems. */\nexport const STORAGE_NAMESPACE = \"uiobs.storage\";\n\n/** Fallback measurement unit applied when none is specified. */\nexport const DEFAULT_METRIC_UNIT = \"count\";\n\n// ----------------------------------\n// Configuration\n// ----------------------------------\n\n/** Default `service.name` when a consumer sets none. */\nexport const UNKNOWN_SERVICE_NAME = \"unknown-service\";\n\n/** Lowest sampling rate (drop everything). */\nexport const SAMPLING_RATE_MIN = 0;\n\n/** Highest sampling rate (keep everything). */\nexport const SAMPLING_RATE_MAX = 1;\n\n/**\n * Fallback for an invalid sampling rate (keep everything).\n * @see {@link SAMPLING_RATE_MAX}\n */\nexport const SAMPLING_RATE_FALLBACK = 1;\n\n/** Version of the remote sampling rules that the library accepts. */\nexport const REMOTE_SAMPLING_VERSION = 1;\n\n/** Maximum length of the sampling header, in characters. */\nexport const REMOTE_SAMPLING_MAX_CHARS = 4096;\n\n/** Maximum time that remote sampling rules stay in force, in milliseconds. */\nexport const REMOTE_SAMPLING_MAX_TTL_MS = 60 * 60 * 1000;\n\n/** Maximum namespace rates in one set of remote sampling rules. */\nexport const REMOTE_SAMPLING_MAX_RATES = 100;\n\n/** Time between two requests of a forwarder for the remote sampling rules, in milliseconds. */\nexport const REMOTE_SAMPLING_POLL_MS = 30_000;\n\n/**\n * Config keys with no default, excluded from `DEFAULT_CONFIG`.\n * @see {@link DEFAULT_CONFIG}\n */\nexport const UNDEFAULTED_CONFIG_KEYS = [\n \"redact\",\n \"onDiagnostic\",\n \"headers\",\n \"serializer\",\n \"otelLoader\",\n \"transport\",\n \"transportOnExit\",\n] as const;\n\n/**\n * Nested config section keys.\n * @see {@link ResolvedConfig}\n */\nexport const CONFIG_SECTIONS = [\"sampling\", \"bus\", \"capture\"] as const;\n\n/**\n * Section keys with no default, excluded from their section of `DEFAULT_CONFIG`.\n * @see {@link UNDEFAULTED_CONFIG_KEYS}\n */\nexport const UNDEFAULTED_SECTION_KEYS: Record<(typeof CONFIG_SECTIONS)[number], string[]> = {\n sampling: [],\n bus: [],\n capture: [\"webVitalsLoader\"],\n};\n\n/**\n * Default runtime config before the consumer calls `configure()`. It excludes `serializer`.\n * `resolveConfig` supplies that default to prevent a circular import.\n * @see {@link ResolvedConfig}\n * @see {@link UNDEFAULTED_CONFIG_KEYS}\n */\nexport const DEFAULT_CONFIG: Omit<ResolvedConfig, \"serializer\"> = {\n endpoint: \"\",\n serviceName: \"\",\n serviceVersion: \"\",\n environment: \"\",\n enabled: true,\n minLevel: \"INFO\",\n compression: \"gzip\",\n credentials: \"omit\",\n storage: \"auto\",\n identity: \"storage\",\n sampling: {\n defaultRate: 1,\n rates: {},\n alwaysSampleTypes: [\"action\"],\n remote: false,\n remoteMaxRate: 1,\n },\n bus: { mode: \"auto\", trustedOrigins: [], openFinRole: \"auto\" },\n capture: {\n errors: true,\n rejections: true,\n resourceErrors: false,\n fetch: false,\n xhr: false,\n interactions: false,\n navigation: false,\n webVitals: false,\n longFrames: false,\n longFrameThresholdMs: LONG_FRAME_THRESHOLD_MS,\n console: false,\n fullUrls: false,\n ignoreUrls: [],\n propagateTraceHeaderTo: [],\n },\n console: { level: null, styles: CONSOLE_DEFAULT_STYLES },\n};\n\n/** Console mirroring level used when a consumer passes `console: true`. */\nexport const CONSOLE_DEFAULT_LEVEL: LogLevel = \"DEBUG\";\n\n// ----------------------------------\n// Batching\n// ----------------------------------\n\n/** Max time a partial log batch waits before the pipeline sends it, in milliseconds. */\nexport const LOG_FLUSH_INTERVAL_MS = 2000;\n\n/** Max records per log batch. At this count, the pipeline sends the batch early. */\nexport const LOG_BATCH_SIZE = 100;\n\n/**\n * Max time a partial metric batch waits before the pipeline sends it, in milliseconds.\n * Metric batches wait longer than log batches. Metrics have a higher volume, and no\n * caller waits for them.\n */\nexport const METRIC_FLUSH_INTERVAL_MS = 10_000;\n\n/** Max records per metric batch. At this count, the pipeline sends the batch early. */\nexport const METRIC_BATCH_SIZE = 500;\n\n/** Max concurrent ingest requests, across both streams. */\nexport const MAX_CONCURRENT_REQUESTS = 2;\n\n// ----------------------------------\n// HTTP transport\n// ----------------------------------\n\n/** Max time for one ingest request, in milliseconds. Then the transport aborts and retries it. */\nexport const REQUEST_TIMEOUT_MS = 15_000;\n\n/** Min payload size to compress, in bytes. */\nexport const COMPRESSION_THRESHOLD_BYTES = 1024;\n\n// ----------------------------------\n// Storage retention\n// ----------------------------------\n\n/** IndexedDB database name. */\nexport const STORAGE_DB_NAME = \"UiObservability\";\n\n/** Capacity and retention thresholds every storage adapter enforces. */\nexport const STORAGE_LIMITS: StorageLimits = {\n maxBatches: 500,\n maxAgeMs: 24 * 60 * 60 * 1000,\n maxAttempts: 5,\n};\n\n/**\n * Max time for one storage call, in milliseconds. Then the library treats the call as failed.\n * A call that does not settle keeps a dispatch slot or the drain flag.\n */\nexport const STORAGE_DEADLINE_MS = 10_000;\n\n// ----------------------------------\n// Retry backoff\n// ----------------------------------\n\n/** First backoff step, in milliseconds. Each attempt doubles it. */\nexport const RETRY_BASE_DELAY_MS = 2000;\n\n/** Backoff ceiling, in milliseconds. */\nexport const RETRY_MAX_DELAY_MS = 60_000;\n\n/** How often to check for stored work when nothing has failed recently, in milliseconds. */\nexport const RETRY_IDLE_DELAY_MS = 30_000;\n\n// ----------------------------------\n// Journey lifetime\n// ----------------------------------\n\n/** Max time a journey stays open, in milliseconds. Then the library treats it as abandoned. */\nexport const JOURNEY_MAX_AGE_MS = 30 * 60 * 1000;\n\n/** Whether closing the owning context ends the journey for everyone. */\nexport const JOURNEY_END_ON_OWNER_CLOSE = false;\n\n/** Query parameter checked at boot for a seeded journey token. */\nexport const JOURNEY_URL_PARAM = \"__uiobs_journey\";\n\n// ----------------------------------\n// Bus handshake\n// ----------------------------------\n\n/** BroadcastChannel name for the control plane. */\nexport const BUS_CHANNEL_NAME = \"ui_observability_control\";\n\n/** Max time a forwarder waits for an owner to answer before it promotes itself, in milliseconds. */\nexport const BUS_HANDSHAKE_TIMEOUT_MS = 1500;\n\n/** Handshake attempts allowed before a cross-origin forwarder promotes itself to sender. */\nexport const BUS_MAX_HANDSHAKE_ATTEMPTS = 3;\n\n/** Max records a context buffers before it knows its bus role. */\nexport const BUS_MAX_BOOT_BUFFER_RECORDS = 500;\n\n// ----------------------------------\n// Capture\n// ----------------------------------\n\n/** Breadcrumbs kept as context for the next error. */\nexport const MAX_BREADCRUMBS = 50;\n\n/**\n * Time window in which the library counts identical errors but does not send them again,\n * in milliseconds.\n */\nexport const ERROR_DEDUPE_MS = 5000;\n\n// ----------------------------------\n// Per-record size caps\n// ----------------------------------\n\n/** Size caps for every record. The library applies them after sanitize and after redact. */\nexport const RECORD_LIMITS = {\n maxBodyChars: 4096,\n maxAttributeChars: 8192,\n maxAttributeCount: 128,\n maxStackChars: 8192,\n maxDepth: 6,\n maxArrayLength: 100,\n maxNodes: 10_000,\n maxRecordBytes: 32_768,\n};\n"],"mappings":"AAcA,IAuCaA,GAAqB,WAGrBC,GAA6B,SAG7BC,EAAwB,yBAGxBC,GAAuB,gBAGvBC,EAAoB,aAqDpBC,EAA4C,CACvD,MAAO,EACP,MAAO,EACP,KAAM,EACN,KAAM,GACN,MAAO,GACP,MAAO,EACT,EAMaC,EAAwCD,EAUxCE,EAAgB,WAGhBC,EAAe,UAGfC,EAAqB,gBAGrBC,EAAgB,WAOhBC,EAAgB,WAGhBC,EAAkB,aAGlBC,EAAoB,eAGpBC,EAAyB,oBAGzBC,EAAuB,wBAMvBC,EAA0B,2BAM1BC,EAAwB,yBAGxBC,EAAwB,eAGxBC,EAA2B,kBAG3BC,EAAkC,yBAMlCC,EAA8B,qBAM9BC,EAAiC,wBAMjCC,EAAkC,yBAGlCC,EAAyB,gBAGzBC,EAAsB,aAGtBC,EAAkB,SAGlBC,EAAsB,aAGtBC,EAA8B,qBAG9BC,EAAwB,eAGxBC,EAAwB,eAMxBC,EAAqB,0BAOrBC,EAAwB,QAMxBC,EAAyB,QAOzBC,EAAuB,OAUvBC,EAAqD,CAAE,KAAM,SAAU,EAGvEC,EAAoB,mBAGpBC,EAAsB,uBAGtBC,EAAkB,SAMlBC,EAAgB,QAOhBC,EAAsB,eAGtBC,EAA0B,mBAG1BC,EAAqB,cAMrBC,EAAkB,mBAGlBC,EAAiB,kBAGjBC,EAAkB,mBAGlBC,EAAgB,OAoChBC,EAAoB,IAOpBC,EAAqB,IAGrBC,EAA0B,2BAM1BC,EAAuB,iBAGvBC,EAA0B,aAO1BC,EAA2B,0BAM3BC,EAA+B,8BAM/BC,EAAoB,yBAMpBC,GAAuB,qBAWvBC,GAAuB,UAGvBC,GAA6B,YAG7BC,GAAyB,YAGzBC,GAAqB,eAGrBC,EAAsB,SAGtBC,GAAoB,OAUpBC,GAAkB,yBAMlBC,GAAsB,6BAUtBC,GAAsB,2BAoBtBC,GAA6B,IAG7BC,GAAkC,eAGlCC,GAAsB,MAGtBC,GAAuB,MAGvBC,GAAyB,MAGzBC,GAAyB,KAGzBC,GAA+B,KAgB/BC,GAAmB,IAYnBC,GAAqB,cAoBrBC,GAAmB,WAGnBC,GAAY,SAGZC,GAAa,WAObC,GAA2B,SAO3BC,GAAe,qBAGfC,GAAqB,2BAGrBC,GAAsB,2BAGtBC,GAAsB,iCAGtBC,GAAsB,iCAUtBC,GAAwB,IA+BxBC,EAA4D,CACvE,UAAW,aACX,MAAO,8BACP,MAAO,8BACP,KAAM,iCACN,KAAM,iCACN,MAAO,iCACP,MAAO,gCACT,EAGaC,GAAqB,IAOrBC,GAAyB,IAGzBC,GAAoB,gBAGpBC,GAAoB,gBAGpBC,GAAsB,QAOtBC,GAAuB,kBAkBvBC,GAA4B,KAG5BC,GAA6B,KAM7BC,GAA0B,IAM1BC,GAA0B,CACrC,SACA,eACA,UACA,aACA,aACA,YACA,iBACF,EAMaC,GAAkB,CAAC,WAAY,MAAO,SAAS,EAM/CC,GAA+E,CAC1F,SAAU,CAAC,EACX,IAAK,CAAC,EACN,QAAS,CAAC,iBAAiB,CAC7B,EAQaC,GAAqD,CAChE,SAAU,GACV,YAAa,GACb,eAAgB,GAChB,YAAa,GACb,QAAS,GACT,SAAU,OACV,YAAa,OACb,YAAa,OACb,QAAS,OACT,SAAU,UACV,SAAU,CACR,YAAa,EACb,MAAO,CAAC,EACR,kBAAmB,CAAC,QAAQ,EAC5B,OAAQ,GACR,cAAe,CACjB,EACA,IAAK,CAAE,KAAM,OAAQ,eAAgB,CAAC,EAAG,YAAa,MAAO,EAC7D,QAAS,CACP,OAAQ,GACR,WAAY,GACZ,eAAgB,GAChB,MAAO,GACP,IAAK,GACL,aAAc,GACd,WAAY,GACZ,UAAW,GACX,WAAY,GACZ,qBAAA,IACA,QAAS,GACT,SAAU,GACV,WAAY,CAAC,EACb,uBAAwB,CAAC,CAC3B,EACA,QAAS,CAAE,MAAO,KAAM,OAAQb,CAAuB,CACzD,EAGac,GAAkC,QAOlCC,GAAwB,IAUxBC,GAA2B,IAa3BC,GAAqB,KAGrBC,GAA8B,KAO9BC,GAAkB,kBAGlBC,GAAgC,CAC3C,WAAY,IACZ,SAAU,MACV,YAAa,CACf,EAMaC,GAAsB,IAOtBC,GAAsB,IAGtBC,GAAqB,IAGrBC,GAAsB,IAOtBC,GAAqB,KAMrBC,GAAoB,kBAOpBC,GAAmB,2BAGnBC,GAA2B,KAmB3BC,GAAkB,IAOlBC,GAAgB,CAC3B,aAAc,KACd,kBAAmB,KACnB,kBAAmB,IACnB,cAAe,KACf,SAAU,EACV,eAAgB,IAChB,SAAU,IACV,eAAgB,KAClB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
var ee = "[ui-observability]", te = 1e3, e = "ui-observability.session", ne = "ui-observability.tab", t = 18e5, n = 6e4, r = /OpenFin/i, i = /\bwv\b/, a = /\b(iPhone|iPad|iPod)\b/, o = /\bMacintosh\b/, s = /\bMobile\b/, c = "AppleWebKit", l = "Safari/", u = 55296, d = 56319, f = 2048, p = {
|
|
3
|
+
TRACE: 1,
|
|
4
|
+
DEBUG: 5,
|
|
5
|
+
INFO: 9,
|
|
6
|
+
WARN: 13,
|
|
7
|
+
ERROR: 17,
|
|
8
|
+
FATAL: 21
|
|
9
|
+
}, m = p, h = "log.type", g = "log.seq", _ = "app.namespace", v = "page.url", y = "url.full", b = "journey.id", x = "journey.name", S = "journey.parent_id", C = "uiobs.sanitize_failed", w = "uiobs.attributes_dropped", T = "uiobs.attributes_bytes", E = "service.name", D = "service.version", O = "deployment.environment", k = "telemetry.sdk.name", A = "telemetry.sdk.version", j = "telemetry.sdk.language", M = "host.platform", N = "session.id", P = "tab.id", F = "context.id", I = "browser.user_agent", L = "openfin.uuid", R = "openfin.name", z = "@utk09/ui-observability", B = "0.8.0", V = "webjs", H = "otlp", U = { WARN: "warning" }, W = "application/json", G = "application/x-ndjson", K = 1000000n, q = /^\d+$/, J = "Content-Type", Y = "Content-Encoding", X = "Retry-After", Z = "X-UiObs-Batch-Id", re = "X-UiObs-Attempt", ie = "X-UiObs-Sampling", ae = "gzip", oe = 1e3, se = 6e4, ce = "text/plain;charset=UTF-8", le = "uiobs_batch_id", ue = "uiobs_exit", de = "ui-observability.batch.", Q = "ui-observability.emergency.", fe = "ui-observability.probe", pe = "QuotaExceededError", me = "batches", he = "createdAt", ge = "indexeddb", _e = "localstorage", ve = "memory", ye = "none", be = "ui-observability.drain", xe = "ui-observability.emergency", Se = "ui-observability.journey", Ce = 2e3, we = "uiObsJourney", Te = /\+/g, Ee = /\//g, De = /=+$/, Oe = /-/g, ke = /_/g, Ae = 3e5, je = "traceparent", Me = 2166136261, Ne = 16777619, Pe = 4294967295, Fe = "metric", Ie = "ui-observability/1", Le = "ui-observability.runtime", Re = "ui-observability.stopped", ze = "ui-observability.request-scope", Be = "ui-observability.console-scope", Ve = 1e4, $ = {
|
|
10
|
+
namespace: "color:#888",
|
|
11
|
+
TRACE: "color:#888;font-weight:bold",
|
|
12
|
+
DEBUG: "color:#888;font-weight:bold",
|
|
13
|
+
INFO: "color:#1e6fd9;font-weight:bold",
|
|
14
|
+
WARN: "color:#c77700;font-weight:bold",
|
|
15
|
+
ERROR: "color:#d32f2f;font-weight:bold",
|
|
16
|
+
FATAL: "color:#d32f2f;font-weight:bold"
|
|
17
|
+
}, He = 1e3, Ue = 6e4, We = "uiobs.capture", Ge = "uiobs.storage", Ke = "count", qe = "unknown-service", Je = 4096, Ye = 36e5, Xe = 3e4, Ze = [
|
|
18
|
+
"redact",
|
|
19
|
+
"onDiagnostic",
|
|
20
|
+
"headers",
|
|
21
|
+
"serializer",
|
|
22
|
+
"otelLoader",
|
|
23
|
+
"transport",
|
|
24
|
+
"transportOnExit"
|
|
25
|
+
], Qe = [
|
|
26
|
+
"sampling",
|
|
27
|
+
"bus",
|
|
28
|
+
"capture"
|
|
29
|
+
], $e = {
|
|
30
|
+
sampling: [],
|
|
31
|
+
bus: [],
|
|
32
|
+
capture: ["webVitalsLoader"]
|
|
33
|
+
}, et = {
|
|
34
|
+
endpoint: "",
|
|
35
|
+
serviceName: "",
|
|
36
|
+
serviceVersion: "",
|
|
37
|
+
environment: "",
|
|
38
|
+
enabled: !0,
|
|
39
|
+
minLevel: "INFO",
|
|
40
|
+
compression: "gzip",
|
|
41
|
+
credentials: "omit",
|
|
42
|
+
storage: "auto",
|
|
43
|
+
identity: "storage",
|
|
44
|
+
sampling: {
|
|
45
|
+
defaultRate: 1,
|
|
46
|
+
rates: {},
|
|
47
|
+
alwaysSampleTypes: ["action"],
|
|
48
|
+
remote: !1,
|
|
49
|
+
remoteMaxRate: 1
|
|
50
|
+
},
|
|
51
|
+
bus: {
|
|
52
|
+
mode: "auto",
|
|
53
|
+
trustedOrigins: [],
|
|
54
|
+
openFinRole: "auto"
|
|
55
|
+
},
|
|
56
|
+
capture: {
|
|
57
|
+
errors: !0,
|
|
58
|
+
rejections: !0,
|
|
59
|
+
resourceErrors: !1,
|
|
60
|
+
fetch: !1,
|
|
61
|
+
xhr: !1,
|
|
62
|
+
interactions: !1,
|
|
63
|
+
navigation: !1,
|
|
64
|
+
webVitals: !1,
|
|
65
|
+
longFrames: !1,
|
|
66
|
+
longFrameThresholdMs: 100,
|
|
67
|
+
console: !1,
|
|
68
|
+
fullUrls: !1,
|
|
69
|
+
ignoreUrls: [],
|
|
70
|
+
propagateTraceHeaderTo: []
|
|
71
|
+
},
|
|
72
|
+
console: {
|
|
73
|
+
level: null,
|
|
74
|
+
styles: $
|
|
75
|
+
}
|
|
76
|
+
}, tt = "DEBUG", nt = 2e3, rt = 1e4, it = 15e3, at = 1024, ot = "UiObservability", st = {
|
|
77
|
+
maxBatches: 500,
|
|
78
|
+
maxAgeMs: 864e5,
|
|
79
|
+
maxAttempts: 5
|
|
80
|
+
}, ct = 1e4, lt = 2e3, ut = 6e4, dt = 3e4, ft = 18e5, pt = "__uiobs_journey", mt = "ui_observability_control", ht = 1500, gt = 5e3, _t = {
|
|
81
|
+
maxBodyChars: 4096,
|
|
82
|
+
maxAttributeChars: 8192,
|
|
83
|
+
maxAttributeCount: 128,
|
|
84
|
+
maxStackChars: 8192,
|
|
85
|
+
maxDepth: 6,
|
|
86
|
+
maxArrayLength: 100,
|
|
87
|
+
maxNodes: 1e4,
|
|
88
|
+
maxRecordBytes: 32768
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
export { he as $, ct as $t, ce as A, O as At, gt as B, A as Bt, We as C, _t as Ct, $ as D, it as Dt, tt as E, Xe as Et, He as F, D as Ft, re as G, Re as Gt, Me as H, dt as Ht, U as I, N as It, J, t as Jt, Z as K, l as Kt, xe as L, P as Lt, Ke as M, R as Mt, te as N, L as Nt, W as O, I as Ot, be as P, E as Pt, u as Q, ot as Qt, Q as R, j as Rt, Ie as S, pe as St, Qe as T, Ye as Tt, Ne as U, ut as Ut, Ve as V, lt as Vt, Ue as W, Le as Wt, ie as X, n as Xt, X as Y, e as Yt, d as Z, p as Zt, Ee as _, f as _n, we as _t, b as a, ye as an, m as at, mt as b, le as bt, g as c, V as cn, ze as ct, C as d, je as dn, o as dt, st as en, me as et, y as f, Ae as fn, rt as ft, Te as g, qe as gn, K as gt, De as h, $e as hn, q as ht, w as i, ve as in, pt as it, et as j, M as jt, G as k, F as kt, h as l, z as ln, nt as lt, ke as m, Ze as mn, s as mt, _ as n, ge as nn, ft as nt, x as o, fe as on, Be as ot, Oe as p, Pe as pn, oe as pt, Y as q, H as qt, T as r, _e as rn, Se as rt, S as s, ne as sn, ee as st, i as t, Ge as tn, a as tt, v as u, B as un, Fe as ut, de as v, c as vn, Ce as vt, at as w, Je as wt, ht as x, ue as xt, se as y, r as yt, ae as z, k as zt };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=constants-Bu49bm39.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-Bu49bm39.js","names":["LIBRARY_LOG_PREFIX","DIAGNOSTIC_THROTTLE_MS","SESSION_ID_KEY","TAB_ID_KEY","SESSION_IDLE_MS","SESSION_TOUCH_MS","OPENFIN_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","IOS_DEVICE_UA_PATTERN","MACINTOSH_UA_PATTERN","MOBILE_UA_PATTERN","WEBKIT_UA_TOKEN","SAFARI_UA_TOKEN","HIGH_SURROGATE_MIN","HIGH_SURROGATE_MAX","UTF8_TWO_BYTE_CEILING","SEVERITY_NUMBER","LEVEL_ORDER","ATTR_LOG_TYPE","ATTR_LOG_SEQ","ATTR_APP_NAMESPACE","ATTR_PAGE_URL","ATTR_URL_FULL","ATTR_JOURNEY_ID","ATTR_JOURNEY_NAME","ATTR_JOURNEY_PARENT_ID","ATTR_SANITIZE_FAILED","ATTR_ATTRIBUTES_DROPPED","ATTR_ATTRIBUTES_BYTES","RESOURCE_SERVICE_NAME","RESOURCE_SERVICE_VERSION","RESOURCE_DEPLOYMENT_ENVIRONMENT","RESOURCE_TELEMETRY_SDK_NAME","RESOURCE_TELEMETRY_SDK_VERSION","RESOURCE_TELEMETRY_SDK_LANGUAGE","RESOURCE_HOST_PLATFORM","RESOURCE_SESSION_ID","RESOURCE_TAB_ID","RESOURCE_CONTEXT_ID","RESOURCE_BROWSER_USER_AGENT","RESOURCE_OPENFIN_UUID","RESOURCE_OPENFIN_NAME","TELEMETRY_SDK_NAME","TELEMETRY_SDK_VERSION","TELEMETRY_SDK_LANGUAGE","SERIALIZER_NAME_OTLP","ECS_LEVEL_NAMES","CONTENT_TYPE_JSON","CONTENT_TYPE_NDJSON","NANOS_PER_MILLI","NANOS_PATTERN","HEADER_CONTENT_TYPE","HEADER_CONTENT_ENCODING","HEADER_RETRY_AFTER","HEADER_BATCH_ID","HEADER_ATTEMPT","HEADER_SAMPLING","ENCODING_GZIP","MILLIS_PER_SECOND","BEACON_LIMIT_BYTES","CONTENT_TYPE_TEXT_PLAIN","QUERY_PARAM_BATCH_ID","QUERY_PARAM_EXIT_REASON","BATCH_STORAGE_KEY_PREFIX","EMERGENCY_STORAGE_KEY_PREFIX","STORAGE_PROBE_KEY","QUOTA_EXCEEDED_ERROR","INDEXEDDB_STORE_NAME","INDEXEDDB_CREATED_AT_INDEX","STORAGE_NAME_INDEXEDDB","STORAGE_NAME_LOCAL","STORAGE_NAME_MEMORY","STORAGE_NAME_NONE","DRAIN_LOCK_NAME","EMERGENCY_LOCK_NAME","JOURNEY_STORAGE_KEY","OPENFIN_OPTIONS_TIMEOUT_MS","OPENFIN_JOURNEY_CUSTOM_DATA_KEY","BASE64_PLUS_PATTERN","BASE64_SLASH_PATTERN","BASE64_PADDING_PATTERN","BASE64URL_DASH_PATTERN","BASE64URL_UNDERSCORE_PATTERN","TRACE_MAX_AGE_MS","TRACEPARENT_HEADER","FNV_OFFSET_BASIS","FNV_PRIME","UINT32_MAX","LOG_TYPE_METRIC","BUS_PROTOCOL","RUNTIME_GLOBAL_KEY","RUNTIME_STOPPED_KEY","LIBRARY_REQUEST_KEY","LIBRARY_CONSOLE_KEY","ERROR_STORM_WINDOW_MS","CONSOLE_DEFAULT_STYLES","DURATION_PRECISION","GAP_REPORT_THROTTLE_MS","CAPTURE_NAMESPACE","STORAGE_NAMESPACE","DEFAULT_METRIC_UNIT","UNKNOWN_SERVICE_NAME","REMOTE_SAMPLING_MAX_CHARS","REMOTE_SAMPLING_MAX_TTL_MS","REMOTE_SAMPLING_POLL_MS","UNDEFAULTED_CONFIG_KEYS","CONFIG_SECTIONS","UNDEFAULTED_SECTION_KEYS","DEFAULT_CONFIG","CONSOLE_DEFAULT_LEVEL","LOG_FLUSH_INTERVAL_MS","METRIC_FLUSH_INTERVAL_MS","REQUEST_TIMEOUT_MS","COMPRESSION_THRESHOLD_BYTES","STORAGE_DB_NAME","STORAGE_LIMITS","STORAGE_DEADLINE_MS","RETRY_BASE_DELAY_MS","RETRY_MAX_DELAY_MS","RETRY_IDLE_DELAY_MS","JOURNEY_MAX_AGE_MS","JOURNEY_URL_PARAM","BUS_CHANNEL_NAME","BUS_HANDSHAKE_TIMEOUT_MS","ERROR_DEDUPE_MS","RECORD_LIMITS"],"sources":["../src/constants.ts"],"sourcesContent":["// src/constants.ts\n//\n// Defines all limits, thresholds, timing windows, storage keys, patterns, and\n// defaults that the library uses.\n\nimport type { ConsoleStyles, ResolvedConfig } from \"./models/config\";\nimport type { LogLevel, LogType } from \"./models/log-record\";\nimport type { StorageLimits } from \"./models/storage\";\n\n// ----------------------------------\n// Library-wide\n// ----------------------------------\n\n/** Prefix on console messages this library writes. */\nexport const LIBRARY_LOG_PREFIX = \"[ui-observability]\";\n\n// ----------------------------------\n// Diagnostics\n// ----------------------------------\n\n/**\n * Throttle window for each diagnostic code, in milliseconds. It limits how often an error\n * loop calls the handler.\n */\nexport const DIAGNOSTIC_THROTTLE_MS = 1000;\n\n// ----------------------------------\n// Identity\n// ----------------------------------\n\n/** `localStorage` key for the session id and its last-seen time. */\nexport const SESSION_ID_KEY = \"ui-observability.session\";\n\n/** `sessionStorage` key for the tab id. */\nexport const TAB_ID_KEY = \"ui-observability.tab\";\n\n/** Session idle timeout, in milliseconds. */\nexport const SESSION_IDLE_MS = 30 * 60 * 1000;\n\n/** Min gap between session last-seen writes, in milliseconds. */\nexport const SESSION_TOUCH_MS = 60_000;\n\n/** Random id length, in bytes, used when `crypto.randomUUID` is unavailable. */\nexport const ID_BYTE_LENGTH = 16;\n\n/** Distinct values in one byte (256). */\nexport const BYTE_VALUE_COUNT = 256;\n\n// ----------------------------------\n// Platform detection\n// ----------------------------------\n\n/** Matches OpenFin's user agent. */\nexport const OPENFIN_UA_PATTERN = /OpenFin/i;\n\n/** Matches Android's webview token (`wv`). */\nexport const ANDROID_WEBVIEW_UA_PATTERN = /\\bwv\\b/;\n\n/** Matches iOS hardware: iPhone, iPad, iPod. */\nexport const IOS_DEVICE_UA_PATTERN = /\\b(iPhone|iPad|iPod)\\b/;\n\n/** Matches desktop macOS in a user agent. */\nexport const MACINTOSH_UA_PATTERN = /\\bMacintosh\\b/;\n\n/** Matches the mobile token. */\nexport const MOBILE_UA_PATTERN = /\\bMobile\\b/;\n\n/** WebKit engine token, present in every WebKit browser including webviews. */\nexport const WEBKIT_UA_TOKEN = \"AppleWebKit\";\n\n/** Safari token sent by real iOS browsers, not in-app webviews. */\nexport const SAFARI_UA_TOKEN = \"Safari/\";\n\n// ----------------------------------\n// Sanitizing and size estimation\n// ----------------------------------\n\n/** First UTF-16 high surrogate code unit. */\nexport const HIGH_SURROGATE_MIN = 0xd800;\n\n/** Last UTF-16 high surrogate code unit. */\nexport const HIGH_SURROGATE_MAX = 0xdbff;\n\n/** Code units below this encode as one UTF-8 byte. */\nexport const UTF8_ONE_BYTE_CEILING = 0x80;\n\n/** Code units below this, and at or above the one-byte ceiling, encode as two UTF-8 bytes. */\nexport const UTF8_TWO_BYTE_CEILING = 0x800;\n\n/** Class names kept in a `describeNode` selector. */\nexport const MAX_NODE_CLASS_NAMES = 3;\n\n/** Byte cost of a null or undefined value. */\nexport const BYTES_PER_NULL = 4;\n\n/** Byte cost of a number (flat estimate). */\nexport const BYTES_PER_NUMBER = 8;\n\n/** Byte cost of a boolean. */\nexport const BYTES_PER_BOOLEAN = 5;\n\n/** Byte cost of an object or array's wrapping braces or brackets. */\nexport const BYTES_PER_CONTAINER = 2;\n\n/** Byte cost of a string's wrapping quotes. */\nexport const BYTES_PER_QUOTED_STRING = 2;\n\n/** Byte cost of one key's punctuation: quotes, colon, comma. */\nexport const BYTES_PER_KEY_OVERHEAD = 4;\n\n// ----------------------------------\n// Record model\n// ----------------------------------\n\n/**\n * Maps each log level to its OpenTelemetry severity number.\n * @see {@link LEVEL_ORDER}\n */\nexport const SEVERITY_NUMBER: Record<LogLevel, number> = {\n TRACE: 1,\n DEBUG: 5,\n INFO: 9,\n WARN: 13,\n ERROR: 17,\n FATAL: 21,\n};\n\n/**\n * Alias for `SEVERITY_NUMBER`, used by the level filter.\n * @see {@link SEVERITY_NUMBER}\n */\nexport const LEVEL_ORDER: Record<LogLevel, number> = SEVERITY_NUMBER;\n\n// ----------------------------------\n// Attribute and resource keys\n// ----------------------------------\n//\n// Attribute and resource key names that records carry in the payload. The names\n// follow OpenTelemetry conventions. The `uiobs.` prefix marks the fields of this library.\n\n/** Record kind attribute key. */\nexport const ATTR_LOG_TYPE = \"log.type\";\n\n/** Record sequence number in its context. It starts at 1. */\nexport const ATTR_LOG_SEQ = \"log.seq\";\n\n/** Logger namespace attribute key. */\nexport const ATTR_APP_NAMESPACE = \"app.namespace\";\n\n/** Document URL when the record was built. */\nexport const ATTR_PAGE_URL = \"page.url\";\n\n/**\n * HTTP request URL attribute key. Network capture sets it. Do not reuse `ATTR_PAGE_URL`.\n * The page URL overwrites the request target under that key.\n * @see {@link ATTR_PAGE_URL}\n */\nexport const ATTR_URL_FULL = \"url.full\";\n\n/** Journey id attribute key. */\nexport const ATTR_JOURNEY_ID = \"journey.id\";\n\n/** Journey name attribute key. */\nexport const ATTR_JOURNEY_NAME = \"journey.name\";\n\n/** Parent journey id, present only on a child journey. */\nexport const ATTR_JOURNEY_PARENT_ID = \"journey.parent_id\";\n\n/** Marks a record whose attributes failed to sanitize. */\nexport const ATTR_SANITIZE_FAILED = \"uiobs.sanitize_failed\";\n\n/**\n * Marks a record when the library drops its attributes because they exceed the byte budget.\n * @see {@link ATTR_ATTRIBUTES_BYTES}\n */\nexport const ATTR_ATTRIBUTES_DROPPED = \"uiobs.attributes_dropped\";\n\n/**\n * Byte size of the dropped attributes.\n * @see {@link ATTR_ATTRIBUTES_DROPPED}\n */\nexport const ATTR_ATTRIBUTES_BYTES = \"uiobs.attributes_bytes\";\n\n/** Application name resource key. */\nexport const RESOURCE_SERVICE_NAME = \"service.name\";\n\n/** Application build version resource key. */\nexport const RESOURCE_SERVICE_VERSION = \"service.version\";\n\n/** Deployment environment resource key. */\nexport const RESOURCE_DEPLOYMENT_ENVIRONMENT = \"deployment.environment\";\n\n/**\n * Producer library name resource key.\n * @see {@link TELEMETRY_SDK_NAME}\n */\nexport const RESOURCE_TELEMETRY_SDK_NAME = \"telemetry.sdk.name\";\n\n/**\n * Producer library version resource key.\n * @see {@link TELEMETRY_SDK_VERSION}\n */\nexport const RESOURCE_TELEMETRY_SDK_VERSION = \"telemetry.sdk.version\";\n\n/**\n * Producer SDK language resource key.\n * @see {@link TELEMETRY_SDK_LANGUAGE}\n */\nexport const RESOURCE_TELEMETRY_SDK_LANGUAGE = \"telemetry.sdk.language\";\n\n/** Host platform resource key: browser, webview, or OpenFin. */\nexport const RESOURCE_HOST_PLATFORM = \"host.platform\";\n\n/** Session id resource key. */\nexport const RESOURCE_SESSION_ID = \"session.id\";\n\n/** Tab id resource key. */\nexport const RESOURCE_TAB_ID = \"tab.id\";\n\n/** Context (realm) id resource key. */\nexport const RESOURCE_CONTEXT_ID = \"context.id\";\n\n/** Raw user agent resource key. */\nexport const RESOURCE_BROWSER_USER_AGENT = \"browser.user_agent\";\n\n/** OpenFin application uuid resource key. */\nexport const RESOURCE_OPENFIN_UUID = \"openfin.uuid\";\n\n/** OpenFin window or view name resource key. */\nexport const RESOURCE_OPENFIN_NAME = \"openfin.name\";\n\n/**\n * Value of `telemetry.sdk.name`.\n * @see {@link RESOURCE_TELEMETRY_SDK_NAME}\n */\nexport const TELEMETRY_SDK_NAME = \"@utk09/ui-observability\";\n\n/**\n * Value of `telemetry.sdk.version`. The code does not read it from package.json.\n * Change it by hand when you change the version in package.json.\n * @see {@link RESOURCE_TELEMETRY_SDK_VERSION}\n */\nexport const TELEMETRY_SDK_VERSION = \"0.8.0\";\n\n/**\n * Value of `telemetry.sdk.language`.\n * @see {@link RESOURCE_TELEMETRY_SDK_LANGUAGE}\n */\nexport const TELEMETRY_SDK_LANGUAGE = \"webjs\";\n\n// ----------------------------------\n// Serializers\n// ----------------------------------\n\n/** OTLP/JSON serializer name. */\nexport const SERIALIZER_NAME_OTLP = \"otlp\";\n\n/** ECS serializer name. */\nexport const SERIALIZER_NAME_ECS = \"ecs\";\n\n/**\n * ECS `log.level` names that differ from the lowercase severity text. ECS spells\n * the warning level in full. All other levels match in lowercase.\n * @see {@link SERIALIZER_NAME_ECS}\n */\nexport const ECS_LEVEL_NAMES: Partial<Record<LogLevel, string>> = { WARN: \"warning\" };\n\n/** Content type for an OTLP/JSON body. */\nexport const CONTENT_TYPE_JSON = \"application/json\";\n\n/** Content type for newline-delimited JSON. */\nexport const CONTENT_TYPE_NDJSON = \"application/x-ndjson\";\n\n/** Nanoseconds per millisecond. */\nexport const NANOS_PER_MILLI = 1000000n;\n\n/**\n * Matches a nanosecond epoch written as decimal digits, e.g. \"1755543600123000000\".\n * @see {@link NANOS_PER_MILLI}\n */\nexport const NANOS_PATTERN = /^\\d+$/;\n\n// ----------------------------------\n// HTTP transport\n// ----------------------------------\n\n/** Content-Type header name. */\nexport const HEADER_CONTENT_TYPE = \"Content-Type\";\n\n/** Content-Encoding header name. */\nexport const HEADER_CONTENT_ENCODING = \"Content-Encoding\";\n\n/** Retry-After header name. */\nexport const HEADER_RETRY_AFTER = \"Retry-After\";\n\n/**\n * Batch deduplication key header name.\n * @see {@link QUERY_PARAM_BATCH_ID}\n */\nexport const HEADER_BATCH_ID = \"X-UiObs-Batch-Id\";\n\n/** Delivery attempt number header name. */\nexport const HEADER_ATTEMPT = \"X-UiObs-Attempt\";\n\n/** Response header that carries sampling rules from the ingest server. */\nexport const HEADER_SAMPLING = \"X-UiObs-Sampling\";\n\n/** Gzip encoding name. */\nexport const ENCODING_GZIP = \"gzip\";\n\n/** Lowest valid HTTP status code. */\nexport const HTTP_STATUS_MIN = 100;\n\n/** Highest valid HTTP status code. */\nexport const HTTP_STATUS_MAX = 599;\n\n/** Lowest HTTP status code that accepts a batch. */\nexport const HTTP_SUCCESS_MIN = 200;\n\n/** Lowest HTTP status code above the success range. */\nexport const HTTP_SUCCESS_END = 300;\n\n/** 401, credentials missing or rejected. */\nexport const HTTP_UNAUTHORIZED = 401;\n\n/** 403, valid credentials but access denied. */\nexport const HTTP_FORBIDDEN = 403;\n\n/** 408, the server closed the connection after a timeout. The transport can retry. */\nexport const HTTP_REQUEST_TIMEOUT = 408;\n\n/** 413, payload too large. The transport must split the batch. */\nexport const HTTP_PAYLOAD_TOO_LARGE = 413;\n\n/** 429, backpressure. */\nexport const HTTP_TOO_MANY_REQUESTS = 429;\n\n/** 500, floor for server-side errors. */\nexport const HTTP_SERVER_ERROR_MIN = 500;\n\n/** 503, temporary unavailability. */\nexport const HTTP_SERVICE_UNAVAILABLE = 503;\n\n/** Milliseconds per second. */\nexport const MILLIS_PER_SECOND = 1000;\n\n// ----------------------------------\n// Exit flush\n// ----------------------------------\n\n/** Max exit payload size, in bytes (`sendBeacon`/`fetch(keepalive)` shared budget). */\nexport const BEACON_LIMIT_BYTES = 60_000;\n\n/** Content type for an exit payload. It is CORS-safelisted and does not cause a preflight. */\nexport const CONTENT_TYPE_TEXT_PLAIN = \"text/plain;charset=UTF-8\";\n\n/**\n * Batch id query param name, for the exit path.\n * @see {@link HEADER_BATCH_ID}\n */\nexport const QUERY_PARAM_BATCH_ID = \"uiobs_batch_id\";\n\n/** Exit reason query param name, for logs only. */\nexport const QUERY_PARAM_EXIT_REASON = \"uiobs_exit\";\n\n// ----------------------------------\n// Storage\n// ----------------------------------\n\n/** localStorage key prefix for a stored batch. */\nexport const BATCH_STORAGE_KEY_PREFIX = \"ui-observability.batch.\";\n\n/** Zero-padded digit width for the creation time in a batch key. */\nexport const BATCH_KEY_TIME_WIDTH = 14;\n\n/** localStorage key prefix for a batch that exit flush stores. */\nexport const EMERGENCY_STORAGE_KEY_PREFIX = \"ui-observability.emergency.\";\n\n/** Max exit batches held at once. */\nexport const EMERGENCY_MAX_ENTRIES = 20;\n\n/** Key used to test whether localStorage accepts writes. */\nexport const STORAGE_PROBE_KEY = \"ui-observability.probe\";\n\n/** Fraction of the store to evict on a quota error (1 in N). */\nexport const QUOTA_EVICTION_DIVISOR = 4;\n\n/** DOMException name for a full store. */\nexport const QUOTA_EXCEEDED_ERROR = \"QuotaExceededError\";\n\n/**\n * Native IndexedDB version. It starts at 11. Dexie, the previous adapter, opened the\n * same database at ten times its declared version. A version below 11 makes open()\n * fail with VersionError for an existing installation. Then no code can read the\n * batches in that database.\n */\nexport const INDEXEDDB_SCHEMA_VERSION = 11;\n\n/** IndexedDB object store that holds batches. Dexie set this name before the library removed it. */\nexport const INDEXEDDB_STORE_NAME = \"batches\";\n\n/** Index on the batch store that orders reads by creation time. */\nexport const INDEXEDDB_CREATED_AT_INDEX = \"createdAt\";\n\n/** IndexedDB adapter/strategy name. */\nexport const STORAGE_NAME_INDEXEDDB = \"indexeddb\";\n\n/** localStorage adapter/strategy name. */\nexport const STORAGE_NAME_LOCAL = \"localstorage\";\n\n/** In-memory adapter/strategy name. */\nexport const STORAGE_NAME_MEMORY = \"memory\";\n\n/** No-op adapter/strategy name. */\nexport const STORAGE_NAME_NONE = \"none\";\n\n// ----------------------------------\n// Retry\n// ----------------------------------\n\n/**\n * Origin-wide lock name a drain runs under.\n * @see {@link EMERGENCY_LOCK_NAME}\n */\nexport const DRAIN_LOCK_NAME = \"ui-observability.drain\";\n\n/**\n * Lock name startup recovery runs under.\n * @see {@link DRAIN_LOCK_NAME}\n */\nexport const EMERGENCY_LOCK_NAME = \"ui-observability.emergency\";\n\n/** Batches sent per drain tick. */\nexport const BATCHES_PER_DRAIN = 20;\n\n// ----------------------------------\n// Journey\n// ----------------------------------\n\n/** `sessionStorage` key for the current journey. */\nexport const JOURNEY_STORAGE_KEY = \"ui-observability.journey\";\n\n/**\n * Max journey name length in a token, in characters.\n * @see {@link JOURNEY_TOKEN_MAX_CHARS}\n */\nexport const JOURNEY_TOKEN_NAME_MAX_CHARS = 64;\n\n/**\n * Max whole-token length, in characters. It rejects an oversized token. It does not\n * validate the token content.\n * @see {@link JOURNEY_TOKEN_NAME_MAX_CHARS}\n */\nexport const JOURNEY_TOKEN_MAX_CHARS = 256;\n\n/**\n * Time to wait for `fin.me.getOptions()`, in milliseconds. After this time, the\n * runtime continues without a seeded journey.\n * @see {@link OPENFIN_JOURNEY_CUSTOM_DATA_KEY}\n */\nexport const OPENFIN_OPTIONS_TIMEOUT_MS = 2000;\n\n/** Key under an OpenFin window's `customData` carrying a seeded journey token. */\nexport const OPENFIN_JOURNEY_CUSTOM_DATA_KEY = \"uiObsJourney\";\n\n/** Matches `+` in standard base64 (`-` in URL-safe). */\nexport const BASE64_PLUS_PATTERN = /\\+/g;\n\n/** Matches `/` in standard base64 (`_` in URL-safe). */\nexport const BASE64_SLASH_PATTERN = /\\//g;\n\n/** Matches trailing `=` padding. */\nexport const BASE64_PADDING_PATTERN = /=+$/;\n\n/** Matches `-` in URL-safe base64 (`+` in standard). */\nexport const BASE64URL_DASH_PATTERN = /-/g;\n\n/** Matches `_` in URL-safe base64 (`/` in standard). */\nexport const BASE64URL_UNDERSCORE_PATTERN = /_/g;\n\n/** Base64 characters per 3-byte group. */\nexport const BASE64_GROUP_CHARS = 4;\n\n// ----------------------------------\n// Tracing\n// ----------------------------------\n\n/** W3C trace id width, in bytes. */\nexport const TRACE_ID_BYTES = 16;\n\n/** W3C span id width, in bytes. */\nexport const SPAN_ID_BYTES = 8;\n\n/** Max ambient trace lifetime with no activity, in milliseconds. */\nexport const TRACE_MAX_AGE_MS = 5 * 60 * 1000;\n\n/** trace-flags value with the sampled bit set. */\nexport const TRACE_FLAGS_SAMPLED = 1;\n\n/** Mask for the one-byte trace-flags field. */\nexport const TRACE_FLAGS_MASK = 0xff;\n\n/**\n * W3C trace context header name\n * @see {@link TRACEPARENT_VERSION}\n */\nexport const TRACEPARENT_HEADER = \"traceparent\";\n\n/** traceparent header version prefix. */\nexport const TRACEPARENT_VERSION = \"00\";\n\n// ----------------------------------\n// Breadcrumbs\n// ----------------------------------\n\n/** Smallest valid breadcrumb buffer capacity. */\nexport const BREADCRUMB_MIN_CAPACITY = 1;\n\n// ----------------------------------\n// Sampling\n// ----------------------------------\n//\n// FNV-1a hash constants. The sampler uses them to change a sampling key into a\n// stable 0-1 fraction.\n\n/** FNV-1a 32-bit offset basis. */\nexport const FNV_OFFSET_BASIS = 0x811c9dc5;\n\n/** FNV-1a 32-bit prime. */\nexport const FNV_PRIME = 0x01000193;\n\n/** Largest 32-bit unsigned value. */\nexport const UINT32_MAX = 0xffffffff;\n\n// ----------------------------------\n// Pipeline\n// ----------------------------------\n\n/** Record kind routed to the metric stream. */\nexport const LOG_TYPE_METRIC: LogType = \"metric\";\n\n// ----------------------------------\n// Bus\n// ----------------------------------\n\n/** Protocol identifier for bus envelopes. The bus drops an envelope with a different version. */\nexport const BUS_PROTOCOL = \"ui-observability/1\";\n\n/** Global window property key used to locate a same-origin runtime instance. */\nexport const RUNTIME_GLOBAL_KEY = \"ui-observability.runtime\";\n\n/** Global key of the runtime that shutdown() stopped. Calls go to it until the next configure(). */\nexport const RUNTIME_STOPPED_KEY = \"ui-observability.stopped\";\n\n/** Global symbol key of the library request scope count. All library copies on a page share it. */\nexport const LIBRARY_REQUEST_KEY = \"ui-observability.request-scope\";\n\n/** Global symbol key of the library console scope count. All library copies on a page share it. */\nexport const LIBRARY_CONSOLE_KEY = \"ui-observability.console-scope\";\n\n// ----------------------------------\n// Capture\n// ----------------------------------\n\n/** Maximum error records captured per throttling window before suppression. */\nexport const ERROR_STORM_MAX_PER_WINDOW = 20;\n\n/** Error rate-limiting window duration in milliseconds. */\nexport const ERROR_STORM_WINDOW_MS = 10_000;\n\n/**\n * Max ERROR and FATAL records that the pipeline admits in each storm window.\n * It is a safety limit for a render loop. It does not shape normal traffic.\n * ERROR and FATAL records skip sampling. A direct logger.error call has no other limit.\n */\nexport const ERROR_CEILING_MAX_PER_WINDOW = 500;\n\n/** Default minimum duration of a long frame that the library records, in milliseconds. */\nexport const LONG_FRAME_THRESHOLD_MS = 100;\n\n/** Maximum long frames recorded in each storm window. A frozen tab cannot flood the pipeline. */\nexport const LONG_FRAME_MAX_PER_WINDOW = 20;\n\n/** Maximum character length of a console breadcrumb message. */\nexport const CONSOLE_BREADCRUMB_MAX_CHARS = 200;\n\n/** Maximum distinct error signatures tracked for deduplication before LRU eviction. */\nexport const MAX_TRACKED_ERROR_SIGNATURES = 200;\n\n/** Maximum character length retained from clicked element text in breadcrumbs. */\nexport const CLICK_TEXT_MAX_CHARS = 50;\n\n/** Maximum character length retained from an aria-label attribute in generated selectors. */\nexport const ARIA_LABEL_MAX_CHARS = 40;\n\n/** Maximum class names included per element in generated CSS selectors. */\nexport const SELECTOR_MAX_CLASSES = 2;\n\n/** Default CSS of the console prefix. The colors are readable on light and dark devtools. */\nexport const CONSOLE_DEFAULT_STYLES: Readonly<Required<ConsoleStyles>> = {\n namespace: \"color:#888\",\n TRACE: \"color:#888;font-weight:bold\",\n DEBUG: \"color:#888;font-weight:bold\",\n INFO: \"color:#1e6fd9;font-weight:bold\",\n WARN: \"color:#c77700;font-weight:bold\",\n ERROR: \"color:#d32f2f;font-weight:bold\",\n FATAL: \"color:#d32f2f;font-weight:bold\",\n};\n\n/** Scaling factor for rounding duration measurements to three decimal places. */\nexport const DURATION_PRECISION = 1000;\n\n// ----------------------------------\n// Runtime\n// ----------------------------------\n\n/** Minimum duration in milliseconds between storage gap warning reports. */\nexport const GAP_REPORT_THROTTLE_MS = 60_000;\n\n/** Default namespace for telemetry records emitted by auto-capture modules. */\nexport const CAPTURE_NAMESPACE = \"uiobs.capture\";\n\n/** Default namespace for telemetry records emitted by storage subsystems. */\nexport const STORAGE_NAMESPACE = \"uiobs.storage\";\n\n/** Fallback measurement unit applied when none is specified. */\nexport const DEFAULT_METRIC_UNIT = \"count\";\n\n// ----------------------------------\n// Configuration\n// ----------------------------------\n\n/** Default `service.name` when a consumer sets none. */\nexport const UNKNOWN_SERVICE_NAME = \"unknown-service\";\n\n/** Lowest sampling rate (drop everything). */\nexport const SAMPLING_RATE_MIN = 0;\n\n/** Highest sampling rate (keep everything). */\nexport const SAMPLING_RATE_MAX = 1;\n\n/**\n * Fallback for an invalid sampling rate (keep everything).\n * @see {@link SAMPLING_RATE_MAX}\n */\nexport const SAMPLING_RATE_FALLBACK = 1;\n\n/** Version of the remote sampling rules that the library accepts. */\nexport const REMOTE_SAMPLING_VERSION = 1;\n\n/** Maximum length of the sampling header, in characters. */\nexport const REMOTE_SAMPLING_MAX_CHARS = 4096;\n\n/** Maximum time that remote sampling rules stay in force, in milliseconds. */\nexport const REMOTE_SAMPLING_MAX_TTL_MS = 60 * 60 * 1000;\n\n/** Maximum namespace rates in one set of remote sampling rules. */\nexport const REMOTE_SAMPLING_MAX_RATES = 100;\n\n/** Time between two requests of a forwarder for the remote sampling rules, in milliseconds. */\nexport const REMOTE_SAMPLING_POLL_MS = 30_000;\n\n/**\n * Config keys with no default, excluded from `DEFAULT_CONFIG`.\n * @see {@link DEFAULT_CONFIG}\n */\nexport const UNDEFAULTED_CONFIG_KEYS = [\n \"redact\",\n \"onDiagnostic\",\n \"headers\",\n \"serializer\",\n \"otelLoader\",\n \"transport\",\n \"transportOnExit\",\n] as const;\n\n/**\n * Nested config section keys.\n * @see {@link ResolvedConfig}\n */\nexport const CONFIG_SECTIONS = [\"sampling\", \"bus\", \"capture\"] as const;\n\n/**\n * Section keys with no default, excluded from their section of `DEFAULT_CONFIG`.\n * @see {@link UNDEFAULTED_CONFIG_KEYS}\n */\nexport const UNDEFAULTED_SECTION_KEYS: Record<(typeof CONFIG_SECTIONS)[number], string[]> = {\n sampling: [],\n bus: [],\n capture: [\"webVitalsLoader\"],\n};\n\n/**\n * Default runtime config before the consumer calls `configure()`. It excludes `serializer`.\n * `resolveConfig` supplies that default to prevent a circular import.\n * @see {@link ResolvedConfig}\n * @see {@link UNDEFAULTED_CONFIG_KEYS}\n */\nexport const DEFAULT_CONFIG: Omit<ResolvedConfig, \"serializer\"> = {\n endpoint: \"\",\n serviceName: \"\",\n serviceVersion: \"\",\n environment: \"\",\n enabled: true,\n minLevel: \"INFO\",\n compression: \"gzip\",\n credentials: \"omit\",\n storage: \"auto\",\n identity: \"storage\",\n sampling: {\n defaultRate: 1,\n rates: {},\n alwaysSampleTypes: [\"action\"],\n remote: false,\n remoteMaxRate: 1,\n },\n bus: { mode: \"auto\", trustedOrigins: [], openFinRole: \"auto\" },\n capture: {\n errors: true,\n rejections: true,\n resourceErrors: false,\n fetch: false,\n xhr: false,\n interactions: false,\n navigation: false,\n webVitals: false,\n longFrames: false,\n longFrameThresholdMs: LONG_FRAME_THRESHOLD_MS,\n console: false,\n fullUrls: false,\n ignoreUrls: [],\n propagateTraceHeaderTo: [],\n },\n console: { level: null, styles: CONSOLE_DEFAULT_STYLES },\n};\n\n/** Console mirroring level used when a consumer passes `console: true`. */\nexport const CONSOLE_DEFAULT_LEVEL: LogLevel = \"DEBUG\";\n\n// ----------------------------------\n// Batching\n// ----------------------------------\n\n/** Max time a partial log batch waits before the pipeline sends it, in milliseconds. */\nexport const LOG_FLUSH_INTERVAL_MS = 2000;\n\n/** Max records per log batch. At this count, the pipeline sends the batch early. */\nexport const LOG_BATCH_SIZE = 100;\n\n/**\n * Max time a partial metric batch waits before the pipeline sends it, in milliseconds.\n * Metric batches wait longer than log batches. Metrics have a higher volume, and no\n * caller waits for them.\n */\nexport const METRIC_FLUSH_INTERVAL_MS = 10_000;\n\n/** Max records per metric batch. At this count, the pipeline sends the batch early. */\nexport const METRIC_BATCH_SIZE = 500;\n\n/** Max concurrent ingest requests, across both streams. */\nexport const MAX_CONCURRENT_REQUESTS = 2;\n\n// ----------------------------------\n// HTTP transport\n// ----------------------------------\n\n/** Max time for one ingest request, in milliseconds. Then the transport aborts and retries it. */\nexport const REQUEST_TIMEOUT_MS = 15_000;\n\n/** Min payload size to compress, in bytes. */\nexport const COMPRESSION_THRESHOLD_BYTES = 1024;\n\n// ----------------------------------\n// Storage retention\n// ----------------------------------\n\n/** IndexedDB database name. */\nexport const STORAGE_DB_NAME = \"UiObservability\";\n\n/** Capacity and retention thresholds every storage adapter enforces. */\nexport const STORAGE_LIMITS: StorageLimits = {\n maxBatches: 500,\n maxAgeMs: 24 * 60 * 60 * 1000,\n maxAttempts: 5,\n};\n\n/**\n * Max time for one storage call, in milliseconds. Then the library treats the call as failed.\n * A call that does not settle keeps a dispatch slot or the drain flag.\n */\nexport const STORAGE_DEADLINE_MS = 10_000;\n\n// ----------------------------------\n// Retry backoff\n// ----------------------------------\n\n/** First backoff step, in milliseconds. Each attempt doubles it. */\nexport const RETRY_BASE_DELAY_MS = 2000;\n\n/** Backoff ceiling, in milliseconds. */\nexport const RETRY_MAX_DELAY_MS = 60_000;\n\n/** How often to check for stored work when nothing has failed recently, in milliseconds. */\nexport const RETRY_IDLE_DELAY_MS = 30_000;\n\n// ----------------------------------\n// Journey lifetime\n// ----------------------------------\n\n/** Max time a journey stays open, in milliseconds. Then the library treats it as abandoned. */\nexport const JOURNEY_MAX_AGE_MS = 30 * 60 * 1000;\n\n/** Whether closing the owning context ends the journey for everyone. */\nexport const JOURNEY_END_ON_OWNER_CLOSE = false;\n\n/** Query parameter checked at boot for a seeded journey token. */\nexport const JOURNEY_URL_PARAM = \"__uiobs_journey\";\n\n// ----------------------------------\n// Bus handshake\n// ----------------------------------\n\n/** BroadcastChannel name for the control plane. */\nexport const BUS_CHANNEL_NAME = \"ui_observability_control\";\n\n/** Max time a forwarder waits for an owner to answer before it promotes itself, in milliseconds. */\nexport const BUS_HANDSHAKE_TIMEOUT_MS = 1500;\n\n/** Handshake attempts allowed before a cross-origin forwarder promotes itself to sender. */\nexport const BUS_MAX_HANDSHAKE_ATTEMPTS = 3;\n\n/** Max records a context buffers before it knows its bus role. */\nexport const BUS_MAX_BOOT_BUFFER_RECORDS = 500;\n\n// ----------------------------------\n// Capture\n// ----------------------------------\n\n/** Breadcrumbs kept as context for the next error. */\nexport const MAX_BREADCRUMBS = 50;\n\n/**\n * Time window in which the library counts identical errors but does not send them again,\n * in milliseconds.\n */\nexport const ERROR_DEDUPE_MS = 5000;\n\n// ----------------------------------\n// Per-record size caps\n// ----------------------------------\n\n/** Size caps for every record. The library applies them after sanitize and after redact. */\nexport const RECORD_LIMITS = {\n maxBodyChars: 4096,\n maxAttributeChars: 8192,\n maxAttributeCount: 128,\n maxStackChars: 8192,\n maxDepth: 6,\n maxArrayLength: 100,\n maxNodes: 10_000,\n maxRecordBytes: 32_768,\n};\n"],"mappings":";AAcA,IAAaA,KAAqB,sBAUrBC,KAAyB,KAOzBC,IAAiB,4BAGjBC,KAAa,wBAGbC,IAAkB,MAGlBC,IAAmB,KAanBC,IAAqB,YAGrBC,IAA6B,UAG7BC,IAAwB,0BAGxBC,IAAuB,iBAGvBC,IAAoB,cAGpBC,IAAkB,eAGlBC,IAAkB,WAOlBC,IAAqB,OAGrBC,IAAqB,OAMrBC,IAAwB,MA+BxBC,IAA4C;CACvD,OAAO;CACP,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,OAAO;AACT,GAMaC,IAAwCD,GAUxCE,IAAgB,YAGhBC,IAAe,WAGfC,IAAqB,iBAGrBC,IAAgB,YAOhBC,IAAgB,YAGhBC,IAAkB,cAGlBC,IAAoB,gBAGpBC,IAAyB,qBAGzBC,IAAuB,yBAMvBC,IAA0B,4BAM1BC,IAAwB,0BAGxBC,IAAwB,gBAGxBC,IAA2B,mBAG3BC,IAAkC,0BAMlCC,IAA8B,sBAM9BC,IAAiC,yBAMjCC,IAAkC,0BAGlCC,IAAyB,iBAGzBC,IAAsB,cAGtBC,IAAkB,UAGlBC,IAAsB,cAGtBC,IAA8B,sBAG9BC,IAAwB,gBAGxBC,IAAwB,gBAMxBC,IAAqB,2BAOrBC,IAAwB,SAMxBC,IAAyB,SAOzBC,IAAuB,QAUvBC,IAAqD,EAAE,MAAM,UAAU,GAGvEC,IAAoB,oBAGpBC,IAAsB,wBAGtBC,IAAkB,UAMlBC,IAAgB,SAOhBC,IAAsB,gBAGtBC,IAA0B,oBAG1BC,IAAqB,eAMrBC,IAAkB,oBAGlBC,KAAiB,mBAGjBC,KAAkB,oBAGlBC,KAAgB,QAoChBC,KAAoB,KAOpBC,KAAqB,KAGrBC,KAA0B,4BAM1BC,KAAuB,kBAGvBC,KAA0B,cAO1BC,KAA2B,2BAM3BC,IAA+B,+BAM/BC,KAAoB,0BAMpBC,KAAuB,sBAWvBC,KAAuB,WAGvBC,KAA6B,aAG7BC,KAAyB,aAGzBC,KAAqB,gBAGrBC,KAAsB,UAGtBC,KAAoB,QAUpBC,KAAkB,0BAMlBC,KAAsB,8BAUtBC,KAAsB,4BAoBtBC,KAA6B,KAG7BC,KAAkC,gBAGlCC,KAAsB,OAGtBC,KAAuB,OAGvBC,KAAyB,OAGzBC,KAAyB,MAGzBC,KAA+B,MAgB/BC,KAAmB,KAYnBC,KAAqB,eAoBrBC,KAAmB,YAGnBC,KAAY,UAGZC,KAAa,YAObC,KAA2B,UAO3BC,KAAe,sBAGfC,KAAqB,4BAGrBC,KAAsB,4BAGtBC,KAAsB,kCAGtBC,KAAsB,kCAUtBC,KAAwB,KA+BxBC,IAA4D;CACvE,WAAW;CACX,OAAO;CACP,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,OAAO;AACT,GAGaC,KAAqB,KAOrBC,KAAyB,KAGzBC,KAAoB,iBAGpBC,KAAoB,iBAGpBC,KAAsB,SAOtBC,KAAuB,mBAkBvBC,KAA4B,MAG5BC,KAA6B,MAM7BC,KAA0B,KAM1BC,KAA0B;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAMaC,KAAkB;CAAC;CAAY;CAAO;AAAS,GAM/CC,KAA+E;CAC1F,UAAU,CAAC;CACX,KAAK,CAAC;CACN,SAAS,CAAC,iBAAiB;AAC7B,GAQaC,KAAqD;CAChE,UAAU;CACV,aAAa;CACb,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,UAAU;CACV,aAAa;CACb,aAAa;CACb,SAAS;CACT,UAAU;CACV,UAAU;EACR,aAAa;EACb,OAAO,CAAC;EACR,mBAAmB,CAAC,QAAQ;EAC5B,QAAQ;EACR,eAAe;CACjB;CACA,KAAK;EAAE,MAAM;EAAQ,gBAAgB,CAAC;EAAG,aAAa;CAAO;CAC7D,SAAS;EACP,QAAQ;EACR,YAAY;EACZ,gBAAgB;EAChB,OAAO;EACP,KAAK;EACL,cAAc;EACd,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,sBAAA;EACA,SAAS;EACT,UAAU;EACV,YAAY,CAAC;EACb,wBAAwB,CAAC;CAC3B;CACA,SAAS;EAAE,OAAO;EAAM,QAAQb;CAAuB;AACzD,GAGac,KAAkC,SAOlCC,KAAwB,KAUxBC,KAA2B,KAa3BC,KAAqB,MAGrBC,KAA8B,MAO9BC,KAAkB,mBAGlBC,KAAgC;CAC3C,YAAY;CACZ,UAAU;CACV,aAAa;AACf,GAMaC,KAAsB,KAOtBC,KAAsB,KAGtBC,KAAqB,KAGrBC,KAAsB,KAOtBC,KAAqB,MAMrBC,KAAoB,mBAOpBC,KAAmB,4BAGnBC,KAA2B,MAmB3BC,KAAkB,KAOlBC,KAAgB;CAC3B,cAAc;CACd,mBAAmB;CACnB,mBAAmB;CACnB,eAAe;CACf,UAAU;CACV,gBAAgB;CAChB,UAAU;CACV,gBAAgB;AAClB"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ export declare const TELEMETRY_SDK_NAME = "@utk09/ui-observability";
|
|
|
143
143
|
* Change it by hand when you change the version in package.json.
|
|
144
144
|
* @see {@link RESOURCE_TELEMETRY_SDK_VERSION}
|
|
145
145
|
*/
|
|
146
|
-
export declare const TELEMETRY_SDK_VERSION = "0.
|
|
146
|
+
export declare const TELEMETRY_SDK_VERSION = "0.8.0";
|
|
147
147
|
/**
|
|
148
148
|
* Value of `telemetry.sdk.language`.
|
|
149
149
|
* @see {@link RESOURCE_TELEMETRY_SDK_LANGUAGE}
|
|
@@ -183,8 +183,18 @@ export declare const HEADER_RETRY_AFTER = "Retry-After";
|
|
|
183
183
|
export declare const HEADER_BATCH_ID = "X-UiObs-Batch-Id";
|
|
184
184
|
/** Delivery attempt number header name. */
|
|
185
185
|
export declare const HEADER_ATTEMPT = "X-UiObs-Attempt";
|
|
186
|
+
/** Response header that carries sampling rules from the ingest server. */
|
|
187
|
+
export declare const HEADER_SAMPLING = "X-UiObs-Sampling";
|
|
186
188
|
/** Gzip encoding name. */
|
|
187
189
|
export declare const ENCODING_GZIP = "gzip";
|
|
190
|
+
/** Lowest valid HTTP status code. */
|
|
191
|
+
export declare const HTTP_STATUS_MIN = 100;
|
|
192
|
+
/** Highest valid HTTP status code. */
|
|
193
|
+
export declare const HTTP_STATUS_MAX = 599;
|
|
194
|
+
/** Lowest HTTP status code that accepts a batch. */
|
|
195
|
+
export declare const HTTP_SUCCESS_MIN = 200;
|
|
196
|
+
/** Lowest HTTP status code above the success range. */
|
|
197
|
+
export declare const HTTP_SUCCESS_END = 300;
|
|
188
198
|
/** 401, credentials missing or rejected. */
|
|
189
199
|
export declare const HTTP_UNAUTHORIZED = 401;
|
|
190
200
|
/** 403, valid credentials but access denied. */
|
|
@@ -323,6 +333,10 @@ export declare const BUS_PROTOCOL = "ui-observability/1";
|
|
|
323
333
|
export declare const RUNTIME_GLOBAL_KEY = "ui-observability.runtime";
|
|
324
334
|
/** Global key of the runtime that shutdown() stopped. Calls go to it until the next configure(). */
|
|
325
335
|
export declare const RUNTIME_STOPPED_KEY = "ui-observability.stopped";
|
|
336
|
+
/** Global symbol key of the library request scope count. All library copies on a page share it. */
|
|
337
|
+
export declare const LIBRARY_REQUEST_KEY = "ui-observability.request-scope";
|
|
338
|
+
/** Global symbol key of the library console scope count. All library copies on a page share it. */
|
|
339
|
+
export declare const LIBRARY_CONSOLE_KEY = "ui-observability.console-scope";
|
|
326
340
|
/** Maximum error records captured per throttling window before suppression. */
|
|
327
341
|
export declare const ERROR_STORM_MAX_PER_WINDOW = 20;
|
|
328
342
|
/** Error rate-limiting window duration in milliseconds. */
|
|
@@ -333,6 +347,12 @@ export declare const ERROR_STORM_WINDOW_MS = 10000;
|
|
|
333
347
|
* ERROR and FATAL records skip sampling. A direct logger.error call has no other limit.
|
|
334
348
|
*/
|
|
335
349
|
export declare const ERROR_CEILING_MAX_PER_WINDOW = 500;
|
|
350
|
+
/** Default minimum duration of a long frame that the library records, in milliseconds. */
|
|
351
|
+
export declare const LONG_FRAME_THRESHOLD_MS = 100;
|
|
352
|
+
/** Maximum long frames recorded in each storm window. A frozen tab cannot flood the pipeline. */
|
|
353
|
+
export declare const LONG_FRAME_MAX_PER_WINDOW = 20;
|
|
354
|
+
/** Maximum character length of a console breadcrumb message. */
|
|
355
|
+
export declare const CONSOLE_BREADCRUMB_MAX_CHARS = 200;
|
|
336
356
|
/** Maximum distinct error signatures tracked for deduplication before LRU eviction. */
|
|
337
357
|
export declare const MAX_TRACKED_ERROR_SIGNATURES = 200;
|
|
338
358
|
/** Maximum character length retained from clicked element text in breadcrumbs. */
|
|
@@ -364,11 +384,21 @@ export declare const SAMPLING_RATE_MAX = 1;
|
|
|
364
384
|
* @see {@link SAMPLING_RATE_MAX}
|
|
365
385
|
*/
|
|
366
386
|
export declare const SAMPLING_RATE_FALLBACK = 1;
|
|
387
|
+
/** Version of the remote sampling rules that the library accepts. */
|
|
388
|
+
export declare const REMOTE_SAMPLING_VERSION = 1;
|
|
389
|
+
/** Maximum length of the sampling header, in characters. */
|
|
390
|
+
export declare const REMOTE_SAMPLING_MAX_CHARS = 4096;
|
|
391
|
+
/** Maximum time that remote sampling rules stay in force, in milliseconds. */
|
|
392
|
+
export declare const REMOTE_SAMPLING_MAX_TTL_MS: number;
|
|
393
|
+
/** Maximum namespace rates in one set of remote sampling rules. */
|
|
394
|
+
export declare const REMOTE_SAMPLING_MAX_RATES = 100;
|
|
395
|
+
/** Time between two requests of a forwarder for the remote sampling rules, in milliseconds. */
|
|
396
|
+
export declare const REMOTE_SAMPLING_POLL_MS = 30000;
|
|
367
397
|
/**
|
|
368
398
|
* Config keys with no default, excluded from `DEFAULT_CONFIG`.
|
|
369
399
|
* @see {@link DEFAULT_CONFIG}
|
|
370
400
|
*/
|
|
371
|
-
export declare const UNDEFAULTED_CONFIG_KEYS: readonly ["redact", "onDiagnostic", "headers", "serializer", "otelLoader"];
|
|
401
|
+
export declare const UNDEFAULTED_CONFIG_KEYS: readonly ["redact", "onDiagnostic", "headers", "serializer", "otelLoader", "transport", "transportOnExit"];
|
|
372
402
|
/**
|
|
373
403
|
* Nested config section keys.
|
|
374
404
|
* @see {@link ResolvedConfig}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Category of a breadcrumb event. */
|
|
2
|
-
export type BreadcrumbCategory = "log" | "action" | "event" | "click" | "navigation" | "http" | "console";
|
|
2
|
+
export type BreadcrumbCategory = "log" | "action" | "event" | "click" | "navigation" | "http" | "console" | "frame";
|
|
3
3
|
/** Short summary of one event that the buffer keeps for an error record. */
|
|
4
4
|
export interface Breadcrumb {
|
|
5
5
|
/** Timestamp in epoch milliseconds. */
|
package/dist/core/pipeline.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LogBatch } from "../models/batch";
|
|
2
2
|
import { type LogRecord } from "../models/log-record";
|
|
3
3
|
import type { StorageAdapter } from "../models/storage";
|
|
4
|
-
import type {
|
|
4
|
+
import type { BatchTransport } from "../transport/status-transport";
|
|
5
5
|
import type { RetryEngine } from "../transport/retry-engine";
|
|
6
6
|
import type { Diagnostics } from "./diagnostics";
|
|
7
7
|
/** Name of a pipeline stream. */
|
|
@@ -45,7 +45,7 @@ export declare class LogPipeline {
|
|
|
45
45
|
* @param diagnostics Diagnostics reporter.
|
|
46
46
|
* @param streamOptions Batching policy per stream.
|
|
47
47
|
*/
|
|
48
|
-
constructor(transport:
|
|
48
|
+
constructor(transport: BatchTransport, storage: StorageAdapter, retry: RetryEngine, diagnostics: Diagnostics, streamOptions?: Record<StreamName, StreamOptions>);
|
|
49
49
|
/**
|
|
50
50
|
* Sets the observed timestamp and adds a record to the pipeline.
|
|
51
51
|
* @param record Record to push.
|
package/dist/core/record.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { TraceEngine } from "../utils/tracing";
|
|
|
8
8
|
import type { ContextStore } from "./context";
|
|
9
9
|
import type { Diagnostics } from "./diagnostics";
|
|
10
10
|
import type { JourneyEngine } from "./journey";
|
|
11
|
+
import type { RemoteSlot } from "./remote-sampling";
|
|
11
12
|
/** Injected dependencies required by RecordBuilder. */
|
|
12
13
|
export interface RecordBuilderDeps {
|
|
13
14
|
/** Active configuration object reference. */
|
|
@@ -28,6 +29,8 @@ export interface RecordBuilderDeps {
|
|
|
28
29
|
identity: Identity;
|
|
29
30
|
/** Detected host platform metadata. */
|
|
30
31
|
platform: PlatformMetadata;
|
|
32
|
+
/** Slot of the sampling rules from the ingest server. */
|
|
33
|
+
remote: RemoteSlot;
|
|
31
34
|
}
|
|
32
35
|
/** Size limits for each record. The builder applies them after sanitize and after redact. */
|
|
33
36
|
export interface RecordLimits extends SanitizeLimits {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ResolvedConfig } from "../models/config";
|
|
2
|
+
import type { Diagnostics } from "./diagnostics";
|
|
3
|
+
import { type RemoteSlot, type RemoteUpdate } from "./remote-sampling";
|
|
4
|
+
/**
|
|
5
|
+
* Validates sampling rules from the server. A rule that is not valid rejects all the rules.
|
|
6
|
+
* @param raw Header text, or a parsed object from a custom transport or the bus.
|
|
7
|
+
* @param diagnostics Diagnostics reporter.
|
|
8
|
+
* @returns The rules and their TTL, or null if they are not valid.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseRemoteRules(raw: unknown, diagnostics: Diagnostics): RemoteUpdate | null;
|
|
11
|
+
/**
|
|
12
|
+
* Puts rules in force in the slot of the runtime. It makes the overlay for the first rules.
|
|
13
|
+
* @param slot Slot of the runtime.
|
|
14
|
+
* @param config Active configuration instance.
|
|
15
|
+
* @param update Validated rules, or null when the upstream has no rules.
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyRemote(slot: RemoteSlot, config: ResolvedConfig, update: RemoteUpdate | null): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { REMOTE_SAMPLING_VERSION } from "../constants";
|
|
2
|
+
import type { ResolvedConfig } from "../models/config";
|
|
3
|
+
import type { LogLevel } from "../models/log-record";
|
|
4
|
+
/** Sampling rules from the ingest server, after validation. */
|
|
5
|
+
export interface RemoteRules {
|
|
6
|
+
/** Rate when no namespace rate matches. Without it, the config rate applies. */
|
|
7
|
+
defaultRate?: number;
|
|
8
|
+
/** Rate for each namespace prefix. They apply over the config rates. */
|
|
9
|
+
rates: Record<string, number>;
|
|
10
|
+
/** Lowest level that the library sends. It can only lower `minLevel`. */
|
|
11
|
+
minLevel?: LogLevel;
|
|
12
|
+
}
|
|
13
|
+
/** Rules and their TTL, after validation. */
|
|
14
|
+
export interface RemoteUpdate {
|
|
15
|
+
/** Validated rules. */
|
|
16
|
+
rules: RemoteRules;
|
|
17
|
+
/** Time that the rules stay in force, in milliseconds. */
|
|
18
|
+
ttlMs: number;
|
|
19
|
+
}
|
|
20
|
+
/** Rules in the shape of the header. A context sends them to a forwarder over the bus. */
|
|
21
|
+
export interface RemoteWire extends RemoteRules {
|
|
22
|
+
/** Rules version. */
|
|
23
|
+
v: typeof REMOTE_SAMPLING_VERSION;
|
|
24
|
+
/** Time that the rules stay in force, in milliseconds. */
|
|
25
|
+
ttlMs: number;
|
|
26
|
+
}
|
|
27
|
+
/** Slot of the runtime for the overlay. The sender or the bus fills it when the first rules arrive. */
|
|
28
|
+
export interface RemoteSlot {
|
|
29
|
+
/** Overlay, or null before the first rules. */
|
|
30
|
+
sampling: RemoteSampling | null;
|
|
31
|
+
}
|
|
32
|
+
/** Remote sampling rules in force for this context. */
|
|
33
|
+
export declare class RemoteSampling {
|
|
34
|
+
private readonly config;
|
|
35
|
+
/** Rules in force, or null. */
|
|
36
|
+
private rules;
|
|
37
|
+
/** Time that the rules arrived, in epoch milliseconds. */
|
|
38
|
+
private receivedAt;
|
|
39
|
+
/** Time that the rules end, in epoch milliseconds. */
|
|
40
|
+
private until;
|
|
41
|
+
/**
|
|
42
|
+
* @param config Active configuration instance. A reconfigure changes it in place.
|
|
43
|
+
*/
|
|
44
|
+
constructor(config: ResolvedConfig);
|
|
45
|
+
/**
|
|
46
|
+
* Puts new rules in force. They replace the rules in force.
|
|
47
|
+
* @param update Validated rules and their TTL, or null when the upstream has no rules.
|
|
48
|
+
*/
|
|
49
|
+
apply(update: RemoteUpdate | null): void;
|
|
50
|
+
/**
|
|
51
|
+
* Returns the rules in force.
|
|
52
|
+
* @returns The rules, or null after the TTL or when `sampling.remote` is off.
|
|
53
|
+
*/
|
|
54
|
+
current(): RemoteRules | null;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the lowest level that the library sends.
|
|
57
|
+
* @returns The remote level if it is lower than `minLevel`, or else `minLevel`.
|
|
58
|
+
*/
|
|
59
|
+
minLevel(): LogLevel;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the rules in force in the shape of the header, with the remaining TTL.
|
|
62
|
+
* @returns The rules, or null if no rules are in force.
|
|
63
|
+
*/
|
|
64
|
+
wire(): RemoteWire | null;
|
|
65
|
+
}
|