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.

Add customer country context to various API routes and actions

Kiran K27e62ecc055a
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/utils.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/utils.ts
index 631420bf7c..7bf47157a6 100644
--- a/apps/web/app/(ee)/api/stripe/integration/webhook/utils.ts
+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/utils.ts
@@ -107,6 +107,11 @@ export async function createNewCustomer(event: Stripe.Event) {
eventId: leadData.event_id,
customerId: customer.id,
quantity: 1,
+ context: {
+ customer: {
+ country: customer.country,
+ },
+ },
});
}
diff --git a/apps/web/app/(ee)/api/track/lead/route.ts b/apps/web/app/(ee)/api/track/lead/route.ts
index 016e90283e..6c97578c83 100644
--- a/apps/web/app/(ee)/api/track/lead/route.ts
+++ b/apps/web/app/(ee)/api/track/lead/route.ts
@@ -252,6 +252,11 @@ export const POST = withWorkspace(
eventId: leadEventId,
customerId: customer.id,
quantity: eventQuantity ?? 1,
+ context: {
+ customer: {
+ country: customer.country,
+ },
+ },
});
}
diff --git a/apps/web/app/(ee)/api/track/sale/route.ts b/apps/web/app/(ee)/api/track/sale/route.ts
index f261160679..b8a2ac2d2c 100644
--- a/apps/web/app/(ee)/api/track/sale/route.ts
+++ b/apps/web/app/(ee)/api/track/sale/route.ts
@@ -225,6 +225,11 @@ export const POST = withWorkspace(
quantity: 1,
invoiceId,
currency,
+ context: {
+ customer: {
+ country: customer.country,
+ },
+ },
});
if (commission) {
diff --git a/apps/web/lib/actions/partners/create-commission.ts b/apps/web/lib/actions/partners/create-commission.ts
index 7df2cec514..ba87c8e225 100644
--- a/apps/web/lib/actions/partners/create-commission.ts
+++ b/apps/web/lib/actions/partners/create-commission.ts
@@ -183,6 +183,11 @@ export const createCommissionAction = authActionClient
createdAt: finalLeadEventDate,
user,
workspaceId: workspace.id,
+ context: {
+ customer: {
+ country: customer.country,
+ },
+ },
}),
]);
}
@@ -219,6 +224,11 @@ export const createCommissionAction = authActionClient
createdAt: saleEventDate,
user,
workspaceId: workspace.id,
+ context: {
+ customer: {
+ country: customer.country,
+ },
+ },
}),
]);
}
diff --git a/apps/web/lib/integrations/shopify/create-sale.ts b/apps/web/lib/integrations/shopify/create-sale.ts
index 674dfaf175..ef9aece567 100644
--- a/apps/web/lib/integrations/shopify/create-sale.ts
+++ b/apps/web/lib/integrations/shopify/create-sale.ts
@@ -137,6 +137,11 @@ export async function createShopifySale({
quantity: 1,
invoiceId: saleData.invoice_id,
currency: saleData.currency,
+ context: {
+ customer: {
+ country: customer.country,
+ },
+ },
});
if (commission) {
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 3379bc91bf..c64baf2e8d 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -467,8 +467,6 @@ export type FolderWithPermissions = {
export type FolderSummary = Pick<Folder, "id" | "name" | "accessLevel">;
-// Rewards
-
export type RewardProps = z.infer<typeof RewardSchema>;
export type CreatePartnerProps = z.infer<typeof createPartnerSchema>;
diff --git a/apps/web/lib/zod/schemas/rewards.ts b/apps/web/lib/zod/schemas/rewards.ts
index e3aa847c65..ad5bd3f843 100644
--- a/apps/web/lib/zod/schemas/rewards.ts
+++ b/apps/web/lib/zod/schemas/rewards.ts
@@ -81,7 +81,7 @@ export const RewardSchema = z.object({
maxDuration: z.number().nullish(),
maxAmount: z.number().nullish(),
default: z.boolean(),
- modifiers: z.array(rewardModifierSchema).nullish(),
+ modifiers: z.any(), // TODO: Fix this
});
export const createOrUpdateRewardSchema = z.object({