/** * Builds the error report payload — the contract the SDK sends to the backend * (POST /api/ingestion/errors). This is intentionally the single place that * defines the shape, so the unit test for it doubles as the living spec that * the backend repo can build against. * * Pure and dependency-free; covered by __tests__/error-payload.test.ts. */ import { StackFrame } from './stack-parser'; import { Breadcrumb } from './breadcrumbs'; import { LinkedException } from './linked-errors'; export type ErrorMechanism = 'onerror' | 'onunhandledrejection' | 'resource' | 'csp' | 'react' | 'console' | 'captureException'; /** Connectivity at the moment the error fired — helps reproduce offline/flaky bugs. */ export interface NetworkState { online: boolean; effectiveType: string | null; } /** * The most recent error-correlated network request (a failed fetch/XHR), with * bodies/headers redacted. Bodies/headers are only present when the host opted * in via `captureRequestBodies`. */ export interface RequestContext { url: string; method: string; status: number | null; errorType?: string; durationMs?: number; requestHeaders?: Record; requestBody?: string; responseBody?: string; } export interface ErrorReportInput { /** The thrown value: an Error, a string, or anything else. */ error: unknown; mechanism: ErrorMechanism; handled: boolean; sessionId: string; endUserId: string | null; url: string; breadcrumbs: Breadcrumb[]; release?: string | null; environment?: string | null; /** Git commit SHA the build was cut from — turns a culprit frame into a GitHub blob link. */ commitSha?: string | null; /** Build/dist discriminator (e.g. build id) — pairs with `release` to locate the right source map. */ dist?: string | null; /** React component stack (set by the error boundary). */ componentStack?: string; /** Connectivity snapshot at error time. */ networkState?: NetworkState; /** Last error-correlated network request (redacted). */ requestContext?: RequestContext; /** Epoch ms the replay session started — lets the backend compute replay offset. */ sessionStartTimestampMs?: number; automaticProperties?: Record; userProperties?: Record; sessionProperties?: Record; timestampMs?: number; } export interface ErrorReport { /** * Client-minted idempotency ID. Set once at capture time; retries reuse * the same serialized body, so the server can drop duplicate deliveries * without touching occurrence counts. */ eventId: string; exceptionType: string; value: string; stackFrames: StackFrame[]; mechanism: ErrorMechanism; handled: boolean; release: string | null; environment: string | null; commitSha: string | null; dist: string | null; componentStack?: string; networkState?: NetworkState; requestContext?: RequestContext; sessionStartTimestampMs?: number; breadcrumbs: Breadcrumb[]; sessionId: string; endUserId: string | null; url: string; timestampMs: number; automaticProperties?: Record; userProperties?: Record; sessionProperties?: Record; /** Cause chain (`Error.cause` / `AggregateError.errors`), outermost first. */ linkedErrors?: LinkedException[]; /** filename → debug ID for the frames' files (from bundler-injected globals). */ debugIdMap?: Record; } /** * Normalize an arbitrary thrown value into a type/message/stack triple. */ export declare function describeError(error: unknown): { type: string; value: string; stack: string | null; }; export declare function buildErrorReport(input: ErrorReportInput): ErrorReport; /** * Key used for client-side de-dup. Built from the error type, message, and * every stack frame's location+function (Sentry's dedupe compares the full * stack), so distinct code paths that share a top frame are NOT collapsed * while the identical crash repeated in a burst is. */ export declare function dedupeKey(report: ErrorReport): string; //# sourceMappingURL=error-payload.d.ts.map