@casoon/auditmysite
Version:
Professional website analysis suite with robust accessibility testing, Core Web Vitals performance monitoring, SEO analysis, and content optimization insights. Features isolated browser contexts, retry mechanisms, and comprehensive API endpoints for profe
131 lines • 3.65 kB
TypeScript
import { Page } from 'playwright';
export interface CoreWebVitals {
lcp: number;
cls: number;
fcp: number;
ttfb: number;
loadTime: number;
domContentLoaded: number;
renderTime: number;
score: number;
grade: 'A' | 'B' | 'C' | 'D' | 'F';
recommendations: string[];
budgetStatus?: BudgetStatus;
}
export interface PerformanceBudget {
lcp: {
good: number;
poor: number;
};
cls: {
good: number;
poor: number;
};
fcp: {
good: number;
poor: number;
};
ttfb: {
good: number;
poor: number;
};
}
export interface BudgetStatus {
passed: boolean;
violations: BudgetViolation[];
summary: string;
}
export interface BudgetViolation {
metric: keyof PerformanceBudget;
actual: number;
threshold: number;
severity: 'warning' | 'error';
message: string;
}
export declare const BUDGET_TEMPLATES: Record<string, PerformanceBudget>;
export declare class WebVitalsCollector {
private budget;
private maxRetries;
private retryDelay;
private verbose;
constructor(budget?: PerformanceBudget, options?: {
maxRetries?: number;
retryDelay?: number;
verbose?: boolean;
});
/**
* Collect Core Web Vitals using robust browser synchronization
* Prevents timing issues and execution context destruction
*/
collectMetrics(page: Page): Promise<CoreWebVitals>;
/**
* Collect metrics using isolated browser context for maximum stability
* Each measurement runs in its own clean environment
*/
collectWithIsolatedContext(page: Page): Promise<any>;
/**
* Advanced retry mechanism with exponential backoff and different strategies
*/
collectWithAdvancedRetry(page: Page): Promise<any>;
/**
* Collect metrics with retry mechanism and robust error handling
*/
private collectWithRetry;
/**
* Single attempt at collecting metrics with better synchronization
*/
private collectMetricsOnce;
/**
* Collect using Google's web-vitals library with better error handling
*/
private collectWithWebVitalsLibrary;
/**
* Fallback collection using PerformanceObserver API directly
*/
private collectWithPerformanceObserver;
/**
* Get navigation timing as fallback when all else fails
*/
private getNavigationTimingFallback;
/**
* Enhanced metrics validation with quality scoring
*/
private hasValidMetrics;
/**
* Assess the quality of collected metrics
*/
private assessMetricsQuality;
/**
* Get metrics quality report for debugging
*/
getMetricsQualityReport(metrics: any): string;
/**
* Apply fallback strategies when Web Vitals metrics are missing or zero
* Provides alternative calculations for small/static sites
*/
private applyFallbackStrategies;
/**
* Calculate performance score based on configurable budget thresholds
* Uses custom scoring methodology based on user-defined budgets
*/
private calculateScore;
private calculateGrade;
private generateRecommendations;
/**
* Evaluate performance against budget and return status
*/
private evaluateBudget;
private getFallbackMetrics;
/**
* Update retry configuration
*/
updateRetryConfig(maxRetries: number, retryDelay: number): void;
/**
* Get current retry configuration
*/
getRetryConfig(): {
maxRetries: number;
retryDelay: number;
};
}
//# sourceMappingURL=web-vitals-collector.d.ts.map