/** * Usage telemetry — client side (spec: "Monetization Gates / Usage * telemetry", phase M3 client half). One snapshot per instance per * page load, built when that map reaches `ready` (manifest fully parsed — * late mutations go uncounted, by design). Deployment-scoped, never * visitor-scoped: the payload describes the page's use of the library. * * LIVE by default since the ingestion Worker deployment (2026-07-14): the * default endpoint is the first-party Worker at om-api.nika.eco (spec's * "beacon must not ship before something is listening" — it is listening). * Disable with `configureTelemetry({ disabled: true })`, per map with * `telemetry="off"`, or clear the endpoint (`{ endpoint: undefined }`). * Disclosure: LICENSE.md §11; public schema: docs/telemetry.md. * * Non-negotiables (spec, binding): * - telemetry never affects function: everything is wrapped, fire-and- * forget, no retry, silent on failure; nothing awaits it; * - no PII, no page URLs (hostname only), no visitor identifiers — * `pageLoadId` dies with the page; `map-id` identifies the map ARTIFACT; * - opt-out: `OmMap.configureTelemetry({ disabled: true })` or * `telemetry="off"` on the map element; * - headless maps (consumer test suites) never report. */ import type { LayerIR } from "./ir"; import type { TelemetrySnapshot, TelemetryErrorReport } from "./telemetry-schema"; export type { TelemetrySnapshot, TelemetryLayerSnapshot } from "./telemetry-schema"; export interface TelemetryConfig { /** Kill switch — disables the map-ready beacon and library-error reports globally. */ disabled?: boolean; /** Ingestion endpoint — the first-party Worker by default; explicitly set `undefined` to silence all sends. */ endpoint?: string; /** Native adapters declare their platform; the web never sets this. */ platform?: "web" | "ios" | "android"; /** Trusted packaged-app identity (native build metadata, never page input); reported in place of origin. */ appId?: string; } /** The first-party ingestion Worker (cloud/workers/telemetry) — a domain we control, never a vendor's. */ export declare const DEFAULT_TELEMETRY_ENDPOINT = "https://om-api.nika.eco/v1/t"; /** Merge-assign: only keys present in `partial` change (so `{ endpoint: undefined }` explicitly clears). */ export declare function configureTelemetry(partial: TelemetryConfig): void; /** Read-only view for the error-reporting module (same gates, same switch). */ export declare function getTelemetryConfig(): Readonly; /** One id per page load, shared by every map on the page. */ export declare const pageLoadId: string; /** Hostname-only origin + dev flag — shared with error reporting. */ export declare function hostContext(): { origin: string; dev: boolean; }; export declare function buildMapSnapshot(mapEl: Element, layerIRs: ReadonlyMap, frontend?: TelemetrySnapshot["frontend"]): TelemetrySnapshot; /** * Fire-and-forget POST. `text/plain` is deliberate: it keeps the request * CORS-simple (no preflight from every customer origin) — the Worker parses * the body as JSON regardless of the content type. sendBeacon survives page * unload; `fetch keepalive` is the fallback where sendBeacon is missing. * Never throws, never retries, nothing observes the result. */ export declare function postPayload(payload: TelemetrySnapshot | TelemetryErrorReport): void; /** * The om-map `ready` hook — one call per map instance per page load * (guarded by the caller's readyFired latch). All gates checked here so the * call site stays a single unconditional line. */ export declare function reportMapReady(mapEl: Element, layerIRs: ReadonlyMap): void;