* 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
665 B
TypeScript
26 lines
665 B
TypeScript
"use client";
|
|
|
|
import { usePathname, useSearchParams } from "next/navigation";
|
|
import { usePostHog } from "posthog-js/react";
|
|
import { useEffect } from "react";
|
|
|
|
export default function PostHogPageView() {
|
|
const pathname = usePathname();
|
|
const searchParams = useSearchParams();
|
|
const posthog = usePostHog();
|
|
useEffect(() => {
|
|
// Track pageviews
|
|
if (pathname && posthog) {
|
|
let url = window.origin + pathname;
|
|
if (searchParams.toString()) {
|
|
url = `${url}?${searchParams.toString()}`;
|
|
}
|
|
posthog.capture("$pageview", {
|
|
$current_url: url,
|
|
});
|
|
}
|
|
}, [pathname, searchParams, posthog]);
|
|
|
|
return null;
|
|
}
|