Skip to content

Commit e15843d

Browse files
authored
Merge pull request dubinc#2827 from dubinc/lead-noop
Add noop response to /track/lead (instead of error)
2 parents 93ec75d + c4f38b4 commit e15843d

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

apps/web/lib/api/conversions/track-sale.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ export const trackSale = async ({
123123
}
124124
}
125125

126-
// No existing customer is found, find the click event and create a new customer (for sale tracking without a pre-existing lead event)
126+
// No existing customer is found, find the click event and create a new customer (for direct sale tracking)
127127
else {
128128
if (!clickId) {
129129
waitUntil(
130130
logConversionEvent({
131131
workspace_id: workspace.id,
132132
path: "/track/sale",
133133
body: JSON.stringify(rawBody),
134-
error: `No existing customer with the provided customerExternalId (${customerExternalId}) was found, and there was no clickId provided for sale tracking without a pre-existing lead event.`,
134+
error: `No existing customer with the provided customerExternalId (${customerExternalId}) was found, and there was no clickId provided for direct sale tracking.`,
135135
}),
136136
);
137137

apps/web/lib/zod/schemas/sales.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,46 +57,42 @@ export const trackSaleRequestSchema = z.object({
5757
.describe(
5858
"Additional metadata to be stored with the sale event. Max 10,000 characters when stringified.",
5959
),
60-
// advanced fields: leadEventName + fields for sale tracking without a pre-existing lead event
60+
// advanced fields: leadEventName + fields for sale tracking without a lead event
6161
leadEventName: z
6262
.string()
6363
.nullish()
6464
.default(null)
6565
.describe(
66-
"The name of the lead event that occurred before the sale (case-sensitive). This is used to associate the sale event with a particular lead event (instead of the latest lead event for a link-customer combination, which is the default behavior). For sale tracking without a pre-existing lead event, this field can also be used to specify the lead event name.",
66+
"The name of the lead event that occurred before the sale (case-sensitive). This is used to associate the sale event with a particular lead event (instead of the latest lead event for a link-customer combination, which is the default behavior). For direct sale tracking, this field can also be used to specify the lead event name.",
6767
)
6868
.openapi({ example: "Cloned template 1481267" }),
6969
clickId: z
7070
.string()
7171
.trim()
7272
.nullish()
7373
.describe(
74-
"[For sale tracking without a pre-existing lead event]: The unique ID of the click that the sale conversion event is attributed to. You can read this value from `dub_id` cookie.",
74+
"[For direct sale tracking]: The unique ID of the click that the sale conversion event is attributed to. You can read this value from `dub_id` cookie.",
7575
),
7676
customerName: z
7777
.string()
7878
.max(100)
7979
.nullish()
8080
.default(null)
8181
.describe(
82-
"[For sale tracking without a pre-existing lead event]: The name of the customer. If not passed, a random name will be generated (e.g. “Big Red Caribou”).",
82+
"[For direct sale tracking]: The name of the customer. If not passed, a random name will be generated (e.g. “Big Red Caribou”).",
8383
),
8484
customerEmail: z
8585
.string()
8686
.email()
8787
.max(100)
8888
.nullish()
8989
.default(null)
90-
.describe(
91-
"[For sale tracking without a pre-existing lead event]: The email address of the customer.",
92-
),
90+
.describe("[For direct sale tracking]: The email address of the customer."),
9391
customerAvatar: z
9492
.string()
9593
.nullish()
9694
.default(null)
97-
.describe(
98-
"[For sale tracking without a pre-existing lead event]: The avatar URL of the customer.",
99-
),
95+
.describe("[For direct sale tracking]: The avatar URL of the customer."),
10096
});
10197

10298
export const trackSaleResponseSchema = z.object({

apps/web/tests/tracks/track-sale.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ describe("POST /track/sale", async () => {
227227
expect(response.data.sale?.amount).toBeLessThanOrEqual(1100); // 1100 cents
228228
});
229229

230-
test("track a sale without a pre-existing lead event", async () => {
230+
test("track a sale with direct sale tracking", async () => {
231231
const clickResponse = await http.post<{ clickId: string }>({
232232
path: "/track/click",
233233
headers: E2E_TRACK_CLICK_HEADERS,

0 commit comments

Comments
 (0)