Skip to content

Commit

Permalink
feat(docs): web analytics from posthog (#1260)
Browse files Browse the repository at this point in the history
  • Loading branch information
tylersayshi authored Jan 23, 2025
1 parent 0fa5f1c commit fd8ab51
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ark/docs/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -24,8 +25,10 @@ export default ({ children }: { children: ReactNode }) => (
defaultTheme: "dark"
}}
>
<ReleaseBanner />
{children}
<CSPostHogProvider>
<ReleaseBanner />
{children}
</CSPostHogProvider>
</RootProvider>
</body>
</html>
Expand Down
21 changes: 21 additions & 0 deletions ark/docs/app/providers.tsx
Original file line number Diff line number Diff line change
@@ -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
}) => <PostHogProvider client={posthog}>{children}</PostHogProvider>
1 change: 1 addition & 0 deletions ark/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit fd8ab51

Please sign in to comment.