import { AppError } from './errorTypes'; /** * Breadcrumb types for categorization */ export type BreadcrumbType = 'navigation' | 'ui' | 'http' | 'console' | 'error' | 'user' | 'custom'; /** * Breadcrumb severity levels */ export type BreadcrumbLevel = 'debug' | 'info' | 'warning' | 'error'; /** * Single breadcrumb entry */ export interface Breadcrumb { /** Type of breadcrumb */ type: BreadcrumbType; /** Category for grouping */ category: string; /** Human-readable message */ message: string; /** Additional data */ data?: Record; /** Timestamp in ms */ timestamp: number; /** Severity level */ level: BreadcrumbLevel; } /** * User action for session recording */ export interface UserAction { /** Action type */ type: 'click' | 'input' | 'scroll' | 'navigation' | 'focus' | 'blur'; /** CSS selector or element identifier */ target: string; /** Value (masked if sensitive) */ value?: string; /** Timestamp in ms */ timestamp: number; /** Additional metadata */ metadata?: Record; } /** * Performance metrics snapshot */ export interface PerformanceMetrics { /** Page load time in ms */ pageLoadTime?: number; /** DOM content loaded time in ms */ domContentLoaded?: number; /** First contentful paint in ms */ firstContentfulPaint?: number; /** Largest contentful paint in ms */ largestContentfulPaint?: number; /** First input delay in ms */ firstInputDelay?: number; /** Cumulative layout shift score */ cumulativeLayoutShift?: number; /** JS heap size in bytes */ jsHeapSize?: number; /** Total memory usage in bytes */ memoryUsage?: number; } /** * Device information */ export interface DeviceInfo { /** User agent string */ userAgent: string; /** Platform (OS) */ platform: string; /** Browser language */ language: string; /** Screen resolution */ screenResolution: string; /** Viewport size */ viewportSize: string; /** Device pixel ratio */ devicePixelRatio: number; /** Color depth */ colorDepth: number; /** Timezone */ timezone: string; /** Cookies enabled */ cookiesEnabled: boolean; /** Do Not Track enabled */ doNotTrack: boolean; } /** * Complete session data for crash report */ export interface SessionData { /** Unique session ID */ sessionId: string; /** User ID if available */ userId?: string; /** Session start time */ startTime: number; /** Session end time (if ended) */ endTime?: number; /** Breadcrumb trail */ breadcrumbs: Breadcrumb[]; /** Recorded user actions */ userActions: UserAction[]; /** Performance metrics */ performanceMetrics: PerformanceMetrics; /** Device information */ deviceInfo: DeviceInfo; /** Errors that occurred */ errors: AppError[]; } /** * Crash analytics configuration */ export interface CrashAnalyticsConfig { /** Maximum breadcrumbs to keep */ maxBreadcrumbs?: number; /** Maximum user actions to keep */ maxUserActions?: number; /** Auto-capture click events */ autoCaptureClicks?: boolean; /** Auto-capture navigation events */ autoCaptureNavigation?: boolean; /** Auto-capture console messages */ autoCaptureConsole?: boolean; /** Auto-capture network requests */ autoCaptureNetwork?: boolean; /** Mask sensitive input values */ maskInputs?: boolean; /** Session recording sample rate (0-1) */ sessionSampleRate?: number; /** Custom user ID getter */ getUserId?: () => string | undefined; } /** * Crash analytics manager for session recording and breadcrumb tracking * * @example * ```tsx * // Initialize crash analytics * crashAnalytics.init(); * * // Add custom breadcrumb * crashAnalytics.addBreadcrumb({ * type: 'custom', * category: 'checkout', * message: 'User started checkout', * level: 'info', * data: { cartItems: 3 } * }); * * // Get session data for crash report * const sessionData = crashAnalytics.getSessionData(); * ``` */ declare class CrashAnalyticsManager { private config; private sessionId; private breadcrumbs; private userActions; private errors; private startTime; private isRecording; private cleanupFns; private initialized; constructor(config?: CrashAnalyticsConfig); /** * Initialize crash analytics */ init(): void; /** * Add a breadcrumb */ addBreadcrumb(crumb: Omit): void; /** * Add a user action */ addUserAction(action: Omit): void; /** * Record an error */ recordError(error: AppError): void; /** * Get session data for crash report */ getSessionData(): SessionData; /** * Get breadcrumbs */ getBreadcrumbs(): Breadcrumb[]; /** * Get recent breadcrumbs (last N) */ getRecentBreadcrumbs(count?: number): Breadcrumb[]; /** * Clear all data */ clear(): void; /** * Start new session */ startNewSession(): void; /** * Dispose and cleanup */ dispose(): void; /** * Check if initialized */ isInitialized(): boolean; /** * Get session ID */ getSessionId(): string; /** * Generate unique session ID */ private generateSessionId; /** * Setup click capture */ private setupClickCapture; /** * Setup navigation capture */ private setupNavigationCapture; /** * Setup console capture */ private setupConsoleCapture; /** * Setup network capture */ private setupNetworkCapture; /** * Capture performance metrics */ private capturePerformanceMetrics; /** * Get current performance metrics */ private getPerformanceMetrics; /** * Get device info */ private getDeviceInfo; /** * Get CSS selector for element */ private getElementSelector; /** * Get element text content */ private getElementText; /** * Stringify value safely */ private stringify; } /** * Global crash analytics instance */ export declare const crashAnalytics: CrashAnalyticsManager; export {};