import { AmplitudeReturn, ServerZone } from '@amplitude/analytics-core'; import { SessionReplayJoinedConfig, SessionReplayLocalConfig, SessionReplayVersion } from '../config/types'; import { TargetingParameters } from '@amplitude/targeting'; export type StorageData = { totalStorageSize: number; percentOfQuota: number; usageDetails: string; }; export interface DebugInfo extends Partial { config: SessionReplayJoinedConfig; version: string; } export type Events = string[]; export type StoreType = 'memory' | 'idb'; export type EventType = 'replay' | 'interaction'; export type ConsoleLogLevel = 'info' | 'log' | 'warn' | 'error'; export interface SessionReplayDestinationSessionMetadata { type: EventType; sessionId: string | number; deviceId: string | undefined; version?: SessionReplayVersion; } export type SessionReplayDestination = { events: Events; flushMaxRetries?: number; apiKey?: string; sampleRate: number; serverZone?: keyof typeof ServerZone; onComplete: () => Promise; } & SessionReplayDestinationSessionMetadata; export interface SessionReplayDestinationContext extends SessionReplayDestination { attempts: number; timeout: number; } export interface SendingSequencesReturn { sequenceId: KeyType; sessionId: string | number; events: Events; } /** * This interface is not guaranteed to be stable, yet. */ export interface EventsStore { getSequencesToSend(): Promise[] | undefined>; /** * Moves current sequence of events to long term storage and resets short term storage. */ storeCurrentSequence(sessionId: string | number): Promise | undefined>; /** * Adds events to the current IDB sequence. Returns events that should be * sent to the track destination right away if should split events is true. */ addEventToCurrentSequence(sessionId: string | number, event: string): Promise | undefined>; /** * Returns the sequence id associated with the events batch. * @returns the new sequence id or undefined if it cannot be determined or on any error. */ storeSendingEvents(sessionId: string | number, events: Events): Promise; /** * Permanently removes the events batch for the session/sequence pair. */ cleanUpSessionEventsStore(sessionId: string | number, sequenceId?: KeyType): Promise; } export interface SessionIdentifiers { /** * Sets an identifier for the device running your application. */ deviceId?: string; /** * Sets an identifier for the users current session. The value must be in milliseconds since epoch (Unix Timestamp). */ sessionId?: string | number; sessionReplayId?: string; } export type SessionReplayOptions = Omit, 'apiKey'>; export interface AmplitudeSessionReplay { init: (apiKey: string, options: SessionReplayOptions) => AmplitudeReturn; setSessionId: (sessionId: string | number, deviceId?: string) => AmplitudeReturn; getSessionId: () => string | number | undefined; getSessionReplayProperties: () => { [key: string]: boolean | string | null; }; evaluateTargetingAndCapture: (targetingParams: Pick, isInit?: boolean, forceRestart?: boolean) => Promise; flush: (useRetry: boolean) => Promise; shutdown: () => void; } export interface SessionReplayTrackDestination { /** * Enqueues events to be sent. */ sendEventsList: (destinationData: SessionReplayDestination) => void; /** * Immediately sends queued events. */ flush: (useRetry: boolean) => Promise; } export type EventsManagerWithType = { name: EventType; manager: SessionReplayEventsManager; }; export interface SessionReplayEventsManager { /** * For each sequence stored in the long term indexed DB send immediately to the track destination. */ sendStoredEvents({ deviceId }: { deviceId: string; }): Promise; /** * Adds an event to the short term storage. If should split based on size or last sent, then send immediately. */ addEvent({ sessionId, event, deviceId, }: { sessionId: string | number; event: { type: Type; data: Event; }; deviceId: string; }): void; /** * Move events in short term storage to long term storage and send immediately to the track destination. */ sendCurrentSequenceEvents({ sessionId, deviceId }: { sessionId: string | number; deviceId: string; }): void; /** * Flush the track destination queue immediately. This should invoke sends for all the events in the queue. */ flush(useRetry?: boolean): Promise; } //# sourceMappingURL=session-replay.d.ts.map