export type ReportErrorScope = 'screen' | 'component' | 'http' export type ReportErrorContext = { componentStack?: string scope?: ReportErrorScope screenName?: string tags?: Record extra?: Record } interface LogAdapterConfig { enabled: boolean error: (message: string, ...args: any[]) => void info: (message: string, ...args: any[]) => void reportError: (error: Error, context?: ReportErrorContext) => void } export class LogAdapter { enabled: boolean onError?: LogAdapterConfig['error'] onInfo?: LogAdapterConfig['info'] onReportError?: LogAdapterConfig['reportError'] constructor(config: Partial = {}) { this.enabled = config.enabled ?? false this.onError = config.error this.onInfo = config.info this.onReportError = config.reportError } error(message: string, ...args: any[]) { if (!this.enabled) return this.onError?.(message, ...args) } info(message: string, ...args: any[]) { if (!this.enabled) return this.onInfo?.(message, ...args) } reportError(error: Error, context?: ReportErrorContext) { if (this.onReportError) { this.onReportError(error, context) return } console.error(error, context) } }