web-perf-analytics
v1.0.0
Published
A comprehensive web performance monitoring solution
Downloads
57
Maintainers
Readme
web-perf-analytics
A comprehensive web performance monitoring solution for modern web applications.
Features
- 📊 Web Vitals Monitoring (LCP, FID, CLS, FCP)
- 🔍 Error Tracking
- 👆 User Interaction Monitoring
- 📈 Custom Performance Metrics
- 📝 Performance Analysis and Recommendations
Installation
npm install web-perf-analytics
# or
yarn add web-perf-analytics
Usage
import { PerformanceMonitor } from 'web-perf-analytics';
// Initialize the monitor
const monitor = new PerformanceMonitor({
sampling: 1.0, // 100% sampling rate
});
// Start monitoring
monitor.start();
// Add custom metrics
const customMetric = monitor.createCustomMetric('page-load');
customMetric.mark('start');
// ... your code here
customMetric.mark('end');
// Get performance data
const performanceData = monitor.getPerformanceData();
console.log(performanceData);
// Stop monitoring when done
monitor.stop();
API Reference
PerformanceMonitor
The main class for monitoring performance.
const monitor = new PerformanceMonitor(options?: {
sampling?: number; // Sampling rate (0-1), default: 1
});
Methods
start()
: Start monitoringstop()
: Stop monitoringcreateCustomMetric(name: string)
: Create a custom metricgetPerformanceData()
: Get all collected performance data
Browser Support
- Chrome 60+
- Firefox 57+
- Safari 11+
- Edge 79+
License
MIT