The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Skip processing for zero or negative sale amounts
Kiran K687899b8205c
diff --git a/apps/web/lib/api/conversions/track-sale.ts b/apps/web/lib/api/conversions/track-sale.tsindex a7263e167a..a330d757a5 100644--- a/apps/web/lib/api/conversions/track-sale.ts+++ b/apps/web/lib/api/conversions/track-sale.ts@@ -12,12 +12,7 @@ import {recordSale,} from "@/lib/tinybird";import { logConversionEvent } from "@/lib/tinybird/log-conversion-events";-import {- ClickEventTB,- LeadEventTB,- WebhookPartner,- WorkspaceProps,-} from "@/lib/types";+import { LeadEventTB, WebhookPartner, WorkspaceProps } from "@/lib/types";import { redis } from "@/lib/upstash";import { sendWorkspaceWebhook } from "@/lib/webhook/publish";import {@@ -59,7 +54,6 @@ export const trackSale = async ({}: TrackSaleParams) => {let existingCustomer: Customer | null = null;let newCustomer: Customer | null = null;- let clickData: ClickEventTB | null = null;let leadEventData: LeadEventTB | null = null;// Return idempotent response if invoiceId is already processed@@ -421,6 +415,24 @@ const _trackSale = async ({});}+ // Skip if amount is 0 or less+ if (amount <= 0) {+ waitUntil(+ logConversionEvent({+ workspace_id: workspace.id,+ path: "/track/sale",+ body: JSON.stringify(rawBody),+ error: `Sale amount is ${amount}, skipping...`,+ }),+ );++ return {+ eventName,+ customer: null,+ sale: null,+ };+ }+// if currency is not USD, convert it to USD based on the current FX rate// TODO: allow custom "defaultCurrency" on workspace table in the futureif (currency !== "usd") {