1 | "use strict";exports.__esModule=true;exports.default=void 0;var _webVitals=require("next/dist/compiled/web-vitals");const initialHref=location.href;let isRegistered=false;let userReportHandler;function onReport(metric){if(userReportHandler){userReportHandler(metric);}
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | if(process.env.NODE_ENV==='production'&&
|
7 | process.env.__NEXT_ANALYTICS_ID){const body={dsn:process.env.__NEXT_ANALYTICS_ID,id:metric.id,page:window.__NEXT_DATA__.page,href:initialHref,event_name:metric.name,value:metric.value.toString(),speed:'connection'in navigator&&navigator['connection']&&'effectiveType'in navigator['connection']?navigator['connection']['effectiveType']:''};const blob=new Blob([new URLSearchParams(body).toString()],{
|
8 | type:'application/x-www-form-urlencoded'});const vitalsUrl='https://vitals.vercel-insights.com/v1/vitals';navigator.sendBeacon&&navigator.sendBeacon(vitalsUrl,blob)||fetch(vitalsUrl,{body:blob,method:'POST',credentials:'omit',keepalive:true});}}var _default=onPerfEntry=>{
|
9 | userReportHandler=onPerfEntry;
|
10 | if(isRegistered){return;}isRegistered=true;(0,_webVitals.getCLS)(onReport);(0,_webVitals.getFID)(onReport);(0,_webVitals.getFCP)(onReport);(0,_webVitals.getLCP)(onReport);(0,_webVitals.getTTFB)(onReport);};exports.default=_default;
|
11 |
|
\ | No newline at end of file |