import { Result } from "@stackframe/stack-shared/dist/utils/results";
//#region src/lib/stack-app/apps/implementations/session-replay.d.ts
type AnalyticsReplayOptions = {
/**
* Whether session replays are enabled.
*
* @default false
*/
enabled?: boolean;
/**
* Whether to mask the content of all `` elements.
*
* @default true
*/
maskAllInputs?: boolean;
/**
* A CSS class name or RegExp. Elements with a matching class will be blocked
* (replaced with a placeholder in the recording).
*
* @default undefined
*/
blockClass?: string | RegExp;
/**
* A CSS selector string. Elements matching this selector will be blocked
* (replaced with a placeholder in the recording).
*
* @default undefined
*/
blockSelector?: string;
};
type AnalyticsOptions = {
/**
* Options for session replay recording. Replays are disabled by default;
* set `enabled: true` to opt in.
*/
replays?: AnalyticsReplayOptions;
};
/**
* Converts AnalyticsOptions to a JSON-safe representation.
* RegExp blockClass values are serialized as `{ __regexp, __flags }` objects.
* The return type is AnalyticsOptions to keep StackClientAppJson simple;
* the actual runtime value is JSON-safe.
*/
declare function analyticsOptionsToJson(options: AnalyticsOptions | undefined): AnalyticsOptions | undefined;
/**
* Reconstructs AnalyticsOptions from a JSON-deserialized value.
* Converts `{ __regexp, __flags }` objects back to RegExp instances.
*/
declare function analyticsOptionsFromJson(json: AnalyticsOptions | undefined): AnalyticsOptions | undefined;
type StoredSession = {
session_id: string;
created_at_ms: number;
last_activity_ms: number;
};
declare function safeParseStoredSession(raw: string | null): StoredSession | null;
declare function makeStorageKey(projectId: string): string;
declare function generateUuid(): string;
declare function getOrRotateSession(options: {
key: string;
nowMs: number;
}): StoredSession;
type SessionRecorderDeps = {
projectId: string;
sendBatch: (body: string, options: {
keepalive: boolean;
}) => Promise>;
};
declare class SessionRecorder {
private _started;
private _cancelled;
private _stopRecording;
private _detachListeners;
private _flushTimer;
private _events;
private _approxBytes;
private _lastPersistActivity;
private _recording;
private _rrwebModule;
private _lastBrowserSessionId;
private _takingSnapshot;
private _flushInProgress;
private readonly _sessionReplaySegmentId;
private readonly _storageKey;
private readonly _deps;
private readonly _replayOptions;
constructor(deps: SessionRecorderDeps, replayOptions: AnalyticsReplayOptions);
/**
* Starts recording. Idempotent — calling multiple times is safe.
*/
start(): void;
stop(): void;
clearBuffer(): void;
private _persistActivity;
private _flush;
private _startRecording;
private _stopCurrentRecording;
private _tick;
}
//#endregion
export { AnalyticsOptions, AnalyticsReplayOptions, SessionRecorder, SessionRecorderDeps, StoredSession, analyticsOptionsFromJson, analyticsOptionsToJson, generateUuid, getOrRotateSession, makeStorageKey, safeParseStoredSession };
//# sourceMappingURL=session-replay.d.ts.map