* adding posthog libs for node + js * updating lock * move to init posthog client - pageview component * adding identify in shell * removing test event captures * add signout tracking to dropdown as it was missed in merge --------- Co-authored-by: sean <[email protected]> Co-authored-by: Bailey Pumfleet <[email protected]>
26 lines
771 B
TypeScript
26 lines
771 B
TypeScript
"use client";
|
|
|
|
import posthog from "posthog-js";
|
|
import { PostHogProvider } from "posthog-js/react";
|
|
import { useEffect } from "react";
|
|
|
|
function Provider({ children }: { children: React.ReactNode }) {
|
|
useEffect(() => {
|
|
if (!process.env.NEXT_PUBLIC_POSTHOG_KEY) return;
|
|
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
|
|
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || "https://us.i.posthog.com",
|
|
autocapture: false,
|
|
persistence: "memory",
|
|
request_batching: false,
|
|
// Enable debug mode in development
|
|
loaded: (posthog) => {
|
|
if (process.env.NODE_ENV === "development") posthog.debug();
|
|
},
|
|
});
|
|
}, []);
|
|
|
|
return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
|
|
}
|
|
|
|
export default Provider;
|