From fd8ab51f5a803f6c305f3b5e5b95a09bbaef4b35 Mon Sep 17 00:00:00 2001 From: Tyler <26290074+tylersayshi@users.noreply.github.com> Date: Thu, 23 Jan 2025 13:35:54 -0800 Subject: [PATCH] feat(docs): web analytics from posthog (#1260) --- ark/docs/app/layout.tsx | 7 +++++-- ark/docs/app/providers.tsx | 21 +++++++++++++++++++++ ark/docs/package.json | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 ark/docs/app/providers.tsx diff --git a/ark/docs/app/layout.tsx b/ark/docs/app/layout.tsx index 8d899187b..552b96c1c 100644 --- a/ark/docs/app/layout.tsx +++ b/ark/docs/app/layout.tsx @@ -4,6 +4,7 @@ import { RootProvider } from "fumadocs-ui/provider" import { Raleway } from "next/font/google" import type { ReactNode } from "react" import { ReleaseBanner } from "../components/ReleaseBanner.tsx" +import { CSPostHogProvider } from "./providers.tsx" const raleway = Raleway({ subsets: ["latin"] @@ -24,8 +25,10 @@ export default ({ children }: { children: ReactNode }) => ( defaultTheme: "dark" }} > - - {children} + + + {children} + diff --git a/ark/docs/app/providers.tsx b/ark/docs/app/providers.tsx new file mode 100644 index 000000000..ab372c1ed --- /dev/null +++ b/ark/docs/app/providers.tsx @@ -0,0 +1,21 @@ +"use client" + +import posthog from "posthog-js" +import { PostHogProvider } from "posthog-js/react" + +if ( + typeof window !== "undefined" && + process.env.NEXT_PUBLIC_POSTHOG_KEY && + process.env.NEXT_PUBLIC_POSTHOG_HOST +) { + posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, { + api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST, + person_profiles: "always" + }) +} + +export const CSPostHogProvider = ({ + children +}: { + children: React.ReactNode +}) => {children} diff --git a/ark/docs/package.json b/ark/docs/package.json index 030de07a5..809b4e417 100644 --- a/ark/docs/package.json +++ b/ark/docs/package.json @@ -35,6 +35,7 @@ "lucide-react": "0.471.1", "next": "15.1.4", "postcss": "8.5.1", + "posthog-js": "^1.207.0", "prettier-plugin-tailwindcss": "0.6.10", "react": "19.0.0", "react-dom": "19.0.0",