import { Metric } from "../../Metrics/Metric.cjs"; import { RequestFormatter } from "./types.cjs"; //#region src/Plugins/Reporter/ProcessingQueue.d.ts /** * Processing Queue * * A scheduler for sending batches of metrics to a specified endpoint * * ```typescript * import { ProcessingQueue } from "@ui-perf/metrics"; * * const Queue = new ProcessingQueue("https://my-analytics-service", metrics => { * // optionally format outgoing data * return JSON.stringify(metrics); * }); * ``` */ declare class ProcessingQueue = Metric> { readonly url: string; readonly formatRequest: RequestFormatter; readonly queue: Map; private readonly IDs; private scheduler; constructor(url: string, formatRequest?: RequestFormatter); /** * Enqueue * * Adds an item to the queue and schedules a request to the provided * destination */ enqueue(item: T): Promise; /** * Beacon * * Sends a request with the currently enqueued items to the server. * Resets the queue. */ private beacon; /** * Schedule * * Schedules a request to the provided endpoint containing the * currently enqueued items */ private schedule; /** * Cancel * * Cancels a currently scheduled request */ private cancel; /** * Listen For Session End * * If the document is ever moved to the background or is closed, a request is * immediately sent to the provided destination containing the contents of * the queue */ private readonly listenForSessionEnd; /** * Default Formatter * * Returns a stringified queue */ private static readonly defaultFormatter; } //#endregion export { ProcessingQueue };