export type EventLevel = 'fatal' | 'error' | 'warning' | 'info' | 'debug'; export interface ContextLevelConfig { maxStackFrames: number; maxBreadcrumbs: number; } export type ContextLevelMap = Record; export interface UserInfo { id?: string; username?: string; email?: string; [key: string]: unknown; } export interface StackFrame { filename: string; function?: string; lineno?: number; colno?: number; in_app?: boolean; } export interface ExceptionInfo { type: string; value: string; stacktrace?: { frames: StackFrame[]; }; } export interface RequestInfo { url: string; method?: string; headers?: Record; referrer?: string; } export interface BrowserContext { name: string; version?: string; } export interface OSContext { name: string; version?: string; } export interface DeviceContext { family?: string; model?: string; brand?: string; type?: string; } export interface Contexts { browser?: BrowserContext; os?: OSContext; device?: DeviceContext; } export interface Breadcrumb { type: string; message: string; timestamp: number; category?: string; data?: Record; level?: EventLevel; } export interface BaseEvent { type: string; level: EventLevel; timestamp: number; release?: string; environment?: string; user?: UserInfo; tags?: Record; extra?: Record; breadcrumbs?: Breadcrumb[]; request?: RequestInfo; contexts?: Contexts; context_id?: string; } export interface ErrorEvent extends BaseEvent { type: 'error'; message: string; exception?: ExceptionInfo; fingerprint?: string; title?: string; } export interface PerformanceEvent extends BaseEvent { type: 'performance'; metric: string; value: number; unit: string; rating?: 'good' | 'needs-improvement' | 'poor'; } export interface NetworkEvent extends BaseEvent { type: 'network'; sub_type: 'fetch' | 'xhr'; method: string; url: string; status_code?: number; duration?: number; request_size?: number; response_size?: number; success: boolean; error?: string; } export interface BehaviorEvent extends BaseEvent { type: 'behavior'; sub_type: 'pv' | 'click' | 'route' | 'scroll' | 'duration'; page_url: string; referrer?: string; properties?: Record; } export interface CountEvent extends BaseEvent { type: 'count'; fingerprint: string; count: number; ts_start: number; ts_end: number; } export type SentryEvent = ErrorEvent | PerformanceEvent | NetworkEvent | BehaviorEvent | CountEvent; export interface DSNInfo { protocol: string; publicKey: string; host: string; projectId: string; } export interface SamplingConfig { rates?: { error?: number; performance?: number; network?: number; behavior?: number; [key: string]: number | undefined; }; } export interface LightConfig { dsn: string; release?: string; environment?: string; enabled?: boolean; debug?: boolean; sampleRate?: number; maxQueueSize?: number; flushInterval?: number; maxRetries?: number; retryDelay?: number; ignoreErrors?: (string | RegExp)[]; ignoreUrls?: (string | RegExp)[]; includePaths?: (string | RegExp)[]; maxBreadcrumbs?: number; beforeSend?: (event: SentryEvent) => SentryEvent | null; user?: UserInfo; plugins?: (LightPlugin | string)[]; contextLevel?: Partial; sampling?: SamplingConfig; [pluginName: string]: unknown; } export interface LightPlugin { name: string; version: string; setup(client: LightClient): void; destroy?(): void; beforeReport?(event: SentryEvent): SentryEvent | null; afterReport?(event: SentryEvent): void; } export interface LightClient { config: LightConfig; dsn: DSNInfo; on(event: string, handler: (...args: unknown[]) => void): void; off(event: string, handler: (...args: unknown[]) => void): void; emit(event: string, ...args: unknown[]): void; captureException(error: Error | unknown): void; captureMessage(message: string, level?: EventLevel): void; captureEvent(event: Partial & { type: string; }): void; setUser(user: UserInfo | null): void; setTag(key: string, value: string): void; setTags(tags: Record): void; setExtra(key: string, value: unknown): void; addBreadcrumb(breadcrumb: Omit): void; flush(): Promise; disable(): void; enable(): void; use(plugin: LightPlugin): void; init(): void; destroy(): void; }