Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

account for coupon-based referrals (no link)

Steven Tey351b27c2181c
diff --git a/apps/web/lib/rewardful/import-customers.ts b/apps/web/lib/rewardful/import-customers.ts
index a80f11657c..9692b87654 100644
--- a/apps/web/lib/rewardful/import-customers.ts
+++ b/apps/web/lib/rewardful/import-customers.ts
@@ -98,6 +98,16 @@ async function createCustomer({
entity_id: referralId,
} as const;
+ if (!referral.link) {
+ await logImportError({
+ ...commonImportLogInputs,
+ code: "LINK_NOT_FOUND",
+ message: `Link not found for referral ${referralId} (could've been a coupon-based referral).`,
+ });
+
+ return;
+ }
+
const link = await prisma.link.findUnique({
where: {
domain_key: {
diff --git a/apps/web/lib/rewardful/types.ts b/apps/web/lib/rewardful/types.ts
index 8790073b6d..cd92c263db 100644
--- a/apps/web/lib/rewardful/types.ts
+++ b/apps/web/lib/rewardful/types.ts
@@ -57,7 +57,7 @@ export interface RewardfulAffiliate {
export interface RewardfulReferral {
id: string;
- link: RewardfulLink;
+ link?: RewardfulLink; // could be null for coupon-based referrals
customer: RewardfulCustomer;
affiliate: RewardfulAffiliate;
created_at: string;