/** * Session Manager - Handles session_id and window_id * * Uses shared StorageManager for consistent storage operations. * * Session ID: Unique per user session, expires after 30 minutes of inactivity * Window ID: Unique per browser tab, persists across page reloads */ import { PersistenceMethod } from "./types"; export declare class SessionManager { private storage; private _windowId; private _isNewSession; constructor(storageMethod?: PersistenceMethod, cross_subdomain?: boolean); /** * Hydrate window ID from sessionStorage. * Called by VTilt._boot() once the browser environment is ready. */ hydrateFromStorage(): void; /** * Get session ID (always returns a value, generates if needed) */ getSessionId(): string; /** * Set session ID in storage * Extends TTL if session_id exists, generates new one if not */ setSessionId(): string; /** * Reset session ID (generates new session on reset) */ resetSessionId(): void; /** * Returns true if the current session was just started (new session ID generated * because the session cookie expired or didn't exist). Resets after first call. * Matches GA4's _ss=1 semantics. */ consumeSessionStart(): boolean; /** * Get session ID from storage (raw, can return null) * Cookie Max-Age handles expiration automatically */ private _getSessionIdRaw; /** * Store session ID * Uses plain string format - cookie Max-Age handles expiration */ private _storeSessionId; /** * Clear session ID from storage */ private _clearSessionId; /** * When a tab stays open for longer than the session timeout, rotate the * session even if a system event (e.g. $pageleave on background) recently * refreshed the cookie TTL. */ private _rotateSessionIfExpired; private _bootstrapSessionActivityFromStorage; private _readSessionActivityMs; private _touchSessionActivity; private _clearSessionActivity; /** * Get window ID * Window ID is unique per browser tab/window and persists across page reloads * Always returns a window_id (generates one if not set) */ getWindowId(): string; /** * Set window ID * Stores in sessionStorage which is unique per tab */ private _setWindowId; /** * Initialize window ID * Detects tab duplication and handles window_id persistence */ private _initializeWindowId; /** * Listen to window unload to clear primary window flag * This helps distinguish between page reloads and tab duplication */ private _listenToUnload; /** * Update storage method at runtime */ updateStorageMethod(method: PersistenceMethod, cross_subdomain?: boolean): void; }