The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Merge branch 'main' into redis
Kiran K28455707f275
diff --cc apps/web/lib/api/links/update-link.tsindex 6714e1d737,d198aaa6f6..4616ba6f31--- a/apps/web/lib/api/links/update-link.ts+++ b/apps/web/lib/api/links/update-link.ts@@@ -133,15 -141,9 +142,12 @@@ export async function updateLink(waitUntil(Promise.all([// record link in Redis- redis.hset(updatedLink.domain.toLowerCase(), {- [updatedLink.key.toLowerCase()]: await formatRedisLink(response),+ linkCache.set({- link: await formatRedisLink({- ...response,- webhookIds: response.webhooks.map(({ webhookId }) => webhookId),- }),++ link: await formatRedisLink(response),+ domain: response.domain,+ key: response.key,}),+// record link in TinybirdrecordLink({link_id: response.id,diff --cc apps/web/lib/middleware/link.tsindex e75095d2f8,7714613db7..71242a1f2d--- a/apps/web/lib/middleware/link.ts+++ b/apps/web/lib/middleware/link.ts@@@ -22,8 -23,9 +23,9 @@@ importNextResponse,userAgent,} from "next/server";+import { linkCache } from "../api/links/cache";import { getLinkViaEdge } from "../planetscale";+ import { getDomainViaEdge } from "../planetscale/get-domain-via-edge";-import { RedisLinkProps } from "../types";export default async function LinkMiddleware(req: NextRequest,@@@ -50,7 -52,19 +52,19 @@@key = "_root";}+ // we don't support .php links (too much bot traffic)+ // hence we redirect to the root domain and add `dub-no-track` header to avoid tracking bot traffic+ if (isUnsupportedKey(key)) {+ return NextResponse.redirect(new URL("/?dub-no-track=1", req.url), {+ headers: {+ ...DUB_HEADERS,+ "X-Robots-Tag": "googlebot: noindex",+ },+ status: 302,+ });+ }+- let link = await redis.hget<RedisLinkProps>(domain, key);+ let link = await linkCache.get({ domain, key });if (!link) {const linkData = await getLinkViaEdge(domain, key);