/** * `@onepatch/rum` — browser telemetry for OnePatch. * * What you get: page views, clicks, fetch/XHR spans, JS errors and web vitals, * all stamped with a session id, and — for backends that accept it — the same * trace id the server span carries, so one trace covers the button and the query * behind it. * * What this is not: a session replay recorder. No DOM is captured. The artifact * is a queryable, ordered list of what someone did, which is what an * investigation actually reads. * * Design rule that outranks every other consideration here: **this library must * never break the page it is measuring.** Nothing below throws. A * misconfiguration is reported through the returned status and a console error, * because a telemetry SDK that white-screens a checkout page has done far more * damage than the data was worth. */ import { type RumOptions } from "./options.js"; import { type BackendCheck } from "./probe.js"; import { type RumAttributes, type RumUser } from "./user.js"; export type { RumOptions, RumTraceDestination } from "./options.js"; export { RumConfigError } from "./options.js"; export type { BackendCheck } from "./probe.js"; export type { RumAttributes, RumIdentity, RumUser, RumUserResolver } from "./user.js"; export type RumStatus = { /** True when telemetry is flowing. */ started: boolean; /** * True when a person is attached to these spans. False when you passed * `user: "anonymous"`, or your resolver returned `null` because nobody was * signed in yet — assert on it in the test that covers your logged-in path. */ identified: boolean; /** Present only when something was wrong. Worth asserting on in a test. */ error?: string; /** One entry per cross-origin backend in `connectTracesTo`. */ backends: BackendCheck[]; }; export type TraceConnectionStatus = { started: boolean; error?: string; backends: BackendCheck[]; }; /** * Start collecting. Safe to call from code that also runs on a server: outside a * browser it does nothing and says so. * * The returned promise resolves once every backend in `connectTracesTo` has been * checked, and never rejects. Awaiting it is optional — telemetry is already * flowing by the time it is returned — but a test should await it to see which * backends will be trace-joined. */ export declare function startRum(options: RumOptions): Promise; /** * Replace the complete cross-origin trace allowlist after login or an org * switch. Include the app's static origins as well as the current org's origins. * Removed origins stop propagating immediately; new ones wait for the same * CORS checks as startup. Pass [] to disable all cross-origin propagation. * * Never rejects. Await the result before requests that need correlation, but * do not block the app on telemetry. Requests made before a probe passes still * work; they simply are not trace-joined. A probe is not proof of a stored join. */ export declare function connectTracesTo(origins: string[]): Promise; /** * Update who the person is: a sign-in, an org switch, a profile edit. Applies to * every span from here on, including ones already buffered but not yet sent; the * last call wins per key. * * The FIRST identity does not belong here — it is the required `user` option on * `startRum`, so that no app can be wired without someone deciding what identity * means for it. This is the update path. */ export declare function identifyUser(user: RumUser): void; /** * Record something the person did that the DOM cannot tell you on its own — * "submitted-onboarding", "ran-workflow". Clicks and navigations are already * captured; use this for the step that has a name in your product's vocabulary. */ export declare function recordAction(name: string, attributes?: RumAttributes): void; /** Record an error you handled, and would otherwise have swallowed. */ export declare function recordError(error: unknown, attributes?: RumAttributes): void; /** * The current session id, the key that ties one person's actions together. * Useful to attach to a support ticket or a bug report. */ export declare function sessionId(): string | undefined; /** Stop collecting and detach. Mainly for tests and for hot reloading. */ export declare function stopRum(): void; //# sourceMappingURL=index.d.ts.map