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.

Update track-lead.ts

Steven Tey2942e67c9dc6
diff --git a/apps/web/lib/api/conversions/track-lead.ts b/apps/web/lib/api/conversions/track-lead.ts
index 04c3d0ba5f..109b1e2327 100644
--- a/apps/web/lib/api/conversions/track-lead.ts
+++ b/apps/web/lib/api/conversions/track-lead.ts
@@ -78,7 +78,7 @@ export const trackLead = async ({
// if not deferred mode, we need to deduplicate lead events – only record 1 unique event for the same customer and event name
// TODO: Maybe we can replace this to rely only on MySQL directly since we're checking the customer above?
if (mode !== "deferred") {
- const ok = await redis.set(
+ const res = await redis.set(
`trackLead:${workspace.id}:${customerExternalId}:${stringifiedEventName}`,
{
timestamp: Date.now(),
@@ -94,7 +94,8 @@ export const trackLead = async ({
nx: true,
},
);
- deduplicate = ok ? true : false;
+ // if res = null it means the key was already set
+ deduplicate = res === null ? true : false;
}
// if this event doesn't need to be deduplicated