UNPKG

@amplitude/session-replay-react-native

Version:
128 lines 4.26 kB
import { SessionReplayConfig } from './session-replay-config'; import { createSessionReplayLogger } from './logger'; /** * Configure the SDK and begin collecting replays. * This function must be called before any other session replay operations. * * @param config - Configuration object containing API key, device ID, session ID, and other options * @returns Promise that resolves when initialization is complete * @throws Error if initialization fails * * @example * ```typescript * await init({ * apiKey: 'YOUR_API_KEY', * deviceId: 'user-device-id', * sessionId: Date.now(), * sampleRate: 0.1 * }); * ``` */ export declare function init(config: SessionReplayConfig): Promise<void>; /** * Call whenever the session ID changes. * The Session ID you pass to the SDK must match the Session ID sent as event properties to Amplitude. * * @param sessionId - The new session identifier number * @returns Promise that resolves when the session ID is updated * * @example * ```typescript * await setSessionId(Date.now()); * ``` */ export declare function setSessionId(sessionId: number): Promise<void>; /** * Update the device ID used for session replay tracking. * The Device ID you pass to the SDK must match the Device ID sent as event properties to Amplitude. * * @param deviceId - The device identifier string, or null to clear the device ID * @returns Promise that resolves when the device ID is updated * * @example * ```typescript * await setDeviceId('user-device-id'); * // or clear device ID * await setDeviceId(null); * ``` */ export declare function setDeviceId(deviceId: string | null): Promise<void>; /** * Get the current session identifier from the session replay SDK. * * @returns Promise that resolves to the current session ID number, or null if not initialized * * @example * ```typescript * const sessionId = await getSessionId(); * if (sessionId !== null) { * console.log('Current session ID:', sessionId); * } * ``` */ export declare function getSessionId(): Promise<number | null>; /** * Interface for session replay properties that should be attached to Amplitude events. * These properties help correlate events with session recordings. */ export interface SessionReplayProperties { [key: string]: string | boolean | null; } /** * When you send events to Amplitude, call this function to get the most up-to-date session replay properties for the event. * Collect Session Replay properties to send with other event properties. * * @returns Promise that resolves to an object containing session replay metadata * * @example * ```typescript * const sessionReplayProperties = await getSessionReplayProperties(); * analytics.track('Button Clicked', { * buttonName: 'submit', * ...sessionReplayProperties // Merge session replay properties * }); * ``` */ export declare function getSessionReplayProperties(): Promise<SessionReplayProperties>; /** * Flush any pending session replay data to the server. * Forces immediate upload of recorded session data that may be buffered locally. * * @returns Promise that resolves when the flush operation is complete * * @example * ```typescript * // Flush data before app termination * await flush(); * ``` */ export declare function flush(): Promise<void>; /** * Start session replay recording. * Begins capturing user interactions and screen content for replay. * If autoStart is enabled in the configuration, this is called automatically during initialization. * * @returns Promise that resolves when recording starts * * @example * ```typescript * // Start recording manually if autoStart is false * await start(); * ``` */ export declare function start(): Promise<void>; /** * Stop session replay recording. * Ends the current recording session and processes any captured data. * * @returns Promise that resolves when recording stops * * @example * ```typescript * // Stop recording when user logs out or app goes to background * await stop(); * ``` */ export declare function stop(): Promise<void>; export declare function privateInit(config: SessionReplayConfig, newLogger: ReturnType<typeof createSessionReplayLogger>): Promise<void>; //# sourceMappingURL=session-replay.d.ts.map