@burdenoff/fe-libs 2026.1115.13 → 2026.1116.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/events/index.d.ts +7 -2
- package/dist/shared/events/sinks/OtelBrowserSink.d.ts +5 -0
- package/dist/shared/events/sinks/WebVitalsSink.d.ts +25 -0
- package/dist/shared/events/sinks/WebVitalsSink.js +51 -0
- package/dist/shared/events/sinks/index.d.ts +3 -0
- package/dist/shared/events/sinks/index.js +2 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/providers/AppShellProvider.d.ts +16 -0
- package/dist/shared/providers/AppShellProvider.js +291 -292
- package/dist/shared/providers/shell/ObservabilityProvider.d.ts +6 -6
- package/dist/shared/rum/context.d.ts +24 -0
- package/dist/shared/rum/context.js +40 -0
- package/dist/shared/rum/index.d.ts +14 -0
- package/dist/shared/rum/mount.d.ts +12 -0
- package/dist/shared/rum/mount.js +5 -0
- package/dist/shared/rum/reporter.d.ts +22 -0
- package/dist/shared/rum/reporter.js +166 -0
- package/dist/shared/rum/types.d.ts +56 -0
- package/dist/shared-events.js +29 -28
- package/dist/shared.js +78 -74
- package/dist/ui/glass-card.d.ts +1 -1
- package/package.json +1 -1
|
@@ -29,12 +29,12 @@ export interface ObservabilityProviderProps {
|
|
|
29
29
|
* browser, so these values are NOT retrievable off-device and this provider
|
|
30
30
|
* alone does NOT constitute real-user monitoring.
|
|
31
31
|
*
|
|
32
|
-
* The transport that
|
|
33
|
-
* AppShellProvider -> ShellTelemetryEmitter (perf.* events) ->
|
|
34
|
-
* which
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
32
|
+
* The transport that ships these off-device is the event-bus path
|
|
33
|
+
* (BOFF-3914): AppShellProvider -> ShellTelemetryEmitter (perf.* events) ->
|
|
34
|
+
* WebVitalsSink, which sends them to the global gateway's `reportWebVitals`
|
|
35
|
+
* mutation; global-activity-svc records them as Prometheus histograms in AMP.
|
|
36
|
+
* The older OtelBrowserSink / VITE_OTEL_HTTP_ENDPOINT path is deprecated and
|
|
37
|
+
* provisioned for no product. This provider stays a dev console aid.
|
|
38
38
|
*
|
|
39
39
|
* OFF-DEVICE ERRORS (BOFF-10705): a shell that passes `reporters` (for example
|
|
40
40
|
* `createRybbitCrashReporter`) additionally ships every captured error off the
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RumDevice } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Coarse device class:
|
|
4
|
+
* - `navigator.userAgentData.mobile === true` is a phone;
|
|
5
|
+
* - a coarse (touch) primary pointer is a phone below 768px and a tablet otherwise;
|
|
6
|
+
* - a fine primary pointer is a desktop;
|
|
7
|
+
* - with no pointer information, the viewport decides (<768 phone, <1024 tablet).
|
|
8
|
+
*/
|
|
9
|
+
export declare function deviceClass(): RumDevice;
|
|
10
|
+
/**
|
|
11
|
+
* Landing section for a pathname: the first segment of the masked route, for
|
|
12
|
+
* example `/workflows`, or `/` for the root. A segment the server would not
|
|
13
|
+
* accept (an id, a slug with capitals, anything long) becomes `/:other` here,
|
|
14
|
+
* so it never leaves the device; the server collapses it to `other`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function rumSection(pathname: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether this browser may send RUM reports: not when the analytics consent
|
|
19
|
+
* choice is `denied`, Global Privacy Control is on, or Do Not Track is on. A
|
|
20
|
+
* choice that was never made means "send" (open owner decision, BOFF-3914).
|
|
21
|
+
* When the consent choice cannot be read at all (storage blocked), nothing is
|
|
22
|
+
* sent.
|
|
23
|
+
*/
|
|
24
|
+
export declare function canReportRum(): boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { readAnalyticsConsentChoice as e } from "../events/sinks/RybbitSink.js";
|
|
2
|
+
import { maskRoute as t } from "../events/sinks/telemetryScrub.js";
|
|
3
|
+
// src/shared/rum/context.ts
|
|
4
|
+
function n() {
|
|
5
|
+
if (typeof window > "u" || typeof navigator > "u") return "desktop";
|
|
6
|
+
if (navigator.userAgentData?.mobile === !0) return "mobile";
|
|
7
|
+
let e = typeof window.innerWidth == "number" ? window.innerWidth : 1024, t = r();
|
|
8
|
+
return t === "coarse" ? e < 768 ? "mobile" : "tablet" : t === "fine" ? "desktop" : e < 768 ? "mobile" : e < 1024 ? "tablet" : "desktop";
|
|
9
|
+
}
|
|
10
|
+
function r() {
|
|
11
|
+
if (typeof window.matchMedia != "function") return null;
|
|
12
|
+
try {
|
|
13
|
+
if (window.matchMedia("(pointer: coarse)").matches) return "coarse";
|
|
14
|
+
if (window.matchMedia("(pointer: fine)").matches) return "fine";
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
var i = /^[a-z][a-z0-9-]{0,31}$/;
|
|
21
|
+
function a(e) {
|
|
22
|
+
let n = t(e).split("/").find((e) => e.length > 0);
|
|
23
|
+
return n ? i.test(n) ? `/${n}` : "/:other" : "/";
|
|
24
|
+
}
|
|
25
|
+
function o() {
|
|
26
|
+
return navigator.globalPrivacyControl === !0;
|
|
27
|
+
}
|
|
28
|
+
function s() {
|
|
29
|
+
let e = window;
|
|
30
|
+
return navigator.doNotTrack === "1" || e.doNotTrack === "1";
|
|
31
|
+
}
|
|
32
|
+
function c() {
|
|
33
|
+
if (typeof window > "u" || typeof navigator > "u" || o() || s()) return !1;
|
|
34
|
+
try {
|
|
35
|
+
return e() !== "denied";
|
|
36
|
+
} catch {
|
|
37
|
+
return !1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export { c as canReportRum, n as deviceClass, a as rumSection };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser real-user monitoring: Core Web Vitals to the global gateway's
|
|
3
|
+
* `reportWebVitals` / `reportPublicWebVitals` mutations (BOFF-3914), recorded
|
|
4
|
+
* by global-activity-svc as Prometheus histograms in AMP.
|
|
5
|
+
*
|
|
6
|
+
* Framework-free; the React mount point is `WebVitalsSink`.
|
|
7
|
+
*
|
|
8
|
+
* @module @burdenoff/fe-libs/shared/rum
|
|
9
|
+
*/
|
|
10
|
+
export { canReportRum, deviceClass, rumSection } from './context';
|
|
11
|
+
export { shouldMountWebVitalsSink } from './mount';
|
|
12
|
+
export type { RumMountConfig } from './mount';
|
|
13
|
+
export { createRumReporter, DEFAULT_RUM_SAMPLE_RATES, MAX_RUM_BODY_BYTES, MAX_RUM_REPORTS, REPORT_PUBLIC_WEB_VITALS_DOCUMENT, REPORT_WEB_VITALS_DOCUMENT, resolveRumSampleRate, toRumNavigationType, } from './reporter';
|
|
14
|
+
export type { CreateRumReporterOptions, RumConfig, RumDevice, RumMetric, RumReporter, } from './types';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RumConfig } from './types';
|
|
2
|
+
/** The parts of `AppShellObservabilityConfig` that decide whether RUM runs. */
|
|
3
|
+
export interface RumMountConfig {
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
appEnv?: 'dev' | 'alpha' | 'prod';
|
|
6
|
+
rum?: RumConfig;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* BOFF-3914: WebVitalsSink mounts when observability and RUM are not switched
|
|
10
|
+
* off and the shell is not running in the `dev` app environment.
|
|
11
|
+
*/
|
|
12
|
+
export declare function shouldMountWebVitalsSink(config: RumMountConfig): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CreateRumReporterOptions, RumReporter } from './types';
|
|
2
|
+
/** Signed-in mutation (`@rbac(scopeType: "self")` on the global gateway). */
|
|
3
|
+
export declare const REPORT_WEB_VITALS_DOCUMENT = "mutation ReportWebVitals($input: ReportWebVitalsInput!) { reportWebVitals(input: $input) { accepted dropped sampleRate } }";
|
|
4
|
+
/** Signed-out mutation (public; dropped server-side unless RUM_ANON_ENABLED). */
|
|
5
|
+
export declare const REPORT_PUBLIC_WEB_VITALS_DOCUMENT = "mutation ReportPublicWebVitals($input: ReportWebVitalsInput!) { reportPublicWebVitals(input: $input) { accepted dropped sampleRate } }";
|
|
6
|
+
/** Reports per page load. */
|
|
7
|
+
export declare const MAX_RUM_REPORTS = 3;
|
|
8
|
+
/** Request bodies at or above this size are not sent. */
|
|
9
|
+
export declare const MAX_RUM_BODY_BYTES = 2048;
|
|
10
|
+
/**
|
|
11
|
+
* Per-product client pre-sample rates. Empty: every product reports every page
|
|
12
|
+
* load until traffic says otherwise. `RumConfig.sampleRate` wins over this map.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_RUM_SAMPLE_RATES: Readonly<Record<string, number>>;
|
|
15
|
+
/** The client pre-sample rate for a product, clamped to [0, 1]. */
|
|
16
|
+
export declare function resolveRumSampleRate(product: string, configured?: number): number;
|
|
17
|
+
type GraphqlNavigationType = 'NAVIGATE' | 'RELOAD' | 'BACK_FORWARD' | 'BACK_FORWARD_CACHE' | 'PRERENDER' | 'RESTORE';
|
|
18
|
+
/** web-vitals `navigationType` -> GraphQL `WebVitalNavigationType`; unknown values are `NAVIGATE`. */
|
|
19
|
+
export declare function toRumNavigationType(navigationType: string): GraphqlNavigationType;
|
|
20
|
+
/** Creates the reporter for the current page load. */
|
|
21
|
+
export declare function createRumReporter(opts: CreateRumReporterOptions): RumReporter;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { canReportRum as e, deviceClass as t, rumSection as n } from "./context.js";
|
|
2
|
+
// src/shared/rum/reporter.ts
|
|
3
|
+
var r = "mutation ReportWebVitals($input: ReportWebVitalsInput!) { reportWebVitals(input: $input) { accepted dropped sampleRate } }", i = "mutation ReportPublicWebVitals($input: ReportWebVitalsInput!) { reportPublicWebVitals(input: $input) { accepted dropped sampleRate } }", a = 3, o = 2048, s = Object.freeze({});
|
|
4
|
+
function c(e, t) {
|
|
5
|
+
return l(t ?? s[e] ?? 1);
|
|
6
|
+
}
|
|
7
|
+
function l(e) {
|
|
8
|
+
return Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
|
|
9
|
+
}
|
|
10
|
+
var u = Object.freeze({
|
|
11
|
+
navigate: "NAVIGATE",
|
|
12
|
+
reload: "RELOAD",
|
|
13
|
+
"back-forward": "BACK_FORWARD",
|
|
14
|
+
"back-forward-cache": "BACK_FORWARD_CACHE",
|
|
15
|
+
prerender: "PRERENDER",
|
|
16
|
+
restore: "RESTORE"
|
|
17
|
+
});
|
|
18
|
+
function d(e) {
|
|
19
|
+
return u[e] ?? "NAVIGATE";
|
|
20
|
+
}
|
|
21
|
+
var f = Object.freeze({
|
|
22
|
+
mobile: "MOBILE",
|
|
23
|
+
tablet: "TABLET",
|
|
24
|
+
desktop: "DESKTOP"
|
|
25
|
+
}), p = [
|
|
26
|
+
"ttfb",
|
|
27
|
+
"fcp",
|
|
28
|
+
"lcp"
|
|
29
|
+
], m = ["inp", "cls"], h = /* @__PURE__ */ new Set(["UNAUTHENTICATED", "FORBIDDEN"]);
|
|
30
|
+
function g(e) {
|
|
31
|
+
return typeof e == "object" && !!e;
|
|
32
|
+
}
|
|
33
|
+
function _(a) {
|
|
34
|
+
let o = a.section ?? n(C()), s = a.device ?? t(), c = Math.random() < l(a.sampleRate), u = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), _ = null, y = 0, x = 1, T = !c, E = !1, D = () => {
|
|
35
|
+
typeof document < "u" && document.visibilityState === "hidden" && M();
|
|
36
|
+
}, O = () => M();
|
|
37
|
+
!T && typeof window < "u" && (typeof document < "u" && document.addEventListener("visibilitychange", D), window.addEventListener("pagehide", O));
|
|
38
|
+
function k() {
|
|
39
|
+
typeof window < "u" && (typeof document < "u" && document.removeEventListener("visibilitychange", D), window.removeEventListener("pagehide", O));
|
|
40
|
+
}
|
|
41
|
+
function A() {
|
|
42
|
+
T = !0, k();
|
|
43
|
+
}
|
|
44
|
+
function j() {
|
|
45
|
+
let e = [];
|
|
46
|
+
if (y === 0) for (let t of p) {
|
|
47
|
+
let n = u.get(t);
|
|
48
|
+
n !== void 0 && !h.has(t) && e.push(v(t, n));
|
|
49
|
+
}
|
|
50
|
+
for (let t of m) {
|
|
51
|
+
let n = u.get(t);
|
|
52
|
+
if (n === void 0) continue;
|
|
53
|
+
let r = h.get(t);
|
|
54
|
+
(r === void 0 || n > r) && e.push(v(t, n));
|
|
55
|
+
}
|
|
56
|
+
return e;
|
|
57
|
+
}
|
|
58
|
+
function M() {
|
|
59
|
+
if (T || E || y >= 3 || !e()) return;
|
|
60
|
+
let t = j();
|
|
61
|
+
if (t.length === 0 || y > 0 && x < 1 && Math.random() >= x) return;
|
|
62
|
+
let n = a.getAccessToken() || null;
|
|
63
|
+
if (!n && !a.anon) return;
|
|
64
|
+
let c = n ? "reportWebVitals" : "reportPublicWebVitals", l = JSON.stringify({
|
|
65
|
+
operationName: n ? "ReportWebVitals" : "ReportPublicWebVitals",
|
|
66
|
+
query: n ? r : i,
|
|
67
|
+
variables: { input: {
|
|
68
|
+
product: a.product,
|
|
69
|
+
section: o,
|
|
70
|
+
device: f[s],
|
|
71
|
+
navigationType: d(_ ?? "navigate"),
|
|
72
|
+
samples: t
|
|
73
|
+
} }
|
|
74
|
+
});
|
|
75
|
+
if (w(l) >= 2048) return;
|
|
76
|
+
y += 1;
|
|
77
|
+
for (let e of t) {
|
|
78
|
+
let t = b(e.metric);
|
|
79
|
+
h.set(t, u.get(t) ?? e.value);
|
|
80
|
+
}
|
|
81
|
+
let p = {
|
|
82
|
+
"content-type": "application/json",
|
|
83
|
+
"x-product-slug": a.product
|
|
84
|
+
};
|
|
85
|
+
n && (p.authorization = `Bearer ${n}`);
|
|
86
|
+
let m;
|
|
87
|
+
try {
|
|
88
|
+
m = fetch(`${a.endpoint}?op=rum`, {
|
|
89
|
+
method: "POST",
|
|
90
|
+
keepalive: !0,
|
|
91
|
+
credentials: "include",
|
|
92
|
+
headers: p,
|
|
93
|
+
body: l
|
|
94
|
+
});
|
|
95
|
+
} catch {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
m.then(N(c)).catch(() => void 0);
|
|
99
|
+
}
|
|
100
|
+
function N(e) {
|
|
101
|
+
return async (t) => {
|
|
102
|
+
if (t.status === 401 || t.status === 403) {
|
|
103
|
+
A();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!t.ok) return;
|
|
107
|
+
let n = await t.json().catch(() => null);
|
|
108
|
+
if (!g(n)) return;
|
|
109
|
+
if (n.errors?.some((e) => S(e.extensions?.code))) {
|
|
110
|
+
A();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
let r = n.data?.[e]?.sampleRate;
|
|
114
|
+
typeof r == "number" && Number.isFinite(r) && (x = l(r), x === 0 && A());
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
record(e, t, n) {
|
|
119
|
+
if (!(T || E) && !(!Number.isFinite(t) || t < 0)) {
|
|
120
|
+
if (_ === null) _ = n;
|
|
121
|
+
else if (n !== _) return;
|
|
122
|
+
u.set(e, t);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
dispose() {
|
|
126
|
+
E = !0, k();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function v(e, t) {
|
|
131
|
+
return {
|
|
132
|
+
metric: y(e),
|
|
133
|
+
value: x(e, t)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function y(e) {
|
|
137
|
+
switch (e) {
|
|
138
|
+
case "lcp": return "LCP";
|
|
139
|
+
case "inp": return "INP";
|
|
140
|
+
case "cls": return "CLS";
|
|
141
|
+
case "ttfb": return "TTFB";
|
|
142
|
+
case "fcp": return "FCP";
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function b(e) {
|
|
146
|
+
switch (e) {
|
|
147
|
+
case "LCP": return "lcp";
|
|
148
|
+
case "INP": return "inp";
|
|
149
|
+
case "CLS": return "cls";
|
|
150
|
+
case "TTFB": return "ttfb";
|
|
151
|
+
case "FCP": return "fcp";
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function x(e, t) {
|
|
155
|
+
return e === "cls" ? Math.round(t * 1e4) / 1e4 : Math.round(t * 10) / 10;
|
|
156
|
+
}
|
|
157
|
+
function S(e) {
|
|
158
|
+
return typeof e == "string" && h.has(e);
|
|
159
|
+
}
|
|
160
|
+
function C() {
|
|
161
|
+
return typeof location > "u" ? "/" : location.pathname;
|
|
162
|
+
}
|
|
163
|
+
function w(e) {
|
|
164
|
+
return new TextEncoder().encode(e).length;
|
|
165
|
+
}
|
|
166
|
+
export { s as DEFAULT_RUM_SAMPLE_RATES, o as MAX_RUM_BODY_BYTES, a as MAX_RUM_REPORTS, i as REPORT_PUBLIC_WEB_VITALS_DOCUMENT, r as REPORT_WEB_VITALS_DOCUMENT, _ as createRumReporter, c as resolveRumSampleRate, d as toRumNavigationType };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real-user monitoring (RUM) types for browser Core Web Vitals (BOFF-3914).
|
|
3
|
+
*
|
|
4
|
+
* @module @burdenoff/fe-libs/shared/rum
|
|
5
|
+
*/
|
|
6
|
+
/** Coarse device class, derived in the browser. The server never parses the user agent. */
|
|
7
|
+
export type RumDevice = 'mobile' | 'tablet' | 'desktop';
|
|
8
|
+
/** The web-vitals metrics the reporter sends. */
|
|
9
|
+
export type RumMetric = 'lcp' | 'inp' | 'cls' | 'ttfb' | 'fcp';
|
|
10
|
+
/**
|
|
11
|
+
* Per-shell RUM configuration (`AppShellObservabilityConfig.rum`). Every field is
|
|
12
|
+
* optional; a shell does not need to pass anything.
|
|
13
|
+
*/
|
|
14
|
+
export interface RumConfig {
|
|
15
|
+
/** Default true. `false` keeps the WebVitalsSink unmounted. */
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Default true: signed-out pages report through `reportPublicWebVitals`. The
|
|
19
|
+
* server's `RUM_ANON_ENABLED` kill switch still decides whether they are kept.
|
|
20
|
+
*/
|
|
21
|
+
anon?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Client pre-sample rate in [0, 1], decided once per page load. Default 1;
|
|
24
|
+
* `DEFAULT_RUM_SAMPLE_RATES[product]` applies when this is not set.
|
|
25
|
+
*/
|
|
26
|
+
sampleRate?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Full URL of the global GraphQL endpoint. Default: the endpoint the shell's
|
|
29
|
+
* own global gateway client talks to.
|
|
30
|
+
*/
|
|
31
|
+
endpoint?: string;
|
|
32
|
+
}
|
|
33
|
+
/** A RUM reporter for one page load. */
|
|
34
|
+
export interface RumReporter {
|
|
35
|
+
/** Record (or update) one metric value. `navigationType` is the web-vitals navigation type. */
|
|
36
|
+
record(metric: RumMetric, value: number, navigationType: string): void;
|
|
37
|
+
/** Remove the page lifecycle listeners. Nothing is sent after this. */
|
|
38
|
+
dispose(): void;
|
|
39
|
+
}
|
|
40
|
+
/** Options for {@link createRumReporter}. */
|
|
41
|
+
export interface CreateRumReporterOptions {
|
|
42
|
+
/** Product slug (canonical spelling, e.g. `botmanor`). */
|
|
43
|
+
product: string;
|
|
44
|
+
/** Full URL of the global GraphQL endpoint. */
|
|
45
|
+
endpoint: string;
|
|
46
|
+
/** The same access-token accessor the shell's global gateway client uses. */
|
|
47
|
+
getAccessToken: () => string | null | undefined;
|
|
48
|
+
/** Client pre-sample rate in [0, 1], decided once when the reporter is created. */
|
|
49
|
+
sampleRate: number;
|
|
50
|
+
/** Whether signed-out pages may report through `reportPublicWebVitals`. */
|
|
51
|
+
anon: boolean;
|
|
52
|
+
/** Landing section. Default: `rumSection(location.pathname)` at creation. */
|
|
53
|
+
section?: string;
|
|
54
|
+
/** Device class. Default: `deviceClass()` at creation. */
|
|
55
|
+
device?: RumDevice;
|
|
56
|
+
}
|
package/dist/shared-events.js
CHANGED
|
@@ -11,12 +11,13 @@ import { BroadcastChannelSink as d } from "./shared/events/sinks/BroadcastChanne
|
|
|
11
11
|
import { BackendAuditSink as f } from "./shared/events/sinks/BackendAuditSink.js";
|
|
12
12
|
import { compileRybbitRoutePattern as p, isRybbitSkippedRoute as m } from "./shared/events/sinks/rybbitRoutes.js";
|
|
13
13
|
import { OtelBrowserSink as h } from "./shared/events/sinks/OtelBrowserSink.js";
|
|
14
|
+
import { WebVitalsSink as g } from "./shared/events/sinks/WebVitalsSink.js";
|
|
14
15
|
import "./shared/events/sinks/index.js";
|
|
15
|
-
import { AnalyticsConsentBanner as
|
|
16
|
-
import { createContext as
|
|
17
|
-
import { jsx as
|
|
16
|
+
import { AnalyticsConsentBanner as _, CONSENT_BANNER_OFFSET_VAR as v, RybbitSink as y, publishConsentBannerOffset as b, readAnalyticsConsent as x, readAnalyticsConsentChoice as S, setAnalyticsConsent as C } from "./shared/events/sinks/RybbitSink.js";
|
|
17
|
+
import { createContext as w, use as T, useCallback as E, useEffect as D, useMemo as O } from "react";
|
|
18
|
+
import { jsx as k } from "react/jsx-runtime";
|
|
18
19
|
// src/shared/events/index.tsx
|
|
19
|
-
var
|
|
20
|
+
var A = w({
|
|
20
21
|
emit: () => {},
|
|
21
22
|
emitCustom: () => {},
|
|
22
23
|
on: () => () => {},
|
|
@@ -24,22 +25,22 @@ var k = C({
|
|
|
24
25
|
getBuffer: () => [],
|
|
25
26
|
onAny: () => () => {}
|
|
26
27
|
});
|
|
27
|
-
function
|
|
28
|
-
if (!e) return
|
|
28
|
+
function j(e, t) {
|
|
29
|
+
if (!e) return M();
|
|
29
30
|
let n = e.getItem(t);
|
|
30
31
|
if (n) return n;
|
|
31
|
-
let r =
|
|
32
|
+
let r = M();
|
|
32
33
|
return e.setItem(t, r), r;
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
+
function M() {
|
|
35
36
|
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
+
function N() {
|
|
38
39
|
if (typeof document > "u") return "light";
|
|
39
40
|
let e = document.documentElement;
|
|
40
41
|
return e.classList.contains("hc") || e.dataset.theme === "hc" ? "hc" : e.classList.contains("dark") || e.dataset.theme === "dark" ? "dark" : "light";
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
function P(t, n, r) {
|
|
43
44
|
let i = typeof window < "u" ? window.location : void 0, a = e(), o = typeof navigator < "u" ? navigator : {
|
|
44
45
|
userAgent: "",
|
|
45
46
|
language: "en"
|
|
@@ -49,11 +50,11 @@ function N(t, n, r) {
|
|
|
49
50
|
pathname: i?.pathname ?? "",
|
|
50
51
|
search: ""
|
|
51
52
|
},
|
|
52
|
-
sessionId:
|
|
53
|
-
deviceId:
|
|
53
|
+
sessionId: j(typeof sessionStorage < "u" ? sessionStorage : void 0, "bf-event-session-id"),
|
|
54
|
+
deviceId: j(typeof localStorage < "u" ? localStorage : void 0, "bf-event-device-id"),
|
|
54
55
|
userAgent: o.userAgent,
|
|
55
56
|
locale: o.language || "en",
|
|
56
|
-
theme:
|
|
57
|
+
theme: N(),
|
|
57
58
|
app: {
|
|
58
59
|
name: t,
|
|
59
60
|
version: n,
|
|
@@ -63,8 +64,8 @@ function N(t, n, r) {
|
|
|
63
64
|
spanId: a.spanId
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
-
let a =
|
|
67
|
+
function F({ appName: e, appVersion: t = "0.0.0", appEnv: n = "dev", sourceMfe: r = e, children: i }) {
|
|
68
|
+
let a = O(() => I({
|
|
68
69
|
appName: e,
|
|
69
70
|
appVersion: t,
|
|
70
71
|
appEnv: n,
|
|
@@ -75,16 +76,16 @@ function P({ appName: e, appVersion: t = "0.0.0", appEnv: n = "dev", sourceMfe:
|
|
|
75
76
|
t,
|
|
76
77
|
r
|
|
77
78
|
]);
|
|
78
|
-
return /* @__PURE__ */
|
|
79
|
+
return /* @__PURE__ */ k(A.Provider, {
|
|
79
80
|
value: a,
|
|
80
81
|
children: i
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
+
function I({ appName: e, appVersion: t = "0.0.0", appEnv: n = "dev", sourceMfe: r = e }) {
|
|
84
85
|
let i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = [];
|
|
85
86
|
function s(i, a, o) {
|
|
86
87
|
return {
|
|
87
|
-
id:
|
|
88
|
+
id: M(),
|
|
88
89
|
name: i,
|
|
89
90
|
version: 1,
|
|
90
91
|
source: {
|
|
@@ -94,7 +95,7 @@ function F({ appName: e, appVersion: t = "0.0.0", appEnv: n = "dev", sourceMfe:
|
|
|
94
95
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
95
96
|
monotonic: performance.now(),
|
|
96
97
|
payload: a,
|
|
97
|
-
metadata:
|
|
98
|
+
metadata: P(e, t, n)
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
101
|
function c(e) {
|
|
@@ -129,23 +130,23 @@ function F({ appName: e, appVersion: t = "0.0.0", appEnv: n = "dev", sourceMfe:
|
|
|
129
130
|
}
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
|
-
function
|
|
133
|
-
return
|
|
133
|
+
function L() {
|
|
134
|
+
return T(A);
|
|
134
135
|
}
|
|
135
|
-
function
|
|
136
|
-
let n =
|
|
137
|
-
|
|
136
|
+
function R(e, t) {
|
|
137
|
+
let n = L();
|
|
138
|
+
D(() => n.on(e, t), [
|
|
138
139
|
n,
|
|
139
140
|
t,
|
|
140
141
|
e
|
|
141
142
|
]);
|
|
142
143
|
}
|
|
143
|
-
function
|
|
144
|
-
let n =
|
|
145
|
-
return
|
|
144
|
+
function z(e, t) {
|
|
145
|
+
let n = L();
|
|
146
|
+
return E((r) => n.emit(e, r, t), [
|
|
146
147
|
n,
|
|
147
148
|
e,
|
|
148
149
|
t
|
|
149
150
|
]);
|
|
150
151
|
}
|
|
151
|
-
export { a as ATHELETEBRIDGE_ANALYTICS_ROUTES, o as ATHELETEBRIDGE_RYBBIT_EVENTS,
|
|
152
|
+
export { a as ATHELETEBRIDGE_ANALYTICS_ROUTES, o as ATHELETEBRIDGE_RYBBIT_EVENTS, _ as AnalyticsConsentBanner, r as BUILDMYIQ_RYBBIT_EVENTS, f as BackendAuditSink, d as BroadcastChannelSink, v as CONSENT_BANNER_OFFSET_VAR, u as DevtoolsSink, F as EventBusProvider, l as FLUIDGRIDS_RYBBIT_EVENTS, i as GGNOMAD_RYBBIT_EVENTS, h as OtelBrowserSink, y as RybbitSink, t as SEMANTICFED_ANALYTICS_ROUTES, n as SEMANTICFED_RYBBIT_EVENTS, c as THECULTUREPOST_RYBBIT_EVENTS, s as TIMECAMPUS_RYBBIT_EVENTS, g as WebVitalsSink, p as compileRybbitRoutePattern, I as createEventBus, m as isRybbitSkippedRoute, b as publishConsentBannerOffset, x as readAnalyticsConsent, S as readAnalyticsConsentChoice, C as setAnalyticsConsent, R as useEvent, L as useEventBus, z as useEventEmitter };
|