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.

fix hasExceededUsageLimit logic

Steven Tey735b1284a0fb
diff --git a/apps/web/lib/tinybird/record-click.ts b/apps/web/lib/tinybird/record-click.ts
index 1eec79d5ff..c2a14753df 100644
--- a/apps/web/lib/tinybird/record-click.ts
+++ b/apps/web/lib/tinybird/record-click.ts
@@ -231,7 +231,7 @@ export async function recordClick({
[workspaceId],
);
- const hasExceededUsageLimit =
+ const workspaceData =
workspaceRows.rows.length > 0
? (workspaceRows.rows[0] as Pick<
WorkspaceProps,
@@ -239,6 +239,9 @@ export async function recordClick({
>)
: null;
+ const hasExceededUsageLimit =
+ workspaceData && workspaceData.usage >= workspaceData.usageLimit;
+
// Send webhook events if link has webhooks enabled and the workspace usage has not exceeded the limit
if (hasWebhooks && !hasExceededUsageLimit) {
await sendLinkClickWebhooks({ webhookIds, linkId, clickData });