@tinytapanalytics/sdk
Version:
Behavioral psychology platform that detects visitor frustration, predicts abandonment, and helps you save at-risk conversions in real-time
88 lines • 2.13 kB
TypeScript
/**
* Error Handler for TinyTapAnalytics SDK
* Provides graceful error handling that never breaks host websites
*/
import { TinyTapAnalyticsConfig } from '../types/index';
export declare class ErrorHandler {
private config;
private errorCount;
private maxErrors;
private errorBuffer;
private reportingInterval;
private isShutdown;
private reportingIntervalMs;
constructor(config: TinyTapAnalyticsConfig, reportingIntervalMs?: number);
/**
* Handle an error gracefully
*/
handle(error: Error, context?: string, data?: any): void;
/**
* Report a warning (non-fatal error)
*/
warn(message: string, context?: string, data?: any): void;
/**
* Get current error statistics
*/
getStats(): {
errorCount: number;
isShutdown: boolean;
bufferSize: number;
};
/**
* Manually shutdown error handling
*/
shutdown(): void;
/**
* Create standardized SDK error
*/
private createSDKError;
/**
* Get appropriate error code based on error type
*/
private getErrorCode;
/**
* Handle specific error types with appropriate actions
*/
private handleSpecificError;
/**
* Handle storage quota exceeded errors
*/
private handleStorageQuotaError;
/**
* Handle network-related errors
*/
private handleNetworkError;
/**
* Handle Content Security Policy violations
*/
private handleCSPViolation;
/**
* Handle CORS errors
*/
private handleCORSError;
/**
* Buffer error for later reporting
*/
private bufferError;
/**
* Set up global error handling for SDK-related errors
*/
private setupGlobalErrorHandling;
/**
* Check if an error is from our SDK
*/
private isSDKError;
/**
* Start periodic error reporting
*/
private startErrorReporting;
/**
* Report buffered errors to the API
*/
private reportErrors;
/**
* Clean up resources
*/
destroy(): void;
}
//# sourceMappingURL=ErrorHandler.d.ts.map