mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-16 01:55:15 +03:00
26 lines
616 B
TypeScript
26 lines
616 B
TypeScript
|
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) {
|
||
|
return;
|
||
|
}
|
||
|
const response = AnalyticsBrowser.load({
|
||
|
writeKey: juneApiKey,
|
||
|
});
|
||
|
setAnalytics(response);
|
||
|
};
|
||
|
loadAnalytics();
|
||
|
}, []);
|
||
|
|
||
|
return analytics;
|
||
|
};
|