From 100f51af9f37ef079662011e8815571f540230b1 Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Mon, 18 Aug 2025 14:23:10 +0100 Subject: [PATCH 1/2] Fix page weight bug --- config/techreport.json | 26 +++++++++++++------------- templates/techreport/drilldown.html | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/config/techreport.json b/config/techreport.json index cab4681b..7accca0e 100644 --- a/config/techreport.json +++ b/config/techreport.json @@ -580,35 +580,35 @@ "cards": [ { "endpoint": "pageWeight", - "category": "images", + "category": "total", "metric": "median_bytes_formatted", - "label": "Image Weight", - "url": "?weight-over-time=image#page-weight", + "label": "Total Page Weight", + "url": "?weight-over-time=total#page-weight", "change": "true", "changeMeaning": "inverted" }, { "endpoint": "pageWeight", - "category": "js", + "category": "images", "metric": "median_bytes_formatted", - "label": "JavaScript Size", - "url": "?weight-over-time=js#page-weight", + "label": "Image Weight", + "url": "?weight-over-time=image#page-weight", "change": "true", "changeMeaning": "inverted" }, { "endpoint": "pageWeight", - "category": "total", + "category": "js", "metric": "median_bytes_formatted", - "label": "Total Page Weight", - "url": "?weight-over-time=total#page-weight", + "label": "JavaScript Size", + "url": "?weight-over-time=js#page-weight", "change": "true", "changeMeaning": "inverted" } ] }, "weight_timeseries": { - "title": "Weight over time", + "title": "Median page weight over time", "description": "", "id": "weight_timeseries", "summary": true, @@ -666,8 +666,8 @@ "viz": { "base": "median_bytes_", "param": "weight-over-time", - "default": "images", - "title": "Image weight over time", + "default": "total", + "title": "Weight over time", "metric": "median_bytes", "suffix": "bytes", "metric_summary": "median_bytes_formatted", @@ -1026,7 +1026,7 @@ } }, "weight_timeseries": { - "title": "Page weight over time", + "title": "Total page weight", "description": "", "id": "weight_timeseries", "endpoint": "pageWeight", diff --git a/templates/techreport/drilldown.html b/templates/techreport/drilldown.html index 01300b79..d9d4cd36 100644 --- a/templates/techreport/drilldown.html +++ b/templates/techreport/drilldown.html @@ -118,7 +118,7 @@

{{ tech_report_page.config.weight_summary.title }}

{% set timeseries = tech_report_page.config.weight_timeseries %} - {% set selected_subcategory = request.args.get('weight-over-time', '') or tech_report_page.config.weight_timeseries.viz.default or 'performance' %} + {% set selected_subcategory = request.args.get('weight-over-time', '') or tech_report_page.config.weight_timeseries.viz.default or 'total' %} {% include "techreport/components/timeseries.html" %}
From 579da015f84bee5333e3668072a855a98a4d6fc4 Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Mon, 18 Aug 2025 14:37:17 +0100 Subject: [PATCH 2/2] Add checks to prevent console errors --- src/js/techreport/index.js | 2 +- src/js/techreport/timeseries.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/techreport/index.js b/src/js/techreport/index.js index 8ff545fb..1a18ebf4 100644 --- a/src/js/techreport/index.js +++ b/src/js/techreport/index.js @@ -406,7 +406,7 @@ class TechReport { // Update drilldown page components updateDrilldownComponents(data) { const app = this.filters.app[0]; - const icon = data[app].at(-1).icon; + const icon = data[app]?.at(-1)?.icon; DrilldownHeader.update(this.filters); DrilldownHeader.setIcon(`${encodeURI(icon)}`); diff --git a/src/js/techreport/timeseries.js b/src/js/techreport/timeseries.js index 5f0a2fc2..38fc3856 100644 --- a/src/js/techreport/timeseries.js +++ b/src/js/techreport/timeseries.js @@ -164,7 +164,7 @@ class Timeseries { } else { /* Add the value to the wrapper */ const valueLabel = document.createElement('p'); - valueLabel.textContent = `${latestValue.toLocaleString()}${breakdown.suffix || ''}`; + valueLabel.textContent = `${latestValue?.toLocaleString()}${breakdown.suffix || ''}`; valueLabel.classList.add('breakdown-value'); itemWrapper.appendChild(valueLabel); }