@burdenoff/fe-libs 2026.1115.12 → 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.
@@ -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 CAN ship these off-device is the event-bus path:
33
- * AppShellProvider -> ShellTelemetryEmitter (perf.* events) -> OtelBrowserSink,
34
- * which POSTs to VITE_OTEL_HTTP_ENDPOINT. That sink only mounts when the
35
- * endpoint is configured; as of 2026-07-16 it is provisioned for no product,
36
- * so the fleet has no field CWV data. Tracked as the RUM-sink follow-up
37
- * (see atheletebridge-specs/business/status/PERFORMANCE_REPORT.md).
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
@@ -3,13 +3,13 @@ import { DEFAULT_LOCALE_STORAGE_KEY as t, I18nProvider as n, resolveInitialLocal
3
3
  import { graphqlFetch as a } from "../../graphql/fetch.js";
4
4
  import { DEFAULT_PLATFORM_I18N_PRODUCT_ID as o, createLayeredTranslationLoader as s, effectivePlatformId as c, translationCacheScope as l } from "./translationLayers.js";
5
5
  import { getDefaultTranslationPersistence as u } from "./translationStore.js";
6
+ import { createExportedDictionaryLoader as d } from "./exportedDictionary.js";
6
7
  import "../../../shared-graphql.js";
7
- import { BrandedSplash as d } from "../../../ui/branded-splash.js";
8
- import { useCallback as f, useMemo as p } from "react";
9
- import { jsx as m } from "react/jsx-runtime";
10
- import { DirectionProvider as h } from "@radix-ui/react-direction";
11
- // src/shared/providers/shell/ProfileI18nBridge.tsx
12
- var g = "\n query ExportTranslations($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n exportTranslations(productId: $productId, languageCode: $languageCode, format: $format) {\n format\n url\n }\n }\n", _ = 2e3, v = {
8
+ import { BrandedSplash as f } from "../../../ui/branded-splash.js";
9
+ import { useCallback as p, useMemo as m } from "react";
10
+ import { jsx as h } from "react/jsx-runtime";
11
+ import { DirectionProvider as g } from "@radix-ui/react-direction";
12
+ var _ = 2e3, v = {
13
13
  en: "Loading…",
14
14
  es: "Cargando…",
15
15
  fr: "Chargement…",
@@ -23,44 +23,39 @@ var g = "\n query ExportTranslations($productId: String!, $languageCode: String
23
23
  function y(e) {
24
24
  return v[e.toLowerCase().split(/[-_]/)[0] ?? "en"] ?? v.en;
25
25
  }
26
- async function b(e, t) {
27
- let n = await a({
28
- gateway: "global",
29
- query: g,
30
- operationName: "ExportTranslations",
31
- batch: !1,
32
- variables: {
33
- productId: e,
34
- languageCode: t,
35
- format: "JSON"
36
- },
37
- extraHeaders: {
38
- "x-actor-id": "system-i18n",
39
- "x-actor-type": "service"
40
- }
41
- });
42
- if (n.errors?.length || !n.data?.exportTranslations?.url) return null;
43
- let r = n.data.exportTranslations.url, i = decodeURIComponent(r.replace("data:application/json;charset=utf-8,", ""));
44
- return JSON.parse(i);
45
- }
26
+ var b = (e) => a({
27
+ gateway: "global",
28
+ query: e.query,
29
+ operationName: e.operationName,
30
+ batch: !1,
31
+ variables: e.variables,
32
+ extraHeaders: {
33
+ "x-actor-id": "system-i18n",
34
+ "x-actor-type": "service"
35
+ }
36
+ });
46
37
  function x({ children: e }) {
47
38
  let { dir: t } = i();
48
- return /* @__PURE__ */ m(h, {
39
+ return /* @__PURE__ */ h(g, {
49
40
  dir: t,
50
41
  children: e
51
42
  });
52
43
  }
53
- function S({ children: i, i18nProductId: a, platformI18nProductId: h = o, defaultLocale: g = "en", fallbackTranslations: v, disableDynamicFetch: S = !1, persistTranslations: C = !0, directionMode: w = "off" }) {
54
- let { user: T } = e(), E = T?.id ?? null, D = !S, O = c(a, h), k = f((e) => v?.[e] ?? {}, [v]), A = p(() => s({
44
+ function S({ children: i, i18nProductId: a, platformI18nProductId: g = o, defaultLocale: v = "en", fallbackTranslations: S, disableDynamicFetch: C = !1, persistTranslations: w = !0, directionMode: T = "off" }) {
45
+ let { user: E } = e(), D = E?.id ?? null, O = !C, k = c(a, g), A = p((e) => S?.[e] ?? {}, [S]), j = m(() => O && w ? u() : null, [w, O]), M = m(() => s({
55
46
  productId: a,
56
- platformId: O,
57
- fallback: k,
58
- fetchDictionary: b
47
+ platformId: k,
48
+ fallback: A,
49
+ fetchDictionary: d({
50
+ query: b,
51
+ persistence: j
52
+ })
59
53
  }), [
60
- k,
54
+ A,
61
55
  a,
62
- O
63
- ]), j = p(() => D && C ? u() : null, [C, D]), M = p(() => /* @__PURE__ */ m(d, { label: y(r(E, t, g)) }), [g, E]), N = p(() => v ?? {
56
+ k,
57
+ j
58
+ ]), N = m(() => /* @__PURE__ */ h(f, { label: y(r(D, t, v)) }), [v, D]), P = m(() => S ?? {
64
59
  en: {},
65
60
  es: {},
66
61
  fr: {},
@@ -70,20 +65,20 @@ function S({ children: i, i18nProductId: a, platformI18nProductId: h = o, defaul
70
65
  ta: {},
71
66
  hi: {},
72
67
  ar: {}
73
- }, [v]);
74
- return /* @__PURE__ */ m(n, {
75
- defaultLocale: g,
76
- translations: N,
77
- loadTranslations: D ? A : void 0,
78
- cacheScope: l(a, O),
68
+ }, [S]);
69
+ return /* @__PURE__ */ h(n, {
70
+ defaultLocale: v,
71
+ translations: P,
72
+ loadTranslations: O ? M : void 0,
73
+ cacheScope: l(a, k),
79
74
  persistence: j,
80
75
  firstPaintHoldMs: j ? 150 : 0,
81
76
  coldCacheHoldMs: j ? _ : 0,
82
- loadingComponent: M,
83
- directionMode: w,
84
- profileId: E,
77
+ loadingComponent: N,
78
+ directionMode: T,
79
+ profileId: D,
85
80
  showChildrenWhileLoading: !0,
86
- children: /* @__PURE__ */ m(x, { children: i })
81
+ children: /* @__PURE__ */ h(x, { children: i })
87
82
  });
88
83
  }
89
84
  export { _ as COLD_CACHE_HOLD_MS, S as ProfileI18nBridge, y as dictionaryLoadingLabel };
@@ -0,0 +1,35 @@
1
+ import { Locale, TranslationDictionary } from './I18nProvider';
2
+ import { TranslationPersistence } from './translationStore';
3
+ /** Result of one GraphQL request, as `graphqlFetch` returns it. */
4
+ export interface ExportGraphqlResult<T> {
5
+ data?: T | null;
6
+ errors?: ReadonlyArray<unknown> | null;
7
+ }
8
+ /** Sends one i18n export query. Injected so the logic is testable without a gateway. */
9
+ export type ExportQueryFn = <T>(request: {
10
+ operationName: string;
11
+ query: string;
12
+ variables: Record<string, unknown>;
13
+ }) => Promise<ExportGraphqlResult<T>>;
14
+ export declare const EXPORT_TRANSLATIONS_CONTENT_QUERY = "\n query ExportTranslations($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n exportTranslations(productId: $productId, languageCode: $languageCode, format: $format) {\n format\n version\n content\n }\n }\n";
15
+ export declare const TRANSLATIONS_EXPORT_VERSION_QUERY = "\n query TranslationsExportVersion($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n translationsExportVersion(productId: $productId, languageCode: $languageCode, format: $format)\n }\n";
16
+ /** The query servers without `content`/`version` answer (before BOFF-14823). */
17
+ export declare const EXPORT_TRANSLATIONS_URL_QUERY = "\n query ExportTranslations($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n exportTranslations(productId: $productId, languageCode: $languageCode, format: $format) {\n format\n url\n }\n }\n";
18
+ /** The persistent-cache scope of one layer's export. Never collides with a merged scope. */
19
+ export declare function exportCacheScope(productId: string): string;
20
+ /**
21
+ * Whether the server rejected the query because it does not know a field: a
22
+ * server from before BOFF-14823. Any other error is transient and is retried
23
+ * on the next load, as before.
24
+ */
25
+ export declare function isUnknownFieldError(errors: ReadonlyArray<unknown> | null | undefined): boolean;
26
+ export interface ExportedDictionaryLoaderOptions {
27
+ query: ExportQueryFn;
28
+ /** Per-layer cache; null when there is none (no IndexedDB, persistence off). */
29
+ persistence: TranslationPersistence | null;
30
+ }
31
+ /**
32
+ * A `FetchDictionaryFn` for the layered loader: the dictionary, or null when
33
+ * it could not be had (transient failure, nothing published).
34
+ */
35
+ export declare function createExportedDictionaryLoader(options: ExportedDictionaryLoaderOptions): (productId: string, locale: Locale) => Promise<TranslationDictionary | null>;
@@ -0,0 +1,68 @@
1
+ // src/shared/providers/shell/exportedDictionary.ts
2
+ var e = "\n query ExportTranslations($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n exportTranslations(productId: $productId, languageCode: $languageCode, format: $format) {\n format\n version\n content\n }\n }\n", t = "\n query TranslationsExportVersion($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n translationsExportVersion(productId: $productId, languageCode: $languageCode, format: $format)\n }\n", n = "\n query ExportTranslations($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n exportTranslations(productId: $productId, languageCode: $languageCode, format: $format) {\n format\n url\n }\n }\n";
3
+ function r(e) {
4
+ return `export:${e}`;
5
+ }
6
+ function i(e) {
7
+ return (e ?? []).some((e) => {
8
+ if (typeof e != "object" || !e) return !1;
9
+ let { message: t, extensions: n } = e;
10
+ return (typeof n == "object" && n ? n.code : void 0) === "GRAPHQL_VALIDATION_FAILED" || typeof t == "string" && t.includes("Cannot query field");
11
+ });
12
+ }
13
+ function a(e) {
14
+ return typeof e == "object" && !!e && !Array.isArray(e);
15
+ }
16
+ function o(e) {
17
+ try {
18
+ let t = JSON.parse(e);
19
+ return a(t) ? t : null;
20
+ } catch {
21
+ return null;
22
+ }
23
+ }
24
+ function s(a) {
25
+ let { query: s, persistence: c } = a, l = async (e) => {
26
+ let t = await s({
27
+ operationName: "ExportTranslations",
28
+ query: n,
29
+ variables: e
30
+ }), r = t.data?.exportTranslations?.url;
31
+ return t.errors?.length || !r ? null : o(decodeURIComponent(r.replace("data:application/json;charset=utf-8,", "")));
32
+ };
33
+ return async (n, a) => {
34
+ let u = {
35
+ productId: n,
36
+ languageCode: a,
37
+ format: "JSON"
38
+ }, d = r(n), f = c ? await c.read(d, a) : null;
39
+ if (f) {
40
+ let e = await s({
41
+ operationName: "TranslationsExportVersion",
42
+ query: t,
43
+ variables: u
44
+ }).then((e) => e.errors?.length ? null : e.data?.translationsExportVersion ?? null, () => null);
45
+ if (e && e === f.hash) return f.translations;
46
+ }
47
+ let p;
48
+ try {
49
+ p = await s({
50
+ operationName: "ExportTranslations",
51
+ query: e,
52
+ variables: u
53
+ });
54
+ } catch (e) {
55
+ if (f) return f.translations;
56
+ throw e;
57
+ }
58
+ let m = p.data?.exportTranslations;
59
+ if (p.errors?.length || !m) return i(p.errors) ? l(u) : f?.translations ?? null;
60
+ if (!m.content) return null;
61
+ let h = o(m.content);
62
+ return h ? (c && m.version && c.write(d, a, {
63
+ translations: h,
64
+ hash: m.version
65
+ }), h) : null;
66
+ };
67
+ }
68
+ export { e as EXPORT_TRANSLATIONS_CONTENT_QUERY, n as EXPORT_TRANSLATIONS_URL_QUERY, t as TRANSLATIONS_EXPORT_VERSION_QUERY, s as createExportedDictionaryLoader, r as exportCacheScope, i as isUnknownFieldError };
@@ -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,5 @@
1
+ // src/shared/rum/mount.ts
2
+ function e(e) {
3
+ return e.enabled !== !1 && e.rum?.enabled !== !1 && e.appEnv !== "dev";
4
+ }
5
+ export { e as shouldMountWebVitalsSink };
@@ -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
+ }
@@ -95,10 +95,11 @@ var d = [
95
95
  ]), p = /* @__PURE__ */ new Set([
96
96
  "ExportTranslations",
97
97
  "exportTranslations",
98
+ "TranslationsExportVersion",
98
99
  "AdminEntityCounts",
99
100
  "GetTenants",
100
101
  "NodeManifest"
101
- ]), m = ["exportTranslations"], h = ["No translation keys found for the specified criteria"], g = [
102
+ ]), m = ["exportTranslations", "translationsExportVersion"], h = ["No translation keys found for the specified criteria"], g = [
102
103
  /failed to fetch/i,
103
104
  /networkerror when attempting to fetch/i,
104
105
  /network request failed/i,