refactor: replace deprecated web-vitals funcs

This commit is contained in:
Bart van der Braak 2023-08-06 17:54:25 +02:00
parent b9e4f43fb1
commit 2f0d6bdbaf

View file

@ -1,5 +1,5 @@
import type { Metric } from 'web-vitals'; import type { Metric } from 'web-vitals';
import { getCLS, getFCP, getFID, getLCP, getTTFB } from 'web-vitals'; import { onCLS, onFCP, onFID, onLCP, onTTFB } from 'web-vitals';
const vitalsUrl = 'https://vitals.vercel-analytics.com/v1/vitals'; const vitalsUrl = 'https://vitals.vercel-analytics.com/v1/vitals';
@ -75,11 +75,11 @@ export function webVitals(options: {
debug: boolean; debug: boolean;
}) { }) {
try { try {
getFID((metric) => sendToAnalytics(metric, options)); onFID((metric) => sendToAnalytics(metric, options));
getTTFB((metric) => sendToAnalytics(metric, options)); onTTFB((metric) => sendToAnalytics(metric, options));
getLCP((metric) => sendToAnalytics(metric, options)); onLCP((metric) => sendToAnalytics(metric, options));
getCLS((metric) => sendToAnalytics(metric, options)); onCLS((metric) => sendToAnalytics(metric, options));
getFCP((metric) => sendToAnalytics(metric, options)); onFCP((metric) => sendToAnalytics(metric, options));
} catch (err) { } catch (err) {
console.error('[Web Vitals]', err); console.error('[Web Vitals]', err);
} }