mirror of
https://github.com/makeplane/plane.git
synced 2025-12-25 08:09:33 +01:00
* [WEB-5473] fix: source map errors * [WEB-5473] chore: run codemod * fix: build errors in editor --------- Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com>
25 lines
667 B
TypeScript
25 lines
667 B
TypeScript
import { useEffect } from "react";
|
|
import { usePathname, useSearchParams } from "next/navigation";
|
|
// posthog
|
|
import { usePostHog } from "posthog-js/react";
|
|
|
|
export default function PostHogPageView(): null {
|
|
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;
|
|
}
|