The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update import-referrals.ts
Steven Teyaaac6230fc6c
diff --git a/apps/web/lib/rewardful/import-referrals.ts b/apps/web/lib/rewardful/import-referrals.tsindex eb7e925de5..1bf400796a 100644--- a/apps/web/lib/rewardful/import-referrals.ts+++ b/apps/web/lib/rewardful/import-referrals.ts@@ -101,11 +101,12 @@ async function createReferral({workspace: Project;program: Program;}) {- const link = await prisma.link.findFirst({+ const link = await prisma.link.findUnique({where: {- key: referral.link.token,- domain: program.domain!,- programId: program.id,+ domain_key: {+ domain: program.domain!,+ key: referral.link.token,+ },},});@@ -114,6 +115,19 @@ async function createReferral({return;}+ const customerFound = await prisma.customer.findUnique({+ where: {+ stripeCustomerId: referral.stripe_customer_id,+ },+ });++ if (customerFound) {+ console.log(+ `A customer already exists with Stripe customer ID ${referral.stripe_customer_id}`,+ );+ return;+ }+const dummyRequest = new Request(link.url, {headers: new Headers({"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)",@@ -140,19 +154,6 @@ async function createReferral({qr: 0,});- const customerFound = await prisma.customer.findUnique({- where: {- stripeCustomerId: referral.stripe_customer_id,- },- });-- if (customerFound) {- console.log(- `A customer already exists with Stripe customer ID ${referral.stripe_customer_id}`,- );- return;- }-const customerId = createId({ prefix: "cus_" });await Promise.all([