quivr/frontend/services/analytics/useEventTracking.ts
Zineb El Bachiri a9411c973a
fix(analytics): june debug for real (#1033)
* 🔥 remove Suspense because no ssr in front anymore

*  add debugging

* 🔥 remove debugger and better logs

* 🐛 fixed tracker by adding it to dependencies

* 🚨 add dependencies to hooks

* 🚨 remove linter warning from unawaited promise
2023-08-25 10:33:14 +02:00

27 lines
650 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): 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);
};
return {
track,
};
};