Update vitals.js

This commit is contained in:
luke-hagar-sp
2022-12-17 21:36:10 -06:00
parent 148672ba47
commit 0f6c130ed6

View File

@@ -1,6 +1,6 @@
import { getCLS, getFCP, getFID, getLCP, getTTFB } from 'web-vitals'; import { getCLS, getFCP, getFID, getLCP, getTTFB } from 'web-vitals';
import { PUBLIC_AXIOM_INGEST_ENDPOINT } from '$env/static/public'; const vitalsUrl = 'https://vitals.vercel-analytics.com/v1/vitals';
function getConnectionSpeed() { function getConnectionSpeed() {
return 'connection' in navigator && return 'connection' in navigator &&
@@ -39,9 +39,9 @@ function sendToAnalytics(metric, options) {
type: 'application/x-www-form-urlencoded' type: 'application/x-www-form-urlencoded'
}); });
if (navigator.sendBeacon) { if (navigator.sendBeacon) {
navigator.sendBeacon(PUBLIC_AXIOM_INGEST_ENDPOINT, blob); navigator.sendBeacon(vitalsUrl, blob);
} else } else
fetch(PUBLIC_AXIOM_INGEST_ENDPOINT, { fetch(vitalsUrl, {
body: blob, body: blob,
method: 'POST', method: 'POST',
credentials: 'omit', credentials: 'omit',