From 13216a1de67532e6507f7ce8553d8f828f045f66 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Wed, 18 Aug 2021 13:52:59 +0200 Subject: [PATCH] Add Google Web Vitals per run (#3437) --- lib/plugins/browsertime/aggregator.js | 14 ++++++++------ lib/plugins/browsertime/index.js | 5 +++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/plugins/browsertime/aggregator.js b/lib/plugins/browsertime/aggregator.js index d33d774de..e858eb3b1 100644 --- a/lib/plugins/browsertime/aggregator.js +++ b/lib/plugins/browsertime/aggregator.js @@ -33,12 +33,14 @@ module.exports = { } if (browsertimeRunData.googleWebVitals) { - statsHelpers.pushGroupStats( - this.statsPerType, - this.groups[group], - ['googleWebVitals'], - browsertimeRunData.googleWebVitals - ); + for (let metric of Object.keys(browsertimeRunData.googleWebVitals)) { + statsHelpers.pushGroupStats( + this.statsPerType, + this.groups[group], + ['googleWebVitals', metric], + browsertimeRunData.googleWebVitals[metric] + ); + } } if (browsertimeRunData.timings.largestContentfulPaint) { diff --git a/lib/plugins/browsertime/index.js b/lib/plugins/browsertime/index.js index 7d833dd89..e809a5e79 100644 --- a/lib/plugins/browsertime/index.js +++ b/lib/plugins/browsertime/index.js @@ -206,6 +206,11 @@ module.exports = { run.visualMetrics = result[resultIndex].visualMetrics[runIndex]; } + if (result[resultIndex].googleWebVitals) { + run.googleWebVitals = + result[resultIndex].googleWebVitals[runIndex]; + } + let harIndex = runIndex * result.length; harIndex += resultIndex; if (result.har) {