Unverified Commit ffb3ce24 authored by vercel[bot]'s avatar vercel[bot] Committed by GitHub

Report Web Vitals for soft navigations

Upgrades the vendored `web-vitals` to v6 and passes `reportSoftNavs: true`
to `onCLS`, `onINP` and `onLCP` in `useReportWebVitals`, so that the Core
Web Vitals are also measured for soft navigations (client-side navigations
that change the URL) in browsers that support the Soft Navigations API,
which shipped in Chrome 151. Metrics measured for a soft navigation are
reported with a `navigationType` of `soft-navigation` and the
`navigationURL` they belong to.

FCP and TTFB keep reporting for the initial page load only, since a soft
navigation has no server request and `web-vitals` would report a TTFB of 0.

`web-vitals` v5 removed `onFID`, so FID is no longer reported and is
removed from `WEB_VITALS`, the `experimental.webVitalsAttribution` schema
and the docs. The v4 patch that made `PerformanceEventTiming.interactionId`
readonly is no longer needed, as that landed upstream.

<!-- NEXT_JS_LLM -->
Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: 's avatarMalte Ubl <89679+cramforce@users.noreply.github.com>
parent 3c97df56
......@@ -88,7 +88,6 @@ experience of a web page. The following web vitals are all included:
- [Time to First Byte](https://developer.mozilla.org/docs/Glossary/Time_to_first_byte) (TTFB)
- [First Contentful Paint](https://developer.mozilla.org/docs/Glossary/First_contentful_paint) (FCP)
- [Largest Contentful Paint](https://web.dev/lcp/) (LCP)
- [First Input Delay](https://web.dev/fid/) (FID)
- [Cumulative Layout Shift](https://web.dev/cls/) (CLS)
- [Interaction to Next Paint](https://web.dev/inp/) (INP)
......
......@@ -69,10 +69,11 @@ export default function Layout({ children }) {
The `metric` object passed as the hook's argument consists of a number of properties:
- `id`: Unique identifier for the metric in the context of the current page load
- `name`: The name of the performance metric. Possible values include names of [Web Vitals](#web-vitals) metrics (TTFB, FCP, LCP, FID, CLS) specific to a web application.
- `name`: The name of the performance metric. Possible values include names of [Web Vitals](#web-vitals) metrics (TTFB, FCP, LCP, CLS, INP) specific to a web application.
- `delta`: The difference between the current value and the previous value of the metric. The value is typically in milliseconds and represents the change in the metric's value over time.
- `entries`: An array of [Performance Entries](https://developer.mozilla.org/docs/Web/API/PerformanceEntry) associated with the metric. These entries provide detailed information about the performance events related to the metric.
- `navigationType`: Indicates the navigation type that triggered metric collection. Values are derived from [PerformanceNavigationTiming.type](https://developer.mozilla.org/docs/Web/API/PerformanceNavigationTiming/type) and may include `"navigate"`, `"reload"`, `"prerender"`, `"back-forward"` (normalized from `"back_forward"`), `"back-forward-cache"` (BFCache restore), and `"restore"` (page restored after discard).
- `navigationType`: Indicates the navigation type that triggered metric collection. Values are derived from [PerformanceNavigationTiming.type](https://developer.mozilla.org/docs/Web/API/PerformanceNavigationTiming/type) and may include `"navigate"`, `"reload"`, `"prerender"`, `"back-forward"` (normalized from `"back_forward"`), `"back-forward-cache"` (BFCache restore), `"restore"` (page restored after discard), and `"soft-navigation"` (see [Soft navigations](#soft-navigations)).
- `navigationURL`: The URL the metric was measured for. Metrics are often reported after the fact, so use this instead of the current URL when attributing a metric to a page.
- `rating`: A qualitative rating of the metric value, providing an assessment of the performance. Possible values are `"good"`, `"needs-improvement"`, and `"poor"`. The rating is typically determined by comparing the metric value against predefined thresholds that indicate acceptable or suboptimal performance.
- `value`: The actual value or duration of the performance entry, typically in milliseconds. The value provides a quantitative measure of the performance aspect being tracked by the metric. The source of the value depends on the specific metric being measured and can come from various [Performance API](https://developer.mozilla.org/docs/Web/API/Performance_API)s.
......@@ -84,12 +85,33 @@ experience of a web page. The following web vitals are all included:
- [Time to First Byte](https://developer.mozilla.org/docs/Glossary/Time_to_first_byte) (TTFB)
- [First Contentful Paint](https://developer.mozilla.org/docs/Glossary/First_contentful_paint) (FCP)
- [Largest Contentful Paint](https://web.dev/lcp/) (LCP)
- [First Input Delay](https://web.dev/fid/) (FID)
- [Cumulative Layout Shift](https://web.dev/cls/) (CLS)
- [Interaction to Next Paint](https://web.dev/inp/) (INP)
You can handle all the results of these metrics using the `name` property.
## Soft navigations
The Core Web Vitals (LCP, CLS, and INP) are also measured for soft navigations, i.e. client-side
navigations that update the URL without a full page load. This requires browser support for the
[Soft Navigations API](https://developer.chrome.com/docs/web-platform/soft-navigations) (Chrome 151
and newer). In browsers without support, the Core Web Vitals are measured for the initial page load
only.
Metrics that were measured for a soft navigation have a `navigationType` of `"soft-navigation"`.
Since a metric can be reported after another navigation already happened, use `navigationURL` to
attribute a metric to the page it was measured for:
```js
const logWebVitals = (metric) => {
console.log(metric.navigationURL, metric.name, metric.value)
}
```
> **Good to know**: Enabling soft navigation measurement also changes how the initial page load is
> measured, because its metrics are finalized as soon as the first soft navigation happens, instead
> of when the page is unloaded.
<PagesOnly>
```jsx filename="pages/_app.js"
......
......@@ -340,7 +340,6 @@
"stacktrace-parser@0.1.10": "patches/stacktrace-parser@0.1.10.patch",
"taskr@1.1.0": "patches/taskr@1.1.0.patch",
"minizlib@3.1.0": "patches/minizlib@3.1.0.patch",
"web-vitals@4.2.1": "patches/web-vitals@4.2.1.patch",
"@rspack/core@1.6.7": "patches/@rspack__core@1.6.7.patch",
"@modelcontextprotocol/sdk": "patches/@modelcontextprotocol__sdk.patch",
"@vercel/blob": "patches/@vercel__blob.patch",
......
......@@ -349,7 +349,7 @@
"util": "0.12.4",
"vm-browserify": "1.1.2",
"watchpack": "2.4.0",
"web-vitals": "4.2.1",
"web-vitals": "6.1.0",
"webpack": "5.98.0",
"webpack-sources1": "npm:webpack-sources@1.4.3",
"webpack-sources3": "npm:webpack-sources@3.2.3",
......
/**
* @jest-environment jsdom
*/
/* eslint-disable @next/internal/typechecked-require -- Not a prod file */
/* eslint-disable import/no-extraneous-dependencies -- Not a prod file */
import type * as WebVitals from './web-vitals'
jest.mock('next/dist/compiled/web-vitals', () => ({
onCLS: jest.fn(),
onFCP: jest.fn(),
onINP: jest.fn(),
onLCP: jest.fn(),
onTTFB: jest.fn(),
}))
type WebVitalsMocks = Record<
'onCLS' | 'onFCP' | 'onINP' | 'onLCP' | 'onTTFB',
jest.Mock
>
describe('useReportWebVitals', () => {
let cleanup: typeof import('@testing-library/react').cleanup
let renderHook: typeof import('@testing-library/react').renderHook
let useReportWebVitals: typeof WebVitals.useReportWebVitals
let webVitals: WebVitalsMocks
beforeEach(() => {
jest.resetModules()
useReportWebVitals = (require('./web-vitals') as typeof WebVitals)
.useReportWebVitals
webVitals = require('next/dist/compiled/web-vitals') as WebVitalsMocks
const rtl = require('@testing-library/react/pure')
renderHook = rtl.renderHook
cleanup = rtl.cleanup
})
afterEach(() => {
cleanup()
})
it('reports the Core Web Vitals for soft navigations', () => {
const report = jest.fn()
renderHook(() => useReportWebVitals(report))
for (const onCoreWebVital of [
webVitals.onCLS,
webVitals.onINP,
webVitals.onLCP,
]) {
expect(onCoreWebVital).toHaveBeenCalledTimes(1)
expect(onCoreWebVital).toHaveBeenCalledWith(report, {
reportSoftNavs: true,
})
}
})
it('reports FCP and TTFB for the initial page load only', () => {
const report = jest.fn()
renderHook(() => useReportWebVitals(report))
for (const onLoadMetric of [webVitals.onFCP, webVitals.onTTFB]) {
expect(onLoadMetric).toHaveBeenCalledTimes(1)
expect(onLoadMetric).toHaveBeenCalledWith(report)
}
})
it('does not register the same callback twice on re-render', () => {
const report = jest.fn()
const { rerender } = renderHook(() => useReportWebVitals(report))
rerender()
expect(webVitals.onLCP).toHaveBeenCalledTimes(1)
})
})
import { useEffect } from 'react'
import {
onLCP,
onFID,
onCLS,
onINP,
onFCP,
......@@ -9,14 +8,25 @@ import {
} from 'next/dist/compiled/web-vitals'
import type { Metric } from 'next/dist/compiled/web-vitals'
// Report the Core Web Vitals for soft navigations (client-side navigations) in
// addition to the initial page load. `web-vitals` feature detects the Soft
// Navigations API and keeps reporting only for the initial page load in
// browsers that don't support it.
// Metrics reported for a soft navigation have a `navigationType` of
// `'soft-navigation'` and a `navigationURL` of the URL they were measured for.
// https://github.com/GoogleChrome/web-vitals#report-metrics-for-soft-navigations
const softNavsOpts = { reportSoftNavs: true }
export function useReportWebVitals(
reportWebVitalsFn: (metric: Metric) => void
) {
useEffect(() => {
onCLS(reportWebVitalsFn)
onFID(reportWebVitalsFn)
onLCP(reportWebVitalsFn)
onINP(reportWebVitalsFn)
onCLS(reportWebVitalsFn, softNavsOpts)
onLCP(reportWebVitalsFn, softNavsOpts)
onINP(reportWebVitalsFn, softNavsOpts)
// FCP and TTFB are load metrics, so they keep reporting for the initial
// page load only. Reporting TTFB for soft navigations would only ever
// report `0`, since no server request is involved.
onFCP(reportWebVitalsFn)
onTTFB(reportWebVitalsFn)
}, [reportWebVitalsFn])
......
(function(){"use strict";var e={};!function(){e.d=function(c,h){for(var C in h){if(e.o(h,C)&&!e.o(c,C)){Object.defineProperty(c,C,{enumerable:true,get:h[C]})}}}}();!function(){e.o=function(e,c){return Object.prototype.hasOwnProperty.call(e,c)}}();!function(){e.r=function(e){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}}();if(typeof e!=="undefined")e.ab=__dirname+"/";var c={};e.r(c);e.d(c,{CLSThresholds:function(){return O},FCPThresholds:function(){return A},FIDThresholds:function(){return bt},INPThresholds:function(){return G},LCPThresholds:function(){return ft},TTFBThresholds:function(){return gt},onCLS:function(){return w},onFCP:function(){return x},onFID:function(){return Tt},onINP:function(){return nt},onLCP:function(){return at},onTTFB:function(){return st}});var h,C,D,r=function(){var e=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},i=function(e){if("loading"===document.readyState)return"loading";var c=r();if(c){if(e<c.domInteractive)return"loading";if(0===c.domContentLoadedEventStart||e<c.domContentLoadedEventStart)return"dom-interactive";if(0===c.domComplete||e<c.domComplete)return"dom-content-loaded"}return"complete"},a=function(e){var c=e.nodeName;return 1===e.nodeType?c.toLowerCase():c.toUpperCase().replace(/^#/,"")},o=function(e,c){var h="";try{for(;e&&9!==e.nodeType;){var C=e,D=C.id?"#"+C.id:a(C)+(C.classList&&C.classList.value&&C.classList.value.trim()&&C.classList.value.trim().length?"."+C.classList.value.trim().replace(/\s+/g,"."):"");if(h.length+D.length>(c||100)-1)return h||D;if(h=h?D+">"+h:D,C.id)break;e=C.parentNode}}catch(e){}return h},I=-1,u=function(){return I},s=function(e){addEventListener("pageshow",(function(c){c.persisted&&(I=c.timeStamp,e(c))}),!0)},f=function(){var e=r();return e&&e.activationStart||0},d=function(e,c){var h=r(),C="navigate";u()>=0?C="back-forward-cache":h&&(document.prerendering||f()>0?C="prerender":document.wasDiscarded?C="restore":h.type&&(C=h.type.replace(/_/g,"-")));return{name:e,value:void 0===c?-1:c,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:C}},l=function(e,c,h){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var C=new PerformanceObserver((function(e){Promise.resolve().then((function(){c(e.getEntries())}))}));return C.observe(Object.assign({type:e,buffered:!0},h||{})),C}}catch(e){}},m=function(e,c,h,C){var D,I;return function(k){c.value>=0&&(k||C)&&((I=c.value-(D||0))||void 0===D)&&(D=c.value,c.delta=I,c.rating=function(e,c){return e>c[1]?"poor":e>c[0]?"needs-improvement":"good"}(c.value,h),e(c))}},p=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}))},v=function(e){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&e()}))},g=function(e){var c=!1;return function(){c||(e(),c=!0)}},k=-1,T=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},y=function(e){"hidden"===document.visibilityState&&k>-1&&(k="visibilitychange"===e.type?e.timeStamp:0,S())},E=function(){addEventListener("visibilitychange",y,!0),addEventListener("prerenderingchange",y,!0)},S=function(){removeEventListener("visibilitychange",y,!0),removeEventListener("prerenderingchange",y,!0)},b=function(){return k<0&&(k=T(),E(),s((function(){setTimeout((function(){k=T(),E()}),0)}))),{get firstHiddenTime(){return k}}},L=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),!0):e()},A=[1800,3e3],M=function(e,c){c=c||{},L((function(){var h,C=b(),D=d("FCP"),I=l("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(I.disconnect(),e.startTime<C.firstHiddenTime&&(D.value=Math.max(e.startTime-f(),0),D.entries.push(e),h(!0)))}))}));I&&(h=m(e,D,A,c.reportAllChanges),s((function(C){D=d("FCP"),h=m(e,D,A,c.reportAllChanges),p((function(){D.value=performance.now()-C.timeStamp,h(!0)}))})))}))},O=[.1,.25],w=function(e,c){!function(e,c){c=c||{},M(g((function(){var h,C=d("CLS",0),D=0,I=[],o=function(e){e.forEach((function(e){if(!e.hadRecentInput){var c=I[0],h=I[I.length-1];D&&e.startTime-h.startTime<1e3&&e.startTime-c.startTime<5e3?(D+=e.value,I.push(e)):(D=e.value,I=[e])}})),D>C.value&&(C.value=D,C.entries=I,h())},k=l("layout-shift",o);k&&(h=m(e,C,O,c.reportAllChanges),v((function(){o(k.takeRecords()),h(!0)})),s((function(){D=0,C=d("CLS",0),h=m(e,C,O,c.reportAllChanges),p((function(){return h()}))})),setTimeout(h,0))})))}((function(c){var h=function(e){var c,h={};if(e.entries.length){var C=e.entries.reduce((function(e,c){return e&&e.value>c.value?e:c}));if(C&&C.sources&&C.sources.length){var D=(c=C.sources).find((function(e){return e.node&&1===e.node.nodeType}))||c[0];D&&(h={largestShiftTarget:o(D.node),largestShiftTime:C.startTime,largestShiftValue:C.value,largestShiftSource:D,largestShiftEntry:C,loadState:i(C.startTime)})}}return Object.assign(e,{attribution:h})}(c);e(h)}),c)},x=function(e,c){M((function(c){var h=function(e){var c={timeToFirstByte:0,firstByteToFCP:e.value,loadState:i(u())};if(e.entries.length){var h=r(),C=e.entries[e.entries.length-1];if(h){var D=h.activationStart||0,I=Math.max(0,h.responseStart-D);c={timeToFirstByte:I,firstByteToFCP:e.value-I,loadState:i(e.entries[0].startTime),navigationEntry:h,fcpEntry:C}}}return Object.assign(e,{attribution:c})}(c);e(h)}),c)},B=0,R=1/0,q=0,F=function(e){e.forEach((function(e){e.interactionId&&(R=Math.min(R,e.interactionId),q=Math.max(q,e.interactionId),B=q?(q-R)/7+1:0)}))},P=function(){"interactionCount"in performance||h||(h=l("event",F,{type:"event",buffered:!0,durationThreshold:0}))},_=[],W=new Map,U=0,j=function(){return(h?B:performance.interactionCount||0)-U},V=[],H=function(e){if(V.forEach((function(c){return c(e)})),e.interactionId||"first-input"===e.entryType){var c=_[_.length-1],h=W.get(e.interactionId);if(h||_.length<10||e.duration>c.latency){if(h)e.duration>h.latency?(h.entries=[e],h.latency=e.duration):e.duration===h.latency&&e.startTime===h.entries[0].startTime&&h.entries.push(e);else{var C={id:e.interactionId,latency:e.duration,entries:[e]};W.set(C.id,C),_.push(C)}_.sort((function(e,c){return c.latency-e.latency})),_.length>10&&_.splice(10).forEach((function(e){return W.delete(e.id)}))}}},N=function(e){var c=self.requestIdleCallback||self.setTimeout,h=-1;return e=g(e),"hidden"===document.visibilityState?e():(h=c(e),v(e)),h},G=[200,500],z=function(e,c){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(c=c||{},L((function(){var h;P();var C,D=d("INP"),a=function(e){N((function(){e.forEach(H);var c,h=(c=Math.min(_.length-1,Math.floor(j()/50)),_[c]);h&&h.latency!==D.value&&(D.value=h.latency,D.entries=h.entries,C())}))},I=l("event",a,{durationThreshold:null!==(h=c.durationThreshold)&&void 0!==h?h:40});C=m(e,D,G,c.reportAllChanges),I&&(I.observe({type:"first-input",buffered:!0}),v((function(){a(I.takeRecords()),C(!0)})),s((function(){U=0,_.length=0,W.clear(),D=d("INP"),C=m(e,D,G,c.reportAllChanges)})))})))},J=[],Y=[],Z=new WeakMap,$=new Map,tt=-1,K=function(e){J=J.concat(e),Q()},Q=function(){tt<0&&(tt=N(X))},X=function(){$.size>10&&$.forEach((function(e,c){W.has(c)||$.delete(c)}));var e=_.map((function(e){return Z.get(e.entries[0])})),c=Y.length-50;Y=Y.filter((function(h,C){return C>=c||e.includes(h)}));for(var h=new Set,C=0;C<Y.length;C++){var I=Y[C];et(I.startTime,I.processingEnd).forEach((function(e){h.add(e)}))}for(var k=0;k<50;k++){var A=J[J.length-1-k];if(!A||A.startTime<D)break;h.add(A)}J=Array.from(h),tt=-1};V.push((function(e){e.interactionId&&e.target&&!$.has(e.interactionId)&&$.set(e.interactionId,e.target)}),(function(e){var c,h=e.startTime+e.duration;D=Math.max(D,e.processingEnd);for(var C=Y.length-1;C>=0;C--){var I=Y[C];if(Math.abs(h-I.renderTime)<=8){(c=I).startTime=Math.min(e.startTime,c.startTime),c.processingStart=Math.min(e.processingStart,c.processingStart),c.processingEnd=Math.max(e.processingEnd,c.processingEnd),c.entries.push(e);break}}c||(c={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:h,entries:[e]},Y.push(c)),(e.interactionId||"first-input"===e.entryType)&&Z.set(e,c),Q()}));var rt,it,ot,ct,et=function(e,c){for(var h,C=[],D=0;h=J[D];D++)if(!(h.startTime+h.duration<e)){if(h.startTime>c)break;C.push(h)}return C},nt=function(e,c){C||(C=l("long-animation-frame",K)),z((function(c){var h=function(e){var c=e.entries[0],h=Z.get(c),C=c.processingStart,D=h.processingEnd,I=h.entries.sort((function(e,c){return e.processingStart-c.processingStart})),k=et(c.startTime,D),A=e.entries.find((function(e){return e.target})),O=A&&A.target||$.get(c.interactionId),B=[c.startTime+c.duration,D].concat(k.map((function(e){return e.startTime+e.duration}))),R=Math.max.apply(Math,B),q={interactionTarget:o(O),interactionTargetElement:O,interactionType:c.name.startsWith("key")?"keyboard":"pointer",interactionTime:c.startTime,nextPaintTime:R,processedEventEntries:I,longAnimationFrameEntries:k,inputDelay:C-c.startTime,processingDuration:D-C,presentationDelay:Math.max(R-D,0),loadState:i(c.startTime)};return Object.assign(e,{attribution:q})}(c);e(h)}),c)},ft=[2500,4e3],dt={},at=function(e,c){!function(e,c){c=c||{},L((function(){var h,C=b(),D=d("LCP"),a=function(e){c.reportAllChanges||(e=e.slice(-1)),e.forEach((function(e){e.startTime<C.firstHiddenTime&&(D.value=Math.max(e.startTime-f(),0),D.entries=[e],h())}))},I=l("largest-contentful-paint",a);if(I){h=m(e,D,ft,c.reportAllChanges);var k=g((function(){dt[D.id]||(a(I.takeRecords()),I.disconnect(),dt[D.id]=!0,h(!0))}));["keydown","click"].forEach((function(e){addEventListener(e,(function(){return N(k)}),!0)})),v(k),s((function(C){D=d("LCP"),h=m(e,D,ft,c.reportAllChanges),p((function(){D.value=performance.now()-C.timeStamp,dt[D.id]=!0,h(!0)}))}))}}))}((function(c){var h=function(e){var c={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:e.value};if(e.entries.length){var h=r();if(h){var C=h.activationStart||0,D=e.entries[e.entries.length-1],I=D.url&&performance.getEntriesByType("resource").filter((function(e){return e.name===D.url}))[0],k=Math.max(0,h.responseStart-C),A=Math.max(k,I?(I.requestStart||I.startTime)-C:0),O=Math.max(A,I?I.responseEnd-C:0),B=Math.max(O,D.startTime-C);c={element:o(D.element),timeToFirstByte:k,resourceLoadDelay:A-k,resourceLoadDuration:O-A,elementRenderDelay:B-O,navigationEntry:h,lcpEntry:D},D.url&&(c.url=D.url),I&&(c.lcpResourceEntry=I)}}return Object.assign(e,{attribution:c})}(c);e(h)}),c)},gt=[800,1800],yt=function t(e){document.prerendering?L((function(){return t(e)})):"complete"!==document.readyState?addEventListener("load",(function(){return t(e)}),!0):setTimeout(e,0)},ut=function(e,c){c=c||{};var h=d("TTFB"),C=m(e,h,gt,c.reportAllChanges);yt((function(){var D=r();D&&(h.value=Math.max(D.responseStart-f(),0),h.entries=[D],C(!0),s((function(){h=d("TTFB",0),(C=m(e,h,gt,c.reportAllChanges))(!0)})))}))},st=function(e,c){ut((function(c){var h=function(e){var c={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(e.entries.length){var h=e.entries[0],C=h.activationStart||0,D=Math.max((h.workerStart||h.fetchStart)-C,0),I=Math.max(h.domainLookupStart-C,0),k=Math.max(h.connectStart-C,0),A=Math.max(h.connectEnd-C,0);c={waitingDuration:D,cacheDuration:I-D,dnsDuration:k-I,connectionDuration:A-k,requestDuration:e.value-A,navigationEntry:h}}return Object.assign(e,{attribution:c})}(c);e(h)}),c)},St={passive:!0,capture:!0},Et=new Date,lt=function(e,c){rt||(rt=c,it=e,ot=new Date,vt(removeEventListener),mt())},mt=function(){if(it>=0&&it<ot-Et){var e={entryType:"first-input",name:rt.type,target:rt.target,cancelable:rt.cancelable,startTime:rt.timeStamp,processingStart:rt.timeStamp+it};ct.forEach((function(c){c(e)})),ct=[]}},pt=function(e){if(e.cancelable){var c=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,c){var n=function(){lt(e,c),i()},r=function(){i()},i=function(){removeEventListener("pointerup",n,St),removeEventListener("pointercancel",r,St)};addEventListener("pointerup",n,St),addEventListener("pointercancel",r,St)}(c,e):lt(c,e)}},vt=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(c){return e(c,pt,St)}))},bt=[100,300],ht=function(e,c){c=c||{},L((function(){var h,C=b(),D=d("FID"),a=function(e){e.startTime<C.firstHiddenTime&&(D.value=e.processingStart-e.startTime,D.entries.push(e),h(!0))},o=function(e){e.forEach(a)},I=l("first-input",o);h=m(e,D,bt,c.reportAllChanges),I&&(v(g((function(){o(I.takeRecords()),I.disconnect()}))),s((function(){var C;D=d("FID"),h=m(e,D,bt,c.reportAllChanges),ct=[],it=-1,rt=null,vt(addEventListener),C=a,ct.push(C),mt()})))}))},Tt=function(e,c){ht((function(c){var h=function(e){var c=e.entries[0],h={eventTarget:o(c.target),eventType:c.name,eventTime:c.startTime,eventEntry:c,loadState:i(c.startTime)};return Object.assign(e,{attribution:h})}(c);e(h)}),c)};module.exports=c})();
\ No newline at end of file
(function(){"use strict";var a={};!function(){a.d=function(S,I){for(var C in I){if(a.o(I,C)&&!a.o(S,C)){Object.defineProperty(S,C,{enumerable:true,get:I[C]})}}}}();!function(){a.o=function(a,S){return Object.prototype.hasOwnProperty.call(a,S)}}();!function(){a.r=function(a){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(a,"__esModule",{value:true})}}();if(typeof a!=="undefined")a.ab=__dirname+"/";var S={};a.r(S);a.d(S,{CLSThresholds:function(){return R},FCPThresholds:function(){return j},INPThresholds:function(){return X},LCPThresholds:function(){return Y},TTFBThresholds:function(){return et},onCLS:function(){return F},onFCP:function(){return _},onINP:function(){return U},onLCP:function(){return G},onTTFB:function(){return Q}});class t{t;o=0;i=[];l(a){if(a.hadRecentInput)return;const S=this.i[0],I=this.i.at(-1);this.o&&S&&I&&a.startTime-I.startTime<1e3&&a.startTime-S.startTime<5e3?(this.o+=a.value,this.i.push(a)):(this.o=a.value,this.i=[a]),this.t?.(a)}}const n=()=>{const a=performance.getEntriesByType("navigation")[0];if(a&&a.responseStart>0&&a.responseStart<performance.now())return a},e=a=>{if("loading"===document.readyState)return"loading";const S=n();if(S){if(a<S.domInteractive)return"loading";if(0===S.domContentLoadedEventStart||a<S.domContentLoadedEventStart)return"dom-interactive";if(0===S.domComplete||a<S.domComplete)return"dom-content-loaded"}return"complete"},o=a=>{const S=a.nodeName;return 1===a.nodeType?S.toLowerCase():S.toUpperCase().replace(/^#/,"")},i=a=>{let S="";try{for(;9!==a?.nodeType;){const I=a,C=I.id?"#"+I.id:[o(I),...Array.from(I.classList??[]).sort()].join(".");if(S.length+C.length>99)return S||C;if(S=S?C+">"+S:C,I.id)break;a=I.parentNode}}catch{}return S},I=new WeakMap;function r(a,S){let C=I.get(S);return C||(C=new WeakMap,I.set(S,C)),C.get(a)||C.set(a,new S),C.get(a)}let C=-1;const c=()=>C,f=a=>{addEventListener("pageshow",(S=>{S.persisted&&(C=S.timeStamp,a(S))}),!0)},l=(a,S,I,C)=>{let L,B;return j=>{S.value>=0&&(j||C)&&(B=S.value-(L??0),(B||void 0===L)&&(L=S.value,S.delta=B,S.rating=((a,S)=>a>S[1]?"poor":a>S[0]?"needs-improvement":"good")(S.value,I),a(S)))}},u=a=>{requestAnimationFrame((()=>requestAnimationFrame(a)))},d=()=>n()?.activationStart??0;let L=-1;const B=new Set,v=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,p=a=>{if("hidden"===document.visibilityState){if("visibilitychange"===a.type)for(const a of B)a();isFinite(L)||(L="visibilitychange"===a.type?a.timeStamp:0,removeEventListener("prerenderingchange",p,!0))}},m=(a=!1)=>{if(a&&(L=1/0),L<0){const a=d(),S=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").find((S=>"hidden"===S.name&&S.startTime>=a))?.startTime;L=S??v(),addEventListener("visibilitychange",p,!0),addEventListener("prerenderingchange",p,!0),f((()=>{setTimeout((()=>{L=v()}))}))}return{get firstHiddenTime(){return L},onHidden(a){B.add(a)}}},y=(a,S=-1,I,C=0,L,B,j)=>{const R=n(),N=R?.navigationId||0;let H="navigate";I?H=I:c()>=0?H="back-forward-cache":R&&(document.prerendering||d()>0?H="prerender":document.wasDiscarded?H="restore":R.type&&(H=R.type.replace(/_/g,"-")));return{name:a,value:S,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:H,navigationId:C||N,navigationInteractionId:L,navigationURL:B||R?.name,navigationStartTime:j||0}},b=(a,S,I={})=>{try{const C=a.filter((a=>PerformanceObserver.supportedEntryTypes.includes(a)));if(C.length>0){const a=new PerformanceObserver((a=>{queueMicrotask((()=>{const I=a.getEntries();C.length>1&&I.sort(((a,S)=>a.startTime+a.duration-(S.startTime+S.duration))),S(I)}))}));for(const S of C)a.observe({type:S,buffered:!0,...I});return a}}catch{}},M=a=>globalThis.PerformanceObserver?.supportedEntryTypes.includes("soft-navigation")&&"function"==typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint&&a&&a.reportSoftNavs,T=(a,S)=>{if(a.set(S.navigationId,S),a.size>2){const S=a.keys().next().value;void 0!==S&&a.delete(S)}},E=a=>{let S=!1;return()=>{S||(a(),S=!0)}};class D{u}const w=a=>{document.prerendering?addEventListener("prerenderingchange",a,!0):a()},j=[1800,3e3],k=(a,S={})=>{const I=M(S);w((()=>{const C=r(S,D),L=m();let B,R=y("FCP");const N=b(["paint"],(a=>{for(const S of a)"first-contentful-paint"===S.name&&(N.disconnect(),S.startTime<L.firstHiddenTime&&(R.value=Math.max(S.startTime-d(),0),R.entries.push(S),R.navigationId=S.navigationId||R.navigationId,B(!0)))}));if(N&&(B=l(a,R,j,S.reportAllChanges),f((I=>{R=y("FCP",-1,"back-forward-cache",R.navigationId,R.navigationInteractionId,R.navigationURL,c()),B=l(a,R,j,S.reportAllChanges),u((()=>{R.value=performance.now()-I.timeStamp,B(!0)}))}))),I){b(["soft-navigation"],(I=>{I.forEach((I=>{C.u&&I.navigationId&&T(C.u,I);const L=Math.max((I.presentationTime||I.paintTime||0)-I.startTime,0);R=y("FCP",L,"soft-navigation",I.navigationId,I.interactionId,I.name,I.startTime),B=l(a,R,j,S.reportAllChanges),B(!0)}))}),S)}}))},R=[.1,.25],P=a=>a.find((a=>1===a.node?.nodeType))||a[0],F=(a,S={})=>{const I=r(S=Object.assign({},S),t),C=new WeakMap;I.t=a=>{if(a?.sources?.length){const I=P(a.sources),L=I?.node;if(L){const a=S.generateTarget?.(L)??i(L);C.set(I,a)}}};((a,S={})=>{const I=m();k(E((()=>{let C,L=y("CLS",0);const B=r(S,t),d=(I,j,N,H,z)=>{L=y("CLS",0,I,j,N,H,z),B.o=0,C=l(a,L,R,S.reportAllChanges)},h=(a=!1)=>{B.o>L.value&&(L.value=B.o,L.entries=B.i),C(a)},g=a=>{h(!0),d("soft-navigation",a.navigationId,a.interactionId,a.name,a.startTime)},v=a=>{for(const S of a)"soft-navigation"!==S.entryType?B.l(S):g(S);h()},j=["layout-shift"];M(S)&&j.push("soft-navigation");const N=b(j,v);N&&(C=l(a,L,R,S.reportAllChanges),I.onHidden((()=>{v(N.takeRecords()),C(!0)})),f((()=>{d("back-forward-cache",L.navigationId,L.navigationInteractionId,L.navigationURL,c()),u(C)})),setTimeout(C))})))})((S=>{a((a=>{let S={};if(a.entries.length){const I=a.entries.reduce(((a,S)=>a.value>S.value?a:S));if(I?.sources?.length){const a=P(I.sources);a&&(S={largestShiftTarget:C.get(a),largestShiftTime:I.startTime,largestShiftValue:I.value,largestShiftSource:a,largestShiftEntry:I,loadState:e(I.startTime)})}}return Object.assign(a,{attribution:S})})(S))}),S)},_=(a,S={})=>{const I=r(S=Object.assign({},S),D);M(S)&&(I.u=new Map);k((S=>{a((a=>{let S={timeToFirstByte:0,firstByteToFCP:a.value,loadState:e(c())};if("soft-navigation"!==a.navigationType){if(a.entries.length){const I=n(),C=a.entries.at(-1);if(I){const L=I.responseStart,B=I.activationStart||0,j=Math.max(0,L-B);S={timeToFirstByte:j,firstByteToFCP:a.value-j,loadState:e(a.entries[0].startTime),navigationEntry:I,fcpEntry:C}}}}else{const C=I.u?.get(a.navigationId);C&&(S={timeToFirstByte:0,firstByteToFCP:a.value,loadState:"complete",navigationEntry:C})}return Object.assign(a,{attribution:S})})(S))}),S)};let N=0,H=1/0,z=0;const O=a=>{for(const S of a)S.interactionId&&(H=Math.min(H,S.interactionId),z=Math.max(z,S.interactionId),N=z?(z-H)/7+1:0)};let V;const A=()=>V?N:performance.interactionCount??0,q=()=>{"interactionCount"in performance||V||(V=b(["event"],O,{durationThreshold:0}))};let J=0;class W{h=[];v=new Map;p;m;M(){J=A(),this.h.length=0,this.v.clear()}T(a){const S=A()-J,I=Math.min(this.h.length-1,Math.floor(S/50));return!S||-1!==I||"soft-navigation"!==a&&"back-forward-cache"!==a?this.h[I]:{D:8,id:-1,entries:[]}}l(a){if(this.p?.(a),!a.interactionId&&"first-input"!==a.entryType)return;const S=this.h.at(-1);let I=this.v.get(a.interactionId);if(I||this.h.length<10||a.duration>S.D){if(I?a.duration>I.D?(I.entries=[a],I.D=a.duration):a.duration===I.D&&a.startTime===I.entries[0].startTime&&I.entries.push(a):(I={id:a.interactionId,entries:[a],D:a.duration},this.v.set(I.id,I),this.h.push(I)),this.h.sort(((a,S)=>S.D-a.D)),this.h.length>10){const a=this.h.splice(10);for(const S of a)this.v.delete(S.id)}this.m?.(I)}}}const x=a=>{const S="requestIdleCallback"in globalThis?1e3:0,I=globalThis.requestIdleCallback||setTimeout,C=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)a();else{const L=E(a);let B=-1;const r=()=>{C(B),L()};addEventListener("visibilitychange",r,{once:!0,capture:!0}),B=I((()=>{removeEventListener("visibilitychange",r,{capture:!0}),L()}),{timeout:S})}},X=[200,500],U=(a,S={})=>{const I=r(S=Object.assign({},S),W);let C=[],L=[],B=0;const j=new WeakMap,R=new WeakMap;let N=!1;const v=()=>{N||(x(p),N=!0)},p=()=>{const a=new Set(I.h.map((a=>j.get(a.entries[0])))),S=L.length-10;L=L.filter(((I,C)=>C>=S||a.has(I)));const R=new Set;for(const a of L){const S=T(a.startTime,a.processingEnd);for(const a of S)R.add(a)}C=C.filter((a=>a.startTime>B||R.has(a))),N=!1};I.p=a=>{const I=a.startTime+a.duration;let C;B=Math.max(B,a.processingEnd);for(let B=L.length-1;B>=0;B--){const j=L[B];if(Math.abs(I-j.renderTime)<=8){C=j,C.startTime=Math.min(a.startTime,C.startTime),C.processingStart=Math.min(a.processingStart,C.processingStart),C.processingEnd=Math.max(a.processingEnd,C.processingEnd),S.includeProcessedEventEntries&&C.entries.push(a);break}}C||(C={startTime:a.startTime,processingStart:a.processingStart,processingEnd:a.processingEnd,renderTime:I,entries:S.includeProcessedEventEntries?[a]:[]},L.push(C)),(a.interactionId||"first-input"===a.entryType)&&j.set(a,C),v()},I.m=a=>{if(!R.get(a)){const I=a.entries.find((a=>a.target))?.target;if(I){const C=S.generateTarget?.(I)??i(I);R.set(a,C)}else{const S=a.entries.find((a=>a.targetSelector))?.targetSelector;S&&R.set(a,S)}}};const T=(a,S)=>{const I=[];for(const L of C)if(!(L.startTime+L.duration<a)){if(L.startTime>S)break;I.push(L)}return I},E=a=>{if(0===a.entries.length){const S=a.navigationStartTime||0,I={processedEventEntries:[],longAnimationFrameEntries:[],inputDelay:0,processingDuration:0,presentationDelay:a.value,loadState:e(S)};return Object.assign(a,{attribution:I})}const S=a.entries[0],C=j.get(S),L=C.processingStart,B=Math.max(S.startTime+S.duration,L),N=Math.min(C.processingEnd,B),H=C.entries.sort(((a,S)=>a.processingStart-S.processingStart)),z=T(S.startTime,N),V=I.v.get(S.interactionId),J={interactionTarget:R.get(V),interactionType:S.name.startsWith("key")?"keyboard":"pointer",interactionTime:S.startTime,nextPaintTime:B,processedEventEntries:H,longAnimationFrameEntries:z,inputDelay:L-S.startTime,processingDuration:N-L,presentationDelay:B-N,loadState:e(S.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(a=>{const S=a.interactionTime,I=a.nextPaintTime;if(!a.longAnimationFrameEntries?.length||!S||!I)return;const C=a.inputDelay,L=a.processingDuration;let B,j,R=0,N=0,H=0,z=0;for(const I of a.longAnimationFrameEntries){N=N+I.startTime+I.duration-I.styleAndLayoutStart;for(const a of I.scripts){const I=a.startTime+a.duration;if(I<S)continue;const H=I-Math.max(S,a.startTime),V=a.duration?H/a.duration*a.forcedStyleAndLayoutDuration:0;R+=H-V,N+=V,H>z&&(j=a.startTime<S+C?"input-delay":a.startTime>=S+C+L?"presentation-delay":"processing-duration",B=a,z=H)}}const V=a.longAnimationFrameEntries.at(-1),J=V?V.startTime+V.duration:0;J>=S+C+L&&(H=I-J),B&&j&&(a.longestScript={entry:B,subpart:j,intersectingDuration:z}),a.totalScriptDuration=R,a.totalStyleAndLayoutDuration=N,a.totalPaintDuration=H,a.totalUnattributedDuration=I-S-R-N-H})(J),Object.assign(a,{attribution:J})};b(["long-animation-frame"],(a=>{C=C.concat(a),v()}),S),((a,S={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const I=m();w((()=>{q();let C,L=y("INP");const B=r(S,W),s=(I,j,R,N,H)=>{B.M(),L=y("INP",-1,I,j,R,N,H),C=l(a,L,X,S.reportAllChanges)},u=()=>{const a=B.T(L.navigationType);a&&a.D!==L.value&&(L.value=a.D,L.entries=a.entries,C())},d=a=>{u(),C(!0),s("soft-navigation",a.navigationId,a.interactionId,a.name,a.startTime)},h=(a,S=!1)=>{x((()=>{for(const S of a)"soft-navigation"!==S.entryType?B.l(S):d(S);u(),S&&C(!0)}))},j=["event","first-input"];M(S)&&j.push("soft-navigation");const R=b(j,h,{...S,durationThreshold:S.durationThreshold??40});C=l(a,L,X,S.reportAllChanges),R&&(I.onHidden((()=>{h(R.takeRecords(),!0)})),f((()=>{s("back-forward-cache",L.navigationId,L.navigationInteractionId,L.navigationURL,c())})))}))})((S=>{a(E(S))}),S)};class ${p;u;l(a){this.p?.(a)}}const Y=[2500,4e3];let Z=50;const tt=[];b(["resource"],(a=>{for(const S of a)tt.push(S),tt.length>Z&&tt.shift()}));const G=(a,S={})=>{null!=(S=Object.assign({},S)).resourceBufferSize&&(Z=S.resourceBufferSize);const I=r(S,$),C=new WeakMap;M(S)&&(I.u=new Map),I.p=a=>{const I=a.element;if(I){const L=S.generateTarget?.(I)??i(I);C.set(a,L)}else a.id&&C.set(a,`#${a.id}`)};((a,S={})=>{let I=!1;const C=M(S);w((()=>{let L,B=m(),j=y("LCP");const R=r(S,$),g=(C,R,N,H,z)=>{j=y("LCP",-1,C,R,N,H,z),L=l(a,j,Y,S.reportAllChanges),I=!1,"soft-navigation"===C&&(B=m(!0))},v=a=>{R.u&&a.navigationId&&T(R.u,a),I||L(!0),g("soft-navigation",a.navigationId,a.interactionId,a.name,a.startTime);const S=a.getLargestInteractionContentfulPaint?.();S&&p([S])},p=a=>{S.reportAllChanges||C||(a=a.slice(-1));for(const S of a){if(!S)continue;if("soft-navigation"===S.entryType){v(S);continue}let a=0,I=[],C=S.startTime;if("largest-contentful-paint"===S.entryType)a=Math.max(S.startTime-d(),0),R.l(S),I=[S];else if("interaction-contentful-paint"===S.entryType){const L=S;if(!j.navigationId)continue;if("interactionId"in L&&L.interactionId!=j.navigationInteractionId)continue;C=L.largestContentfulPaint?.renderTime||0,a=Math.max(C-S.startTime,0),L.largestContentfulPaint&&(R.l(L.largestContentfulPaint),I=[L.largestContentfulPaint])}C<B.firstHiddenTime&&(j.value=a,j.entries=I,L())}},N=["largest-contentful-paint"];C&&N.push("interaction-contentful-paint","soft-navigation");const H=b(N,p);if(H){L=l(a,j,Y,S.reportAllChanges);const B=["keydown","click","visibilitychange"],r=a=>{if(a.isTrusted&&!I){const a=j.id;x((()=>{if(!I){if(!C){H.disconnect();for(const a of B)removeEventListener(a,r,{capture:!0})}a===j.id&&(I=!0,L(!0))}}))}};for(const a of B)addEventListener(a,r,{capture:!0});f((C=>{g("back-forward-cache",j.navigationId,j.navigationInteractionId,j.navigationURL,c()),L=l(a,j,Y,S.reportAllChanges),u((()=>{j.value=performance.now()-C.timeStamp,I=!0,L(!0)}))}))}}))})((S=>{a((a=>{let S={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:a.value};if(a.entries.length){const L=a.entries.at(-1),B=L.url&&(tt.findLast((a=>a.name===L.url))||performance.getEntriesByType("resource").findLast((a=>a.name===L.url)));let j;S.target=C.get(L),S.lcpEntry=L,L.url&&(S.url=L.url),B&&(S.lcpResourceEntry=B);let R=0,N=0;if("soft-navigation"!==a.navigationType?(j=n(),R=j?.activationStart??0,N=j?.responseStart??0):(R=a.navigationStartTime||0,j=I.u?.get(a.navigationId)),j){const I=Math.max(0,N-R),C=Math.max(I,B?(B.requestStart||B.startTime)-R:0),L=Math.min(a.value,Math.max(C,B?B.responseEnd-R:0));S={...S,timeToFirstByte:I,resourceLoadDelay:C-I,resourceLoadDuration:L-C,elementRenderDelay:a.value-L,navigationEntry:j}}}return Object.assign(a,{attribution:S})})(S))}),S)},et=[800,1800],K=a=>{document.prerendering?w((()=>K(a))):"complete"!==document.readyState?addEventListener("load",(()=>K(a)),!0):setTimeout(a)},Q=(a,S={})=>{((a,S={})=>{const I=M(S);let C=y("TTFB"),L=l(a,C,et,S.reportAllChanges);K((()=>{const B=n();if(B){const j=B.responseStart;C.value=Math.max(j-d(),0),C.entries=[B],L(!0),f((()=>{C=y("TTFB",0,"back-forward-cache",C.navigationId,C.navigationInteractionId,C.navigationURL,c()),L=l(a,C,et,S.reportAllChanges),L(!0)})),I&&b(["soft-navigation"],(I=>{I.forEach((I=>{I.navigationId&&(C=y("TTFB",0,"soft-navigation",I.navigationId,I.interactionId,I.name,I.startTime),C.entries=[I],L=l(a,C,et,S.reportAllChanges),L(!0))}))}),S)}}))})((S=>{a((a=>{const S=a.entries[0];let I={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0,navigationEntry:S};if(a.entries.length&&S instanceof PerformanceNavigationTiming){const C=S.activationStart||0,L=Math.max((S.workerStart||S.fetchStart||0)-C,0),B=Math.max(S.domainLookupStart-C,0),j=Math.max(S.connectStart-C,0),R=Math.max(S.connectEnd-C,0);I={waitingDuration:L,cacheDuration:B-L,dnsDuration:j-B,connectionDuration:R-j,requestDuration:a.value-R,navigationEntry:S}}return Object.assign(a,{attribution:I})})(S))}),S)};module.exports=S})();
\ No newline at end of file
(function(){"use strict";var n={};!function(){n.d=function(b,L){for(var P in L){if(n.o(L,P)&&!n.o(b,P)){Object.defineProperty(b,P,{enumerable:true,get:L[P]})}}}}();!function(){n.o=function(n,b){return Object.prototype.hasOwnProperty.call(n,b)}}();!function(){n.r=function(n){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(n,"__esModule",{value:true})}}();if(typeof n!=="undefined")n.ab=__dirname+"/";var b={};n.r(b);n.d(b,{CLSThresholds:function(){return j},FCPThresholds:function(){return B},FIDThresholds:function(){return cn},INPThresholds:function(){return nn},LCPThresholds:function(){return en},TTFBThresholds:function(){return rn},onCLS:function(){return w},onFCP:function(){return S},onFID:function(){return $},onINP:function(){return N},onLCP:function(){return z},onTTFB:function(){return K}});var L,P,I,A,F,D=-1,a=function(n){addEventListener("pageshow",(function(b){b.persisted&&(D=b.timeStamp,n(b))}),!0)},c=function(){var n=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStart<performance.now())return n},u=function(){var n=c();return n&&n.activationStart||0},f=function(n,b){var L=c(),P="navigate";D>=0?P="back-forward-cache":L&&(document.prerendering||u()>0?P="prerender":document.wasDiscarded?P="restore":L.type&&(P=L.type.replace(/_/g,"-")));return{name:n,value:void 0===b?-1:b,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:P}},s=function(n,b,L){try{if(PerformanceObserver.supportedEntryTypes.includes(n)){var P=new PerformanceObserver((function(n){Promise.resolve().then((function(){b(n.getEntries())}))}));return P.observe(Object.assign({type:n,buffered:!0},L||{})),P}}catch(n){}},d=function(n,b,L,P){var I,A;return function(F){b.value>=0&&(F||P)&&((A=b.value-(I||0))||void 0===I)&&(I=b.value,b.delta=A,b.rating=function(n,b){return n>b[1]?"poor":n>b[0]?"needs-improvement":"good"}(b.value,L),n(b))}},l=function(n){requestAnimationFrame((function(){return requestAnimationFrame((function(){return n()}))}))},p=function(n){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&n()}))},v=function(n){var b=!1;return function(){b||(n(),b=!0)}},O=-1,h=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},g=function(n){"hidden"===document.visibilityState&&O>-1&&(O="visibilitychange"===n.type?n.timeStamp:0,T())},y=function(){addEventListener("visibilitychange",g,!0),addEventListener("prerenderingchange",g,!0)},T=function(){removeEventListener("visibilitychange",g,!0),removeEventListener("prerenderingchange",g,!0)},E=function(){return O<0&&(O=h(),y(),a((function(){setTimeout((function(){O=h(),y()}),0)}))),{get firstHiddenTime(){return O}}},C=function(n){document.prerendering?addEventListener("prerenderingchange",(function(){return n()}),!0):n()},B=[1800,3e3],S=function(n,b){b=b||{},C((function(){var L,P=E(),I=f("FCP"),A=s("paint",(function(n){n.forEach((function(n){"first-contentful-paint"===n.name&&(A.disconnect(),n.startTime<P.firstHiddenTime&&(I.value=Math.max(n.startTime-u(),0),I.entries.push(n),L(!0)))}))}));A&&(L=d(n,I,B,b.reportAllChanges),a((function(P){I=f("FCP"),L=d(n,I,B,b.reportAllChanges),l((function(){I.value=performance.now()-P.timeStamp,L(!0)}))})))}))},j=[.1,.25],w=function(n,b){b=b||{},S(v((function(){var L,P=f("CLS",0),I=0,A=[],c=function(n){n.forEach((function(n){if(!n.hadRecentInput){var b=A[0],L=A[A.length-1];I&&n.startTime-L.startTime<1e3&&n.startTime-b.startTime<5e3?(I+=n.value,A.push(n)):(I=n.value,A=[n])}})),I>P.value&&(P.value=I,P.entries=A,L())},F=s("layout-shift",c);F&&(L=d(n,P,j,b.reportAllChanges),p((function(){c(F.takeRecords()),L(!0)})),a((function(){I=0,P=f("CLS",0),L=d(n,P,j,b.reportAllChanges),l((function(){return L()}))})),setTimeout(L,0))})))},x=0,_=1/0,G=0,M=function(n){n.forEach((function(n){n.interactionId&&(_=Math.min(_,n.interactionId),G=Math.max(G,n.interactionId),x=G?(G-_)/7+1:0)}))},k=function(){"interactionCount"in performance||L||(L=s("event",M,{type:"event",buffered:!0,durationThreshold:0}))},J=[],Q=new Map,U=0,R=function(){return(L?x:performance.interactionCount||0)-U},Z=[],H=function(n){if(Z.forEach((function(b){return b(n)})),n.interactionId||"first-input"===n.entryType){var b=J[J.length-1],L=Q.get(n.interactionId);if(L||J.length<10||n.duration>b.latency){if(L)n.duration>L.latency?(L.entries=[n],L.latency=n.duration):n.duration===L.latency&&n.startTime===L.entries[0].startTime&&L.entries.push(n);else{var P={id:n.interactionId,latency:n.duration,entries:[n]};Q.set(P.id,P),J.push(P)}J.sort((function(n,b){return b.latency-n.latency})),J.length>10&&J.splice(10).forEach((function(n){return Q.delete(n.id)}))}}},q=function(n){var b=self.requestIdleCallback||self.setTimeout,L=-1;return n=v(n),"hidden"===document.visibilityState?n():(L=b(n),p(n)),L},nn=[200,500],N=function(n,b){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(b=b||{},C((function(){var L;k();var P,I=f("INP"),o=function(n){q((function(){n.forEach(H);var b,L=(b=Math.min(J.length-1,Math.floor(R()/50)),J[b]);L&&L.latency!==I.value&&(I.value=L.latency,I.entries=L.entries,P())}))},A=s("event",o,{durationThreshold:null!==(L=b.durationThreshold)&&void 0!==L?L:40});P=d(n,I,nn,b.reportAllChanges),A&&(A.observe({type:"first-input",buffered:!0}),p((function(){o(A.takeRecords()),P(!0)})),a((function(){U=0,J.length=0,Q.clear(),I=f("INP"),P=d(n,I,nn,b.reportAllChanges)})))})))},en=[2500,4e3],tn={},z=function(n,b){b=b||{},C((function(){var L,P=E(),I=f("LCP"),o=function(n){b.reportAllChanges||(n=n.slice(-1)),n.forEach((function(n){n.startTime<P.firstHiddenTime&&(I.value=Math.max(n.startTime-u(),0),I.entries=[n],L())}))},A=s("largest-contentful-paint",o);if(A){L=d(n,I,en,b.reportAllChanges);var F=v((function(){tn[I.id]||(o(A.takeRecords()),A.disconnect(),tn[I.id]=!0,L(!0))}));["keydown","click"].forEach((function(n){addEventListener(n,(function(){return q(F)}),!0)})),p(F),a((function(P){I=f("LCP"),L=d(n,I,en,b.reportAllChanges),l((function(){I.value=performance.now()-P.timeStamp,tn[I.id]=!0,L(!0)}))}))}}))},rn=[800,1800],on=function e(n){document.prerendering?C((function(){return e(n)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(n)}),!0):setTimeout(n,0)},K=function(n,b){b=b||{};var L=f("TTFB"),P=d(n,L,rn,b.reportAllChanges);on((function(){var I=c();I&&(L.value=Math.max(I.responseStart-u(),0),L.entries=[I],P(!0),a((function(){L=f("TTFB",0),(P=d(n,L,rn,b.reportAllChanges))(!0)})))}))},an={passive:!0,capture:!0},un=new Date,V=function(n,b){P||(P=b,I=n,A=new Date,Y(removeEventListener),W())},W=function(){if(I>=0&&I<A-un){var n={entryType:"first-input",name:P.type,target:P.target,cancelable:P.cancelable,startTime:P.timeStamp,processingStart:P.timeStamp+I};F.forEach((function(b){b(n)})),F=[]}},X=function(n){if(n.cancelable){var b=(n.timeStamp>1e12?new Date:performance.now())-n.timeStamp;"pointerdown"==n.type?function(n,b){var t=function(){V(n,b),i()},r=function(){i()},i=function(){removeEventListener("pointerup",t,an),removeEventListener("pointercancel",r,an)};addEventListener("pointerup",t,an),addEventListener("pointercancel",r,an)}(b,n):V(b,n)}},Y=function(n){["mousedown","keydown","touchstart","pointerdown"].forEach((function(b){return n(b,X,an)}))},cn=[100,300],$=function(n,b){b=b||{},C((function(){var L,A=E(),D=f("FID"),l=function(n){n.startTime<A.firstHiddenTime&&(D.value=n.processingStart-n.startTime,D.entries.push(n),L(!0))},m=function(n){n.forEach(l)},O=s("first-input",m);L=d(n,D,cn,b.reportAllChanges),O&&(p(v((function(){m(O.takeRecords()),O.disconnect()}))),a((function(){var A;D=f("FID"),L=d(n,D,cn,b.reportAllChanges),F=[],I=-1,P=null,Y(addEventListener),A=l,F.push(A),W()})))}))};module.exports=b})();
\ No newline at end of file
(function(){"use strict";var t={};!function(){t.d=function(r,c){for(var I in c){if(t.o(c,I)&&!t.o(r,I)){Object.defineProperty(r,I,{enumerable:true,get:c[I]})}}}}();!function(){t.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)}}();!function(){t.r=function(t){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(t,"__esModule",{value:true})}}();if(typeof t!=="undefined")t.ab=__dirname+"/";var r={};t.r(r);t.d(r,{CLSThresholds:function(){return M},FCPThresholds:function(){return w},INPThresholds:function(){return $},LCPThresholds:function(){return z},TTFBThresholds:function(){return G},onCLS:function(){return P},onFCP:function(){return _},onINP:function(){return H},onLCP:function(){return W},onTTFB:function(){return R}});let c=-1;const n=()=>c,e=t=>{addEventListener("pageshow",(r=>{r.persisted&&(c=r.timeStamp,t(r))}),!0)},i=(t,r,c,I)=>{let L,S;return w=>{r.value>=0&&(w||I)&&(S=r.value-(L??0),(S||void 0===L)&&(L=r.value,r.delta=S,r.rating=((t,r)=>t>r[1]?"poor":t>r[0]?"needs-improvement":"good")(r.value,c),t(r)))}},o=t=>{requestAnimationFrame((()=>requestAnimationFrame(t)))},s=()=>{const t=performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStart<performance.now())return t},a=()=>s()?.activationStart??0;let I=-1;const L=new Set,f=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,d=t=>{if("hidden"===document.visibilityState){if("visibilitychange"===t.type)for(const t of L)t();isFinite(I)||(I="visibilitychange"===t.type?t.timeStamp:0,removeEventListener("prerenderingchange",d,!0))}},h=(t=!1)=>{if(t&&(I=1/0),I<0){const t=a(),r=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").find((r=>"hidden"===r.name&&r.startTime>=t))?.startTime;I=r??f(),addEventListener("visibilitychange",d,!0),addEventListener("prerenderingchange",d,!0),e((()=>{setTimeout((()=>{I=f()}))}))}return{get firstHiddenTime(){return I},onHidden(t){L.add(t)}}},l=(t,r=-1,c,I=0,L,S,w)=>{const M=s(),k=M?.navigationId||0;let F="navigate";c?F=c:n()>=0?F="back-forward-cache":M&&(document.prerendering||a()>0?F="prerender":document.wasDiscarded?F="restore":M.type&&(F=M.type.replace(/_/g,"-")));return{name:t,value:r,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:F,navigationId:I||k,navigationInteractionId:L,navigationURL:S||M?.name,navigationStartTime:w||0}},S=new WeakMap;function u(t,r){let c=S.get(r);return c||(c=new WeakMap,S.set(r,c)),c.get(t)||c.set(t,new r),c.get(t)}class v{t;i=0;o=[];h(t){if(t.hadRecentInput)return;const r=this.o[0],c=this.o.at(-1);this.i&&r&&c&&t.startTime-c.startTime<1e3&&t.startTime-r.startTime<5e3?(this.i+=t.value,this.o.push(t)):(this.i=t.value,this.o=[t]),this.t?.(t)}}const m=(t,r,c={})=>{try{const I=t.filter((t=>PerformanceObserver.supportedEntryTypes.includes(t)));if(I.length>0){const t=new PerformanceObserver((t=>{queueMicrotask((()=>{const c=t.getEntries();I.length>1&&c.sort(((t,r)=>t.startTime+t.duration-(r.startTime+r.duration))),r(c)}))}));for(const r of I)t.observe({type:r,buffered:!0,...c});return t}}catch{}},p=t=>globalThis.PerformanceObserver?.supportedEntryTypes.includes("soft-navigation")&&"function"==typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint&&t&&t.reportSoftNavs,b=(t,r)=>{if(t.set(r.navigationId,r),t.size>2){const r=t.keys().next().value;void 0!==r&&t.delete(r)}},T=t=>{let r=!1;return()=>{r||(t(),r=!0)}};class y{l}const E=t=>{document.prerendering?addEventListener("prerenderingchange",t,!0):t()},w=[1800,3e3],_=(t,r={})=>{const c=p(r);E((()=>{const I=u(r,y),L=h();let S,M=l("FCP");const k=m(["paint"],(t=>{for(const r of t)"first-contentful-paint"===r.name&&(k.disconnect(),r.startTime<L.firstHiddenTime&&(M.value=Math.max(r.startTime-a(),0),M.entries.push(r),M.navigationId=r.navigationId||M.navigationId,S(!0)))}));if(k&&(S=i(t,M,w,r.reportAllChanges),e((c=>{M=l("FCP",-1,"back-forward-cache",M.navigationId,M.navigationInteractionId,M.navigationURL,n()),S=i(t,M,w,r.reportAllChanges),o((()=>{M.value=performance.now()-c.timeStamp,S(!0)}))}))),c){m(["soft-navigation"],(c=>{c.forEach((c=>{I.l&&c.navigationId&&b(I.l,c);const L=Math.max((c.presentationTime||c.paintTime||0)-c.startTime,0);M=l("FCP",L,"soft-navigation",c.navigationId,c.interactionId,c.name,c.startTime),S=i(t,M,w,r.reportAllChanges),S(!0)}))}),r)}}))},M=[.1,.25],P=(t,r={})=>{const c=h();_(T((()=>{let I,L=l("CLS",0);const S=u(r,v),d=(c,w,k,F,x)=>{L=l("CLS",0,c,w,k,F,x),S.i=0,I=i(t,L,M,r.reportAllChanges)},h=(t=!1)=>{S.i>L.value&&(L.value=S.i,L.entries=S.o),I(t)},g=t=>{h(!0),d("soft-navigation",t.navigationId,t.interactionId,t.name,t.startTime)},b=t=>{for(const r of t)"soft-navigation"!==r.entryType?S.h(r):g(r);h()},w=["layout-shift"];p(r)&&w.push("soft-navigation");const k=m(w,b);k&&(I=i(t,L,M,r.reportAllChanges),c.onHidden((()=>{b(k.takeRecords()),I(!0)})),e((()=>{d("back-forward-cache",L.navigationId,L.navigationInteractionId,L.navigationURL,n()),o(I)})),setTimeout(I))})))};let k=0,F=1/0,x=0;const C=t=>{for(const r of t)r.interactionId&&(F=Math.min(F,r.interactionId),x=Math.max(x,r.interactionId),k=x?(x-F)/7+1:0)};let U;const B=()=>U?k:performance.interactionCount??0,N=()=>{"interactionCount"in performance||U||(U=m(["event"],C,{durationThreshold:0}))};let j=0;class q{u=[];v=new Map;m;p;T(){j=B(),this.u.length=0,this.v.clear()}M(t){const r=B()-j,c=Math.min(this.u.length-1,Math.floor(r/50));return!r||-1!==c||"soft-navigation"!==t&&"back-forward-cache"!==t?this.u[c]:{_:8,id:-1,entries:[]}}h(t){if(this.m?.(t),!t.interactionId&&"first-input"!==t.entryType)return;const r=this.u.at(-1);let c=this.v.get(t.interactionId);if(c||this.u.length<10||t.duration>r._){if(c?t.duration>c._?(c.entries=[t],c._=t.duration):t.duration===c._&&t.startTime===c.entries[0].startTime&&c.entries.push(t):(c={id:t.interactionId,entries:[t],_:t.duration},this.v.set(c.id,c),this.u.push(c)),this.u.sort(((t,r)=>r._-t._)),this.u.length>10){const t=this.u.splice(10);for(const r of t)this.v.delete(r.id)}this.p?.(c)}}}const A=t=>{const r="requestIdleCallback"in globalThis?1e3:0,c=globalThis.requestIdleCallback||setTimeout,I=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)t();else{const L=T(t);let S=-1;const a=()=>{I(S),L()};addEventListener("visibilitychange",a,{once:!0,capture:!0}),S=c((()=>{removeEventListener("visibilitychange",a,{capture:!0}),L()}),{timeout:r})}},$=[200,500],H=(t,r={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const c=h();E((()=>{N();let I,L=l("INP");const S=u(r,q),f=(c,w,M,k,F)=>{S.T(),L=l("INP",-1,c,w,M,k,F),I=i(t,L,$,r.reportAllChanges)},d=()=>{const t=S.M(L.navigationType);t&&t._!==L.value&&(L.value=t._,L.entries=t.entries,I())},h=t=>{d(),I(!0),f("soft-navigation",t.navigationId,t.interactionId,t.name,t.startTime)},g=(t,r=!1)=>{A((()=>{for(const r of t)"soft-navigation"!==r.entryType?S.h(r):h(r);d(),r&&I(!0)}))},w=["event","first-input"];p(r)&&w.push("soft-navigation");const M=m(w,g,{...r,durationThreshold:r.durationThreshold??40});I=i(t,L,$,r.reportAllChanges),M&&(c.onHidden((()=>{g(M.takeRecords(),!0)})),e((()=>{f("back-forward-cache",L.navigationId,L.navigationInteractionId,L.navigationURL,n())})))}))};class O{m;l;h(t){this.m?.(t)}}const z=[2500,4e3],W=(t,r={})=>{let c=!1;const I=p(r);E((()=>{let L,S=h(),w=l("LCP");const M=u(r,O),p=(I,M,k,F,x)=>{w=l("LCP",-1,I,M,k,F,x),L=i(t,w,z,r.reportAllChanges),c=!1,"soft-navigation"===I&&(S=h(!0))},T=t=>{M.l&&t.navigationId&&b(M.l,t),c||L(!0),p("soft-navigation",t.navigationId,t.interactionId,t.name,t.startTime);const r=t.getLargestInteractionContentfulPaint?.();r&&y([r])},y=t=>{r.reportAllChanges||I||(t=t.slice(-1));for(const r of t){if(!r)continue;if("soft-navigation"===r.entryType){T(r);continue}let t=0,c=[],I=r.startTime;if("largest-contentful-paint"===r.entryType)t=Math.max(r.startTime-a(),0),M.h(r),c=[r];else if("interaction-contentful-paint"===r.entryType){const L=r;if(!w.navigationId)continue;if("interactionId"in L&&L.interactionId!=w.navigationInteractionId)continue;I=L.largestContentfulPaint?.renderTime||0,t=Math.max(I-r.startTime,0),L.largestContentfulPaint&&(M.h(L.largestContentfulPaint),c=[L.largestContentfulPaint])}I<S.firstHiddenTime&&(w.value=t,w.entries=c,L())}},k=["largest-contentful-paint"];I&&k.push("interaction-contentful-paint","soft-navigation");const F=m(k,y);if(F){L=i(t,w,z,r.reportAllChanges);const S=["keydown","click","visibilitychange"],d=t=>{if(t.isTrusted&&!c){const t=w.id;A((()=>{if(!c){if(!I){F.disconnect();for(const t of S)removeEventListener(t,d,{capture:!0})}t===w.id&&(c=!0,L(!0))}}))}};for(const t of S)addEventListener(t,d,{capture:!0});e((I=>{p("back-forward-cache",w.navigationId,w.navigationInteractionId,w.navigationURL,n()),L=i(t,w,z,r.reportAllChanges),o((()=>{w.value=performance.now()-I.timeStamp,c=!0,L(!0)}))}))}}))},G=[800,1800],D=t=>{document.prerendering?E((()=>D(t))):"complete"!==document.readyState?addEventListener("load",(()=>D(t)),!0):setTimeout(t)},R=(t,r={})=>{const c=p(r);let I=l("TTFB"),L=i(t,I,G,r.reportAllChanges);D((()=>{const S=s();if(S){const w=S.responseStart;if(I.value=Math.max(w-a(),0),I.entries=[S],L(!0),e((()=>{I=l("TTFB",0,"back-forward-cache",I.navigationId,I.navigationInteractionId,I.navigationURL,n()),L=i(t,I,G,r.reportAllChanges),L(!0)})),c){m(["soft-navigation"],(c=>{c.forEach((c=>{c.navigationId&&(I=l("TTFB",0,"soft-navigation",c.navigationId,c.interactionId,c.name,c.startTime),I.entries=[c],L=i(t,I,G,r.reportAllChanges),L(!0))}))}),r)}}}))};module.exports=r})();
\ No newline at end of file
......@@ -342,7 +342,6 @@ export const experimentalSchema = {
z.union([
z.literal('CLS'),
z.literal('FCP'),
z.literal('FID'),
z.literal('INP'),
z.literal('LCP'),
z.literal('TTFB'),
......
......@@ -42,7 +42,7 @@ export type AppTreeType = ComponentType<
* Web vitals provided to _app.reportWebVitals by Core Web Vitals plugin developed by Google Chrome team.
* https://nextjs.org/blog/next-9-4#integrated-web-vitals-reporting
*/
export const WEB_VITALS = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'] as const
export const WEB_VITALS = ['CLS', 'FCP', 'INP', 'LCP', 'TTFB'] as const
export type NextWebVitalsMetric = {
id: string
startTime: number
......
diff --git a/dist/modules/types.d.ts b/dist/modules/types.d.ts
index 080d3667303398f9ee8cf782c43f2230ea72ef53..cdfe14ad4bdbe07023301dae36e7ea64a5048bf4 100644
--- a/dist/modules/types.d.ts
+++ b/dist/modules/types.d.ts
@@ -27,7 +27,8 @@ declare global {
}
interface PerformanceEventTiming extends PerformanceEntry {
duration: DOMHighResTimeStamp;
- interactionId: number;
+ // Waiting for https://github.com/GoogleChrome/web-vitals/commit/a92f8a78bce9e400366bc29db5fc23fdf23db469
+ readonly interactionId: number;
}
interface LayoutShiftAttribution {
node?: Node;
......@@ -53,9 +53,6 @@ patchedDependencies:
taskr@1.1.0:
hash: 1d0f571943b5d4761d4f2f39723796e402dd317f14a7c714e2021d3f12cc481c
path: patches/taskr@1.1.0.patch
web-vitals@4.2.1:
hash: f4d0a6719cc28520df7c47a0e2c2641759c2a0ad06ad57868c4c9d0567d4276d
path: patches/web-vitals@4.2.1.patch
webpack-sources@3.2.3:
hash: 26afc15966a3fc37a3d1d366312a95ce66723513f6a3a720e4166a37147da8bd
path: patches/webpack-sources@3.2.3.patch
......@@ -1783,8 +1780,8 @@ importers:
specifier: 2.4.0
version: 2.4.0
web-vitals:
specifier: 4.2.1
version: 4.2.1(patch_hash=f4d0a6719cc28520df7c47a0e2c2641759c2a0ad06ad57868c4c9d0567d4276d)
specifier: 6.1.0
version: 6.1.0
webpack:
specifier: 5.98.0
version: 5.98.0(@swc/core@1.11.24(@swc/helpers@0.5.23))(esbuild@0.25.9)
......@@ -17936,8 +17933,8 @@ packages:
web-namespaces@1.1.4:
resolution: {integrity: sha512-wYxSGajtmoP4WxfejAPIr4l0fVh+jeMXZb08wNc0tMg6xsfZXj3cECqIK0G7ZAqUq0PP8WlMDtaOGVBTAWztNw==}
web-vitals@4.2.1:
resolution: {integrity: sha512-U6bAxeudnhDqcXNl50JC4hLlqox9DZnngxfISZm3DMZnonW35xtJOVUc091L+DOY+6hVZVpKXoiCP0RiT6339Q==}
web-vitals@6.1.0:
resolution: {integrity: sha512-ZNoJ/MbU6aaR2WjKrFVUvy5WQx+G96YvXQFSsmKTz3A/0VlAFywjUcxl00hc/S6wef2stfgQ4yWYIJCWCNudkA==}
web-worker@1.3.0:
resolution: {integrity: sha512-BSR9wyRsy/KOValMgd5kMyr3JzpdeoR9KVId8u5GVlTTAtNChlsE4yTxeY7zMdNSyOmoKBv8NH2qeRY9Tg+IaA==}
......@@ -37424,7 +37421,7 @@ snapshots:
web-namespaces@1.1.4: {}
web-vitals@4.2.1(patch_hash=f4d0a6719cc28520df7c47a0e2c2641759c2a0ad06ad57868c4c9d0567d4276d): {}
web-vitals@6.1.0: {}
web-worker@1.3.0: {}
export default function component() {
return (
<>
<h1 id="destination">Destination</h1>
{/* Some content to paint, so that the client-side navigation to this page
can be detected as a soft navigation by the browser. */}
<p>{'Lorem ipsum dolor sit amet. '.repeat(100)}</p>
</>
)
}
'use client'
import { useState, useEffect } from 'react'
import Link from 'next/link'
import Reporter from './reporter'
export default function ClientNestedLayout({ children }) {
const [count, setCount] = useState(0)
......@@ -13,6 +15,12 @@ export default function ClientNestedLayout({ children }) {
<button id="btn" onClick={() => setCount(count + 1)}>
{count}
</button>
<Link href="/report-web-vitals/destination" id="to-destination">
To destination
</Link>
{/* Rendered by the layout, so that it stays mounted across client-side
navigations, like a root layout would. */}
<Reporter />
{children}
</>
)
......
import Reporter from './reporter'
export default function component() {
return (
<>
<h1>Test</h1>
<Reporter />
</>
)
}
import { nextTestSetup } from 'e2e-utils'
import { check } from 'next-test-utils'
import { retry } from 'next-test-utils'
type ReportedMetric = Record<string, string>
describe('useReportWebVitals hook', () => {
const { next } = nextTestSetup({
......@@ -15,30 +17,102 @@ describe('useReportWebVitals hook', () => {
await next.start()
})
// Analytics events are only sent in production
it('should send web-vitals', async () => {
await next.fetch('/report-web-vitals')
// The reporter posts every metric to `https://example.vercel.sh/vitals`, which
// is intercepted here so that the reported metrics can be asserted on.
async function openReportWebVitalsPage() {
const metrics: ReportedMetric[] = []
let eventsCount = 0
const browser = await next.browser('/report-web-vitals', {
beforePageLoad: (page) => {
page.route('https://example.vercel.sh/vitals', (route) => {
eventsCount += 1
metrics.push(
Object.fromEntries(
new URLSearchParams(route.request().postData() ?? '')
)
)
route.fulfill()
})
},
})
// Refresh will trigger CLS and LCP. When page loads FCP and TTFB will trigger:
await browser.refresh()
return { browser, metrics }
}
// After interaction LCP and FID will trigger
// Analytics events are only sent in production
it('should send web-vitals', async () => {
await next.fetch('/report-web-vitals')
const { browser, metrics } = await openReportWebVitalsPage()
// Interacting with the page is required for INP to be measured.
await browser.elementById('btn').click()
// Make sure all registered events in performance-relayer has fired
await check(async () => {
expect(eventsCount).toBeGreaterThanOrEqual(6)
return 'success'
}, 'success')
// Refreshing hides the current page, which finalizes CLS, INP and LCP for
// it. Loading the page again reports FCP and TTFB another time.
await browser.refresh()
await retry(async () => {
expect(metrics.map((metric) => metric.name)).toEqual(
expect.arrayContaining(['CLS', 'FCP', 'INP', 'LCP', 'TTFB'])
)
})
// Metrics are reported for the URL they were measured for, which is not
// necessarily the URL of the page at the time of reporting.
for (const metric of metrics) {
expect(metric.navigationURL).toContain('/report-web-vitals')
}
})
it('should send web-vitals for soft navigations', async () => {
await next.fetch('/report-web-vitals/destination')
const { browser, metrics } = await openReportWebVitalsPage()
// Soft navigations are only measured by browsers that support the Soft
// Navigations API (Chromium 151+). `web-vitals` feature detects it, and
// keeps reporting metrics for the initial page load only otherwise.
const supportsSoftNavigations = await browser.eval(
() =>
PerformanceObserver.supportedEntryTypes.includes('soft-navigation') &&
typeof (globalThis as any).PerformanceSoftNavigation?.prototype
?.getLargestInteractionContentfulPaint === 'function'
)
await browser.elementById('to-destination').click()
await retry(async () => {
expect(await browser.elementById('destination').text()).toBe(
'Destination'
)
})
// Hiding the page finalizes the metrics that are still pending for it.
await browser.refresh()
await retry(async () => {
expect(metrics.map((metric) => metric.name)).toEqual(
expect.arrayContaining(['CLS', 'FCP', 'LCP', 'TTFB'])
)
})
const softNavigationMetrics = metrics.filter(
(metric) => metric.navigationType === 'soft-navigation'
)
if (!supportsSoftNavigations) {
expect(softNavigationMetrics).toEqual([])
return
}
// The Core Web Vitals are measured again for the soft navigation, and are
// reported for the URL that was navigated to.
expect(softNavigationMetrics.map((metric) => metric.name)).toEqual(
expect.arrayContaining(['LCP'])
)
for (const metric of softNavigationMetrics) {
expect(metric.navigationURL).toContain('/report-web-vitals/destination')
}
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment