mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-23 19:32:30 +03:00
1ec736b357
* feat(brainSettings): add feed process instrcution to knowledge tab * feat: prevent default brain auto fetch * feat: prevent chat submision on submit button click * feat: remove unrelevant toast * feat: remove duplicated GA initialization * feat: add brain name in notifications * fix(test): update analytics import path * refactor: move ChatsList utils to ChatsList directory * fix(test): update chatlist tests
32 lines
560 B
TypeScript
32 lines
560 B
TypeScript
import ReactGA from "react-ga4";
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
export const useGAnalyticsEventTracker = ({
|
|
category,
|
|
}: {
|
|
category: string;
|
|
}) => {
|
|
const ga_id = process.env.NEXT_PUBLIC_GA_ID;
|
|
|
|
if (ga_id === undefined) {
|
|
return { eventTracker: undefined };
|
|
}
|
|
|
|
ReactGA.initialize(ga_id);
|
|
|
|
const eventTracker = ({
|
|
action,
|
|
label,
|
|
}: {
|
|
action: string;
|
|
label?: string;
|
|
}) => {
|
|
ReactGA.event(action, {
|
|
category,
|
|
label,
|
|
});
|
|
};
|
|
|
|
return { eventTracker };
|
|
};
|