Skip to content

Commit

Permalink
Merge pull request #81 from GoogleChrome/update-readme
Browse files Browse the repository at this point in the history
Update sendToAnalytics() example
  • Loading branch information
philipwalton committed Oct 22, 2020
2 parents 56c736b + f461ce0 commit 39a0937
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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});
Expand Down

0 comments on commit 39a0937

Please sign in to comment.