Skip to content

Commit 39538b5

Browse files
committed
feat: track to variables
1 parent 72523ed commit 39538b5

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

apps/frontend/src/app/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default async function AppLayout({ children }: { children: ReactNode }) {
4141
isGeneral={!!process.env.IS_GENERAL}
4242
uploadDirectory={process.env.NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY!}
4343
tolt={process.env.NEXT_PUBLIC_TOLT!}
44+
facebookPixel={process.env.NEXT_PUBLIC_FACEBOOK_PIXEL!}
4445
>
4546
<ToltScript />
4647
<FacebookComponent />

libraries/react-shared-libraries/src/helpers/use.track.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import { TrackEnum } from '@gitroom/nestjs-libraries/user/track.enum';
22
import { useUser } from '@gitroom/frontend/components/layout/user.context';
33
import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
44
import { useCallback } from 'react';
5+
import { useVariables } from '@gitroom/react/helpers/variable.context';
56

67
export const useTrack = () => {
78
const user = useUser();
89
const fetch = useFetch();
10+
const {facebookPixel} = useVariables();
911

1012
return useCallback(
1113
async (track: TrackEnum, additional?: Record<string, any>) => {
12-
if (!process.env.NEXT_PUBLIC_FACEBOOK_PIXEL) {
14+
if (!facebookPixel) {
1315
return;
1416
}
1517

libraries/react-shared-libraries/src/helpers/variable.context.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface VariableContextInterface {
1111
backendUrl: string;
1212
discordUrl: string;
1313
uploadDirectory: string;
14+
facebookPixel: string;
1415
tolt: string;
1516
}
1617
const VariableContext = createContext({
@@ -22,6 +23,7 @@ const VariableContext = createContext({
2223
backendUrl: '',
2324
discordUrl: '',
2425
uploadDirectory: '',
26+
facebookPixel: '',
2527
tolt: '',
2628
} as VariableContextInterface);
2729

0 commit comments

Comments
 (0)