mirror of
https://github.com/makeplane/plane.git
synced 2025-12-22 22:59:33 +01:00
27 lines
682 B
TypeScript
27 lines
682 B
TypeScript
"use client";
|
|
|
|
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;
|
|
}
|