diff --git a/cli/README.md b/cli/README.md index 6a1b382..971727e 100644 --- a/cli/README.md +++ b/cli/README.md @@ -126,7 +126,7 @@ benchmark-server-timing -f path/to/urls.txt -n 5 ### `benchmark-web-vitals` -Loads the provided URLs in a headless browser several times to measure median Web Vitals metrics for each URL. Currently the results cover load time metrics FCP, LCP, and TTFB. Including additional metrics is explored in a [follow up pull request](https://github.com/GoogleChromeLabs/wpp-research/pull/41). +Loads the provided URLs in a headless browser several times to measure median Web Vitals metrics for each URL. Currently the results cover metrics CLS, FCP, FID, INP, LCP, and TTFB. #### Arguments diff --git a/cli/commands/benchmark-web-vitals.mjs b/cli/commands/benchmark-web-vitals.mjs index 8cd9cf4..741c6e9 100644 --- a/cli/commands/benchmark-web-vitals.mjs +++ b/cli/commands/benchmark-web-vitals.mjs @@ -97,20 +97,31 @@ export async function handler( opt ) { } async function benchmarkURL( browser, params ) { - /* - * For now this only includes load time metrics. - * In the future, additional Web Vitals like CLS, FID, and INP should be - * added, however they are slightly more complex to retrieve through an - * automated headless browser test. - * See https://github.com/GoogleChromeLabs/wpp-research/pull/41. - */ const metricsDefinition = { + CLS: { + listen: 'onCLS', + global: 'webVitalsCLS', + get: () => window.webVitalsCLS, + results: [], + }, FCP: { listen: 'onFCP', global: 'webVitalsFCP', get: () => window.webVitalsFCP, results: [], }, + FID: { + listen: 'onFID', + global: 'webVitalsFID', + get: () => window.webVitalsFID, + results: [], + }, + INP: { + listen: 'onINP', + global: 'webVitalsINP', + get: () => window.webVitalsINP, + results: [], + }, LCP: { listen: 'onLCP', global: 'webVitalsLCP',