/** * @file Breadcrumbs module - chronological trail of events before an error. Custom breadcrumbs only (HawkCatcher.breadcrumbs.add()). Possible future auto-capture: outgoing HTTP, unhandledRejection/uncaughtException, console.log/intercept, DB query hooks. */ import type { Breadcrumb } from '@hawk.so/types'; /** * Hint object passed to beforeBreadcrumb callback (same concept as in JS catcher; in Node no event/response yet, use for custom context) */ export interface BreadcrumbHint { [key: string]: unknown; } /** * Configuration options for breadcrumbs (same shape as @hawk.so/javascript; no trackFetch/trackNavigation/trackClicks in Node) */ export interface BreadcrumbsOptions { /** * Maximum number of breadcrumbs to store (FIFO). When the limit is reached, oldest are removed. * @default 15 */ maxBreadcrumbs?: number; /** * Hook called before each breadcrumb is stored. * - Return modified breadcrumb — it will be stored instead of the original. * - Return `false` — the breadcrumb will be discarded. * - Any other value is invalid — the original breadcrumb is stored as-is (a warning is logged). * @param breadcrumb - Breadcrumb to store (can be mutated and returned) * @param hint - Optional context (e.g. for filtering) */ beforeBreadcrumb?: (breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => Breadcrumb | false | void; } /** * Breadcrumb input - timestamp optional (auto-generated if omitted). Same as @hawk.so/javascript BreadcrumbInput. */ export type BreadcrumbInput = Omit & { timestamp?: Breadcrumb['timestamp']; }; /** * Manages breadcrumb buffer and add/get/clear API */ export declare class BreadcrumbManager { private static instance; private readonly breadcrumbs; private options; private isInitialized; /** * Private constructor for singleton */ private constructor(); /** * Get singleton instance (created on first call). * @returns The shared BreadcrumbManager */ static getInstance(): BreadcrumbManager; /** * Initialize with options. Call once when HawkCatcher.init() runs. * @param options - Configuration (maxBreadcrumbs, beforeBreadcrumb) */ init(options?: BreadcrumbsOptions): void; /** * Add a breadcrumb. Timestamp is set to Date.now() if omitted. * @param breadcrumb - Breadcrumb data (type, message, category, level, data) * @param hint - Optional hint for beforeBreadcrumb callback */ addBreadcrumb(breadcrumb: BreadcrumbInput, hint?: BreadcrumbHint): void; /** * Snapshot of current breadcrumbs (oldest to newest) */ getBreadcrumbs(): Breadcrumb[]; /** * Clear all breadcrumbs (e.g. after sending an event) */ clear(): void; }