From a5fe5e136b060f093fac5f356ce9be9f8113ff34 Mon Sep 17 00:00:00 2001 From: pablodanswer Date: Sat, 25 Jan 2025 17:33:20 -0800 Subject: [PATCH] add web vitals --- web/src/app/layout.tsx | 2 ++ web/src/app/web-vitals.tsx | 12 ++++++++++++ web/src/components/Modal.tsx | 3 +-- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 web/src/app/web-vitals.tsx diff --git a/web/src/app/layout.tsx b/web/src/app/layout.tsx index 744050c67262..3847177156dc 100644 --- a/web/src/app/layout.tsx +++ b/web/src/app/layout.tsx @@ -23,6 +23,7 @@ import PostHogPageView from "./PostHogPageView"; import Script from "next/script"; import { LogoType } from "@/components/logo/Logo"; import { Hanken_Grotesk } from "next/font/google"; +import { WebVitals } from "./web-vitals"; const inter = Inter({ subsets: ["latin"], @@ -206,6 +207,7 @@ export default async function RootLayout({ {children} + {process.env.NEXT_PUBLIC_POSTHOG_KEY && } ); } diff --git a/web/src/app/web-vitals.tsx b/web/src/app/web-vitals.tsx new file mode 100644 index 000000000000..cec3e26b2293 --- /dev/null +++ b/web/src/app/web-vitals.tsx @@ -0,0 +1,12 @@ +"use client"; +import { useReportWebVitals } from "next/web-vitals"; +import { usePostHog } from "posthog-js/react"; + +export function WebVitals() { + const posthog = usePostHog(); + + useReportWebVitals((metric) => { + posthog.capture(metric.name, metric); + }); + return <>; +} diff --git a/web/src/components/Modal.tsx b/web/src/components/Modal.tsx index f3037bd415d8..a3fc9d375d06 100644 --- a/web/src/components/Modal.tsx +++ b/web/src/components/Modal.tsx @@ -63,7 +63,7 @@ export function Modal({
@@ -76,7 +76,6 @@ export function Modal({ }} className={` bg-background - bg-blue-400 text-emphasis rounded shadow-2xl