Skip to content

Commit

Permalink
add method to measure Interaction to Next Paint (INP)
Browse files Browse the repository at this point in the history
`web-vitals` CHANGELOG for v3:

- [BREAKING] Report TTFB after a bfcache restore
- [BREAKING] Only include last LCP entry in metric entries
- Add support for the new INP metric
- Rename getXXX() functions to onXXX()
- Add a navigationType property to the Metric object

See https://github.com/GoogleChrome/web-vitals/blob/next/CHANGELOG.md
  • Loading branch information
Keen Yee Liau committed May 11, 2022
1 parent 334d42c commit 5e514f0
Show file tree
Hide file tree
Showing 7 changed files with 113,802 additions and 113,725 deletions.
28 changes: 15 additions & 13 deletions packages/next/client/performance-relayer.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/* global location */
import {
getCLS,
getFCP,
getFID,
getLCP,
getTTFB,
onCLS,
onFCP,
onFID,
onINP,
onLCP,
onTTFB,
Metric,
ReportHandler,
ReportCallback,
} from 'next/dist/compiled/web-vitals'

const initialHref = location.href
let isRegistered = false
let userReportHandler: ReportHandler | undefined
let userReportHandler: ReportCallback | undefined

function onReport(metric: Metric): void {
if (userReportHandler) {
Expand Down Expand Up @@ -71,7 +72,7 @@ function onReport(metric: Metric): void {
}
}

export default (onPerfEntry?: ReportHandler): void => {
export default (onPerfEntry?: ReportCallback): void => {
// Update function if it changes:
userReportHandler = onPerfEntry

Expand All @@ -81,9 +82,10 @@ export default (onPerfEntry?: ReportHandler): void => {
}
isRegistered = true

getCLS(onReport)
getFID(onReport)
getFCP(onReport)
getLCP(onReport)
getTTFB(onReport)
onCLS(onReport)
onFID(onReport)
onFCP(onReport)
onLCP(onReport)
onTTFB(onReport)
onINP(onReport)
}
149 changes: 112 additions & 37 deletions packages/next/compiled/babel-packages/packages-bundle.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions packages/next/compiled/babel/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/next/compiled/web-vitals/web-vitals.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5e514f0

Please sign in to comment.