From 2f0d6bdbaf4c30cbd0d484772d74feba4ec435b8 Mon Sep 17 00:00:00 2001 From: Bart van der Braak Date: Sun, 6 Aug 2023 17:54:25 +0200 Subject: [PATCH] refactor: replace deprecated web-vitals funcs --- src/lib/vitals.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/vitals.ts b/src/lib/vitals.ts index 48f9159..0c4a30d 100644 --- a/src/lib/vitals.ts +++ b/src/lib/vitals.ts @@ -1,5 +1,5 @@ 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'; @@ -75,11 +75,11 @@ export function webVitals(options: { debug: boolean; }) { try { - getFID((metric) => sendToAnalytics(metric, options)); - getTTFB((metric) => sendToAnalytics(metric, options)); - getLCP((metric) => sendToAnalytics(metric, options)); - getCLS((metric) => sendToAnalytics(metric, options)); - getFCP((metric) => sendToAnalytics(metric, options)); + onFID((metric) => sendToAnalytics(metric, options)); + onTTFB((metric) => sendToAnalytics(metric, options)); + onLCP((metric) => sendToAnalytics(metric, options)); + onCLS((metric) => sendToAnalytics(metric, options)); + onFCP((metric) => sendToAnalytics(metric, options)); } catch (err) { console.error('[Web Vitals]', err); }