@tinytapanalytics/sdk
Version:
Behavioral psychology platform that detects visitor frustration, predicts abandonment, and helps you save at-risk conversions in real-time
84 lines • 2.1 kB
TypeScript
/**
* Performance Monitor for TinyTapAnalytics SDK
* Tracks Core Web Vitals and SDK performance metrics
*/
import { TinyTapAnalyticsConfig } from '../types/index';
interface PerformanceMetric {
name: string;
value: number;
timestamp: number;
rating: 'good' | 'needs-improvement' | 'poor';
}
interface WebVitalsData {
CLS?: PerformanceMetric;
FID?: PerformanceMetric;
FCP?: PerformanceMetric;
LCP?: PerformanceMetric;
TTFB?: PerformanceMetric;
}
export declare class PerformanceMonitor {
private config;
private observers;
private vitals;
private sdkMetrics;
private isSupported;
constructor(config: TinyTapAnalyticsConfig);
/**
* Initialize performance monitoring
*/
init(): void;
/**
* Measure Core Web Vitals
*/
private measureWebVitals;
/**
* Measure SDK-specific performance metrics
*/
private measureSDKPerformance;
/**
* Setup navigation timing measurements
*/
private setupNavigationTiming;
/**
* Observe performance metrics
*/
private observeMetric;
/**
* Measure synchronous operation performance
*/
measureSync<T>(name: string, fn: () => T): T;
/**
* Measure asynchronous operation performance
*/
measureAsync<T>(name: string, fn: () => Promise<T>): Promise<T>;
/**
* Get performance rating based on metric thresholds
*/
private getRating;
/**
* Get all Web Vitals data
*/
getWebVitals(): WebVitalsData;
/**
* Get SDK performance metrics
*/
getSDKMetrics(): Record<string, number>;
/**
* Get performance summary
*/
getPerformanceSummary(): {
webVitals: WebVitalsData;
sdkMetrics: Record<string, number>;
overallRating: 'good' | 'needs-improvement' | 'poor';
};
/**
* Report performance data to analytics endpoint
*/
reportPerformance(): Promise<void>;
/**
* Clean up performance observers
*/
destroy(): void;
}
export {};
//# sourceMappingURL=PerformanceMonitor.d.ts.map