/** * Sentry adapter — captures misina errors with the originating request * as Sentry context. Adds optional breadcrumbs for successful requests. * * No package dependency: pass any object that satisfies the minimal * `SentryHub` shape (`@sentry/browser`, `@sentry/node`, `@sentry/core`, * or your own wrapper). No peer dep — you already install Sentry yourself. * * @example * ```ts * import * as Sentry from "@sentry/browser" * import { createMisina } from "misina" * import { sentry } from "misina/sentry" * * const api = createMisina({ * baseURL, * use: [sentry({ Sentry, captureLevel: "error", redactHeaders: ["authorization", "cookie"] })], * }) * ``` */ import type { MisinaPlugin } from "../types.mjs"; /** Minimal Sentry surface used by the adapter. */ export interface SentryHub { captureException: (error: unknown, context?: { contexts?: Record; tags?: Record; }) => string | undefined; addBreadcrumb?: (breadcrumb: SentryBreadcrumb) => void; } export interface SentryBreadcrumb { category?: string; message?: string; level?: "debug" | "info" | "warning" | "error" | "fatal"; type?: string; data?: Record; } export interface SentryOptions { Sentry: SentryHub; /** * Which errors to capture: * - `'all'`: every error (HTTP + network + timeout) * - `'error'` (default): everything except 4xx HTTPError * - `'5xx'`: only HTTPError with status ≥ 500 */ captureLevel?: "all" | "error" | "5xx"; /** * Header names to redact in the captured request context. * Default: `['authorization', 'cookie', 'proxy-authorization']`. */ redactHeaders?: string[]; /** Add a breadcrumb on every successful request. Default: false. */ successBreadcrumb?: boolean; } export declare function sentry(options: SentryOptions): MisinaPlugin;