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.

Don't track lead/sales for disabled links (#3081)

Steven Teydbdb8287d442
diff --git a/apps/web/lib/api/conversions/track-lead.ts b/apps/web/lib/api/conversions/track-lead.ts
index da280e5ebd..3d29fd56f3 100644
--- a/apps/web/lib/api/conversions/track-lead.ts
+++ b/apps/web/lib/api/conversions/track-lead.ts
@@ -131,7 +131,14 @@ export const trackLead = async ({
if (link.projectId !== workspace.id) {
throw new DubApiError({
code: "not_found",
- message: `Link for clickId ${clickId} does not belong to the workspace`,
+ message: `Link ${link.id} for clickId ${clickId} does not belong to the workspace`,
+ });
+ }
+
+ if (link.disabledAt) {
+ throw new DubApiError({
+ code: "not_found",
+ message: `Link ${link.id} for clickId ${clickId} is disabled, lead not tracked`,
});
}
diff --git a/apps/web/lib/api/conversions/track-sale.ts b/apps/web/lib/api/conversions/track-sale.ts
index 63e32d26c8..a7263e167a 100644
--- a/apps/web/lib/api/conversions/track-sale.ts
+++ b/apps/web/lib/api/conversions/track-sale.ts
@@ -176,6 +176,7 @@ export const trackSale = async ({
select: {
id: true,
projectId: true,
+ disabledAt: true,
},
});
@@ -189,7 +190,14 @@ export const trackSale = async ({
if (link.projectId !== workspace.id) {
throw new DubApiError({
code: "not_found",
- message: `Link for clickId ${clickData.click_id} does not belong to the workspace`,
+ message: `Link ${link.id} for clickId ${clickData.click_id} does not belong to the workspace`,
+ });
+ }
+
+ if (link.disabledAt) {
+ throw new DubApiError({
+ code: "not_found",
+ message: `Link ${link.id} for clickId ${clickData.click_id} is disabled, sale not tracked`,
});
}