feat: Implement Dub.co for conversion tracking (#16165)
* FEAT: Implement Dub.co for conversion tracking * add link creation, @vercel/functions * use refer.cal.com/:username instead of go.cal.com/r/:username * sale conversion tracking * add copy referral link * limit to IS_CALCOM only * Update yarn.lock * fix DubAnalytics * use workaround for isNewUser * pass req to getOptions * Update next-auth-options.ts * fix ts errors * only show DubAnalytics outside EU * add Dub Analytics to /signup * use WEBSITE_URL instead * on-demand generate links * add migration * add check for existing link + change fetch method to poast * remove refer.cal.com from PoweredByCal * limit DubAnalytics to /signup only * simplify generate-referral-link * restore yarn.lock * add yarn with dub sdk in * add yarn with dub sdk in * yarn * Update yarn.lock --------- Co-authored-by: sean <sean@brydon.io> Co-authored-by: Peer Richelsen <peer@cal.com>
This commit is contained in:
co-authored by
sean
Peer Richelsen
parent
f4bc7d2ea4
commit
cf16cd3ed2
@@ -37,6 +37,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
const availability = await checkUsername(usernameParam, currentOrgDomain);
|
||||
if (availability.available && availability.premium && IS_PREMIUM_USERNAME_ENABLED) {
|
||||
const stripePremiumUrl = await getStripePremiumUsernameUrl({
|
||||
userId: session.user.id.toString(),
|
||||
userEmail: session.user.email,
|
||||
username: usernameParam,
|
||||
successDestination,
|
||||
@@ -104,12 +105,14 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
};
|
||||
|
||||
type GetStripePremiumUsernameUrl = {
|
||||
userId: string;
|
||||
userEmail: string;
|
||||
username: string;
|
||||
successDestination: string;
|
||||
};
|
||||
|
||||
const getStripePremiumUsernameUrl = async ({
|
||||
userId,
|
||||
userEmail,
|
||||
username,
|
||||
successDestination,
|
||||
@@ -136,6 +139,9 @@ const getStripePremiumUsernameUrl = async ({
|
||||
success_url: `${process.env.NEXT_PUBLIC_WEBAPP_URL}${successDestination}&session_id={CHECKOUT_SESSION_ID}`,
|
||||
cancel_url: process.env.NEXT_PUBLIC_WEBAPP_URL || "https://app.cal.com",
|
||||
allow_promotion_codes: true,
|
||||
metadata: {
|
||||
dubCustomerId: userId, // pass the userId during checkout creation for sales conversion tracking: https://d.to/conversions/stripe
|
||||
},
|
||||
});
|
||||
|
||||
return checkoutSession.url;
|
||||
|
||||
Reference in New Issue
Block a user