import { F as FeedbackApi } from './types-CfSqqfkw.js'; import './types-CRbb2Pp0.js'; /** * withTelemetryStream — opt-in module that streams already-captured browser * events (JS errors, failed network requests, web-vitals) to the backend * telemetry ingestion endpoint in batches. * * Same opt-in wrapper pattern as withErrorTracking / withWebVitals / withReplay. * Host apps that want curated-feedback-only simply don't import this. * * Design notes: * - Installs its own lightweight capture listeners (same events as the ring * buffers in capture/) rather than reading snapshots from them. The ring * buffer API is internal to core.ts with no public subscription hook, so * the correct pattern — established by withErrorTracking — is to install * independent listeners that observe the same global surfaces. * - Network capture: only failed requests (status 0 or >=400) are emitted to * keep volume low. Successful requests are high-cardinality noise in a * telemetry stream. * - Scrubbing: error messages/stacks are scrubbed via the shared * scrubCredentials helper. URLs are sanitized via sanitizeUrl (same helper * the ring-buffer patch uses). Data entering this module's buffers is already * scrubbed at the source by the global patches; we add a second pass for the * events we capture independently. * - Flush: periodic (default 10 s) + visibilitychange→hidden/pagehide via * keepalive fetch. We do NOT use navigator.sendBeacon — it can't carry the * Authorization header, and the backend authenticates the pk_proj_ key only * from `Authorization: Bearer`. The key never travels in a query string. * - Per-flush cap (default 50 events) prevents a single bad page from * flooding the backend on flush. * - No rrweb / session replay. Events only. */ interface TelemetryStreamOptions { /** Kill switch without removing the import. Default `true`. */ enabled?: boolean; /** Flush interval in ms. Default 10 000 (10 s). */ flushIntervalMs?: number; /** Max events per flush. Older events are dropped first. Default 50. */ maxBatchSize?: number; /** * Custom URL sanitizer for network event URLs. Defaults to the same * sanitizeUrl used by the widget's network ring-buffer patch. */ sanitizeUrl?: (url: string) => string; } interface TelemetryStreamConfig { endpoint: string; apiKey: string; } declare function withTelemetryStream(fb: FeedbackApi, config: TelemetryStreamConfig, options?: TelemetryStreamOptions): FeedbackApi; export { type TelemetryStreamConfig, type TelemetryStreamOptions, withTelemetryStream };