The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
wip
Kiran K9ffb9ecabb82
diff --git a/apps/web/lib/tinybird/record-click.ts b/apps/web/lib/tinybird/record-click.tsindex 723bb2636a..426a2953f6 100644--- a/apps/web/lib/tinybird/record-click.ts+++ b/apps/web/lib/tinybird/record-click.ts@@ -4,6 +4,7 @@ import {capitalize,fetchWithRetry,getDomainWithoutWWW,+ log,} from "@dub/utils";import { EU_COUNTRY_CODES } from "@dub/utils/src/constants/countries";import { geolocation, ipAddress } from "@vercel/functions";@@ -80,13 +81,13 @@ export async function recordClick({// by default, we deduplicate clicks for a domain + key pair from the same IP address – only record 1 click per hour// we only need to do these if skipRatelimit is not true (we skip it in /api/track/:path endpoints)- if (!skipRatelimit) {- // here, we check if the clickId is cached in Redis within the last hour- const cachedClickId = await clickCache.get({ domain, key, ip });- if (cachedClickId) {- return null;- }- }+ // if (!skipRatelimit) {+ // // here, we check if the clickId is cached in Redis within the last hour+ // const cachedClickId = await clickCache.get({ domain, key, ip });+ // if (cachedClickId) {+ // return null;+ // }+ // }const isQr = detectQr(req);@@ -149,7 +150,7 @@ export async function recordClick({const hasWebhooks = webhookIds && webhookIds.length > 0;- const [, , , , workspaceRows] = await Promise.allSettled([+ const response = await Promise.allSettled([fetchWithRetry(`${process.env.TINYBIRD_API_URL}/v0/events?name=dub_click_events&wait=true`,{@@ -194,6 +195,19 @@ export async function recordClick({: null,]);+ // Alert Slack if any of the promises are rejected+ if (response.some((result) => result.status === "rejected")) {+ const errors = response.filter((result) => result.status === "rejected");++ await log({+ message: `[Record click] - ${errors.map((error) => error.reason).join(", ")}`,+ type: "errors",+ mention: true,+ });+ }++ const [, , , , workspaceRows] = response;+const workspace =workspaceRows.status === "fulfilled" &&workspaceRows.value &&