diff --git a/README.md b/README.md index c2cfaee3..f750ddc5 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ The `sendToAnalytics()` function uses the [`navigator.sendBeacon()`](https://dev import {getCLS, getFID, getLCP} from 'web-vitals'; function sendToAnalytics(metric) { - const body = JSON.stringify(metric); + const body = JSON.stringify({[metric.name]: metric.value}); // Use `navigator.sendBeacon()` if available, falling back to `fetch()`. (navigator.sendBeacon && navigator.sendBeacon('/analytics', body)) || fetch('/analytics', {body, method: 'POST', keepalive: true});