From 7999640f2445656858f891ebe3694a0bcf273480 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 29 Oct 2023 18:35:49 +0000 Subject: [PATCH] add timezone to analytics --- src/app/analytics/page.tsx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/app/analytics/page.tsx b/src/app/analytics/page.tsx index a1358a6..8d9e8ac 100644 --- a/src/app/analytics/page.tsx +++ b/src/app/analytics/page.tsx @@ -19,22 +19,22 @@ async function getData() { ); const json = await response.json(); - return json as ScoresaberMetricsHistory; + return { + data: json as ScoresaberMetricsHistory, + timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, + }; } export async function generateMetadata(): Promise { - const historyData = await getData(); + const { data } = await getData(); const description = "View Scoresaber metrics and statistics over the last 30 days."; const lastActivePlayers = - historyData.activePlayersHistory[ - historyData.activePlayersHistory.length - 1 - ].value; + data.activePlayersHistory[data.activePlayersHistory.length - 1].value; const lastScoreCount = - historyData.scoreCountHistory[historyData.scoreCountHistory.length - 1] - .value; + data.scoreCountHistory[data.scoreCountHistory.length - 1].value; return { title: `Analytics`, @@ -53,7 +53,7 @@ export async function generateMetadata(): Promise { } export default async function Analytics() { - const historyData = await getData(); + const { data, timezone } = await getData(); return (
@@ -63,7 +63,7 @@ export default async function Analytics() { innerClassName="flex flex-col items-center justify-center" >

Analytics

-

+

Scoresaber metrics and statistics over the last 30 days.

@@ -78,8 +78,9 @@ export default async function Analytics() {

+

Timezone: {timezone}

- +