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.

Handle trial sale events

Steven Tey2be1fe48e0ca
diff --git a/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts b/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts
index 421ea6676c..828e5e4c33 100644
--- a/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts
+++ b/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts
@@ -22,6 +22,10 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {
return "Customer ID not found in Stripe checkout session metadata, skipping...";
}
+ if (charge.amount_total === 0) {
+ return `Checkout session completed for customer with external ID ${dubCustomerId} and invoice ID ${invoiceId} but amount is 0, skipping...`;
+ }
+
let customer: Customer;
try {
// Update customer with stripe customerId if exists
diff --git a/apps/web/app/api/stripe/integration/webhook/invoice-paid.ts b/apps/web/app/api/stripe/integration/webhook/invoice-paid.ts
index cdf80ae48f..d2809e6f18 100644
--- a/apps/web/app/api/stripe/integration/webhook/invoice-paid.ts
+++ b/apps/web/app/api/stripe/integration/webhook/invoice-paid.ts
@@ -16,6 +16,10 @@ export async function invoicePaid(event: Stripe.Event) {
const stripeCustomerId = invoice.customer as string;
const invoiceId = invoice.id;
+ if (invoice.amount_paid === 0) {
+ return `Invoice with ID ${invoiceId} has an amount of 0, skipping...`;
+ }
+
// Find customer using projectConnectId and stripeCustomerId
const customer = await prisma.customer.findFirst({
where: {
diff --git a/apps/web/ui/links/link-details-column.tsx b/apps/web/ui/links/link-details-column.tsx
index fd0a16f39a..f67a7462ae 100644
--- a/apps/web/ui/links/link-details-column.tsx
+++ b/apps/web/ui/links/link-details-column.tsx
@@ -151,7 +151,8 @@ function AnalyticsBadge({ link }: { link: ResponseLink }) {
? undefined
: (value) => pluralize("click", value),
},
- ...(trackConversion
+ // TODO: Remove this once Dub Conversions goes GA
+ ...(trackConversion || link.leads > 0 || link.saleAmount > 0
? [
{
id: "leads",