fix: add condition for web vitals to ignore dev mode

This commit is contained in:
Torsten Dittmann
2022-09-15 13:40:45 +02:00
parent fad1b65f48
commit df74206e14
2 changed files with 4 additions and 2 deletions
+2
View File
@@ -1,3 +1,4 @@
import { dev } from '$app/environment';
import { getCLS, getFCP, getFID, getLCP, getTTFB, type Metric } from 'web-vitals';
type Options = {
@@ -45,6 +46,7 @@ function sendToAnalytics(metric: Metric, options: Options) {
// This content type is necessary for `sendBeacon`
type: 'application/x-www-form-urlencoded'
});
if (navigator.sendBeacon) {
navigator.sendBeacon(vitalsUrl, blob);
} else
+2 -2
View File
@@ -5,7 +5,7 @@
import { redirectTo } from '$lib/stores/organization';
import { onMount } from 'svelte';
import { base } from '$app/paths';
import { browser } from '$app/environment';
import { browser, dev } from '$app/environment';
import { app } from '$lib/stores/app';
import Notifications from '$lib/layout/notifications.svelte';
import Loading from './_loading.svelte';
@@ -38,7 +38,7 @@
}
});
$: if (browser && window.VERCEL_ANALYTICS_ID) {
$: if (!dev && browser && window.VERCEL_ANALYTICS_ID) {
webVitals({
path: $page.url.pathname,
params: $page.params,