From d41d05d7d13344bb829207bd46c99567c49ce9b9 Mon Sep 17 00:00:00 2001 From: Patrick Meenan Date: Thu, 7 Apr 2022 21:24:50 +0000 Subject: [PATCH] Fixed the reporting of CrUX and lighthouse data for sharded tests --- www/page_data.inc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/www/page_data.inc b/www/page_data.inc index 11d38f33c0..eb76a81132 100644 --- a/www/page_data.inc +++ b/www/page_data.inc @@ -79,8 +79,29 @@ function loadPageStepData($localPaths, $testInfo = null) { } } - if (isset($ret) && is_array($ret) && isset($ret['edge-processed']) && $ret['edge-processed']) + if (isset($ret) && is_array($ret) && isset($ret['edge-processed']) && $ret['edge-processed']) { + // Add the CrUX data which is collected only on the first Run + $crux_file = $localPaths->cruxJsonFile(); + if (gz_is_file($crux_file)) { + $crux_data = json_decode(gz_file_get_contents($crux_file), true); + if (isset($crux_data) && is_array($crux_data)) { + if (isset($crux_data['record'])) { + $ret['CrUX'] = $crux_data['record']; + } else { + $ret['CrUX'] = $crux_data; + } + } + } + // Add the Lighthouse data which is collected only on the first Run + $lighthouse_audits_file = $localPaths->lighthouseAuditsFile(); + if (gz_is_file($lighthouse_audits_file)) { + $audits = json_decode(gz_file_get_contents($lighthouse_audits_file), true); + foreach ($audits as $name => $value) { + $ret["lighthouse.$name"] = $value; + } + } return $ret; + } if (!isset($ret) || !is_array($ret)) { $ret = loadPageData($localPaths->pageDataFile());