import type { EvaluationSummaryAggregator } from "./evaluationSummaryAggregator"; import type TelemetryUploader from "./uploader"; import { type TelemetryLogger } from "./transportQueue"; /** Resolved transport settings (see the `telemetry*` options on InitOptions). */ export interface TelemetryReporterConfig { flushIntervalMs: number; timeoutMs: number; maxRetainedBatches: number; maxRetainedBytes: number; maxRetainedAgeMs: number; maxEvaluationSummaries: number; } /** A positive finite number, else the default. */ export declare function positiveOr(value: number | undefined, fallback: number): number; /** * Resolve the `telemetry*` init options against the browser defaults. Invalid * values (non-finite, <= 0) fall back to the default. */ export declare function resolveTelemetryConfig(opts: { flushIntervalMs?: number; timeoutMs?: number; maxRetainedBatches?: number; maxRetainedBytes?: number; maxRetainedAgeMs?: number; maxEvaluationSummaries?: number; }): TelemetryReporterConfig; /** * TelemetryReporter drains the evaluation-summary aggregator once per tick * and hands the serialized window to a {@link TelemetryTransportQueue}, which * retains failed batches byte-for-byte (in memory, for the life of the page) * and resends them under the transport policy (qfg-y8je.11: 30s ticks, one * POST in flight, 30s floor after a failure, Retry-After, 5 batches / 512KB / * 5 min retention, disable on 401/403/404, keepalive final flush on pagehide). * Mirrors sdk-node's src/telemetry/reporter.ts. */ export declare class TelemetryReporter { readonly config: TelemetryReporterConfig; private aggregator; private logger; private queue; private timer; private closed; private closing; private pendingTick; constructor(args: { uploader: TelemetryUploader; aggregator: EvaluationSummaryAggregator; logger: TelemetryLogger; config: TelemetryReporterConfig; }); /** * Start the tick timer. Fixed cadence: tick k fires at k * flushIntervalMs * regardless of how long a drain takes. */ start(): void; private schedule; private clearTimer; /** * One tick of the contract's model: skip if closed, disabled or a POST is in * flight (P2; the live window keeps aggregating); expire aged batches; skip * if the 30s floor or Retry-After has not elapsed; serialize the live window * once and append it; drain oldest-first. Never rejects. */ tick(): Promise; private runTick; /** Resolves when no tick (and so no POST) is running. */ whenIdle(): Promise; /** * Send the live window now (public `Quonfig.flush()`). Waits for an * in-flight POST first (bounded by the request timeout), then runs a tick, * so after a failure it respects the 30s floor and Retry-After. Never throws. */ flush(): Promise; /** * pagehide (P8, browser): send the live window once with `keepalive` and a * 2s deadline. Returns synchronously: the POST is fire-and-forget, so the * handler never blocks unload. The retained queue is not drained (a page * being unloaded is no time to resend an outage backlog); if the page comes * back from the back/forward cache, ticking simply continues. */ onPageHide(): void; /** * Shutdown (public `Quonfig.close()`): stop the timer, abort any in-flight * POST, then give the live window one keepalive POST with a 2s deadline. The * retained queue is not drained. Idempotent; never throws; leaves no timer * armed once it resolves. */ close(): Promise; /** Stop the timer and abort any in-flight POST without a final flush. */ stop(): void; /** Test-visible state (the contract's retained_count / retained_bytes / telemetry_enabled). */ debugState(): { retainedCount: number; retainedBytes: number; enabled: boolean; inFlight: boolean; timerActive: boolean; }; private onDisabled; }