quivr/frontend/services/analytics/google/useGAnalyticsEventTracker.ts
Mamadou DICKO 1ec736b357
fix: fix some bugs (#1201)
* 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
2023-09-18 21:28:07 +02:00

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 };
};