Skip to content

Commit 7064683

Browse files
author
Keen Yee Liau
committed
add method to measure Interaction to Next Paint (INP)
`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
1 parent fc06fe6 commit 7064683

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

packages/next/client/performance-relayer.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
/* global location */
22
import {
3-
getCLS,
4-
getFCP,
5-
getFID,
6-
getLCP,
7-
getTTFB,
3+
onCLS,
4+
onFCP,
5+
onFID,
6+
onINP,
7+
onLCP,
8+
onTTFB,
89
Metric,
9-
ReportHandler,
10+
ReportCallback,
1011
} from 'next/dist/compiled/web-vitals'
1112

1213
const initialHref = location.href
1314
let isRegistered = false
14-
let userReportHandler: ReportHandler | undefined
15+
let userReportHandler: ReportCallback | undefined
1516

1617
function onReport(metric: Metric): void {
1718
if (userReportHandler) {
@@ -71,7 +72,7 @@ function onReport(metric: Metric): void {
7172
}
7273
}
7374

74-
export default (onPerfEntry?: ReportHandler): void => {
75+
export default (onPerfEntry?: ReportCallback): void => {
7576
// Update function if it changes:
7677
userReportHandler = onPerfEntry
7778

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

84-
getCLS(onReport)
85-
getFID(onReport)
86-
getFCP(onReport)
87-
getLCP(onReport)
88-
getTTFB(onReport)
85+
onCLS(onReport)
86+
onFID(onReport)
87+
onFCP(onReport)
88+
onLCP(onReport)
89+
onTTFB(onReport)
90+
onINP(onReport)
8991
}

packages/next/compiled/web-vitals/web-vitals.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
"vm-browserify": "1.1.2",
267267
"watchpack": "2.3.1",
268268
"web-streams-polyfill": "3.0.3",
269-
"web-vitals": "2.1.0",
269+
"web-vitals": "3.0.0-beta.1",
270270
"webpack-sources1": "npm:[email protected]",
271271
"webpack-sources3": "npm:[email protected]",
272272
"webpack4": "npm:[email protected]",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21537,10 +21537,10 @@ [email protected]:
2153721537
resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.1.tgz#3b19b9817374b7cee06d374ba7eeb3aeb80e8c95"
2153821538
integrity sha512-3ux37gEX670UUphBF9AMCq8XM6iQ8Ac6A+DSRRjDoRBm1ufCkaCDdNVbaqq60PsEkdNlLKrGtv/YBP4EJXqNtQ==
2153921539

21540-
web-vitals@2.1.0:
21541-
version "2.1.0"
21542-
resolved "https://registry.yarnpkg.com/web-vitals/-/web-vitals-2.1.0.tgz#ebf5428875ab5bfc1056c2e80cd177001287de7b"
21543-
integrity sha512-npEyJP8jHf3J71t1tRTEtz9FeKp8H2udWJUUq5ykfPhhstr//TUxiYhIEzLNwk4zv2ybAilMn7v7N6Mxmuitmg==
21540+
web-vitals@3.0.0-beta.1:
21541+
version "3.0.0-beta.1"
21542+
resolved "https://registry.yarnpkg.com/web-vitals/-/web-vitals-3.0.0-beta.1.tgz#cfa887f270be52d0bee1249d246d78271a71e55d"
21543+
integrity sha512-iXNgLB8vrEfeBEfKZYmJSQCcw3fUBP1TuO/3lorvD3L8Jn77ZLnU1oh2a9olUxuiAcEdfOdP98H4Idfigy8llg==
2154421544

2154521545
webcrypto-core@^1.6.0:
2154621546
version "1.6.0"

0 commit comments

Comments
 (0)