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; /** * Identified user ID to associate with sessions * When provided during initialization, all sessions will be linked to this user * @default undefined */ userId?: string; /** * Organization ID to associate with the identified user * Only used when userId is also provided * @default undefined */ organizationId?: string; /** * Additional attributes/metadata about the identified user * Only used when userId is also provided * @default {} */ userAttributes?: Record; } /** * 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; /** * Identified user ID linked to this session (if available) */ user_id?: string; /** * Organization ID associated with the user (if available) */ organization_id?: string; /** * User attributes/metadata (if available) */ user_attributes?: Record; /** * 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 userId; private organizationId; private userAttributes; private events; private pendingEvents; private stopFn; private eventsInterval; private metrics; private idGenerationInProgress; private productionEndpoint; private debugEndpoint; private productionIdentifyEndpoint; private debugIdentifyEndpoint; 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; /** * Get the identified user ID, if available */ getUserId(): string | null; /** * Get the organization ID, if available */ getOrganizationId(): string | null; /** * Get the user attributes, if available */ getUserAttributes(): Record | null; /** * Add custom metadata to the session */ addMetadata(metadata: Record): void; /** * Identify the current session with a user ID * This links the anonymous session to an identified user * * @param userId - The ID of the identified user * @param organizationId - Optional organization ID to associate with the user * @param userAttributes - Optional user metadata/attributes * @returns Promise that resolves when identification is complete */ identify(userId: string, organizationId?: string, userAttributes?: Record): Promise; /** * Send events to the Sessionable API */ private sendEvents; /** * Update session metrics */ private updateMetrics; /** * Initialize the anonymous ID - either from localStorage or by generating a new one * * This is asynchronous when useDeviceId is true and we need to generate a new ID. * When the ID is ready, it will process any pending events. */ private initializeAnonymousId; /** * Create a human-readable ID */ private createHumanReadableId; /** * Set the anonymous ID and process any pending events */ private setAnonymousId; /** * Notify listeners that the ID is ready */ private notifyIdReady; /** * Process any events that were waiting for the ID to be generated */ private processPendingEvents; /** * Generate a device-specific ID using FingerprintJS * Maps the fingerprint to a deterministic human-readable ID format * Format: "adverb-adjective-adjective-noun-verb-number" */ private generateDeviceId; /** * Creates a deterministic human-readable ID from a fingerprint * Uses vocabulary from human-id package but with deterministic selection */ private createDeterministicId; } export { Sessionable as S, type SessionableOptions as a, type SessionMetrics as b, type SessionPayload as c, type SessionRecorderProps as d };