From 14b436923c5b582cea454b69441a28e16f2f191e Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Tue, 10 Sep 2024 09:51:49 +1000 Subject: [PATCH] FEATURE: Switch to new methods of pageview measurement and reporting (#28729) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### UI changes All of the UI changes described are gated behind the `use_legacy_pageviews` site setting. This commit changes the admin dashboard pageviews report to use the "Consolidated Pageviews with Browser Detection" report introduced in 2f2da7274732cba30d03b6c5c3a4194652cb6783 with the following changes: * The report name is changed to "Site traffic" * The pageview count on the dashboard is counting only using the new method * The old "Consolidated Pageviews" report is renamed as "Consolidated Legacy Pageviews" * By default "known crawlers" and "other" sources of pageviews are hidden on the report When `use_legacy_pageviews` is `true`, we do not show or allow running the "Site traffic" report for admins. When `use_legacy_pageviews` is `false`, we do not show or allow running the following legacy reports: * consolidated_page_views * consolidated_page_views_browser_detection * page_view_anon_reqs * page_view_logged_in_reqs ### Historical data changes Also part of this change is that, since we introduced our new "Consolidated Pageviews with Browser Detection" report, some admins are confused at either: * The lack of data before a certain date , which didn’t exist before we started collecting it * Comparing this and the current "Consolidated Pageviews" report data, which rolls up "Other Pageviews" into "Anonymous Browser" and so it appears inaccurate All pageview data in the new report before the date where the _first_ anon or logged in browser pageview was recorded is now hidden. --- .../components/admin-report-stacked-chart.gjs | 5 + .../admin/addon/components/admin-report.hbs | 2 +- .../admin/addon/components/admin-report.js | 2 + .../controllers/admin-dashboard-general.js | 8 + .../addon/templates/dashboard_general.hbs | 19 ++- .../stylesheets/common/admin/dashboard.scss | 3 +- app/controllers/admin/reports_controller.rb | 68 ++++++-- .../reports/consolidated_page_views.rb | 2 + ...nsolidated_page_views_browser_detection.rb | 70 +------- app/models/concerns/reports/site_traffic.rb | 80 +++++++++ app/models/report.rb | 37 +++-- config/locales/server.en.yml | 12 +- config/site_settings.yml | 1 + spec/models/report_spec.rb | 88 ++++++++-- .../requests/admin/reports_controller_spec.rb | 154 ++++++++++++++++++ .../admin_dashboard_community_health_spec.rb | 33 ++++ 16 files changed, 477 insertions(+), 107 deletions(-) create mode 100644 app/models/concerns/reports/site_traffic.rb create mode 100644 spec/system/admin_dashboard_community_health_spec.rb diff --git a/app/assets/javascripts/admin/addon/components/admin-report-stacked-chart.gjs b/app/assets/javascripts/admin/addon/components/admin-report-stacked-chart.gjs index 8a7e2df0973..fb04e15790d 100644 --- a/app/assets/javascripts/admin/addon/components/admin-report-stacked-chart.gjs +++ b/app/assets/javascripts/admin/addon/components/admin-report-stacked-chart.gjs @@ -8,10 +8,14 @@ export default class AdminReportStackedChart extends Component { get chartConfig() { const { model } = this.args; + const options = this.args.options || {}; + options.hiddenLabels ??= []; + const chartData = makeArray(model.chartData || model.data).map((cd) => ({ label: cd.label, color: cd.color, data: Report.collapse(model, cd.data), + req: cd.req, })); const data = { @@ -21,6 +25,7 @@ export default class AdminReportStackedChart extends Component { stack: "pageviews-stack", data: cd.data, backgroundColor: cd.color, + hidden: options.hiddenLabels.includes(cd.req), })), }; diff --git a/app/assets/javascripts/admin/addon/components/admin-report.hbs b/app/assets/javascripts/admin/addon/components/admin-report.hbs index 65aea850595..f13e0c7d6a2 100644 --- a/app/assets/javascripts/admin/addon/components/admin-report.hbs +++ b/app/assets/javascripts/admin/addon/components/admin-report.hbs @@ -7,7 +7,7 @@