From 0f70a50bd47b20f621506cc467b461c632118400 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 1 Feb 2024 01:37:52 +0000 Subject: [PATCH] remove analytics page --- src/app/analytics/page.tsx | 89 -------------------------------- src/components/navbar/Navbar.tsx | 12 +---- src/store/IndexedDBStorage.ts | 19 +++++++ 3 files changed, 20 insertions(+), 100 deletions(-) delete mode 100644 src/app/analytics/page.tsx diff --git a/src/app/analytics/page.tsx b/src/app/analytics/page.tsx deleted file mode 100644 index 63c3f3e..0000000 --- a/src/app/analytics/page.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import AnalyticsChart from "@/components/AnalyticsChart"; -import Card from "@/components/Card"; -import Container from "@/components/Container"; -import { ScoresaberMetricsHistory } from "@/schemas/fascinated/scoresaberMetricsHistory"; -import ssrSettings from "@/ssrSettings.json"; -import { formatNumber } from "@/utils/numberUtils"; -import { formatDate } from "@/utils/timeUtils"; -import { isProduction } from "@/utils/utils"; -import { Metadata } from "next"; -import Link from "next/link"; - -async function getData() { - const response = await fetch( - "https://bs-tracker.fascinated.cc/analytics?time=30d", - { - next: { - revalidate: isProduction() ? 600 : 0, // 10 minutes (0 seconds in dev) - }, - }, - ); - - const json = await response.json(); - return { - data: json as ScoresaberMetricsHistory, - }; -} - -export async function generateMetadata(): Promise { - const { data } = await getData(); - - const description = - "View Scoresaber metrics and statistics over the last 30 days."; - - const lastActivePlayers = - data.activePlayersHistory[data.activePlayersHistory.length - 1].value; - const lastScoreCount = - data.scoreCountHistory[data.scoreCountHistory.length - 1].value; - - return { - title: `Analytics`, - description: description, - openGraph: { - siteName: ssrSettings.siteName, - title: `Analytics`, - description: - description + - ` - - Last Updated: ${formatDate(new Date().toISOString())} - Players Online Today: ${formatNumber(lastActivePlayers)} - Scores set Today: ${formatNumber(lastScoreCount)}`, - }, - }; -} - -export default async function Analytics() { - const { data } = await getData(); - - return ( -
- - -

Analytics

-

- Scoresaber metrics and statistics over the last 30 days. -

-

- Want more in-depth data? Click{" "} - - - here - - -

-
- -
-
-
-
- ); -} diff --git a/src/components/navbar/Navbar.tsx b/src/components/navbar/Navbar.tsx index 06b3b58..bf63e2f 100644 --- a/src/components/navbar/Navbar.tsx +++ b/src/components/navbar/Navbar.tsx @@ -1,8 +1,4 @@ -import { - CogIcon, - MagnifyingGlassIcon, - ServerIcon, -} from "@heroicons/react/20/solid"; +import { MagnifyingGlassIcon } from "@heroicons/react/20/solid"; import { GlobeAltIcon, TvIcon } from "@heroicons/react/24/outline"; import { Card } from "../ui/card"; import FriendsButton from "./FriendsButton"; @@ -29,12 +25,6 @@ export default function Navbar() { icon={} href="/overlay/builder" /> - } - href="/analytics" - />
diff --git a/src/store/IndexedDBStorage.ts b/src/store/IndexedDBStorage.ts index cf4aeda..9ece53a 100644 --- a/src/store/IndexedDBStorage.ts +++ b/src/store/IndexedDBStorage.ts @@ -9,15 +9,34 @@ if (typeof window !== "undefined") { } export const IDBStorage: StateStorage = { + /** + * Fetch an item from the storage + * + * @param name name of the item to be fetched + * @returns the value of the item or null if it doesn't exist + */ getItem: async (name: string): Promise => { //console.log(name, "has been retrieved"); return (await get(name, storage)) || null; }, + + /** + * Save an item to the storage + * + * @param name name of the item to be saved + * @param value value of the item to be saved + */ setItem: async (name: string, value: string): Promise => { //console.log(name, "with value", value, "has been saved"); await set(name, value, storage); }, + + /** + * Delete an item from the storage + * + * @param name name of the item to be deleted + */ removeItem: async (name: string): Promise => { //console.log(name, "has been deleted"); await del(name, storage);