/**
 * Names of signals the SDK emits. Add new entries as the taxonomy grows.
 * Counter signals are unbounded integers; histogram signals are millisecond floats.
 */
export type CounterSignal = 'bootstrap_ok' | 'bootstrap_errors' | 'flag_fetch_count' | 'flag_fetch_errors' | 'longtasks_self_count'
/** Cumulative blocking time (ms) from long tasks attributed to the SDK
 *  script. Counter rather than histogram so HogQL sum() across windows
 *  gives the total — which is what alerts/dashboards actually want. */
 | 'longtasks_self_blocking_ms';
/**
 * Histogram signals. Web vitals are field-RUM measurements from the customer's
 * browser, not synthetic Lighthouse audits — same metrics Lighthouse reports
 * as "Core Web Vitals from CrUX," but measured live.
 *
 * - lcp_ms       — Largest Contentful Paint
 * - inp_ms       — Interaction to Next Paint
 * - cls_score    — Cumulative Layout Shift (unitless 0..1+)
 * - fcp_ms       — First Contentful Paint
 * - ttfb_ms      — Time to First Byte
 */
export type HistogramSignal = 'flag_fetch_latency_ms' | 'lcp_ms' | 'inp_ms' | 'cls_score' | 'fcp_ms' | 'ttfb_ms';
/**
 * Resource attributes for the OTLP payload. The static fields are set at
 * reporter init; the dynamic fields are resolved at flush time via runtime
 * binding (see HealthReporter.bindRuntime).
 */
export interface ReporterResource {
    serviceName: 'syntro-runtime-sdk';
    serviceVersion: string;
    /** Customer's PostHog project SDK key. Identifies which PostHog project
     *  this telemetry corresponds to. The exporter joins on this. */
    posthogKey: string;
    /** Page origin where the SDK booted (e.g. https://customer.com). */
    hostOrigin: string;
}
/**
 * Runtime-derived attributes resolved at flush time. The HealthReporter
 * binds resolvers via bindRuntime() once the canvas/telemetry are ready.
 * Before bindRuntime is called, defaults apply.
 */
export interface ReporterRuntimeBinding {
    /** PostHog session ID. Returns empty string before telemetry is ready. */
    getSessionId(): string;
    /** Surface context snapshot. Returns null before context is ready. */
    getSurface(): {
        type: 'web' | 'telegram' | 'mcp-app';
        host: string;
        device: 'mobile' | 'tablet' | 'desktop';
        mode: 'agent' | 'mobile' | 'desktop';
    } | null;
}
/**
 * In-memory aggregate produced at flush time. Resource is the snapshot
 * of static + runtime-bound fields at flush moment.
 */
export interface FlushPayload {
    resource: ReporterResource & {
        sessionId: string;
        surfaceType: 'web' | 'telegram' | 'mcp-app' | 'unknown';
        surfaceHost: string;
        surfaceDevice: 'mobile' | 'tablet' | 'desktop' | 'unknown';
        surfaceMode: 'agent' | 'mobile' | 'desktop' | 'unknown';
    };
    windowSeconds: number;
    windowStartUnixMs: number;
    counters: Partial<Record<CounterSignal, number>>;
    /** Histograms expose count, p50, p95 — raw samples are NOT shipped. */
    histograms: Partial<Record<HistogramSignal, {
        count: number;
        p50: number;
        p95: number;
    }>>;
}
/** Configuration for the reporter singleton. */
export interface HealthReporterConfig {
    resource: ReporterResource;
    flushIntervalMs?: number;
    emit: (payload: FlushPayload) => Promise<void>;
}
