feat: fix posthog

This commit is contained in:
Nevo David 2024-10-30 22:59:37 +07:00
parent 792fa7fba0
commit 605c3457ff
2 changed files with 6 additions and 6 deletions

View File

@ -46,7 +46,7 @@ export default async function AppLayout({ children }: { children: ReactNode }) {
domain={!!process.env.IS_GENERAL ? 'postiz.com' : 'gitroom.com'}
>
<PHProvider
key={process.env.NEXT_PUBLIC_POSTHOG_KEY}
phkey={process.env.NEXT_PUBLIC_POSTHOG_KEY}
host={process.env.NEXT_PUBLIC_POSTHOG_HOST}
>
<LayoutContext>{children}</LayoutContext>

View File

@ -6,22 +6,22 @@ import { FC, ReactNode, useEffect } from 'react';
export const PHProvider: FC<{
children: ReactNode;
key?: string;
phkey?: string;
host?: string;
}> = ({ children, key, host }) => {
}> = ({ children, phkey, host }) => {
useEffect(() => {
if (!key || !host) {
if (!phkey || !host) {
return;
}
posthog.init(key, {
posthog.init(phkey, {
api_host: host,
person_profiles: 'identified_only',
capture_pageview: false, // Disable automatic pageview capture, as we capture manually
});
}, []);
if (!key || !host) {
if (!phkey || !host) {
return <>{children}</>;
}
return <PostHogProvider client={posthog}>{children}</PostHogProvider>;