UNPKG

rusty-replay

Version:

Lightweight error tracking and replay system for React apps using rrweb and Rust-powered backend integration.

90 lines (81 loc) 2.56 kB
import { eventWithTime } from '@rrweb/types'; import { WebTracerProvider } from '@opentelemetry/sdk-trace-web'; interface AdditionalInfo { pageUrl: string; request: { url: string; method: string; headers: Record<string, string>; }; response: { data: { message: string; errorCode: string; }; status: number; statusText: string; }; } interface BatchedEvent { id: string; timestamp: string; message: string; stacktrace: string; replay: string | null; environment: string; browser: string; os: string; userAgent: string; userId?: number; additionalInfo?: Partial<AdditionalInfo>; appVersion: string; apiKey: string; } interface BatcherOptions { endpoint: string; apiKey: string; flushIntervalMs?: number; maxBufferSize?: number; } interface InitOptions { endpoint: string; apiKey: string; flushIntervalMs?: number; maxBufferSize?: number; beforeErrorSec?: number; } declare function init(options: InitOptions): void; declare function captureException(error: Error, additionalInfo?: Partial<AdditionalInfo>, userId?: number): string; declare function setupGlobalErrorHandler(): void; declare function startRecording(): void; declare function getRecordedEvents(beforeErrorSec?: number, errorTime?: number, source?: eventWithTime[]): eventWithTime[]; declare function getBrowserInfo(): { browser: string; os: string; userAgent: string; }; declare function getEnvironment(): 'development' | 'staging' | 'production'; declare class ErrorBatcher { private opts; private queue; private isFlushing; private flushTimer; private readonly apiKey; constructor(opts: BatcherOptions); getApiKey(): string; capture(evt: Omit<BatchedEvent, 'id' | 'timestamp'>): string; private flush; private flushOnUnload; private makeId; destroy(): void; } declare function decompressFromBase64(base64: string): any[]; interface OtelConfig { serviceName?: string; endpoint?: string; isSyntheticRequest?: boolean; scheduledDelayMillis?: number; customHeaders?: Record<string, string>; } declare const initOtel: (config?: OtelConfig) => Promise<WebTracerProvider>; export { type AdditionalInfo, type BatchedEvent, type BatcherOptions, ErrorBatcher, type InitOptions, captureException, decompressFromBase64, getBrowserInfo, getEnvironment, getRecordedEvents, init, initOtel, setupGlobalErrorHandler, startRecording };