/** * * Copyright 2020-2026 Splunk Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import { ExternalSessionMetadata } from '../../types/external-session-metadata'; import { StorageManager } from '../storage'; import { SessionState } from './session-state'; type SessionStateChange = { currentState: SessionState & { isNew?: true; }; previousState: SessionState | null; }; export declare class SessionManager { private readonly storageManager; private readonly externalSessionMetadata?; private readonly adjustSessionStartToTimeOrigin; sessionHistory: Map; private _session; private isStarted; private lastActivityProcessed; private readonly newSessionsPendingToReport; private previousSessionState; private get session(); private set session(value); private readonly sessionStateChange; private stopCallbacks; constructor(storageManager: StorageManager, externalSessionMetadata?: NonNullable | undefined, adjustSessionStartToTimeOrigin?: boolean); static getExternalSession(): SessionState | null; static hasExternalSession(): boolean; getSessionId(): string; getSessionMetadata(): { sessionId: string; sessionLastActivity: number; sessionStart: number; } | null; getSessionState(): SessionState; start(): void; stop(): void; subscribe(f: (sessionChangeState: SessionStateChange) => void): () => void; private static canContinueUsingSession; private static generateNewSession; private static isSessionExpired; private static isSessionMaxDurationReached; private addEventListeners; private attachExternalSessionWatcher; private attachStorageWatch; private attachUserActivityListeners; private attachVisibilityListener; private attachWatchSessionState; /** * When the tab is in the background or sleeps, setInterval is throttled, which may cause the session state to be updated too late. * For example, a span might be emitted before the interval runs, resulting in the span being sent even though it should be dropped due to session expiration. * This ensures that a fresh session state is always retrieved. */ private ensureSessionStateIsUpToDate; private extendOrCreateNewSession; private getSessionStateFromStorageAndValidate; private getUpdatedSessionStateIfExpired; private notifySessionStateChange; private synchronizeStorageWithCurrentSessionState; private watchSessionState; } export {};