UNPKG

@critters/next

Version:

Secure bug reporting library for Next.js applications

91 lines (90 loc) 2.51 kB
/** * Core types for the bug tracking system */ export interface BugReport { title: string; error_message?: string; description?: string; severity?: "LOW" | "MEDIUM" | "HIGH" | "CRITICAL"; source: "CLIENT" | "SERVER"; stack_trace?: string; component_stack?: string; application_state?: Record<string, any>; props_context?: Record<string, any>; network_requests?: Array<{ url: string; method: string; status?: number; duration?: number; request_headers?: Record<string, string>; response_headers?: Record<string, string>; request_body?: any; response_body?: any; }>; console_logs?: Array<{ level: "log" | "info" | "warn" | "error"; message: string; timestamp: string; }>; user_interaction?: { last_action?: string; last_action_timestamp?: string; user_path?: string[]; }; browser_info?: { name?: string; version?: string; os?: string; device?: string; viewport?: { width: number; height: number; }; }; error_boundary?: { name?: string; location?: string; }; source_map_url?: string; logData?: Record<string, any>; metadata?: Record<string, any>; projectId?: string; userId?: string; userAgent?: string; url?: string; timestamp?: string; } export interface BugTrackerConfigOptions { endpoint?: string; apiKey: string; secretKey?: string; projectId?: string; environment?: string; enabled?: boolean; debug?: boolean; captureConsole?: boolean; captureNetworkRequests?: boolean; captureUserInteractions?: boolean; captureApplicationState?: boolean; onBeforeReport?: (report: BugReport) => BugReport | false; onAfterReport?: (report: BugReport, result: ReportResult) => void; } export interface ReportResult { success: boolean; message: string; reportId?: string; timestamp?: string; } export interface ErrorHandlerOptions { captureUnhandledRejections?: boolean; captureUncaughtExceptions?: boolean; captureConsoleErrors?: boolean; } export interface ErrorBoundaryProps { children: React.ReactNode; fallback?: React.ReactNode; onError?: (error: Error, errorInfo: React.ErrorInfo) => void; captureProps?: boolean; captureState?: boolean; } export type NextApiHandler = (req: any, res: any) => Promise<any>;