@brainfish-ai/web-tracker
Version:
Brainfish Tracker for Web
35 lines (34 loc) • 1.31 kB
TypeScript
export type SessionCallbacks = {
takeFullSnapshot?: () => void;
};
/**
* Manages session state and transitions for the tracker
* This mostly concerns session recording events as the analytics events are considered the 'master' session
* and the session recording needs to know the session state from the backend which is initiated by analytic events
*/
export declare class SessionManager {
private static instance;
private sessionId;
private lastScreenViewEventTime;
isIdle: boolean;
static getInstance(): SessionManager;
/**
* Determines the current session state based on previous and current session IDs
*/
private determineSessionState;
/**
* Handles session state transitions and triggers appropriate actions
*/
private handleSessionTransition;
/**
* Updates the session state based on a new session ID
* @param newSessionId The new session ID from the server
* @param callbacks Optional callbacks for session state changes
*/
updateSession(newSessionId: string | null, callbacks?: SessionCallbacks): void;
updateLastScreenViewEventTime(): void;
updateIdleStatus(isIdle: boolean): void;
getLastScreenViewEventTime(): number;
getCurrentSessionId(): string | null;
}
export default SessionManager;