Skip to content

A platform for community discussion. Free, open, simple.

UX: Update Site Traffic Explorer pageview limit warning (#42662)

Alan Guo Xiang Tand9108c229482
diff --git a/app/services/admin_dashboard_site_traffic_explorer.rb b/app/services/admin_dashboard_site_traffic_explorer.rb
index 65445c6ddcd..699b5a89649 100644
--- a/app/services/admin_dashboard_site_traffic_explorer.rb
+++ b/app/services/admin_dashboard_site_traffic_explorer.rb
@@ -103,7 +103,12 @@ class AdminDashboardSiteTrafficExplorer
row = execute_query(start_date: params.start_date, end_date: params.end_date, filters:)
traffic = {
- partial_data: partial_data(row.fetch("pageview_limited"), start_date: params.start_date),
+ partial_data:
+ partial_data(
+ row.fetch("pageview_limited"),
+ pageview_limit_start_at: row["oldest_pageview_at"],
+ start_date: params.start_date,
+ ),
summary: row.fetch("summary"),
series: row.fetch("series"),
series_colors: series_colors,
@@ -348,6 +353,10 @@ class AdminDashboardSiteTrafficExplorer
)
FROM population_boundary
) AS pageview_limited,
+ (
+ SELECT population_boundary.oldest_created_at
+ FROM population_boundary
+ ) AS oldest_pageview_at,
jsonb_build_object(
'country', (
SELECT host(MIN(ip_address))
@@ -541,7 +550,7 @@ class AdminDashboardSiteTrafficExplorer
SQL
end
- def partial_data(pageview_limited, start_date:)
+ def partial_data(pageview_limited, pageview_limit_start_at:, start_date:)
retention_limited = start_date < BrowserPageviewEvent.retention_cutoff.to_date
return nil if !retention_limited && !pageview_limited
@@ -550,6 +559,7 @@ class AdminDashboardSiteTrafficExplorer
reason: "retention_and_pageview_limit",
available_start_date: BrowserPageviewEvent.retention_cutoff.to_date.iso8601,
pageview_limit: SiteSetting.site_traffic_explorer_event_limit,
+ pageview_limit_start_at: pageview_limit_start_at.iso8601,
}
elsif retention_limited
{
@@ -557,7 +567,11 @@ class AdminDashboardSiteTrafficExplorer
available_start_date: BrowserPageviewEvent.retention_cutoff.to_date.iso8601,
}
else
- { reason: "pageview_limit", pageview_limit: SiteSetting.site_traffic_explorer_event_limit }
+ {
+ reason: "pageview_limit",
+ pageview_limit: SiteSetting.site_traffic_explorer_event_limit,
+ pageview_limit_start_at: pageview_limit_start_at.iso8601,
+ }
end
end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 9e95411385a..0551883db07 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -7320,9 +7320,9 @@ en:
anonymous_human: "Anonymous"
likely_crawler: "Likely crawlers"
partial:
- retention: "Detailed pageview activity before %{date} is no longer available, so these results cover only part of the selected date range."
- pageview_limit: "These results are limited to the most recent %{limit} pageviews in the selected date range. Choose a shorter date range to include all available traffic."
- combined: "Detailed pageview activity before %{date} is no longer available, so these results cover only part of the selected date range. They are also limited to the most recent %{limit} pageviews. Choose a shorter date range within the available dates to include all available pageview activity."
+ retention: "Pageview data before %{date} is no longer available, so these results cover only part of the selected date range."
+ pageview_limit: "Results include the most recent %{limit} pageviews, beginning %{date} at %{time}. Earlier pageviews in the selected date range are not included."
+ combined: "Results include the most recent %{limit} pageviews, beginning %{pageviewLimitDate} at %{pageviewLimitTime}. Earlier pageviews in the selected date range are not included; pageview data before %{date} is no longer available."
dashboard:
title: "Dashboard"
last_updated: "Dashboard updated:"
diff --git a/frontend/discourse/admin/components/site-traffic-explorer.gjs b/frontend/discourse/admin/components/site-traffic-explorer.gjs
index aaf8d577223..6cf5a70eecb 100644
--- a/frontend/discourse/admin/components/site-traffic-explorer.gjs
+++ b/frontend/discourse/admin/components/site-traffic-explorer.gjs
@@ -170,20 +170,28 @@ export default class SiteTrafficExplorer extends Component {
const availableDate = partial.available_start_date
? moment(partial.available_start_date).format("ll")
: null;
+ if (partial.reason === "retention") {
+ return i18n("admin.site_traffic_explorer.partial.retention", {
+ date: availableDate,
+ });
+ }
+
+ const pageviewLimitStart = moment(partial.pageview_limit_start_at);
+ const pageviewLimitDate = pageviewLimitStart.format("ll");
+ const pageviewLimitTime = pageviewLimitStart.format("LT");
if (partial.reason === "retention_and_pageview_limit") {
return i18n("admin.site_traffic_explorer.partial.combined", {
date: availableDate,
limit: this.#number(partial.pageview_limit),
- });
- }
- if (partial.reason === "retention") {
- return i18n("admin.site_traffic_explorer.partial.retention", {
- date: availableDate,
+ pageviewLimitDate,
+ pageviewLimitTime,
});
}
return i18n("admin.site_traffic_explorer.partial.pageview_limit", {
limit: this.#number(partial.pageview_limit),
+ date: pageviewLimitDate,
+ time: pageviewLimitTime,
});
}
diff --git a/spec/requests/admin/dashboard_controller_spec.rb b/spec/requests/admin/dashboard_controller_spec.rb
index 4ede54b380f..423d8f20be3 100644
--- a/spec/requests/admin/dashboard_controller_spec.rb
+++ b/spec/requests/admin/dashboard_controller_spec.rb
@@ -1765,6 +1765,7 @@ RSpec.describe Admin::DashboardController do
"partial_data" => {
"reason" => "pageview_limit",
"pageview_limit" => 2,
+ "pageview_limit_start_at" => "2026-05-10T10:00:00Z",
},
"summary" => {
"pageviews" => 2,
@@ -1860,6 +1861,7 @@ RSpec.describe Admin::DashboardController do
"reason" => "retention_and_pageview_limit",
"available_start_date" => "2026-02-14",
"pageview_limit" => 2,
+ "pageview_limit_start_at" => "2026-05-10T10:00:00Z",
},
"summary" => {
"pageviews" => 2,
diff --git a/spec/system/admin_dashboard_redesign/site_traffic_explorer_spec.rb b/spec/system/admin_dashboard_redesign/site_traffic_explorer_spec.rb
index a070fb1f182..347fa66f8ae 100644
--- a/spec/system/admin_dashboard_redesign/site_traffic_explorer_spec.rb
+++ b/spec/system/admin_dashboard_redesign/site_traffic_explorer_spec.rb
@@ -403,7 +403,8 @@ RSpec.describe "Admin Dashboard Redesign | Site Traffic Explorer" do
end
it "warns an admin when the selected range has incomplete traffic data",
- time: Time.zone.local(2026, 5, 14, 12, 0, 0) do
+ time: Time.zone.local(2026, 5, 14, 12, 0, 0),
+ timezone: "UTC" do
sign_in(admin)
SiteSetting.site_traffic_explorer_event_limit = 2
@@ -425,7 +426,7 @@ RSpec.describe "Admin Dashboard Redesign | Site Traffic Explorer" do
expect(traffic).to have_partial_data_warning(
reason:
- "Detailed pageview activity before Feb 14, 2026 is no longer available, so these results cover only part of the selected date range. They are also limited to the most recent 2 pageviews. Choose a shorter date range within the available dates to include all available pageview activity.",
+ "Results include the most recent 2 pageviews, beginning May 10, 2026 at 10:00 AM. Earlier pageviews in the selected date range are not included; pageview data before Feb 14, 2026 is no longer available.",
)
end