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.

Allow null PartnerStack customer emails

Pedro Ladeira81a9929b86fe
diff --git a/apps/web/lib/partnerstack/import-commissions.ts b/apps/web/lib/partnerstack/import-commissions.ts
index c52826c5f5..e1368cf3a5 100644
--- a/apps/web/lib/partnerstack/import-commissions.ts
+++ b/apps/web/lib/partnerstack/import-commissions.ts
@@ -250,8 +250,10 @@ export async function createCommissionFromPS({
const customer = customersData.find(
({ email, externalId }) =>
- email === commission.customer?.email ||
- externalId === commission.customer?.external_key,
+ (commission.customer?.email != null &&
+ email === commission.customer.email) ||
+ (commission.customer?.external_key != null &&
+ externalId === commission.customer.external_key),
);
if (!customer) {
diff --git a/apps/web/lib/partnerstack/import-customers.ts b/apps/web/lib/partnerstack/import-customers.ts
index 126d279326..22faee4704 100644
--- a/apps/web/lib/partnerstack/import-customers.ts
+++ b/apps/web/lib/partnerstack/import-customers.ts
@@ -212,7 +212,7 @@ async function createCustomer({
import_id: importId,
source: "partnerstack",
entity: "customer",
- entity_id: customer.customer_key || customer.email,
+ entity_id: customer.customer_key || customer.email || customer.key,
} as const;
if (links.length === 0) {
diff --git a/apps/web/lib/partnerstack/schemas.ts b/apps/web/lib/partnerstack/schemas.ts
index 13872553cf..c9b1465a0c 100644
--- a/apps/web/lib/partnerstack/schemas.ts
+++ b/apps/web/lib/partnerstack/schemas.ts
@@ -63,7 +63,7 @@ export const partnerStackLink = z.object({
export const partnerStackCustomer = z.object({
key: z.string(),
name: z.string().nullable(),
- email: z.string(),
+ email: z.string().nullable(),
provider_key: z
.string()
.nullable()
@@ -85,7 +85,7 @@ export const partnerStackCommission = z.object({
created_at: z.number(),
customer: z
.object({
- email: z.string(),
+ email: z.string().nullable(),
external_key: z.string().nullable(),
})
.nullable(),