/** * Event Capture Manager * * Handles event capture, payload enrichment, rate limiting, * and initial pageview capture. */ import { VTiltConfig, EventPayload, TrackingEvent } from "../types"; /** * Interface for the VTilt instance methods needed by CaptureManager. * Using a minimal interface avoids circular dependency. */ export interface CaptureHost { getConfig(): VTiltConfig; sessionManager: { setSessionId(): void; getSessionId(): string | null; getWindowId(): string; consumeSessionStart(): boolean; }; userManager: { getAnonymousId(): string; getDistinctId(): string | null; getUserProperties(): Record; consumeFirstVisit(): boolean; }; consentManager?: { hasConsent(): boolean; getConsentProperties(): Record; }; rateLimiter: { shouldAllowEvent(): boolean; }; sendRequest(url: string, event: TrackingEvent): void; bufferEvent(name: string, url: string, event: TrackingEvent): void; buildUrl(): string; buildEndpointUrl(path: string): string; /** Keep session recording batch $current_url aligned with analytics pageviews. */ notifyRecordingPageUrl?(href: string): void; } export interface CaptureOptions { skip_client_rate_limiting?: boolean; /** When true, do not add inter-capture engagement_time_msec (e.g. $pageleave uses dwell). */ skip_engagement?: boolean; /** When true, read the session id without extending the 30-minute activity window. */ skip_session_refresh?: boolean; } export declare class CaptureManager { private _host; private _initial_pageview_captured; private _visibility_state_listener; private _vt_person_id; private readonly _pageLifecycle; constructor(host: CaptureHost); /** Set the vt person ID from URL parameter */ setVtPersonId(id: string | null): void; /** * Capture an event. * Automatically adds common properties ($current_url, $host, etc.) * * @param name - Event name (e.g., '$pageview', 'button_clicked') * @param payload - Event properties * @param options - Capture options */ capture(name: string, payload: EventPayload, options?: CaptureOptions): void; /** * Internal capture that bypasses rate limiting. * Used for system events like rate limit warnings. */ captureInternal(name: string, payload: EventPayload): void; /** * Capture initial pageview with visibility check. * Waits for page to become visible before capturing. */ captureInitialPageview(): void; tryCapturePageleave(reason: string, extraProps?: EventPayload): void; resetPageleaveDedupe(): void; private _isDebugMode; /** * Build enriched event payload with all common properties. */ private _buildEventPayload; }