feat: track to variables
This commit is contained in:
parent
72523ed2c1
commit
39538b5f95
|
|
@ -41,6 +41,7 @@ export default async function AppLayout({ children }: { children: ReactNode }) {
|
|||
isGeneral={!!process.env.IS_GENERAL}
|
||||
uploadDirectory={process.env.NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY!}
|
||||
tolt={process.env.NEXT_PUBLIC_TOLT!}
|
||||
facebookPixel={process.env.NEXT_PUBLIC_FACEBOOK_PIXEL!}
|
||||
>
|
||||
<ToltScript />
|
||||
<FacebookComponent />
|
||||
|
|
|
|||
|
|
@ -2,14 +2,16 @@ import { TrackEnum } from '@gitroom/nestjs-libraries/user/track.enum';
|
|||
import { useUser } from '@gitroom/frontend/components/layout/user.context';
|
||||
import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
|
||||
import { useCallback } from 'react';
|
||||
import { useVariables } from '@gitroom/react/helpers/variable.context';
|
||||
|
||||
export const useTrack = () => {
|
||||
const user = useUser();
|
||||
const fetch = useFetch();
|
||||
const {facebookPixel} = useVariables();
|
||||
|
||||
return useCallback(
|
||||
async (track: TrackEnum, additional?: Record<string, any>) => {
|
||||
if (!process.env.NEXT_PUBLIC_FACEBOOK_PIXEL) {
|
||||
if (!facebookPixel) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ interface VariableContextInterface {
|
|||
backendUrl: string;
|
||||
discordUrl: string;
|
||||
uploadDirectory: string;
|
||||
facebookPixel: string;
|
||||
tolt: string;
|
||||
}
|
||||
const VariableContext = createContext({
|
||||
|
|
@ -22,6 +23,7 @@ const VariableContext = createContext({
|
|||
backendUrl: '',
|
||||
discordUrl: '',
|
||||
uploadDirectory: '',
|
||||
facebookPixel: '',
|
||||
tolt: '',
|
||||
} as VariableContextInterface);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue