import type { ConfigObject, UserConfig } from "./config"; import Logger from "./logger"; import type { LoAFScriptSummary, LoAFSummary } from "./metric/LoAF"; import type { NavigationTimingData } from "./metric/navigation-timing"; type BeaconOptions = { config: ConfigObject; logger: Logger; customerId: string; sessionId: string; pageId: string; startTime?: number; }; export type CollectorFunction = (config: UserConfig) => any; /** * Some values should only be reported if they are non-zero. The exception to this is when the page * was prerendered or restored from BF cache */ export declare function shouldReportValue(value: number): boolean; /** * Fit an array of user timing delimited strings into a URL and return both the entries that fit and * the remaining entries that didn't fit. */ export declare function fitUserTimingEntries(utValues: string[], config: ConfigObject, url: string): string[][]; export declare class Beacon { config: ConfigObject; logger: Logger; isRecording: boolean; isSent: boolean; sendRetries: number; maxMeasureTimeout: number; customerId: string; pageId: string; sessionId: string; flags: number; startTime: number; metricCollectors: { [k in BeaconMetricKey]?: CollectorFunction; }; onBeforeSendCbs: Array<() => void>; constructor(opts: BeaconOptions); isBeingSampled(): boolean; stopRecording(): void; addCollector(metric: K, collector: CollectorFunction): void; addFlag(flag: number): void; beaconUrl(): string; onBeforeSend(cb: () => void): void; send(): void; } export type BeaconPayload = BeaconMetaData & Partial; export type BeaconMetaData = { customerId: string; pageId: string; sessionId: string; flags: number; /** When this beacon started measuring */ startTime: number; /** The lux.js version that sent the beacon */ scriptVersion: string; /** The lux.js snippet version that sent the beacon */ snippetVersion?: string; /** How long in milliseconds did this beacon capture page data for */ measureDuration: number; /** How long in milliseconds did the collection process take */ collectionDuration: number; }; export declare enum BeaconMetricKey { CLS = "cls", INP = "inp", FCP = "fcp", LCP = "lcp", LoAF = "loaf", RageClick = "rage", NavigationTiming = "nt" } export type BeaconMetricData = { [BeaconMetricKey.NavigationTiming]: NavigationTimingData; [BeaconMetricKey.FCP]: MetricWithValue; [BeaconMetricKey.LCP]: MetricWithValue & { attribution: MetricAttribution | null; /** LCP sub-parts can be null if the LCP element was not loaded by a resource */ subParts: { resourceLoadDelay: number; resourceLoadTime: number; elementRenderDelay: number; } | null; }; [BeaconMetricKey.LoAF]: LoAFSummary; [BeaconMetricKey.INP]: MetricWithValue & { startTime: number; duration: number; attribution: INPAttribution | null; subParts: { inputDelay: number; processingTime: number; presentationDelay: number; processingStart: number; processingEnd: number; }; }; [BeaconMetricKey.CLS]: MetricWithValue & { startTime: number | null; /** Largest entry can be null if there were no layout shifts (value will be 0) */ largestEntry: { value: number; startTime: number; } | null; sources: CLSAttribution[] | null; }; [BeaconMetricKey.RageClick]: MetricWithValue & { startTime: number; attribution: MetricAttribution; }; }; export type CLSAttribution = MetricAttribution & { value: number; startTime: number; }; export type INPAttribution = MetricAttribution & { eventType: string; loafScripts: LoAFScriptSummary[]; }; type MetricWithValue = { value: number; }; export type MetricAttribution = { elementSelector: string | null; elementType: string | null; }; export {};