@multiplayer-app/session-recorder-browser
Version:
Multiplayer Fullstack Session Recorder for Browser
191 lines • 6.14 kB
TypeScript
import { Observable } from 'lib0/observable';
import { SessionType, type ISession, type IUserAttributes } from '@multiplayer-app/session-recorder-common';
import { SessionState, SessionRecorderOptions, SessionRecorderEvents } from './types';
import { ISessionRecorder } from './types';
import { NavigationRecorderPublicApi } from './navigation';
export declare class SessionRecorder extends Observable<SessionRecorderEvents> implements ISessionRecorder {
private _configs;
private _apiService;
private _socketService;
private _tracer;
private _recorder;
private _sessionWidget;
private _navigationRecorder;
private _startRequestController;
get navigation(): NavigationRecorderPublicApi;
private _isInitialized;
get isInitialized(): boolean;
private _sessionId;
get sessionId(): string | null;
set sessionId(sessionId: string | null);
private _sessionType;
get sessionType(): SessionType;
set sessionType(sessionType: SessionType);
get continuousRecording(): boolean;
private _sessionState;
get sessionState(): SessionState | null;
set sessionState(state: SessionState | null);
private _session;
get session(): ISession | null;
set session(session: ISession | null);
private _sessionAttributes;
get sessionAttributes(): Record<string, any>;
set sessionAttributes(attributes: Record<string, any> | null);
private _userAttributes;
get userAttributes(): IUserAttributes | null;
set userAttributes(userAttributes: IUserAttributes | null);
/**
* Error message getter and setter
*/
private _error;
get error(): string;
set error(v: string);
/**
* Returns the HTML button element for the session widget's recorder button.
*
* This element is used to control the start/stop recording functionality in the session widget UI.
*
* @returns {HTMLButtonElement | null} The recorder button element from the session widget.
*/
get sessionWidgetButtonElement(): HTMLButtonElement | null;
/**
* Initialize debugger with default or custom configurations
*/
constructor();
/**
* Initialize the session debugger
* @param configs - custom configurations for session debugger
*/
init(configs: SessionRecorderOptions): void;
/**
* Save the continuous recording session
*/
save(): Promise<any>;
/**
* Start a new session
* @param type - the type of session to start
* @param session - the session to start
*/
start(type?: SessionType, session?: ISession): void;
/**
* Stop the current session with an optional comment
* @param comment - user-provided comment to include in session session attributes
*/
stop(comment?: string): Promise<void>;
/**
* Pause the current session
*/
pause(): Promise<void>;
/**
* Resume the current session
*/
resume(): Promise<void>;
/**
* Cancel the current session
*/
cancel(): Promise<void>;
/**
* Set the session attributes
* @param attributes - the attributes to set
*/
setSessionAttributes(attributes: Record<string, any>): void;
/**
* Set the user attributes
* @param userAttributes - the user attributes to set
*/
setUserAttributes(userAttributes: IUserAttributes | null): void;
/**
* Updates the button click handler in the library.
* @param handler - A function that will be invoked when the button is clicked.
* The function receives the click event as its parameter and
* should return `false` to prevent the default button action,
* or `true` (or nothing) to allow it.
*/
set recordingButtonClickHandler(handler: () => boolean | void);
/**
* Capture an exception manually and send it as an error trace.
*/
captureException(error: unknown, errorInfo?: Record<string, any>): void;
/**
* @description Check if session should be started/stopped automatically
* @param {ISession} [sessionPayload]
* @returns {Promise<void>}
*/
checkRemoteContinuousSession(sessionPayload?: Omit<ISession, '_id' | 'shortId'>): Promise<void>;
/**
* Register session widget event listeners for controlling session actions
*/
private _registerWidgetEvents;
/**
* Handle the safe start event
*/
private _handleStart;
/**
* Handle the safe stop event
*/
private _handleStop;
/**
* Handle the safe pause event
*/
private _handlePause;
/**
* Handle the safe resume event
*/
private _handleResume;
/**
* Handle the safe cancel event
*/
private _handleCancel;
/**
* Handle the safe save event
*/
private _handleSave;
/**
* Handle the safe continuous debugging event
*/
private _handleContinuousDebugging;
/**
* Register socket service event listeners
*/
private _registerSocketServiceListeners;
/**
* Create a new session and start it
*/
private _createSessionAndStart;
/**
* Start tracing and recording for the session
*/
private _start;
/**
* Stop tracing and recording for the session
*/
private _stop;
/**
* Pause the session tracing and recording
*/
private _pause;
/**
* Resume the session tracing and recording
*/
private _resume;
private _setupSessionAndStart;
/**
* Set the session ID in localStorage
* @param sessionId - the session ID to set or clear
*/
private _setSession;
private _clearSession;
/**
* Check the operation validity based on the session state and action
* @param action - action being checked ('init', 'start', 'stop', 'cancel', 'pause', 'resume')
*/
private _checkOperation;
private _normalizeError;
private _normalizeErrorInfo;
/**
* Get the session name
* @returns the session name
*/
private _getSessionName;
}
//# sourceMappingURL=session-recorder.d.ts.map