datadog-ux-utils
Version:
Datadog RUM focused UX & performance toolkit: API guards (retry, breaker, rate), React telemetry (error boundary, profiler, Suspense), web vitals & resource observers, offline queues.
34 lines (33 loc) • 931 B
TypeScript
import { LayoutShiftOptions } from '../types/types.ts';
/**
* Starts tracking Cumulative Layout Shift (CLS) for the current page.
*
* @param opts - Configuration for tracking layout shifts.
* @returns A function to stop tracking CLS.
*
* @example
* ```ts
* import { startLayoutShiftTracking } from "datadog-ux-utils/layoutShifts";
*
* const stopTracking = startLayoutShiftTracking({
* onChange: (cls, entry) => {
* console.log("CLS updated:", cls, entry);
* }
* });
*
* // Stop tracking later:
* stopTracking();
* ```
*/
export declare function startLayoutShiftTracking(opts?: LayoutShiftOptions): () => void;
/**
* Returns the current cumulative layout shift score.
*
* @example
* ```ts
* import { getCLSValue } from "datadog-ux-utils/layoutShifts";
* console.log("Current CLS:", getCLSValue());
* ```
*/
export declare function getCLSValue(): number;
//# sourceMappingURL=layoutShifts.d.ts.map