import { ILogger } from '@amplitude/analytics-core'; import { LoggingConfig, SessionReplayJoinedConfig, SessionReplayJoinedConfigGenerator } from './config/types'; import { CustomRRwebEvent } from './constants'; import { EventCompressor } from './events/event-compressor'; import { EventsManagerWithBeacon } from './events/events-manager'; import { AmplitudeSessionReplay, SessionReplayEventsManager as AmplitudeSessionReplayEventsManager, SessionIdentifiers as ISessionIdentifiers, SessionReplayOptions, SessionReplayTargetingInput } from './typings/session-replay'; import type { RecordFunction } from './utils/rrweb'; type PageLeaveFn = (e: PageTransitionEvent | Event) => void; export declare class SessionReplay implements AmplitudeSessionReplay { name: string; config: SessionReplayJoinedConfig | undefined; joinedConfigGenerator: SessionReplayJoinedConfigGenerator | undefined; identifiers: ISessionIdentifiers | undefined; eventsManager?: AmplitudeSessionReplayEventsManager<'replay' | 'interaction', string>; loggerProvider: ILogger; recordCancelCallback: ReturnType | null; eventCount: number; eventCompressor: EventCompressor | undefined; sessionTargetingMatch: boolean; private lastTargetingParams?; private lastShouldRecordDecision?; pageLeaveFns: PageLeaveFn[]; sessionStartTime: number | undefined; rrwebEventManager: EventsManagerWithBeacon<'replay'> | undefined; /** * Count of sendEvents() calls suppressed by the min-session-duration gate for the * current session. Drives the REPLAY_GATE_DECISION rrweb event on first send-after-pass. */ private suppressedSendCount; /** True once REPLAY_GATE_DECISION has been emitted for the current session. */ private hasEmittedGateDecision; private scrollHook?; private clickHandler?; private networkObservers?; private metadata; private recordFunction; private recordEventsInFlight; private pendingEmitEvents; /** Current page URL, kept in sync with SPA navigations for URL-based masking */ private currentPageUrl; private recordEventsPendingShouldLogMetadata; /** Cleanup for URL change listener used to re-evaluate targeting on SPA route changes */ private urlChangeCleanup; private crossOriginIframeCoordinator; private crossOriginParentSignalCleanup; /** Monotonic counter to ignore stale URL-change targeting results */ private latestUrlChangeTargetingEvaluationId; constructor(); init(apiKey: string, options: SessionReplayOptions): import("@amplitude/analytics-core").AmplitudeReturn; private teardownEventListeners; /** * Subscribes to SPA URL changes via the URL tracking plugin. Always keeps * `currentPageUrl` in sync (needed for URL-based masking). When a targeting * config is present it also re-evaluates targeting on every navigation. */ private setupUrlChangeListener; /** * Single source of truth for the min_session_duration_ms gate. Returns true when the * current session has not yet reached the configured threshold (and we have both a * configured value and a recorded start time). Returns false when there's no * threshold, no recorded start time, or the threshold has been met — i.e. it * answers "should this batch be suppressed?". * * Centralizing the check means future changes (clock-skew tolerance, switching to * performance.now(), etc.) are one-line edits. */ private isBelowMinSessionDuration; private getCurrentPageForTargeting; protected _init(apiKey: string, options: SessionReplayOptions): Promise; setSessionId(sessionId: string | number, deviceId?: string): import("@amplitude/analytics-core").AmplitudeReturn; asyncSetSessionId(sessionId: string | number, deviceId?: string, options?: { userProperties?: { [key: string]: any; }; }): Promise; getSessionReplayProperties(): { [key: string]: string | null; }; blurListener: () => void; focusListener: () => void; /** * This is an instance member so that if init is called multiple times * it doesn't add another listener to the page leave event. This is to * prevent duplicate listener actions from firing. */ private pageLeaveListener; evaluateTargetingAndCapture: (targetingParams: SessionReplayTargetingInput, isInit?: boolean, forceRestart?: boolean, forceTargetingReevaluation?: boolean) => Promise; sendEvents(sessionId?: string | number): void; initialize(shouldSendStoredEvents?: boolean): Promise; shouldOptOut(): boolean | undefined; getShouldRecord(): boolean; getBlockSelectors(): string | string[] | undefined; getMaskTextSelectors(): string | undefined; getRecordingPlugins(loggingConfig: LoggingConfig | undefined): Promise<(import("@amplitude/rrweb-types").RecordPlugin | import("@amplitude/rrweb-types").RecordPlugin)[] | undefined>; private getRecordFunction; recordEvents(shouldLogMetadata?: boolean): Promise; private _recordEvents; private buildRRWebRecordOptions; private _recordEventsInChildMode; addCustomRRWebEvent: (eventName: CustomRRwebEvent, eventData?: { [key: string]: any; }, addStorageInfo?: boolean) => Promise; stopRecordingEvents: () => void; getDeviceId(): string | undefined; getSessionId(): string | number | undefined; flush(useRetry?: boolean): Promise; shutdown(): void; private mapSDKType; private setMetadata; private initializeNetworkObservers; } export {}; //# sourceMappingURL=session-replay.d.ts.map