The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
edit ratelimit setup
Steven Teyc82cbeda1a5f
diff --git a/apps/web/lib/tinybird.ts b/apps/web/lib/tinybird.tsindex bc4cc51587..85815bafb9 100644--- a/apps/web/lib/tinybird.ts+++ b/apps/web/lib/tinybird.ts@@ -37,10 +37,10 @@ export async function recordClick({const referer = req.headers.get("referer");const ip = process.env.VERCEL === "1" ? ipAddress(req) : LOCALHOST_IP;const identity_hash = await getIdentityHash(req);- // if in production / preview env, deduplicate clicks from the same IP & link ID – only record 1 click per hour+ // if in production / preview env, deduplicate clicks from the same IP address + link ID – only record 1 click per hourif (process.env.VERCEL === "1") {const { success } = await ratelimit(2, "1 h").limit(- `recordClick:${identity_hash}:${id}`,+ `recordClick:${ip}:${id}`,);if (!success) {return null;