npaw-plugin-nwf
Version:
NPAW's Plugin
76 lines (75 loc) • 2.4 kB
TypeScript
import SessionsRequest from '../SessionsRequest';
/**
* SessionsRequestHandler - Orchestrates request queuing and processing
*/
export default class SessionsRequestHandler {
private _core;
private _coreStorage;
private _expirationManager;
private _queue;
private _sendabilityPolicy;
private _retryPolicy;
private _flushController;
private _expirationRecovery;
private _requestProcessor;
onRequestQueued: ((sessionRequest: SessionsRequest) => void)[];
onWillSendRequest: ((sessionRequest: SessionsRequest) => void)[];
onRequestSent: ((sessionRequest: SessionsRequest) => void)[];
/**
* Constructor
* @param options - Optional configuration options
*/
constructor(options?: any);
/**
* Destroy the request handler
*/
destroy(): void;
/**
* Update the maximum waiting requests limit
* @param maxWaitingRequests - New maximum limit
*/
setMaxWaitingRequests(maxWaitingRequests: number): void;
/**
* Enqueue a request
* @param request - Request to be enqueued
* @returns true if queued, false if dropped
*/
queueRequest(request: SessionsRequest): boolean;
/**
* Flush the request queue
* @param timeoutMs - Timeout in milliseconds
* @returns Promise that resolves when the request queue is flushed
*/
flush(timeoutMs: number): Promise<unknown>;
/**
* Destroy the current session synchronously without firing SESSION_EXPIRE
* and without auto-recovery. Drops any queued requests. After this call the
* handler is still usable — the host app can start a new session right away.
*/
destroySession(): void;
/**
* Check if session has expired
* @returns true if expired
*/
hasExpired(): boolean;
/**
* Check whether the session is active (can queue events)
* @returns true if active
*/
isActive(): boolean;
/**
* Check whether session can accept events
* @returns true if queueable
*/
private _queueableEvent;
/**
* Get the last start and stop indices in the request array
* @returns Object containing the last start and stop indices
*/
private _getLastStartStopIndices;
/**
* Check if should send stats (for compatibility)
* @returns true if session is started
*/
shouldSendStats(): boolean;
}