/** * Page context, dwell time, and inter-event engagement for GA4-style metrics. */ import type { EventPayload } from "../types"; import type { VTiltConfig } from "../types"; export interface PageleaveCaptureFn { (name: string, payload: EventPayload, options?: { skip_engagement?: boolean; skip_session_refresh?: boolean; }): void; } /** * Tracks time on current URL and milliseconds since last capture for engagement_time_msec. */ export declare class PageLifecycleTracker { private _pageEnterPerf; /** Null until first engagement-consuming event; then wall clock for next delta */ private _lastCapturePerf; private readonly _bootPerf; private _prevUrl; private _prevPathname; private _prevTitle; /** Dedupe pagehide + visibility hidden for the same page */ private _leaveEmittedForPageKey; /** * Call after a $pageview is sent (initial or SPA) to reset dwell timer and snapshot. */ onAfterPageview(): void; /** * Milliseconds since last capture (or since boot on the first event). Does not advance the clock. */ peekEngagementSinceLastCaptureMs(): number; /** Call after a capture is enqueued so the next peek measures from this point. */ commitCaptureClock(): void; private _pageKey; /** Call when the tab becomes visible again so a later hide can emit another $pageleave. */ clearLeaveDedupe(): void; /** * Fire $pageleave if enabled and not already emitted for this page. */ tryCapturePageleave(config: VTiltConfig, capture: PageleaveCaptureFn, reason: string, extraProps?: EventPayload): void; }