UNPKG

web-performance-monitor-sdk

Version:

A modern, lightweight performance monitoring SDK for web applications. Monitor Core Web Vitals (LCP, FCP, FID, CLS, TTFB) with sendBeacon support.

35 lines 1.05 kB
/** * 性能指标工具函数 */ import { PerformanceScore, MetricDetail } from './types'; /** * 根据性能指标值计算评分 */ export declare function getPerformanceScore(metric: string, value: number): PerformanceScore; /** * 创建性能指标详情 */ export declare function createMetricDetail(value: number, metric: string): MetricDetail; /** * 格式化性能数据用于输出 */ export declare function formatMetrics(metrics: Record<string, MetricDetail>): Record<string, any>; /** * 检查浏览器是否支持Performance Observer */ export declare function isPerformanceObserverSupported(): boolean; /** * 检查浏览器是否支持sendBeacon */ export declare function isSendBeaconSupported(): boolean; /** * 生成随机采样ID */ /** * 根据采样率决定是否采集数据。 * * @param sampleRate 介于0和1之间的数,表示采样概率 * @returns 是否采样(true为采样,false为跳过) */ export declare function shouldSample(sampleRate?: number): boolean; //# sourceMappingURL=utils.d.ts.map