diff --git a/apps/frontend/src/app/layout.tsx b/apps/frontend/src/app/layout.tsx index c143d959..17b2c758 100644 --- a/apps/frontend/src/app/layout.tsx +++ b/apps/frontend/src/app/layout.tsx @@ -13,6 +13,7 @@ import { VariableContextComponent } from '@gitroom/react/helpers/variable.contex import { Fragment } from 'react'; import { PHProvider } from '@gitroom/react/helpers/posthog'; import UtmSaver from '@gitroom/helpers/utils/utm.saver'; +import { ToltScript } from '@gitroom/frontend/components/layout/tolt.script'; const chakra = Chakra_Petch({ weight: '400', subsets: ['latin'] }); @@ -42,7 +43,9 @@ export default async function AppLayout({ children }: { children: ReactNode }) { frontEndUrl={process.env.FRONTEND_URL!} isGeneral={!!process.env.IS_GENERAL} uploadDirectory={process.env.NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY!} + tolt={process.env.NEXT_PUBLIC_TOLT!} > + diff --git a/apps/frontend/src/components/billing/main.billing.component.tsx b/apps/frontend/src/components/billing/main.billing.component.tsx index 3a4e331d..c2e9395c 100644 --- a/apps/frontend/src/components/billing/main.billing.component.tsx +++ b/apps/frontend/src/components/billing/main.billing.component.tsx @@ -23,6 +23,7 @@ import { TopTitle } from '@gitroom/frontend/components/launches/helpers/top.titl import { Textarea } from '@gitroom/react/form/textarea'; import { useFireEvents } from '@gitroom/helpers/utils/use.fire.events'; import { useUtmUrl } from '@gitroom/helpers/utils/utm.saver'; +import { useTolt } from '@gitroom/frontend/components/layout/tolt.script'; export interface Tiers { month: Array<{ @@ -221,6 +222,7 @@ export const MainBillingComponent: FC<{ const modal = useModals(); const router = useRouter(); const utm = useUtmUrl(); + const tolt = useTolt(); const [subscription, setSubscription] = useState( sub @@ -348,6 +350,7 @@ export const MainBillingComponent: FC<{ period: monthlyOrYearly === 'on' ? 'YEARLY' : 'MONTHLY', utm, billing, + tolt: tolt() }), }) ).json(); diff --git a/apps/frontend/src/components/layout/tolt.script.tsx b/apps/frontend/src/components/layout/tolt.script.tsx new file mode 100644 index 00000000..e881f7d9 --- /dev/null +++ b/apps/frontend/src/components/layout/tolt.script.tsx @@ -0,0 +1,23 @@ +'use client'; + +import { useVariables } from '@gitroom/react/helpers/variable.context'; +import Script from 'next/script'; + +export const useTolt = () => { + return () => { + // @ts-ignore + return window?.tolt_referral || ''; + }; +}; + +export const ToltScript = () => { + const { tolt } = useVariables(); + if (!tolt) return null; + return ( +