feat: initial setup posthog
This commit is contained in:
parent
b046ee3e22
commit
655a4a159a
@ -36,6 +36,7 @@
|
|||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"plop": "^4.0.1",
|
"plop": "^4.0.1",
|
||||||
"plop-helper-date": "^1.0.0",
|
"plop-helper-date": "^1.0.0",
|
||||||
|
"posthog-js": "^1.186.3",
|
||||||
"react": "^18",
|
"react": "^18",
|
||||||
"react-dom": "^18",
|
"react-dom": "^18",
|
||||||
"react-hook-form": "^7.51.1",
|
"react-hook-form": "^7.51.1",
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import { Metadata } from 'next'
|
|||||||
|
|
||||||
import '@/styles/main.scss'
|
import '@/styles/main.scss'
|
||||||
|
|
||||||
|
import { CSPostHogProvider } from './posthog'
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: 'Jan',
|
title: 'Jan',
|
||||||
description:
|
description:
|
||||||
@ -13,10 +15,12 @@ export const metadata: Metadata = {
|
|||||||
export default function RootLayout({ children }: PropsWithChildren) {
|
export default function RootLayout({ children }: PropsWithChildren) {
|
||||||
return (
|
return (
|
||||||
<html lang="en" suppressHydrationWarning>
|
<html lang="en" suppressHydrationWarning>
|
||||||
<body className="h-screen font-sans text-sm antialiased">
|
<CSPostHogProvider>
|
||||||
<div className="dragable-bar" />
|
<body className="h-screen font-sans text-sm antialiased">
|
||||||
{children}
|
<div className="dragable-bar" />
|
||||||
</body>
|
{children}
|
||||||
|
</body>
|
||||||
|
</CSPostHogProvider>
|
||||||
</html>
|
</html>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
14
web/app/posthog.js
Normal file
14
web/app/posthog.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import posthog from 'posthog-js'
|
||||||
|
import { PostHogProvider } from 'posthog-js/react'
|
||||||
|
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
|
||||||
|
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
|
||||||
|
person_profiles: 'identified_only', // or 'always' to create profiles for anonymous users as well
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export function CSPostHogProvider({ children }) {
|
||||||
|
return <PostHogProvider client={posthog}>{children}</PostHogProvider>
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user