mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-01 05:35:09 +03:00
97d2c9de10
* feat: add june tracking config * feat(tracking): add page view tracking * feat(tracking): add event tracking
26 lines
634 B
TypeScript
26 lines
634 B
TypeScript
"use client";
|
|
|
|
import { usePathname } from "next/navigation";
|
|
import { useEffect } from "react";
|
|
|
|
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
|
|
|
import { useJune } from "./useJune";
|
|
|
|
export const usePageTracking = (): void => {
|
|
const analytics = useJune();
|
|
const pathname = usePathname();
|
|
const { session } = useSupabase();
|
|
|
|
useEffect(() => {
|
|
if (pathname !== null) {
|
|
const handleRouteChange = async () => {
|
|
await analytics?.identify(session?.user.id);
|
|
await analytics?.page(pathname);
|
|
};
|
|
|
|
void handleRouteChange();
|
|
}
|
|
}, [analytics, pathname, session?.user.id]);
|
|
};
|