From b348c5e890876f19665a08ee66cc584f2851c730 Mon Sep 17 00:00:00 2001 From: Tim Raderschad Date: Wed, 11 Sep 2024 16:23:04 +0200 Subject: [PATCH] feat(web): add event counter --- apps/web/next.config.mjs | 6 ----- apps/web/public/img/companies/mavenoid.svg | 15 ------------ apps/web/src/components/EventCounter.tsx | 28 ++++++++++++++++++++++ apps/web/src/components/UsedBy.tsx | 7 +----- apps/web/src/pages/index.tsx | 2 ++ apps/web/src/server/trpc/router/events.ts | 19 ++++++++++++++- 6 files changed, 49 insertions(+), 28 deletions(-) delete mode 100644 apps/web/public/img/companies/mavenoid.svg create mode 100644 apps/web/src/components/EventCounter.tsx diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs index 31da536f..dab3ba8d 100644 --- a/apps/web/next.config.mjs +++ b/apps/web/next.config.mjs @@ -66,12 +66,6 @@ const config = { }, }; -console.log({ - "process.env.SENTRY_ORG": process.env.SENTRY_ORG, - "process.env.SENTRY_PROJECT": process.env.SENTRY_PROJECT, - -}) - const withSentry = process.env.SENTRY_ORG && process.env.SENTRY_PROJECT ? withSentryConfig diff --git a/apps/web/public/img/companies/mavenoid.svg b/apps/web/public/img/companies/mavenoid.svg deleted file mode 100644 index 15ccaaf1..00000000 --- a/apps/web/public/img/companies/mavenoid.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/apps/web/src/components/EventCounter.tsx b/apps/web/src/components/EventCounter.tsx new file mode 100644 index 00000000..7e3e3cec --- /dev/null +++ b/apps/web/src/components/EventCounter.tsx @@ -0,0 +1,28 @@ +import {} from "react"; +import { motion, AnimatePresence } from "framer-motion"; +import { trpc } from "utils/trpc"; + +export function EventCounter() { + const { data } = trpc.events.getEventCount.useQuery(); + + return ( +
+ + + {new Intl.NumberFormat("en", { notation: "compact" }).format( + data ?? 0 + )} + + + + Events processed and counting... + +
+ ); +} diff --git a/apps/web/src/components/UsedBy.tsx b/apps/web/src/components/UsedBy.tsx index 50977f61..cf38319d 100644 --- a/apps/web/src/components/UsedBy.tsx +++ b/apps/web/src/components/UsedBy.tsx @@ -2,7 +2,7 @@ import Image from "next/image"; import Link from "next/link"; import DynabaseLogo from "../../public/img/companies/dynabase.svg"; import IgusLogo from "../../public/img/companies/igus.svg"; -import MavenoidLogo from "../../public/img/companies/mavenoid.svg"; + import RBTXLogo from "../../public/img/companies/rbtx.svg"; const COMPANIES = [ @@ -21,11 +21,6 @@ const COMPANIES = [ logo: DynabaseLogo, companyUrl: "https://dynabase.de/", }, - { - name: "Mavenoid", - logo: MavenoidLogo, - companyUrl: "https://mavenoid.com/", - }, ] satisfies Array<{ logo: React.ReactNode; name: string; diff --git a/apps/web/src/pages/index.tsx b/apps/web/src/pages/index.tsx index 39af10db..f5c302b8 100644 --- a/apps/web/src/pages/index.tsx +++ b/apps/web/src/pages/index.tsx @@ -29,6 +29,7 @@ import { twMerge } from "tailwind-merge"; import { generateCodeSnippets } from "utils/snippets"; import abbyScreenshot from "../../public/screenshot.png"; import type { NextPageWithLayout } from "./_app"; +import { EventCounter } from "components/EventCounter"; const { useAbby, AbbyProvider, useFeatureFlag, __abby__, withDevtools } = createAbby({ @@ -137,6 +138,7 @@ const Home: NextPageWithLayout< Start free, scale at a fair price. + {heroMediaVariant === "Image" && ( { @@ -325,4 +326,20 @@ export const eventRouter = router({ )), }; }), + getEventCount: publicProcedure.query(async ({ ctx }) => { + return await getTotalEventCount(ctx); + }), }); + +const getTotalEventCount = memoize( + async (ctx: Context) => { + const [eventCount, apiRequestCount] = await Promise.all([ + ctx.prisma.event.count(), + ctx.prisma.apiRequest.count(), + ]); + return eventCount + apiRequestCount; + }, + { + maxAge: 1000 * 60, + } +);