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.

67 lines 1.32 kB
/** * 性能指标收集器 */ import { PerformanceMetrics, MetricDetail, PerformanceMonitorConfig } from './types'; export declare class MetricsCollector { private metrics; private config; private observers; constructor(config: PerformanceMonitorConfig); /** * 初始化性能监控 */ private init; /** * 判断是否应该收集数据 */ private shouldCollect; /** * 监控Paint指标 (FCP) */ private observePaint; /** * 监控LCP指标 */ private observeLCP; /** * 监控FID指标 */ private observeFID; /** * 监控CLS指标 */ private observeCLS; /** * 监控TTFB指标 */ private observeTTFB; /** * 报告单个指标 */ private reportMetric; /** * 通过sendBeacon发送数据 */ private sendViaBeacon; /** * 通过fetch发送数据 */ private sendViaFetch; /** * 获取所有收集的指标 */ getMetrics(): PerformanceMetrics; /** * 获取详细的指标信息 */ getDetailedMetrics(): Record<string, MetricDetail>; /** * 停止监控 */ disconnect(): void; /** * 调试日志 */ private log; } //# sourceMappingURL=metrics-collector.d.ts.map