feat: tolt affiliate
This commit is contained in:
parent
573de24e9c
commit
65e3bf0852
|
|
@ -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!}
|
||||
>
|
||||
<ToltScript />
|
||||
<Plausible
|
||||
domain={!!process.env.IS_GENERAL ? 'postiz.com' : 'gitroom.com'}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -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<Subscription | undefined>(
|
||||
sub
|
||||
|
|
@ -348,6 +350,7 @@ export const MainBillingComponent: FC<{
|
|||
period: monthlyOrYearly === 'on' ? 'YEARLY' : 'MONTHLY',
|
||||
utm,
|
||||
billing,
|
||||
tolt: tolt()
|
||||
}),
|
||||
})
|
||||
).json();
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Script
|
||||
async={true}
|
||||
src="https://cdn.tolt.io/tolt.js"
|
||||
data-tolt={tolt}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
@ -8,4 +8,6 @@ export class BillingSubscribeDto {
|
|||
billing: 'STANDARD' | 'PRO' | 'TEAM' | 'ULTIMATE';
|
||||
|
||||
utm: string;
|
||||
|
||||
tolt: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -286,6 +286,11 @@ export class StripeService {
|
|||
uniqueId,
|
||||
},
|
||||
},
|
||||
...body.tolt ? {
|
||||
metadata: {
|
||||
tolt_referral: body.tolt,
|
||||
}
|
||||
} : {},
|
||||
allow_promotion_codes: true,
|
||||
line_items: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ interface VariableContextInterface {
|
|||
backendUrl: string;
|
||||
discordUrl: string;
|
||||
uploadDirectory: string;
|
||||
tolt: string;
|
||||
}
|
||||
const VariableContext = createContext({
|
||||
billingEnabled: false,
|
||||
|
|
@ -21,6 +22,7 @@ const VariableContext = createContext({
|
|||
backendUrl: '',
|
||||
discordUrl: '',
|
||||
uploadDirectory: '',
|
||||
tolt: '',
|
||||
} as VariableContextInterface);
|
||||
|
||||
export const VariableContextComponent: FC<
|
||||
|
|
|
|||
Loading…
Reference in New Issue