From 1065004fa374b5facd20537b690ed014a8a2850c Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Fri, 16 Jan 2026 02:07:08 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=9A=B8=20show=20a=20better=20loading?= =?UTF-8?q?=20state=20for=20analytics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- messages/en-US.json | 1 + src/components/LogAnalyticsData.tsx | 51 ++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/messages/en-US.json b/messages/en-US.json index 82b419bb..be515a8f 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -1281,6 +1281,7 @@ "setupErrorCreateAdmin": "An error occurred while creating the server admin account.", "certificateStatus": "Certificate Status", "loading": "Loading", + "loadingAnalytics": "Loading Analytics", "restart": "Restart", "domains": "Domains", "domainsDescription": "Create and manage domains available in the organization", diff --git a/src/components/LogAnalyticsData.tsx b/src/components/LogAnalyticsData.tsx index 90379fdf..174865e4 100644 --- a/src/components/LogAnalyticsData.tsx +++ b/src/components/LogAnalyticsData.tsx @@ -48,6 +48,7 @@ import { TooltipTrigger } from "./ui/tooltip"; import { getSevenDaysAgo } from "@app/lib/getSevenDaysAgo"; +import type { QueryRequestAnalyticsResponse } from "@server/routers/auditLogs"; export type AnalyticsContentProps = { orgId: string; @@ -276,13 +277,32 @@ export function LogAnalyticsData(props: AnalyticsContentProps) { - + + {isLoadingAnalytics && ( +
+
+ + {t("loadingAnalytics")} +
+
+ )} +

{t("requestsByDay")}

- + + {isLoadingAnalytics && ( +
+ )}
@@ -323,6 +343,28 @@ export function LogAnalyticsData(props: AnalyticsContentProps) { ); } +function generateSampleDailyRequests(): QueryRequestAnalyticsResponse["requestsPerDay"] { + const today = new Date(); + + // generate sample data for the last 7 days + const requestsPerDay = Array.from({ length: 7 }, (_, i) => { + const date = new Date(today); + date.setDate(date.getDate() - (6 - i)); + // generate a random number of requests between 1 and 100 + const totalCount = Math.floor(Math.random() * 100) + 1; + // generate a random number of requests between 1 and totalCount + const blockedCount = Math.floor(Math.random() * (totalCount + 1)); + return { + day: date.toISOString().split("T")[0], + allowedCount: totalCount - blockedCount, + blockedCount, + totalCount + }; + }); + + return requestsPerDay; +} + type RequestChartProps = { data: { day: string; @@ -331,6 +373,7 @@ type RequestChartProps = { totalCount: number; }[]; isLoading: boolean; + className?: string; }; function RequestChart(props: RequestChartProps) { @@ -359,7 +402,7 @@ function RequestChart(props: RequestChartProps) { return ( } /> From c93766bb48b157ecf900e88f6f3fbc1e01e43f13 Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Fri, 16 Jan 2026 17:35:17 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=92=84fix=20countries=20list=20grid?= =?UTF-8?q?=20items?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/LogAnalyticsData.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/LogAnalyticsData.tsx b/src/components/LogAnalyticsData.tsx index 174865e4..0c3e1ec8 100644 --- a/src/components/LogAnalyticsData.tsx +++ b/src/components/LogAnalyticsData.tsx @@ -510,7 +510,7 @@ function TopCountriesList(props: TopCountriesListProps) { )} {/* `aspect-475/335` is the same aspect ratio as the world map component */} -
    +
      {props.countries.length === 0 && (
      {props.isLoading ? ( @@ -523,12 +523,12 @@ function TopCountriesList(props: TopCountriesListProps) { )}
      )} - {props.countries.map((country) => { + {props.countries.slice(0, 3).map((country) => { const percent = country.count / props.total; return (
    1. Date: Fri, 16 Jan 2026 17:36:48 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20show=20all=20country?= =?UTF-8?q?=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/LogAnalyticsData.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/LogAnalyticsData.tsx b/src/components/LogAnalyticsData.tsx index 0c3e1ec8..2c541239 100644 --- a/src/components/LogAnalyticsData.tsx +++ b/src/components/LogAnalyticsData.tsx @@ -523,7 +523,7 @@ function TopCountriesList(props: TopCountriesListProps) { )}
      )} - {props.countries.slice(0, 3).map((country) => { + {props.countries.map((country) => { const percent = country.count / props.total; return (