From 3aaee12327952c0fa6919a424fb36c4ac2d344c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Alvarez?= Date: Fri, 24 Nov 2023 09:12:42 +0100 Subject: [PATCH] feat(packages/sui-react-web-vitals): add presentationTime comment --- packages/sui-react-web-vitals/src/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/sui-react-web-vitals/src/index.js b/packages/sui-react-web-vitals/src/index.js index f391c2e88..aa1ee42ea 100644 --- a/packages/sui-react-web-vitals/src/index.js +++ b/packages/sui-react-web-vitals/src/index.js @@ -81,6 +81,9 @@ export default function WebVitalsReporter({ } const computeINPMetrics = entry => { + // RenderTime is an estimate because duration is rounded and may get rounded down. + // In rare cases, it can be less than processingEnd and that breaks performance.measure(). + // Let's ensure it's at least 4ms in those cases so you can barely see it. const presentationTime = Math.max(entry.processingEnd + 4, entry.startTime + entry.duration) return {