The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Remove `logConversionEvent` (#3740)
Steven Tey2649eac1bccb
diff --git a/apps/web/lib/api/conversions/track-lead.ts b/apps/web/lib/api/conversions/track-lead.tsindex 11c8beee3d..07fc8acaf5 100644--- a/apps/web/lib/api/conversions/track-lead.ts+++ b/apps/web/lib/api/conversions/track-lead.ts@@ -7,7 +7,6 @@ import { createPartnerCommission } from "@/lib/partners/create-partner-commissioimport { sendPartnerPostback } from "@/lib/postback/api/send-partner-postback";import { isStored, storage } from "@/lib/storage";import { getClickEvent, recordLead } from "@/lib/tinybird";-import { logConversionEvent } from "@/lib/tinybird/log-conversion-events";import { CustomerSource, WorkspaceProps } from "@/lib/types";import { redis } from "@/lib/upstash";import { sendWorkspaceWebhook } from "@/lib/webhook/publish";@@ -228,15 +227,6 @@ export const trackLead = async ({if (mode !== "deferred") {await recordLead(createLeadEventPayload(customer.id));}-- // track the conversion event in our logs- await logConversionEvent({- workspace_id: workspace.id,- link_id: link.id,- path: "/track/lead",- body: JSON.stringify(rawBody),- });-if (customerAvatar &&!isStored(customerAvatar) &&diff --git a/apps/web/lib/api/conversions/track-sale.ts b/apps/web/lib/api/conversions/track-sale.tsindex 5fc3eb47c8..0b3495a712 100644--- a/apps/web/lib/api/conversions/track-sale.ts+++ b/apps/web/lib/api/conversions/track-sale.ts@@ -13,7 +13,6 @@ import {recordLead,recordSale,} from "@/lib/tinybird";-import { logConversionEvent } from "@/lib/tinybird/log-conversion-events";import {ClickEventTB,CustomerSource,@@ -96,15 +95,6 @@ export const trackSale = async ({if (!leadEvent) {const errorMessage = `Lead event not found for externalId: ${customerExternalId} and leadEventName: ${leadEventName}`;- waitUntil(- logConversionEvent({- workspace_id: workspace.id,- path: "/track/sale",- body: JSON.stringify(rawBody),- error: errorMessage,- }),- );-throw new DubApiError({code: "not_found",message: errorMessage,@@ -119,15 +109,6 @@ export const trackSale = async ({// If no existing customer is found and no clickId is provided, return an errorif (!existingCustomer && !clickId) {- waitUntil(- logConversionEvent({- workspace_id: workspace.id,- path: "/track/sale",- body: JSON.stringify(rawBody),- error: `No existing customer with the provided customerExternalId (${customerExternalId}) was found, and there was no clickId provided for direct sale tracking.`,- }),- );-return {eventName,customer: null,@@ -259,15 +240,6 @@ export const trackSale = async ({// This should never happen, but just in caseif (!customer) {- waitUntil(- logConversionEvent({- workspace_id: workspace.id,- path: "/track/sale",- body: JSON.stringify(rawBody),- error: `Customer not found for customerExternalId: ${customerExternalId}`,- }),- );-return {eventName,customer: null,@@ -434,15 +406,6 @@ const _trackSale = async ({// Skip if amount is 0 or lessif (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,@@ -523,14 +486,6 @@ const _trackSale = async ({},},}),-- // Log conversion event- logConversionEvent({- workspace_id: workspace.id,- link_id: saleData.link_id,- path: "/track/sale",- body: JSON.stringify(rawBody),- }),]);let createdCommission:diff --git a/apps/web/lib/auth/workspace.ts b/apps/web/lib/auth/workspace.tsindex a476deb2e9..d3efda76cb 100644--- a/apps/web/lib/auth/workspace.ts+++ b/apps/web/lib/auth/workspace.ts@@ -17,7 +17,6 @@ import { throwIfNoAccess } from "../api/tokens/throw-if-no-access";import { normalizeWorkspaceId } from "../api/workspaces/workspace-id";import { withAxiomBodyLog } from "../axiom/server";import { getFeatureFlags } from "../edge-config";-import { logConversionEvent } from "../tinybird/log-conversion-events";import { hashToken } from "./hash-token";import { rateLimitRequest } from "./rate-limit-request";import { TokenCacheItem, tokenCache } from "./token-cache";@@ -493,21 +492,6 @@ export const withWorkspace = (return response;} catch (error) {- // Log the conversion events for debugging purposes- waitUntil(- (async () => {- const paths = ["/track/lead", "/track/sale"];-- if (workspace && paths.includes(req.nextUrl.pathname)) {- logConversionEvent({- workspace_id: workspace.id,- path: req.nextUrl.pathname,- error: error.message,- });- }- })(),- );-const errorResponse = handleAndReturnErrorResponse(error,responseHeaders,diff --git a/apps/web/lib/tinybird/log-conversion-events.ts b/apps/web/lib/tinybird/log-conversion-events.tsdeleted file mode 100644index 5ec6a78b8d..0000000000--- a/apps/web/lib/tinybird/log-conversion-events.ts+++ /dev/null@@ -1,16 +0,0 @@-import * as z from "zod/v4";-import { tb } from "./client";--const schema = z.object({- workspace_id: z.string(),- link_id: z.string().default(""),- path: z.string(),- body: z.string().default(""),- error: z.string().default(""),-});--// Log the conversion events for debugging purposes-export const logConversionEvent = tb.buildIngestEndpoint({- datasource: "dub_conversion_events_log",- event: schema,-});