@interfere/react 9.0.2 → 10.0.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/README.md +4 -4
- package/dist/api.d.mts +25 -0
- package/dist/api.d.mts.map +1 -0
- package/dist/api.mjs +68 -0
- package/dist/api.mjs.map +1 -0
- package/dist/error-boundary.d.mts +11 -4
- package/dist/error-boundary.d.mts.map +1 -1
- package/dist/error-boundary.mjs +6 -3
- package/dist/error-boundary.mjs.map +1 -1
- package/dist/internal/browser-context.d.mts +6 -0
- package/dist/internal/browser-context.d.mts.map +1 -0
- package/dist/internal/browser-context.mjs +59 -0
- package/dist/internal/browser-context.mjs.map +1 -0
- package/dist/internal/capture-boundary.d.mts +5 -1
- package/dist/internal/capture-boundary.d.mts.map +1 -1
- package/dist/internal/capture-boundary.mjs +9 -5
- package/dist/internal/capture-boundary.mjs.map +1 -1
- package/dist/internal/capture.d.mts +16 -5
- package/dist/internal/capture.d.mts.map +1 -1
- package/dist/internal/capture.mjs +20 -16
- package/dist/internal/capture.mjs.map +1 -1
- package/dist/internal/config.d.mts +20 -4
- package/dist/internal/config.d.mts.map +1 -1
- package/dist/internal/config.mjs +12 -12
- package/dist/internal/config.mjs.map +1 -1
- package/dist/internal/consent.d.mts.map +1 -1
- package/dist/internal/consent.mjs +3 -1
- package/dist/internal/consent.mjs.map +1 -1
- package/dist/internal/console-patch.d.mts +19 -0
- package/dist/internal/console-patch.d.mts.map +1 -0
- package/dist/internal/console-patch.mjs +62 -0
- package/dist/internal/console-patch.mjs.map +1 -0
- package/dist/internal/dom/actionable.d.mts +27 -0
- package/dist/internal/dom/actionable.d.mts.map +1 -0
- package/dist/internal/dom/actionable.mjs +62 -0
- package/dist/internal/dom/actionable.mjs.map +1 -0
- package/dist/internal/kernel-registry.d.mts +8 -0
- package/dist/internal/kernel-registry.d.mts.map +1 -0
- package/dist/internal/kernel-registry.mjs +31 -0
- package/dist/internal/kernel-registry.mjs.map +1 -0
- package/dist/internal/kernel.d.mts +267 -0
- package/dist/internal/kernel.d.mts.map +1 -0
- package/dist/internal/kernel.mjs +322 -0
- package/dist/internal/kernel.mjs.map +1 -0
- package/dist/internal/otel/exporter.d.mts +93 -0
- package/dist/internal/otel/exporter.d.mts.map +1 -0
- package/dist/internal/otel/exporter.mjs +212 -0
- package/dist/internal/otel/exporter.mjs.map +1 -0
- package/dist/internal/otel/index.d.mts +6 -0
- package/dist/internal/otel/index.mjs +6 -0
- package/dist/internal/otel/instrumentations.d.mts +42 -0
- package/dist/internal/otel/instrumentations.d.mts.map +1 -0
- package/dist/internal/otel/instrumentations.mjs +150 -0
- package/dist/internal/otel/instrumentations.mjs.map +1 -0
- package/dist/internal/otel/page-scope-context-manager.d.mts +32 -0
- package/dist/internal/otel/page-scope-context-manager.d.mts.map +1 -0
- package/dist/internal/otel/page-scope-context-manager.mjs +36 -0
- package/dist/internal/otel/page-scope-context-manager.mjs.map +1 -0
- package/dist/internal/otel/propagation.d.mts +21 -0
- package/dist/internal/otel/propagation.d.mts.map +1 -0
- package/dist/internal/otel/propagation.mjs +40 -0
- package/dist/internal/otel/propagation.mjs.map +1 -0
- package/dist/internal/otel/provider.d.mts +107 -0
- package/dist/internal/otel/provider.d.mts.map +1 -0
- package/dist/internal/otel/provider.mjs +151 -0
- package/dist/internal/otel/provider.mjs.map +1 -0
- package/dist/internal/otel/web-vitals.d.mts +35 -0
- package/dist/internal/otel/web-vitals.d.mts.map +1 -0
- package/dist/internal/otel/web-vitals.mjs +162 -0
- package/dist/internal/otel/web-vitals.mjs.map +1 -0
- package/dist/internal/page-lifecycle.d.mts +21 -0
- package/dist/internal/page-lifecycle.d.mts.map +1 -0
- package/dist/internal/page-lifecycle.mjs +33 -0
- package/dist/internal/page-lifecycle.mjs.map +1 -0
- package/dist/internal/plugin-runtime.d.mts +0 -2
- package/dist/internal/plugin-runtime.d.mts.map +1 -1
- package/dist/internal/plugin-runtime.mjs +1 -7
- package/dist/internal/plugin-runtime.mjs.map +1 -1
- package/dist/internal/react-context.d.mts +45 -0
- package/dist/internal/react-context.d.mts.map +1 -0
- package/dist/internal/react-context.mjs +34 -0
- package/dist/internal/react-context.mjs.map +1 -0
- package/dist/internal/sw.d.mts +22 -2
- package/dist/internal/sw.d.mts.map +1 -1
- package/dist/internal/sw.mjs +30 -3
- package/dist/internal/sw.mjs.map +1 -1
- package/dist/internal/version.d.mts +3 -1
- package/dist/internal/version.d.mts.map +1 -1
- package/dist/internal/version.mjs +4 -2
- package/dist/internal/version.mjs.map +1 -1
- package/dist/internal/wrapper-singleton.d.mts +47 -0
- package/dist/internal/wrapper-singleton.d.mts.map +1 -0
- package/dist/internal/wrapper-singleton.mjs +73 -0
- package/dist/internal/wrapper-singleton.mjs.map +1 -0
- package/dist/package.mjs +1 -1
- package/dist/plugins/errors.d.mts.map +1 -1
- package/dist/plugins/errors.mjs +18 -25
- package/dist/plugins/errors.mjs.map +1 -1
- package/dist/plugins/lib/loader.d.mts +1 -2
- package/dist/plugins/lib/loader.d.mts.map +1 -1
- package/dist/plugins/lib/loader.mjs +2 -11
- package/dist/plugins/lib/loader.mjs.map +1 -1
- package/dist/plugins/lib/types.d.mts +3 -2
- package/dist/plugins/lib/types.d.mts.map +1 -1
- package/dist/plugins/logs.d.mts +13 -0
- package/dist/plugins/logs.d.mts.map +1 -0
- package/dist/plugins/logs.mjs +53 -0
- package/dist/plugins/logs.mjs.map +1 -0
- package/dist/plugins/rage-clicks.d.mts.map +1 -1
- package/dist/plugins/rage-clicks.mjs +12 -10
- package/dist/plugins/rage-clicks.mjs.map +1 -1
- package/dist/plugins/replay.d.mts.map +1 -1
- package/dist/plugins/replay.mjs +58 -19
- package/dist/plugins/replay.mjs.map +1 -1
- package/dist/provider.d.mts +11 -20
- package/dist/provider.d.mts.map +1 -1
- package/dist/provider.mjs +13 -14
- package/dist/provider.mjs.map +1 -1
- package/dist/react-error-handler.d.mts +21 -5
- package/dist/react-error-handler.d.mts.map +1 -1
- package/dist/react-error-handler.mjs +15 -7
- package/dist/react-error-handler.mjs.map +1 -1
- package/dist/sw.d.mts +2 -0
- package/dist/sw.mjs +2 -0
- package/dist/tracking/api.d.mts +41 -15
- package/dist/tracking/api.d.mts.map +1 -1
- package/dist/tracking/api.mjs +122 -104
- package/dist/tracking/api.mjs.map +1 -1
- package/dist/tracking/device.d.mts +30 -7
- package/dist/tracking/device.d.mts.map +1 -1
- package/dist/tracking/device.mjs +70 -46
- package/dist/tracking/device.mjs.map +1 -1
- package/dist/tracking/geo.d.mts +11 -3
- package/dist/tracking/geo.d.mts.map +1 -1
- package/dist/tracking/geo.mjs +33 -29
- package/dist/tracking/geo.mjs.map +1 -1
- package/dist/tracking/session.d.mts +3 -1
- package/dist/tracking/session.d.mts.map +1 -1
- package/dist/tracking/session.mjs.map +1 -1
- package/dist/util/bot.d.mts +10 -0
- package/dist/util/bot.d.mts.map +1 -0
- package/dist/util/bot.mjs +14 -0
- package/dist/util/bot.mjs.map +1 -0
- package/dist/util/global.d.mts +10 -0
- package/dist/util/global.d.mts.map +1 -0
- package/dist/util/global.mjs +12 -0
- package/dist/util/global.mjs.map +1 -0
- package/dist/util/log.d.mts.map +1 -1
- package/dist/util/log.mjs +8 -1
- package/dist/util/log.mjs.map +1 -1
- package/dist/util/stringify.d.mts +9 -0
- package/dist/util/stringify.d.mts.map +1 -0
- package/dist/util/stringify.mjs +16 -0
- package/dist/util/stringify.mjs.map +1 -0
- package/package.json +73 -20
- package/dist/internal/client.d.mts +0 -48
- package/dist/internal/client.d.mts.map +0 -1
- package/dist/internal/client.mjs +0 -146
- package/dist/internal/client.mjs.map +0 -1
- package/dist/internal/context.d.mts +0 -6
- package/dist/internal/context.d.mts.map +0 -1
- package/dist/internal/context.mjs +0 -32
- package/dist/internal/context.mjs.map +0 -1
- package/dist/internal/envelope.d.mts +0 -15
- package/dist/internal/envelope.d.mts.map +0 -1
- package/dist/internal/envelope.mjs +0 -24
- package/dist/internal/envelope.mjs.map +0 -1
- package/dist/internal/errors.d.mts +0 -4
- package/dist/internal/errors.d.mts.map +0 -1
- package/dist/internal/errors.mjs +0 -4
- package/dist/internal/errors.mjs.map +0 -1
- package/dist/plugins/device.d.mts +0 -6
- package/dist/plugins/device.d.mts.map +0 -1
- package/dist/plugins/device.mjs +0 -13
- package/dist/plugins/device.mjs.map +0 -1
- package/dist/plugins/pages.d.mts +0 -6
- package/dist/plugins/pages.d.mts.map +0 -1
- package/dist/plugins/pages.mjs +0 -102
- package/dist/plugins/pages.mjs.map +0 -1
- package/dist/transport/http.d.mts +0 -25
- package/dist/transport/http.d.mts.map +0 -1
- package/dist/transport/http.mjs +0 -80
- package/dist/transport/http.mjs.map +0 -1
- package/dist/transport/queue.d.mts +0 -34
- package/dist/transport/queue.d.mts.map +0 -1
- package/dist/transport/queue.mjs +0 -100
- package/dist/transport/queue.mjs.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/internal/console-patch.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Single point of `console.{debug,log,info,warn,error}` patching. The
|
|
4
|
+
* errors plugin and the logs plugin both want to observe console calls;
|
|
5
|
+
* before this consolidation, each patched independently and the
|
|
6
|
+
* resulting wrap-order coupling made teardown leaky.
|
|
7
|
+
*
|
|
8
|
+
* Now: a single set of patched methods is installed on first
|
|
9
|
+
* subscription, fans out to every subscriber, and is uninstalled on the
|
|
10
|
+
* last unsubscription. Handlers never wrap each other; they observe.
|
|
11
|
+
*/
|
|
12
|
+
declare const CONSOLE_LEVELS: readonly ["debug", "log", "info", "warn", "error"];
|
|
13
|
+
type ConsoleLevel = (typeof CONSOLE_LEVELS)[number];
|
|
14
|
+
type ConsoleHandler = (level: ConsoleLevel, args: unknown[]) => void;
|
|
15
|
+
declare function onConsoleCall(handler: ConsoleHandler): () => void;
|
|
16
|
+
/** Test hook — drops every handler and restores originals. */
|
|
17
|
+
declare function _resetConsolePatchForTests(): void;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { CONSOLE_LEVELS, ConsoleHandler, ConsoleLevel, _resetConsolePatchForTests, onConsoleCall };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-patch.d.mts","names":[],"sources":["../../src/internal/console-patch.ts"],"mappings":";;AAUA;;;;;AAQA;;;;cARa,cAAA;AAAA,KAQD,YAAA,WAAuB,cAAA;AAAA,KAEvB,cAAA,IAAkB,KAAA,EAAO,YAAA,EAAc,IAAA;AAAA,iBAiDnC,aAAA,CAAc,OAAA,EAAS,cAAA;;iBAYvB,0BAAA,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region src/internal/console-patch.ts
|
|
2
|
+
/**
|
|
3
|
+
* Single point of `console.{debug,log,info,warn,error}` patching. The
|
|
4
|
+
* errors plugin and the logs plugin both want to observe console calls;
|
|
5
|
+
* before this consolidation, each patched independently and the
|
|
6
|
+
* resulting wrap-order coupling made teardown leaky.
|
|
7
|
+
*
|
|
8
|
+
* Now: a single set of patched methods is installed on first
|
|
9
|
+
* subscription, fans out to every subscriber, and is uninstalled on the
|
|
10
|
+
* last unsubscription. Handlers never wrap each other; they observe.
|
|
11
|
+
*/
|
|
12
|
+
const CONSOLE_LEVELS = [
|
|
13
|
+
"debug",
|
|
14
|
+
"log",
|
|
15
|
+
"info",
|
|
16
|
+
"warn",
|
|
17
|
+
"error"
|
|
18
|
+
];
|
|
19
|
+
const handlers = /* @__PURE__ */ new Set();
|
|
20
|
+
const originals = {};
|
|
21
|
+
let installed = false;
|
|
22
|
+
function install() {
|
|
23
|
+
if (installed) return;
|
|
24
|
+
installed = true;
|
|
25
|
+
const target = globalThis.console;
|
|
26
|
+
for (const level of CONSOLE_LEVELS) {
|
|
27
|
+
const orig = target[level];
|
|
28
|
+
if (typeof orig !== "function") continue;
|
|
29
|
+
originals[level] = orig;
|
|
30
|
+
target[level] = (...args) => {
|
|
31
|
+
orig.apply(globalThis.console, args);
|
|
32
|
+
for (const handler of handlers) handler(level, args);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function uninstall() {
|
|
37
|
+
if (!installed) return;
|
|
38
|
+
installed = false;
|
|
39
|
+
const target = globalThis.console;
|
|
40
|
+
for (const level of CONSOLE_LEVELS) {
|
|
41
|
+
const orig = originals[level];
|
|
42
|
+
if (orig) {
|
|
43
|
+
target[level] = orig;
|
|
44
|
+
delete originals[level];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function onConsoleCall(handler) {
|
|
49
|
+
install();
|
|
50
|
+
handlers.add(handler);
|
|
51
|
+
return () => {
|
|
52
|
+
handlers.delete(handler);
|
|
53
|
+
if (handlers.size === 0) uninstall();
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Test hook — drops every handler and restores originals. */
|
|
57
|
+
function _resetConsolePatchForTests() {
|
|
58
|
+
handlers.clear();
|
|
59
|
+
uninstall();
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { CONSOLE_LEVELS, _resetConsolePatchForTests, onConsoleCall };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-patch.mjs","names":[],"sources":["../../src/internal/console-patch.ts"],"sourcesContent":["/**\n * Single point of `console.{debug,log,info,warn,error}` patching. The\n * errors plugin and the logs plugin both want to observe console calls;\n * before this consolidation, each patched independently and the\n * resulting wrap-order coupling made teardown leaky.\n *\n * Now: a single set of patched methods is installed on first\n * subscription, fans out to every subscriber, and is uninstalled on the\n * last unsubscription. Handlers never wrap each other; they observe.\n */\nexport const CONSOLE_LEVELS = [\n \"debug\",\n \"log\",\n \"info\",\n \"warn\",\n \"error\",\n] as const;\n\nexport type ConsoleLevel = (typeof CONSOLE_LEVELS)[number];\n\nexport type ConsoleHandler = (level: ConsoleLevel, args: unknown[]) => void;\n\nconst handlers = new Set<ConsoleHandler>();\nconst originals: Partial<Record<ConsoleLevel, (...args: unknown[]) => void>> =\n {};\nlet installed = false;\n\nfunction install(): void {\n if (installed) {\n return;\n }\n installed = true;\n const target = globalThis.console as unknown as Record<\n ConsoleLevel,\n (...args: unknown[]) => void\n >;\n for (const level of CONSOLE_LEVELS) {\n const orig = target[level];\n if (typeof orig !== \"function\") {\n continue;\n }\n originals[level] = orig;\n target[level] = (...args: unknown[]) => {\n orig.apply(globalThis.console, args);\n for (const handler of handlers) {\n handler(level, args);\n }\n };\n }\n}\n\nfunction uninstall(): void {\n if (!installed) {\n return;\n }\n installed = false;\n const target = globalThis.console as unknown as Record<\n ConsoleLevel,\n (...args: unknown[]) => void\n >;\n for (const level of CONSOLE_LEVELS) {\n const orig = originals[level];\n if (orig) {\n target[level] = orig;\n delete originals[level];\n }\n }\n}\n\nexport function onConsoleCall(handler: ConsoleHandler): () => void {\n install();\n handlers.add(handler);\n return () => {\n handlers.delete(handler);\n if (handlers.size === 0) {\n uninstall();\n }\n };\n}\n\n/** Test hook — drops every handler and restores originals. */\nexport function _resetConsolePatchForTests(): void {\n handlers.clear();\n uninstall();\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACD;AAMD,MAAM,2BAAW,IAAI,KAAqB;AAC1C,MAAM,YACJ,EAAE;AACJ,IAAI,YAAY;AAEhB,SAAS,UAAgB;CACvB,IAAI,WACF;CAEF,YAAY;CACZ,MAAM,SAAS,WAAW;CAI1B,KAAK,MAAM,SAAS,gBAAgB;EAClC,MAAM,OAAO,OAAO;EACpB,IAAI,OAAO,SAAS,YAClB;EAEF,UAAU,SAAS;EACnB,OAAO,UAAU,GAAG,SAAoB;GACtC,KAAK,MAAM,WAAW,SAAS,KAAK;GACpC,KAAK,MAAM,WAAW,UACpB,QAAQ,OAAO,KAAK;;;;AAM5B,SAAS,YAAkB;CACzB,IAAI,CAAC,WACH;CAEF,YAAY;CACZ,MAAM,SAAS,WAAW;CAI1B,KAAK,MAAM,SAAS,gBAAgB;EAClC,MAAM,OAAO,UAAU;EACvB,IAAI,MAAM;GACR,OAAO,SAAS;GAChB,OAAO,UAAU;;;;AAKvB,SAAgB,cAAc,SAAqC;CACjE,SAAS;CACT,SAAS,IAAI,QAAQ;CACrB,aAAa;EACX,SAAS,OAAO,QAAQ;EACxB,IAAI,SAAS,SAAS,GACpB,WAAW;;;;AAMjB,SAAgB,6BAAmC;CACjD,SAAS,OAAO;CAChB,WAAW"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/internal/dom/actionable.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Single source of truth for "what counts as a clickable element" across
|
|
4
|
+
* the SDK. Used by both the `pages` plugin (which captures `ui_event`
|
|
5
|
+
* envelopes) and the OTel `UserInteractionInstrumentation` enrichment
|
|
6
|
+
* hook (which gates span creation + stamps target attrs). Before this
|
|
7
|
+
* was extracted, the two sites diverged and produced inconsistent
|
|
8
|
+
* notions of "actionable."
|
|
9
|
+
*
|
|
10
|
+
* `data-track-click` is the customer escape hatch — any element opted
|
|
11
|
+
* in via that attribute is treated as actionable regardless of tag/role.
|
|
12
|
+
*/
|
|
13
|
+
declare function isActionable(el: Element): boolean;
|
|
14
|
+
declare function closestActionable(target: EventTarget | null): Element | null;
|
|
15
|
+
interface ActionableDescriptor {
|
|
16
|
+
ariaLabel?: string | undefined;
|
|
17
|
+
href?: string | undefined;
|
|
18
|
+
id?: string | undefined;
|
|
19
|
+
name?: string | undefined;
|
|
20
|
+
role?: string | undefined;
|
|
21
|
+
tag: string;
|
|
22
|
+
text?: string | undefined;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
declare function describeActionable(el: Element): ActionableDescriptor;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ActionableDescriptor, closestActionable, describeActionable, isActionable };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionable.d.mts","names":[],"sources":["../../../src/internal/dom/actionable.ts"],"mappings":";;AAkCA;;;;;AAWA;;;;;iBAXgB,YAAA,CAAa,EAAA,EAAI,OAAA;AAAA,iBAWjB,iBAAA,CAAkB,MAAA,EAAQ,WAAA,UAAqB,OAAA;AAAA,UAc9C,oBAAA;EACf,SAAA;EACA,IAAA;EACA,EAAA;EACA,IAAA;EACA,IAAA;EACA,GAAA;EACA,IAAA;EAAA,CACC,GAAA;AAAA;AAAA,iBAGa,kBAAA,CAAmB,EAAA,EAAI,OAAA,GAAU,oBAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region src/internal/dom/actionable.ts
|
|
2
|
+
/**
|
|
3
|
+
* Single source of truth for "what counts as a clickable element" across
|
|
4
|
+
* the SDK. Used by both the `pages` plugin (which captures `ui_event`
|
|
5
|
+
* envelopes) and the OTel `UserInteractionInstrumentation` enrichment
|
|
6
|
+
* hook (which gates span creation + stamps target attrs). Before this
|
|
7
|
+
* was extracted, the two sites diverged and produced inconsistent
|
|
8
|
+
* notions of "actionable."
|
|
9
|
+
*
|
|
10
|
+
* `data-track-click` is the customer escape hatch — any element opted
|
|
11
|
+
* in via that attribute is treated as actionable regardless of tag/role.
|
|
12
|
+
*/
|
|
13
|
+
const ACTIONABLE_TAGS = new Set([
|
|
14
|
+
"a",
|
|
15
|
+
"button",
|
|
16
|
+
"input",
|
|
17
|
+
"select",
|
|
18
|
+
"textarea",
|
|
19
|
+
"summary",
|
|
20
|
+
"label"
|
|
21
|
+
]);
|
|
22
|
+
const ACTIONABLE_ROLES = new Set([
|
|
23
|
+
"button",
|
|
24
|
+
"link",
|
|
25
|
+
"menuitem",
|
|
26
|
+
"tab",
|
|
27
|
+
"checkbox",
|
|
28
|
+
"radio",
|
|
29
|
+
"switch"
|
|
30
|
+
]);
|
|
31
|
+
const TEXT_TRUNCATE = 120;
|
|
32
|
+
function isActionable(el) {
|
|
33
|
+
if (ACTIONABLE_TAGS.has(el.tagName.toLowerCase())) return true;
|
|
34
|
+
const role = el.getAttribute("role");
|
|
35
|
+
if (role && ACTIONABLE_ROLES.has(role)) return true;
|
|
36
|
+
return el.hasAttribute("data-track-click");
|
|
37
|
+
}
|
|
38
|
+
function closestActionable(target) {
|
|
39
|
+
if (!(target instanceof Element)) return null;
|
|
40
|
+
let el = target;
|
|
41
|
+
while (el) {
|
|
42
|
+
if (isActionable(el)) return el;
|
|
43
|
+
el = el.parentElement;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
function describeActionable(el) {
|
|
48
|
+
const desc = { tag: el.tagName.toLowerCase() };
|
|
49
|
+
if (el.id) desc.id = el.id;
|
|
50
|
+
const role = el.getAttribute("role");
|
|
51
|
+
if (role) desc.role = role;
|
|
52
|
+
const name = el.getAttribute("name");
|
|
53
|
+
if (name) desc.name = name;
|
|
54
|
+
const ariaLabel = el.getAttribute("aria-label");
|
|
55
|
+
if (ariaLabel) desc.ariaLabel = ariaLabel;
|
|
56
|
+
if (el instanceof HTMLAnchorElement) desc.href = el.href;
|
|
57
|
+
const text = el.textContent?.trim().slice(0, TEXT_TRUNCATE);
|
|
58
|
+
if (text) desc.text = text;
|
|
59
|
+
return desc;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { closestActionable, describeActionable, isActionable };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionable.mjs","names":[],"sources":["../../../src/internal/dom/actionable.ts"],"sourcesContent":["/**\n * Single source of truth for \"what counts as a clickable element\" across\n * the SDK. Used by both the `pages` plugin (which captures `ui_event`\n * envelopes) and the OTel `UserInteractionInstrumentation` enrichment\n * hook (which gates span creation + stamps target attrs). Before this\n * was extracted, the two sites diverged and produced inconsistent\n * notions of \"actionable.\"\n *\n * `data-track-click` is the customer escape hatch — any element opted\n * in via that attribute is treated as actionable regardless of tag/role.\n */\n\nconst ACTIONABLE_TAGS = new Set([\n \"a\",\n \"button\",\n \"input\",\n \"select\",\n \"textarea\",\n \"summary\",\n \"label\",\n]);\n\nconst ACTIONABLE_ROLES = new Set([\n \"button\",\n \"link\",\n \"menuitem\",\n \"tab\",\n \"checkbox\",\n \"radio\",\n \"switch\",\n]);\n\nconst TEXT_TRUNCATE = 120;\n\nexport function isActionable(el: Element): boolean {\n if (ACTIONABLE_TAGS.has(el.tagName.toLowerCase())) {\n return true;\n }\n const role = el.getAttribute(\"role\");\n if (role && ACTIONABLE_ROLES.has(role)) {\n return true;\n }\n return el.hasAttribute(\"data-track-click\");\n}\n\nexport function closestActionable(target: EventTarget | null): Element | null {\n if (!(target instanceof Element)) {\n return null;\n }\n let el: Element | null = target;\n while (el) {\n if (isActionable(el)) {\n return el;\n }\n el = el.parentElement;\n }\n return null;\n}\n\nexport interface ActionableDescriptor {\n ariaLabel?: string | undefined;\n href?: string | undefined;\n id?: string | undefined;\n name?: string | undefined;\n role?: string | undefined;\n tag: string;\n text?: string | undefined;\n [key: string]: unknown;\n}\n\nexport function describeActionable(el: Element): ActionableDescriptor {\n const desc: ActionableDescriptor = {\n tag: el.tagName.toLowerCase(),\n };\n if (el.id) {\n desc.id = el.id;\n }\n const role = el.getAttribute(\"role\");\n if (role) {\n desc.role = role;\n }\n const name = el.getAttribute(\"name\");\n if (name) {\n desc.name = name;\n }\n const ariaLabel = el.getAttribute(\"aria-label\");\n if (ariaLabel) {\n desc.ariaLabel = ariaLabel;\n }\n if (el instanceof HTMLAnchorElement) {\n desc.href = el.href;\n }\n const text = el.textContent?.trim().slice(0, TEXT_TRUNCATE);\n if (text) {\n desc.text = text;\n }\n return desc;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,kBAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,mBAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,gBAAgB;AAEtB,SAAgB,aAAa,IAAsB;CACjD,IAAI,gBAAgB,IAAI,GAAG,QAAQ,aAAa,CAAC,EAC/C,OAAO;CAET,MAAM,OAAO,GAAG,aAAa,OAAO;CACpC,IAAI,QAAQ,iBAAiB,IAAI,KAAK,EACpC,OAAO;CAET,OAAO,GAAG,aAAa,mBAAmB;;AAG5C,SAAgB,kBAAkB,QAA4C;CAC5E,IAAI,EAAE,kBAAkB,UACtB,OAAO;CAET,IAAI,KAAqB;CACzB,OAAO,IAAI;EACT,IAAI,aAAa,GAAG,EAClB,OAAO;EAET,KAAK,GAAG;;CAEV,OAAO;;AAcT,SAAgB,mBAAmB,IAAmC;CACpE,MAAM,OAA6B,EACjC,KAAK,GAAG,QAAQ,aAAa,EAC9B;CACD,IAAI,GAAG,IACL,KAAK,KAAK,GAAG;CAEf,MAAM,OAAO,GAAG,aAAa,OAAO;CACpC,IAAI,MACF,KAAK,OAAO;CAEd,MAAM,OAAO,GAAG,aAAa,OAAO;CACpC,IAAI,MACF,KAAK,OAAO;CAEd,MAAM,YAAY,GAAG,aAAa,aAAa;CAC/C,IAAI,WACF,KAAK,YAAY;CAEnB,IAAI,cAAc,mBAChB,KAAK,OAAO,GAAG;CAEjB,MAAM,OAAO,GAAG,aAAa,MAAM,CAAC,MAAM,GAAG,cAAc;CAC3D,IAAI,MACF,KAAK,OAAO;CAEd,OAAO"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Kernel } from "./kernel.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/internal/kernel-registry.d.ts
|
|
4
|
+
declare function registerKernel(kernel: Kernel): void;
|
|
5
|
+
declare function unregisterKernel(kernel: Kernel): void;
|
|
6
|
+
declare function activeKernel(): Kernel | null;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { activeKernel, registerKernel, unregisterKernel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel-registry.d.mts","names":[],"sources":["../../src/internal/kernel-registry.ts"],"mappings":";;;iBAsBgB,cAAA,CAAe,MAAA,EAAQ,MAAA;AAAA,iBASvB,gBAAA,CAAiB,MAAA,EAAQ,MAAA;AAAA,iBAMzB,YAAA,CAAA,GAAgB,MAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createLogger } from "../util/log.mjs";
|
|
2
|
+
//#region src/internal/kernel-registry.ts
|
|
3
|
+
const log = createLogger("kernel-registry");
|
|
4
|
+
/**
|
|
5
|
+
* Module-scoped active kernel reference. The framework wrapper
|
|
6
|
+
* (`@interfere/next`, `@interfere/vite`) registers its kernel here on
|
|
7
|
+
* `init()` so the public `api.ts` helpers can find it without each customer
|
|
8
|
+
* call site threading the kernel through.
|
|
9
|
+
*
|
|
10
|
+
* Single-kernel by design: each app bundle has its own module instance, so
|
|
11
|
+
* the common case (one app, one init) gets a clean global. The warn on
|
|
12
|
+
* overwrite catches HMR / accidental double-init / module-federated MFEs
|
|
13
|
+
* that share `@interfere/react` across surfaces — those setups need to
|
|
14
|
+
* reach for `kernel.recordException()` directly rather than the registry.
|
|
15
|
+
*
|
|
16
|
+
* @internal Wrappers only. Importing this from app code will silently
|
|
17
|
+
* de-fang the public api helpers.
|
|
18
|
+
*/
|
|
19
|
+
let active = null;
|
|
20
|
+
function registerKernel(kernel) {
|
|
21
|
+
if (active && active !== kernel) log.warn("init() called twice with different kernels; later one wins. The public capture()/span() helpers route only to the latest kernel — multi-surface apps should call kernel.recordException() directly.");
|
|
22
|
+
active = kernel;
|
|
23
|
+
}
|
|
24
|
+
function unregisterKernel(kernel) {
|
|
25
|
+
if (active === kernel) active = null;
|
|
26
|
+
}
|
|
27
|
+
function activeKernel() {
|
|
28
|
+
return active;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { activeKernel, registerKernel, unregisterKernel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel-registry.mjs","names":[],"sources":["../../src/internal/kernel-registry.ts"],"sourcesContent":["import { createLogger } from \"../util/log.js\";\nimport type { Kernel } from \"./kernel.js\";\n\nconst log = createLogger(\"kernel-registry\");\n\n/**\n * Module-scoped active kernel reference. The framework wrapper\n * (`@interfere/next`, `@interfere/vite`) registers its kernel here on\n * `init()` so the public `api.ts` helpers can find it without each customer\n * call site threading the kernel through.\n *\n * Single-kernel by design: each app bundle has its own module instance, so\n * the common case (one app, one init) gets a clean global. The warn on\n * overwrite catches HMR / accidental double-init / module-federated MFEs\n * that share `@interfere/react` across surfaces — those setups need to\n * reach for `kernel.recordException()` directly rather than the registry.\n *\n * @internal Wrappers only. Importing this from app code will silently\n * de-fang the public api helpers.\n */\nlet active: Kernel | null = null;\n\nexport function registerKernel(kernel: Kernel): void {\n if (active && active !== kernel) {\n log.warn(\n \"init() called twice with different kernels; later one wins. The public capture()/span() helpers route only to the latest kernel — multi-surface apps should call kernel.recordException() directly.\"\n );\n }\n active = kernel;\n}\n\nexport function unregisterKernel(kernel: Kernel): void {\n if (active === kernel) {\n active = null;\n }\n}\n\nexport function activeKernel(): Kernel | null {\n return active;\n}\n"],"mappings":";;AAGA,MAAM,MAAM,aAAa,kBAAkB;;;;;;;;;;;;;;;;AAiB3C,IAAI,SAAwB;AAE5B,SAAgB,eAAe,QAAsB;CACnD,IAAI,UAAU,WAAW,QACvB,IAAI,KACF,sMACD;CAEH,SAAS;;AAGX,SAAgB,iBAAiB,QAAsB;CACrD,IAAI,WAAW,QACb,SAAS;;AAIb,SAAgB,eAA8B;CAC5C,OAAO"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { PluginContext } from "../plugins/lib/types.mjs";
|
|
2
|
+
import { PluginOverrides } from "../plugins/lib/loader.mjs";
|
|
3
|
+
import { SessionTracker } from "../tracking/api.mjs";
|
|
4
|
+
import { OtelProviderHandle } from "./otel/provider.mjs";
|
|
5
|
+
import { PluginRuntime } from "./plugin-runtime.mjs";
|
|
6
|
+
import { NonErrorException } from "@interfere/types/sdk/errors";
|
|
7
|
+
import { ConsentState } from "@interfere/types/sdk/plugins/manifest";
|
|
8
|
+
import { ReleaseSlug } from "@interfere/types/releases/slug";
|
|
9
|
+
import { MetricReader } from "@opentelemetry/sdk-metrics";
|
|
10
|
+
import { LogRecordProcessor } from "@opentelemetry/sdk-logs";
|
|
11
|
+
import { SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
12
|
+
import { IngestedFrame } from "@interfere/types/data/frame";
|
|
13
|
+
import { SessionId } from "@interfere/types/data/session";
|
|
14
|
+
import { IdentifyParams } from "@interfere/types/sdk/identify";
|
|
15
|
+
import { ErrorMechanism } from "@interfere/types/sdk/plugins/payload/errors";
|
|
16
|
+
|
|
17
|
+
//#region src/internal/kernel.d.ts
|
|
18
|
+
declare function buildSdkStack(wrapperVersions?: string[]): string[];
|
|
19
|
+
interface KernelOptions {
|
|
20
|
+
consent?: ConsentState;
|
|
21
|
+
/**
|
|
22
|
+
* Override the automatic dev-mode guard. When `undefined`, the SDK
|
|
23
|
+
* auto-detects: it disables itself if `process.env["NODE_ENV"]` is not
|
|
24
|
+
* `"production"` (Node / webpack / Next.js). In environments where
|
|
25
|
+
* `process` does not exist (Vite, CRA, plain browser) the SDK
|
|
26
|
+
* defaults to **enabled** — pass `false` to disable explicitly.
|
|
27
|
+
*/
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
/** Override `globalThis.fetch` for tests / non-browser hosts. */
|
|
30
|
+
fetch?: typeof globalThis.fetch;
|
|
31
|
+
plugins?: PluginOverrides;
|
|
32
|
+
/**
|
|
33
|
+
* Override the OTel `service.name` resource attribute. Defaults to
|
|
34
|
+
* `"interfere-sdk"`. Customers running multiple frontends in one
|
|
35
|
+
* monitoring backend (e.g. `"@interfere/homepage"` vs
|
|
36
|
+
* `"@interfere/dashboard"`) set this so spans/metrics/logs slice
|
|
37
|
+
* cleanly by surface.
|
|
38
|
+
*/
|
|
39
|
+
serviceName?: string;
|
|
40
|
+
/**
|
|
41
|
+
* `false` skips the OTel module entirely — the bundler code-splits
|
|
42
|
+
* `internal/otel/*` out of this path so the error-only bundle never
|
|
43
|
+
* imports the OTel SDK. `true` (default) loads it with default
|
|
44
|
+
* instrumentation config. An object loads it with the supplied
|
|
45
|
+
* config.
|
|
46
|
+
*/
|
|
47
|
+
tracing?: boolean | TracingOptions;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Per-instrumentation tuning. Every field is optional; defaults match
|
|
51
|
+
* what `interfere/homepage` and `interfere/dashboard` use today via
|
|
52
|
+
* the internal `observability/browser/rum.ts`. New customers don't
|
|
53
|
+
* need to touch any of these — sensible defaults ship out of the box.
|
|
54
|
+
*/
|
|
55
|
+
interface TracingOptions {
|
|
56
|
+
/**
|
|
57
|
+
* Additional URL patterns to skip when creating fetch / XHR spans.
|
|
58
|
+
* The SDK's own collector endpoint is always ignored; customer-side
|
|
59
|
+
* third-party SDKs (Clerk, Sentry, GTM, etc.) are also skipped by
|
|
60
|
+
* default — supplement with anything specific to your app.
|
|
61
|
+
*/
|
|
62
|
+
ignoreUrls?: (string | RegExp)[];
|
|
63
|
+
/**
|
|
64
|
+
* URL patterns that should receive W3C `traceparent` + `baggage`
|
|
65
|
+
* headers on outgoing fetch / XHR. Same-origin requests always
|
|
66
|
+
* propagate; this allowlist enables cross-origin propagation
|
|
67
|
+
* (separate API origin, internal service mesh, etc.).
|
|
68
|
+
*/
|
|
69
|
+
propagateContextUrls?: (string | RegExp)[];
|
|
70
|
+
/**
|
|
71
|
+
* Resolve a URL pathname to a low-cardinality route template
|
|
72
|
+
* (e.g. `/blog/[slug]`). Without this, dynamic routes produce one
|
|
73
|
+
* unique span / metric label per visited slug — a cardinality
|
|
74
|
+
* hazard. Used by fetch, document-load resource enrichment,
|
|
75
|
+
* user-interaction, long-task, and web-vitals.
|
|
76
|
+
*/
|
|
77
|
+
resolveRoute?: (pathname: string) => string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* `false` disables Core Web Vitals capture (LCP/FCP/TTFB/INP/CLS).
|
|
80
|
+
* Defaults to enabled; customers who run their own vitals reporting
|
|
81
|
+
* can opt out.
|
|
82
|
+
*/
|
|
83
|
+
webVitals?: boolean;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @internal
|
|
87
|
+
* Framework wrappers (`@interfere/next`, `@interfere/vite`) pass extra
|
|
88
|
+
* fields through `createKernel` that customers never set themselves.
|
|
89
|
+
* Kept off the customer-facing `KernelOptions` to make the public surface
|
|
90
|
+
* clean.
|
|
91
|
+
*/
|
|
92
|
+
interface KernelInternalOptions extends KernelOptions {
|
|
93
|
+
/**
|
|
94
|
+
* Extra log-record processors fanned into the LoggerProvider's
|
|
95
|
+
* processor list. Used by `@interfere/observability` for internal-only
|
|
96
|
+
* dual-write to BetterStack from `interfere/homepage` +
|
|
97
|
+
* `interfere/dashboard`. **Not part of the customer surface** — the
|
|
98
|
+
* SDK doesn't expose a way to fan-out to other observability vendors.
|
|
99
|
+
*/
|
|
100
|
+
_internalAdditionalLogRecordProcessors?: LogRecordProcessor[];
|
|
101
|
+
/**
|
|
102
|
+
* Extra metric readers fanned into the MeterProvider's reader list.
|
|
103
|
+
* See `_internalAdditionalLogRecordProcessors`. Used to keep web
|
|
104
|
+
* vitals histograms landing on the BetterStack-fronting OTel
|
|
105
|
+
* collector after the rum.ts → SDK migration moved the primary path
|
|
106
|
+
* to `/v2/sink` (Tinybird-only).
|
|
107
|
+
*/
|
|
108
|
+
_internalAdditionalMetricReaders?: MetricReader[];
|
|
109
|
+
/**
|
|
110
|
+
* Extra span processors fanned into the WebTracerProvider's processor
|
|
111
|
+
* list. See `_internalAdditionalLogRecordProcessors`.
|
|
112
|
+
*/
|
|
113
|
+
_internalAdditionalSpanProcessors?: SpanProcessor[];
|
|
114
|
+
/** Wrapper SDK versions (e.g. `@interfere/next@10.0.0`). */
|
|
115
|
+
_wrapperVersions?: string[];
|
|
116
|
+
}
|
|
117
|
+
interface KernelConsent {
|
|
118
|
+
get(): ConsentState | null;
|
|
119
|
+
set(value?: ConsentState): void;
|
|
120
|
+
}
|
|
121
|
+
interface KernelIdentity {
|
|
122
|
+
get(): IdentifyParams | null;
|
|
123
|
+
set(params: IdentifyParams): Promise<void>;
|
|
124
|
+
}
|
|
125
|
+
interface KernelDevice {
|
|
126
|
+
getDeviceId(): string | null;
|
|
127
|
+
getFpHash(): string | null;
|
|
128
|
+
}
|
|
129
|
+
interface KernelSession {
|
|
130
|
+
getId(): SessionId | null;
|
|
131
|
+
getWindowId(): string | null;
|
|
132
|
+
}
|
|
133
|
+
interface RecordExceptionOpts {
|
|
134
|
+
/**
|
|
135
|
+
* Frames always appended to the first exception's stack. Used by
|
|
136
|
+
* `<ErrorBoundary>` to inject React's component-stack frames as
|
|
137
|
+
* supplementary context — these add on top of the real JS frames, they
|
|
138
|
+
* don't replace them.
|
|
139
|
+
*/
|
|
140
|
+
readonly appendFrames?: readonly IngestedFrame[];
|
|
141
|
+
/**
|
|
142
|
+
* `error.digest` from React when an RSC server-side throw is
|
|
143
|
+
* sanitised and rebuilt as a synthetic Error on the client. The only
|
|
144
|
+
* identifier that pairs the redacted client capture with the
|
|
145
|
+
* unredacted server capture — enrichment mixes this into the
|
|
146
|
+
* fingerprint so both events group as one problem.
|
|
147
|
+
*/
|
|
148
|
+
readonly errorDigest?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Frames adopted only when the first exception's parsed stack is empty.
|
|
151
|
+
* Used by the `window.onerror` handler when the browser hands us
|
|
152
|
+
* source/line/col but the `Error` itself has a degenerate stack — never
|
|
153
|
+
* glued on top of a real stack.
|
|
154
|
+
*/
|
|
155
|
+
readonly fallbackFrames?: readonly IngestedFrame[];
|
|
156
|
+
readonly mechanism: ErrorMechanism;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The replacement for the old `Client` god-object. Pure construction graph
|
|
160
|
+
* via `createKernel`; no module-level mutable state, no global lookups.
|
|
161
|
+
* Framework wrappers (`@interfere/next`, `@interfere/vite`) own the
|
|
162
|
+
* singleton lifecycle.
|
|
163
|
+
*
|
|
164
|
+
* Implements `PluginContext` directly: plugins are wired with the kernel
|
|
165
|
+
* itself rather than a closure adapter. The kernel⇄runtime cycle is
|
|
166
|
+
* resolved by constructing the kernel first and binding the runtime via
|
|
167
|
+
* `attachRuntime` immediately after.
|
|
168
|
+
*/
|
|
169
|
+
declare class Kernel implements PluginContext {
|
|
170
|
+
readonly consent: KernelConsent;
|
|
171
|
+
readonly identity: KernelIdentity;
|
|
172
|
+
readonly device: KernelDevice;
|
|
173
|
+
readonly session: KernelSession;
|
|
174
|
+
private readonly tracker;
|
|
175
|
+
private readonly seen;
|
|
176
|
+
private runtime;
|
|
177
|
+
private otel;
|
|
178
|
+
private otelDispose;
|
|
179
|
+
private unsubscribePageHidden;
|
|
180
|
+
constructor(tracker: SessionTracker);
|
|
181
|
+
/** @internal Bound by `createKernel` immediately after construction. */
|
|
182
|
+
attachRuntime(runtime: PluginRuntime): void;
|
|
183
|
+
private requireRuntime;
|
|
184
|
+
/** PluginContext shim: plugins expect a non-null string. */
|
|
185
|
+
getSessionId(): string;
|
|
186
|
+
/**
|
|
187
|
+
* Records an exception event on the active OTel span. No envelope
|
|
188
|
+
* path — the SDK is OTel-only. Single dedup boundary: drops repeats
|
|
189
|
+
* of the same `Error` instance, plus browser-extension noise and
|
|
190
|
+
* unresolvable stacks. Upstream callers (the errors plugin's
|
|
191
|
+
* `window.onerror` / `console.error` / `unhandledrejection`, the
|
|
192
|
+
* React error boundary) just call this — they don't pre-filter.
|
|
193
|
+
*
|
|
194
|
+
* Does NOT mark the active span as failed. A console.error inside a
|
|
195
|
+
* customer-owned `span()` block would otherwise taint the customer's
|
|
196
|
+
* span even when the customer caught the error explicitly. The
|
|
197
|
+
* customer's `span()` helper sets status itself when it observes a
|
|
198
|
+
* throw.
|
|
199
|
+
*
|
|
200
|
+
* `appendFrames` are always appended (component-stack supplements);
|
|
201
|
+
* `fallbackFrames` are only adopted when the parsed stack is empty
|
|
202
|
+
* (`window.onerror` source/line/col when the Error has no usable
|
|
203
|
+
* stack). Both ride on the serialised `interfere.exception.chain`
|
|
204
|
+
* attribute when the chain is non-trivial.
|
|
205
|
+
*/
|
|
206
|
+
recordException(value: Error | NonErrorException, opts: RecordExceptionOpts): void;
|
|
207
|
+
/**
|
|
208
|
+
* Emits an OTel `LogRecord` via the kernel's logger provider. Used by
|
|
209
|
+
* `plugins/logs.ts` to capture string-only `console.*` calls (the
|
|
210
|
+
* errors plugin still owns Error-bearing console calls — class
|
|
211
|
+
* boundary). No-ops when OTel is not wired (`tracing: false`) since
|
|
212
|
+
* there's no logger provider to emit through.
|
|
213
|
+
*/
|
|
214
|
+
recordLog(input: {
|
|
215
|
+
severityText: string;
|
|
216
|
+
severityNumber: number;
|
|
217
|
+
body: string;
|
|
218
|
+
attributes?: Record<string, string>;
|
|
219
|
+
}): void;
|
|
220
|
+
/**
|
|
221
|
+
* Force-flushes the OTel exporters. Returns once they've settled
|
|
222
|
+
* (success or failure) so callers driving unload — page-lifecycle
|
|
223
|
+
* handlers, integration test teardown — can actually await
|
|
224
|
+
* completion. The OTel SDK swallows export errors internally; we
|
|
225
|
+
* surface the resolution either way.
|
|
226
|
+
*/
|
|
227
|
+
flush(): Promise<void>;
|
|
228
|
+
/**
|
|
229
|
+
* @internal Wired by `createKernel` after the OTel module has been
|
|
230
|
+
* lazy-loaded. Held on the kernel so `flush()` and `dispose()` can fan
|
|
231
|
+
* out to the providers. The tracer/meter providers stay private —
|
|
232
|
+
* customers don't get raw OTel access; the public surface is the
|
|
233
|
+
* `span()` / `capture()` helpers in `api.ts`.
|
|
234
|
+
*/
|
|
235
|
+
attachOtel(handle: OtelProviderHandle, dispose: () => void): void;
|
|
236
|
+
/**
|
|
237
|
+
* Provider-driven consent sync. Pass `undefined` to clear consent (treats
|
|
238
|
+
* the prop as "unmanaged"); pass a state to apply it.
|
|
239
|
+
*/
|
|
240
|
+
syncConsent(value: ConsentState | undefined): void;
|
|
241
|
+
dispose(): Promise<void>;
|
|
242
|
+
}
|
|
243
|
+
interface CreateKernelInput {
|
|
244
|
+
opts?: KernelInternalOptions;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Pure construction graph. Awaits the remote-config fetch before resolving,
|
|
248
|
+
* so the runtime sees a fully-applied config before any capture is attempted
|
|
249
|
+
* by the caller. Removes the capture-before-config race the old `Client`
|
|
250
|
+
* had.
|
|
251
|
+
*/
|
|
252
|
+
declare function createKernel(input?: CreateKernelInput): Promise<Kernel>;
|
|
253
|
+
declare function isEnabledByEnvironment(): boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Build-time-derived release slug. The build step
|
|
256
|
+
* (`@interfere/next/withInterfere`, `@interfere/vite/plugin`) takes the
|
|
257
|
+
* leading 16 hex chars of the commit SHA (`rel_<16hex>`) and stamps it into
|
|
258
|
+
* the bundle as `__INTERFERE_RELEASE_SLUG__`. The collector derives the same
|
|
259
|
+
* value from the create-release request, so the bundle's runtime slug is
|
|
260
|
+
* guaranteed to match the row without a round-trip.
|
|
261
|
+
*
|
|
262
|
+
* Returns `null` when no slug was injected (dev builds, customers who
|
|
263
|
+
* haven't wired up the plugin).
|
|
264
|
+
*/
|
|
265
|
+
declare function readReleaseSlugFromGlobals(): ReleaseSlug | null;
|
|
266
|
+
//#endregion
|
|
267
|
+
export { Kernel, KernelConsent, KernelDevice, KernelIdentity, KernelInternalOptions, KernelOptions, KernelSession, RecordExceptionOpts, TracingOptions, buildSdkStack, createKernel, isEnabledByEnvironment, readReleaseSlugFromGlobals };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel.d.mts","names":[],"sources":["../../src/internal/kernel.ts"],"mappings":";;;;;;;;;;;;;;;;;iBAyCgB,aAAA,CAAc,eAAA;AAAA,UAyDb,aAAA;EACf,OAAA,GAAU,YAAA;EA1DI;;;;;AAyDhB;;EASE,OAAA;EARU;EAUV,KAAA,UAAe,UAAA,CAAW,KAAA;EAC1B,OAAA,GAAU,eAAA;EAgBU;;;;;;;EARpB,WAAA;EAT0B;;;;;;;EAiB1B,OAAA,aAAoB,cAAA;AAAA;;;;;;;UASL,cAAA;EAsBf;;;;;AAgBF;EA/BE,UAAA,aAAuB,MAAA;;;;;;;EAOvB,oBAAA,aAAiC,MAAA;EAwBY;;;;;;;EAhB7C,YAAA,IAAgB,QAAA;EAuCA;;AAGlB;;;EApCE,SAAA;AAAA;;;;;;;AAyCF;UA/BiB,qBAAA,SAA8B,aAAA;;;;;;;;EAQ7C,sCAAA,GAAyC,kBAAA;EAyBzC;;;;;;AAGF;EApBE,gCAAA,GAAmC,YAAA;;;;AAyBrC;EApBE,iCAAA,GAAoC,aAAA;;EAEpC,gBAAA;AAAA;AAAA,UAGe,aAAA;EACf,GAAA,IAAO,YAAA;EACP,GAAA,CAAI,KAAA,GAAQ,YAAA;AAAA;AAAA,UAGG,cAAA;EACf,GAAA,IAAO,cAAA;EACP,GAAA,CAAI,MAAA,EAAQ,cAAA,GAAiB,OAAA;AAAA;AAAA,UAGd,YAAA;EACf,WAAA;EACA,SAAA;AAAA;AAAA,UAGe,aAAA;EACf,KAAA,IAAS,SAAA;EACT,WAAA;AAAA;AAAA,UAGe,mBAAA;EAuBN;;;;AAcX;;EAdW,SAhBA,YAAA,YAAwB,aAAA;EA+Bf;;;;;;;EAAA,SAvBT,WAAA;EA0HD;;;;;;EAAA,SAnHC,cAAA,YAA0B,aAAA;EAAA,SAC1B,SAAA,EAAW,cAAA;AAAA;;;;;;;;;;;;cAcT,MAAA,YAAkB,aAAA;EAAA,SACpB,OAAA,EAAS,aAAA;EAAA,SACT,QAAA,EAAU,cAAA;EAAA,SACV,MAAA,EAAQ,YAAA;EAAA,SACR,OAAA,EAAS,aAAA;EAAA,iBAED,OAAA;EAAA,iBAGA,IAAA;EAAA,QAKT,OAAA;EAAA,QACA,IAAA;EAAA,QACA,WAAA;EAAA,QACA,qBAAA;cAEI,OAAA,EAAS,cAAA;EA+ErB;EAtCA,aAAA,CAAc,OAAA,EAAS,aAAA;EAAA,QAIf,cAAA;EAmCN;EAzBF,YAAA,CAAA;EA0BE;;;;;;;;;;;;;;;;;;;;EAFF,eAAA,CACE,KAAA,EAAO,KAAA,GAAQ,iBAAA,EACf,IAAA,EAAM,mBAAA;EA6HA;;;;;AAUV;;EAlFE,SAAA,CAAU,KAAA;IACR,YAAA;IACA,cAAA;IACA,IAAA;IACA,UAAA,GAAa,MAAA;EAAA;EA+ER;;;;;;AA6PT;EAxTQ,KAAA,CAAA,GAAS,OAAA;;;;AAiVjB;;;;EApUE,UAAA,CAAW,MAAA,EAAQ,kBAAA,EAAoB,OAAA;;;;;EASvC,WAAA,CAAY,KAAA,EAAO,YAAA;EASb,OAAA,CAAA,GAAW,OAAA;AAAA;AAAA,UAiBT,iBAAA;EACR,IAAA,GAAO,qBAAA;AAAA;;;;;;;iBASa,YAAA,CACpB,KAAA,GAAO,iBAAA,GACN,OAAA,CAAQ,MAAA;AAAA,iBA4PK,sBAAA,CAAA;;;;;;;;;;;;iBAyBA,0BAAA,CAAA,GAA8B,WAAA"}
|