@bentolabs/sdk
Version:
BentoLabs SDK for user session recording and analytics
92 lines (91 loc) • 2.13 kB
TypeScript
interface SDKConfig {
apiKey: string;
endpoint: string;
debug: boolean;
batchSize: number;
batchInterval: number;
enableRecording: boolean;
maxRetries: number;
baseRetryDelay: number;
}
interface SDKOptions {
endpoint?: string;
debug?: boolean;
batchSize?: number;
batchInterval?: number;
enableRecording?: boolean;
maxRetries?: number;
baseRetryDelay?: number;
}
export declare class BentoLabsSDK {
private config;
private sessionId;
private events;
private isRecording;
private batchTimer;
private retryTimer;
private stopRecording;
constructor();
/**
* Initialize the BentoLabs SDK
* @param apiKey - Your API key for authentication
* @param options - Optional configuration options
*/
init(apiKey: string, options?: SDKOptions): void;
/**
* Generate a unique session ID with 'sess_' prefix
*/
private generateSessionId;
/**
* Generate a simple UUID v4
*/
private generateUUID;
/**
* Start recording user interactions
*/
private startRecording;
/**
* Start batching events for transmission
*/
private startBatching;
/**
* Add an event to the events array
*/
private addEvent;
/**
* Send batched events to the API with exponential backoff retry
*/
private sendBatch;
/**
* Schedule retry attempts for failed events
*/
private scheduleRetry;
/**
* Stop recording and clean up resources
*/
stop(): void;
/**
* Get current session ID
*/
getSessionId(): string;
/**
* Check if recording is active
*/
isRecordingActive(): boolean;
/**
* Get current configuration (without exposing sensitive data)
*/
getConfig(): Omit<SDKConfig, 'apiKey'> & {
apiKey: string;
};
/**
* Get current event queue length
*/
getEventQueueLength(): number;
/**
* Manually trigger a batch send
*/
flushEvents(): Promise<void>;
}
declare const _default: BentoLabsSDK;
export default _default;