mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-16 10:02:30 +03:00
886d30cf9e
* 🚚 move june analytics to folder and update paths * ✨ set up google analytics * ✨ sent firt GA event with react-ga * 🔒️ update security headers to include vercel and google analytics * 🚚 rename Vercel Analytics * ✨ use react-ga4 instread * 💚 fix tests
30 lines
712 B
TypeScript
30 lines
712 B
TypeScript
"use client";
|
|
|
|
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
|
|
|
import { useJune } from "./useJune";
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
export const useEventTracking = () => {
|
|
const analytics = useJune();
|
|
const { session } = useSupabase();
|
|
|
|
const track = async (
|
|
event: string,
|
|
properties?: Record<string, unknown>
|
|
): Promise<void> => {
|
|
console.log("Event to track", event);
|
|
if (analytics === undefined) {
|
|
console.log("No analytics found");
|
|
|
|
return;
|
|
}
|
|
await analytics.identify(session?.user.id, { email: session?.user.email });
|
|
await analytics.track(event, properties);
|
|
};
|
|
|
|
return {
|
|
track,
|
|
};
|
|
};
|