/** * Error Tracking Handler * * P1 - Global error tracking and monitoring * * Supports: * - JavaScript error capture * - Unhandled rejection tracking * - Error aggregation and deduplication * - Error context collection * - Error reporting * * @see https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers */ export interface ErrorInfo { /** Error message */ message: string; /** Error stack trace */ stack: string; /** Error name */ name: string; /** Source file */ filename?: string; /** Line number */ line?: number; /** Column number */ column?: number; /** Error type */ type: 'error' | 'unhandledrejection' | 'resource' | 'console'; /** Timestamp */ timestamp: number; /** User agent */ userAgent: string; /** Page URL */ pageUrl: string; /** Additional context */ context?: { viewport?: { width: number; height: number; }; console?: string[]; localStorage?: Record; }; } export interface ErrorGroup { /** Unique error key */ key: string; /** Error name */ name: string; /** Error message */ message: string; /** Count of occurrences */ count: number; /** First occurrence timestamp */ firstSeen: number; /** Last occurrence timestamp */ lastSeen: number; /** Sample stack trace */ stack: string; /** Affected pages */ pages: string[]; } export interface ResourceError { /** Resource URL */ url: string; /** Resource type */ type: string; /** Error status */ status: number; /** Error message */ message: string; /** Timestamp */ timestamp: number; } export interface ErrorReport { /** Total errors captured */ totalErrors: number; /** Errors by type */ errorsByType: Record; /** Grouped errors */ groupedErrors: ErrorGroup[]; /** Resource errors */ resourceErrors: ResourceError[]; /** Most frequent error */ mostFrequent: ErrorGroup | null; /** Unhandled rejections */ unhandledRejections: number; /** Console errors */ consoleErrors: number; } /** * Error Tracking Handler class */ export declare class ErrorTrackingHandler { private page; private errors; private resourceErrors; private trackingEnabled; private consoleErrors; constructor(page: any); /** * Setup global error tracking */ setupTracking(): Promise; /** * Get all captured errors from the page */ getErrors(): Promise; /** * Get all resource errors */ getResourceErrors(): Promise; /** * Get console errors */ getConsoleErrors(): Promise; /** * Generate error report */ generateReport(): Promise; /** * Group errors by similarity */ private groupErrors; /** * Capture error with additional context */ captureError(error: Error, context?: Record): Promise; /** * Clear all captured errors */ clearErrors(): Promise; /** * Get errors by type */ getErrorsByType(type: ErrorInfo['type']): Promise; /** * Get errors by page URL */ getErrorsByPage(pageUrl: string): Promise; /** * Check if there are any critical errors */ hasCriticalErrors(): Promise; /** * Get error statistics */ getStatistics(): Promise<{ total: number; byType: Record; critical: number; unique: number; avgPerMinute: number; }>; /** * Export errors as JSON */ exportErrors(): Promise; /** * Setup error threshold monitoring */ setupThresholdMonitoring(threshold: number, callback: (errors: ErrorInfo[]) => void | Promise): Promise<() => void>; /** * Check if tracking is enabled */ isEnabled(): boolean; /** * Disable error tracking */ disableTracking(): Promise; } /** * Factory function to create Error Tracking Handler */ export declare function createErrorTrackingHandler(page: any): ErrorTrackingHandler; export default ErrorTrackingHandler;