import { Config } from '../orchestration/config'; import { Page, PageManager } from './PageManager'; import { AppMonitorDetails } from '../dispatch/dataplane'; import { RecordEvent } from '../plugins/types'; export declare const NIL_UUID = "00000000-0000-0000-0000-000000000000"; export declare const UNKNOWN = "unknown"; export declare const DESKTOP_DEVICE_TYPE = "desktop"; export declare const WEB_PLATFORM_TYPE = "web"; export declare const RUM_SESSION_START = "rum_session_start"; export declare const RUM_SESSION_EXPIRE = "rum_session_expire"; export type Session = { sessionId: string; record: boolean; eventCount: number; page?: Page; }; export type Attributes = { 'aws:releaseId'?: string; browserLanguage: string; browserName?: string; browserVersion?: string; osName?: string; osVersion?: string; deviceType: string; platformType: string; domain: string; [k: string]: string | number | boolean | undefined; }; /** * The session handler handles user id and session id. * * A session is the {user id, session id} tuple which groups events that occur on a single browser over a continuous * period of time. A session begins when no session exists or the last session has expired. If user id does not exist, * session handler will assign a new one and store it in cookie. If session id does not exist or has expired, session * handler will assign a new one and store it in cookie. Session handler detects user interactions and updates session * id expiration time. */ export declare class SessionManager { private pageManager; private appMonitorDetails; private userExpiry; private sessionExpiry; private userId; private session; private config; private recordEvent; private attributes; private sessionCookieName; private isSessionIdManual; private isUserIdManual; constructor(appMonitorDetails: AppMonitorDetails, config: Config, recordEvent: RecordEvent, pageManager: PageManager); /** * Returns true if the session is sampled, false otherwise. */ isSampled(): boolean; /** * Returns the session ID. If no session ID exists, one will be created. */ getSession(): Session; getAttributes(): Attributes; /** * Adds custom session attributes to the session's attributes * * @param sessionAttributes object containing custom attribute data in the form of key, value pairs */ addSessionAttributes(sessionAttributes: { [k: string]: string | number | boolean; }): void; /** * Adopt an externally-minted session ID. Subsequent events use this ID. * Does NOT emit session_start — followers must not duplicate the * leader's session_start. Sampling decision is preserved. * * Engages manual mode for the rest of the instance's lifespan: once a * host has called this, the SDK will not auto-mint a new session ID on * expiry. The host is the sole source of truth for rotation. */ pinSessionId(sessionId: string): void; /** * Begin a new session immediately. Use when the host knows a logical * session boundary has occurred (sign-in, sign-out, kiosk handoff) * and wants the next event to belong to a fresh session. * * Default behavior (no args) mints a fresh UUID, re-rolls sampling, * disengages session manual mode, and emits a session_start event * (subject to suppressSessionStartEvent). Returns the new session ID * for broadcast to follower contexts. * * Optional overrides let a leader hand a pre-chosen ID to the SDK and * rotate the user identity in the same call. `sessionId` adopts that * ID as the new session and engages session manual mode (same * stickiness as pinSessionId). session_start is still emitted — * startSession is the leader-side rotation API; followers should keep * using pinSessionId for silent adoption. `userId` rotates the user * identity (same stickiness as pinUserId). No user_start event exists, * so the rotation is silent regardless. * * Empty-string overrides emit a warn log. An empty `userId` is rejected * (existing user identity preserved); an empty `sessionId` falls back * to minting a fresh session. The rest of the call still proceeds. */ startSession(options?: { sessionId?: string; userId?: string; }): string; getUserId(): string; /** * Adopt an externally-supplied user ID. Subsequent UserDetails payloads * use this ID. Engages manual mode for the rest of the instance's * lifespan: once a host has called this, the host is the source of * truth for the user identity. No event is emitted (there is no * user_start analogue to session_start). */ pinUserId(userId: string): void; incrementSessionEventCount(): void; isLimitExceeded(): boolean; canRecord(): boolean; private initializeUser; private createOrRenewSessionCookie; private createOrRenewUserCookie; private getUserIdCookie; private getSessionFromCookie; private storeSessionAsCookie; private createSession; private adoptSession; private adoptUser; private renewSession; private collectAttributes; /** * Returns true when cookies should be used to store user ID and session ID. */ private useCookies; /** * Returns {@code true} when the session has been selected to be recorded. */ private sample; }