Skip to content

Commit

Permalink
feat(packages/sui-react-web-vitals): add presentationTime comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrés Alvarez authored and Andrés Alvarez committed Nov 24, 2023
1 parent 55f1eaf commit 3aaee12
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/sui-react-web-vitals/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3aaee12

Please sign in to comment.