import { eventWithTime } from 'rrweb'; /** * Configuration options for the Sessionable SDK */ interface SessionableOptions { /** * Your Sessionable API key */ apiKey: string; /** * Start recording automatically after initialization * @default false */ autoStart?: boolean; /** * Custom metadata to include with each session * @default {} */ metadata?: Record; /** * Whether to mask input fields (passwords, text inputs, etc.) * @default false */ maskInputs?: boolean; /** * CSS selector for text content that should be masked * When provided, any text matching this selector will be masked in recordings * Example: '.sensitive-data, [data-mask]' * @default undefined */ maskTextSelector?: string; /** * Debug mode - when true, uses localhost:5173 as API endpoint * Use this for local development and testing * @default false */ debug?: boolean; /** * Whether to use device fingerprinting for anonymous user identification * When true, uses FingerprintJS to generate a more stable device ID * When false, uses the current human-readable ID implementation * @default true */ useDeviceId?: boolean; } /** * Session metrics and status information */ interface SessionMetrics { /** * Unique ID for this session */ sessionId: string; /** * Total number of events recorded in this session */ eventsRecorded: number; /** * Number of batches sent to the server */ batchesSent: number; /** * Number of batches successfully uploaded */ batchesSuccessful: number; /** * Current connection status with the API */ connectionStatus: 'connected' | 'disconnected' | 'connecting' | 'error'; /** * Last error message if any */ lastError: string | null; /** * Size of the last batch sent */ lastBatchSize: number; /** * Timestamp of the last successful upload */ lastSuccessfulUpload: Date | null; /** * Timestamp when recording started */ recordingStartTime: Date; /** * Whether recording is currently active */ isRecording: boolean; } /** * Payload sent to the Sessionable API */ interface SessionPayload { /** * Unique ID for this session */ session_id: string; /** * Anonymous user ID associated with this session */ anonymous_id: string; /** * Array of recorded events */ events: eventWithTime[]; /** * Metadata associated with this session */ metadata: Record; } /** * Props for the React SessionRecorder component */ interface SessionRecorderProps extends SessionableOptions { /** * Children components that can access the Sessionable instance * through the useSessionable hook */ children?: React.ReactNode; } /** * Core Sessionable class for session recording */ declare class Sessionable { private options; private anonymousUserId; private events; private stopFn; private eventsInterval; private metrics; private productionEndpoint; private debugEndpoint; private batchSize; private batchInterval; private static readonly ANON_ID_STORAGE_KEY; /** * Creates a new Sessionable instance */ constructor(options: SessionableOptions); /** * Start recording the session */ start(): void; /** * Stop recording the session */ stop(): void; /** * Get current session metrics */ getMetrics(): SessionMetrics; /** * Add custom metadata to the session */ addMetadata(metadata: Record): void; /** * Send events to the Sessionable API */ private sendEvents; /** * Update session metrics */ private updateMetrics; /** * Get existing anonymous ID from local storage or create a new one * * If useDeviceId is true, uses FingerprintJS to generate a stable device ID * and maps it to a human-readable ID. * * If useDeviceId is false, creates human-readable IDs with a number suffix * for high uniqueness. Format example: "happy-blue-cats-dance-quickly-1234" */ private getOrCreateAnonymousId; /** * Generate a device-specific ID using FingerprintJS * Maps the fingerprint hash to a human-readable ID format using the human-id package */ private generateDeviceId; } export { Sessionable as S, type SessionableOptions as a, type SessionMetrics as b, type SessionPayload as c, type SessionRecorderProps as d };