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.

address coderabbitai feedbacks

Kiran K153b409be09f
diff --git a/apps/web/app/(ee)/api/singular/webhook/route.ts b/apps/web/app/(ee)/api/singular/webhook/route.ts
index fc21758ab0..d615fa12fc 100644
--- a/apps/web/app/(ee)/api/singular/webhook/route.ts
+++ b/apps/web/app/(ee)/api/singular/webhook/route.ts
@@ -55,6 +55,22 @@ export const GET = async (req: Request) => {
});
}
+ const { event_name: eventName } = queryParams;
+
+ if (!eventName) {
+ throw new DubApiError({
+ code: "bad_request",
+ message: "event_name is required.",
+ });
+ }
+
+ if (!supportedEvents.includes(eventName)) {
+ throw new DubApiError({
+ code: "bad_request",
+ message: `Event ${eventName} is not supported by Singular <> Dub integration.`,
+ });
+ }
+
const workspace = await prisma.project.findUnique({
where: {
id: workspaceId,
@@ -73,15 +89,6 @@ export const GET = async (req: Request) => {
});
}
- const { event_name: eventName } = queryParams;
-
- if (!supportedEvents.includes(eventName)) {
- throw new DubApiError({
- code: "bad_request",
- message: `Event ${eventName} is not supported by Singular <> Dub integration.`,
- });
- }
-
const dubEvent = singularToDubEvent[eventName];
if (dubEvent === "lead") {
@@ -94,11 +101,6 @@ export const GET = async (req: Request) => {
queryParams,
workspace,
});
- } else {
- throw new DubApiError({
- code: "bad_request",
- message: `Event ${eventName} is not supported by Singular <> Dub integration.`,
- });
}
return NextResponse.json("OK");
diff --git a/apps/web/lib/api/conversions/track-lead.ts b/apps/web/lib/api/conversions/track-lead.ts
index 218f5fac6f..0e73474a08 100644
--- a/apps/web/lib/api/conversions/track-lead.ts
+++ b/apps/web/lib/api/conversions/track-lead.ts
@@ -38,7 +38,7 @@ export const trackLead = async ({
rawBody,
workspace,
}: TrackLeadParams) => {
- const stringifiedEventName = eventName.toLowerCase().replace(" ", "-");
+ const stringifiedEventName = eventName.toLowerCase().replaceAll(" ", "-");
// deduplicate lead events – only record 1 unique event for the same customer and event name
const ok = await redis.set(
diff --git a/apps/web/lib/api/conversions/track-sale.ts b/apps/web/lib/api/conversions/track-sale.ts
index 00b7d02cd6..c4a7557cc1 100644
--- a/apps/web/lib/api/conversions/track-sale.ts
+++ b/apps/web/lib/api/conversions/track-sale.ts
@@ -93,7 +93,7 @@ export const trackSale = async ({
// otherwise, we check for all cached lead events for that customer
const cachedLeadEvent = await redis.get<LeadEventTB>(
- `leadCache:${customer.id}${leadEventName ? `:${leadEventName.toLowerCase().replace(" ", "-")}` : ""}`,
+ `leadCache:${customer.id}${leadEventName ? `:${leadEventName.toLowerCase().replaceAll(" ", "-")}` : ""}`,
);
if (!cachedLeadEvent) {