/** * Event Buffer * * Buffers events until fresh remote config is resolved. Ensures every * event respects current project config. * * Ready condition: * - _configReady: fresh /api/d response applied (or fetch failed) * * When config IS ready, queued events are filtered against the resolved * analytics toggles (capture_pageview, capture_pageleave, etc.) and * dropped if disabled — mirroring the server-side $config_pending filter. * * Events that flush before config is ready (safety timeout, page unload) * are tagged with $config_pending for server-side filtering. */ import type { TrackingEvent, VTiltConfig } from "../types"; export interface BufferedEvent { name: string; url: string; event: TrackingEvent; } export interface EventBufferHost { sendRequest(url: string, event: TrackingEvent): void; requestQueue: { flush(): void; }; getConfig(): VTiltConfig; } export declare class EventBuffer { private _host; private readonly _queue; private _ready; private _configReady; private _safetyTimer; constructor(host: EventBufferHost); /** * Push an event into the buffer. * If ready, processes inline (pass-through). Otherwise queues. */ push(item: BufferedEvent): void; /** Signal that fresh remote config has been loaded (or fetch failed). */ markConfigReady(): void; /** * Force-flush all buffered events (page unload / safety timeout). * Tags events with $config_pending when config hasn't loaded. */ forceFlush(): void; private _checkReady; private _tryFlush; private _flush; private _process; /** * Check whether the event should be dropped based on resolved config. * Mirrors the server-side checkProjectConfigFilter logic. */ private _isDisabledByConfig; private _tagConfigPending; private _clearSafetyTimer; }