1
1
mirror of https://github.com/QuivrHQ/quivr.git synced 2024-12-15 17:43:03 +03:00
quivr/frontend/services/analytics/useJune.ts
Zineb El Bachiri a9411c973a
fix(analytics): june debug for real ()
* 🔥 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

30 lines
731 B
TypeScript

"use client";
import { AnalyticsBrowser } from "@june-so/analytics-next";
import { useEffect, useState } from "react";
const juneApiKey = process.env.NEXT_PUBLIC_JUNE_API_KEY;
export const useJune = (): AnalyticsBrowser | undefined => {
const [analytics, setAnalytics] = useState<AnalyticsBrowser | undefined>(
undefined
);
useEffect(() => {
const loadAnalytics = () => {
if (juneApiKey === undefined) {
console.log("No June API key found");
return;
}
const response = AnalyticsBrowser.load({
writeKey: juneApiKey,
});
console.log("Loaded June Analytics", response);
setAnalytics(response);
};
loadAnalytics();
}, []);
return analytics;
};