Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
icco committed Dec 7, 2024
1 parent 8a9d91d commit d6d3171
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,22 @@ Also need to add support for Reporting API v1. see migration policy https://deve
This service will log the reports recieved for web-vitals. We have only tested with next.js. See https://nextjs.org/docs/advanced-features/measuring-performance and https://web.dev/vitals/ for more information.

To start sending analytics, target https://reportd.natwelch.com/analytics/$yourservicename

```html
<script type="module">
import { onCLS, onINP, onLCP, onFCP, onFID, onTTFB } from 'https://unpkg.com/web-vitals@4?module';
function sendToAnalytics(metric) {
const body = JSON.stringify(metric);
(navigator.sendBeacon && navigator.sendBeacon('https://reportd.natwelch.com/analytics/$yourservicename', body)) ||
fetch('https://reportd.natwelch.com/analytics/$yourservicename', { body, method: 'POST', keepalive: true });
}
onCLS(sendToAnalytics);
onFCP(sendToAnalytics);
onFID(sendToAnalytics);
onINP(sendToAnalytics);
onLCP(sendToAnalytics);
onTTFB(sendToAnalytics);
</script>
```

0 comments on commit d6d3171

Please # to comment.