feat: fix posthog
This commit is contained in:
parent
792fa7fba0
commit
605c3457ff
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue