export type SessionReplayUrlMatcher = string | RegExp | ((url: string) => boolean); /** rrweb `sampling` shape (mousemove/scroll/media throttles, input strategy). */ export type ReplayEventSampling = Record; /** * Console capture cap overrides. `maxEvents` bounds the number of * `agent-native.console` custom events emitted per recording session * (default 1000); once hit, capture stops for the rest of the session and one * final truncation-notice event is emitted. */ export interface SessionReplayConsoleOptions { maxEvents?: number; } /** * Network capture cap overrides. `maxEvents` bounds the number of * `agent-native.network` custom events emitted per recording session * (default 2000); once hit, capture stops for the rest of the session and one * final truncation-notice event is emitted. * * `captureErrorBodies` (default true) additionally captures a bounded, * redacted response-body snippet for 5xx responses only -- request bodies * and headers are never captured, and non-5xx/network-failure responses * never carry a body. `maxErrorBodyLength` (default 2048) caps that snippet. */ export interface SessionReplayNetworkOptions { maxEvents?: number; captureErrorBodies?: boolean; maxErrorBodyLength?: number; } export interface SessionReplayUploadRejectedDetails { status: number; restartAttempted: boolean; restartSucceeded: boolean; restartReason?: SessionReplayStartResult["reason"]; } export interface SessionReplayOptions { enabled?: boolean; /** Rechecked immediately before rrweb starts to cancel deferred startup. */ shouldStart?: () => boolean; publicKey?: string; endpoint?: string; /** Analytics app origin used to build timestamped replay links. */ linkBaseUrl?: string; requireSignedInUser?: boolean; sampleRate?: number; samplingSalt?: string; allowUrls?: SessionReplayUrlMatcher[]; blockUrls?: SessionReplayUrlMatcher[]; flushIntervalMs?: number; maxDurationMs?: number; maxEventsPerBatch?: number; maxBatchBytes?: number; checkoutEveryNth?: number; checkoutEveryNms?: number; inlineStylesheet?: boolean; blockSelector?: string; ignoreSelector?: string; maskTextClass?: string | RegExp; maskTextSelector?: string; maskAllInputs?: boolean; recordCanvas?: boolean; recordCrossOriginIframes?: boolean; collectFonts?: boolean; inlineImages?: boolean; /** * rrweb per-event throttling (distinct from `sampleRate`, which decides * whether a whole session records). Throttles high-frequency event types * (mousemove/scroll/input) to keep the recorded page responsive and the * payloads small. Passed straight through to `rrweb.record({ sampling })`. */ eventSampling?: ReplayEventSampling; /** * Capture console.log/info/warn/error/debug plus window `error` and * `unhandledrejection` events as `agent-native.console` custom rrweb * events. Defaults to on whenever session replay is enabled. Pass `false` * to disable, or an options object to override caps. */ console?: boolean | SessionReplayConsoleOptions; /** * Capture fetch/XHR requests as `agent-native.network` custom rrweb * events (method, URL, status, timing). Request bodies and headers are * never captured; response bodies are captured only as a bounded, * redacted snippet for 5xx responses (see `captureErrorBodies`). * Defaults to on whenever session replay is enabled. Pass `false` to * disable, or an options object to override caps. */ network?: boolean | SessionReplayNetworkOptions; /** Rare recorder lifecycle signal; never includes replay content or URLs. */ onUploadRejected?: (details: SessionReplayUploadRejectedDetails) => void; extraProperties?: Record | (() => Record | undefined); } export interface SessionReplayContext { replayId: string; sessionId: string; startedAtMs: number; startedAt: string; linkBaseUrl: string | null; active: boolean; } export interface SessionReplayLinkOptions { /** Event time to seek to when the replay link opens. */ at?: Date | number | string; /** Overrides the configured Analytics app origin for this link. */ linkBaseUrl?: string; } export interface SessionReplayStartResult { started: boolean; reason?: "disabled" | "not-browser" | "missing-public-key" | "missing-session-id" | "missing-user-id" | "sampled-out" | "url-blocked" | "already-active" | "import-failed" | "record-failed"; replayId?: string; sessionId?: string; sampled?: boolean; } /** rrweb custom-event tag for captured console/window-error entries. */ export declare const SESSION_REPLAY_CONSOLE_EVENT_TAG = "agent-native.console"; /** rrweb custom-event tag for captured fetch/XHR request summaries. */ export declare const SESSION_REPLAY_NETWORK_EVENT_TAG = "agent-native.network"; /** Content-free agent-chat lifecycle markers for replay incident forensics. */ export declare const SESSION_REPLAY_AGENT_CHAT_EVENT_TAG = "agent-native.chat"; export declare function getSessionReplaySamplingScore(sessionId: string, salt?: string): number; export declare function shouldSampleSessionReplay(sessionId: string, sampleRate?: number, salt?: string): boolean; export declare function flushSessionReplay(reason?: string): Promise; export declare function startSessionReplay(options?: SessionReplayOptions): Promise; export declare function stopSessionReplay(reason?: string): Promise; export declare function maybeStartSessionReplay(options?: SessionReplayOptions): Promise; export declare function isSessionReplayActive(): boolean; /** * The active session replay id when a recording is running, or the last one * persisted for this analytics session in this tab's `sessionStorage`. * First-party error capture uses this to tie each captured exception to the * replay it happened in, so triage can jump straight to * `/sessions/`. */ export declare function getSessionReplayId(): string | null; /** * Return the replay identity associated with this browser tab. The context is * intentionally small so it can be attached to analytics events without * exposing replay content or credentials. */ export declare function getSessionReplayContext(): SessionReplayContext | null; /** * Build a scoped Analytics replay lookup link. The Analytics server resolves * the client replay id to its server recording id and converts the event time * into the replay player's offset before redirecting to the detail page. */ export declare function getSessionReplayUrl(options?: SessionReplayLinkOptions): string | null; /** * Surface a manually captured exception on the active session replay timeline * as an `agent-native.console` custom event, reusing the diagnostics contract * (`level`, `source: "console"`, `message`, `stack`, `url`). No-op when no * recording is active. Auto-captured `window.onerror` / `unhandledrejection` * are intentionally NOT routed here — the recorder already logs those as * `window-error` / `unhandledrejection`, so re-emitting would double-count. */ export declare function emitSessionReplayException(input: { type: string; message: string; level?: "fatal" | "error" | "warning" | "info" | "debug"; stack?: string; url?: string; }): void; export type SessionReplayAgentChatEvent = { phase: "surface-mounted" | "run-observed" | "run-stopped"; surface: string; threadId?: string; runId?: string; tabId?: string; }; /** * Add a content-free chat lifecycle marker to the active replay. The payload * deliberately accepts only ids and low-cardinality state; prompt/response * content must never enter replay diagnostics through this path. */ export declare function emitSessionReplayAgentChatEvent(input: SessionReplayAgentChatEvent): void; //# sourceMappingURL=session-replay.d.ts.map