The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
improve docs
Steven Tey06b1c092bd09
diff --git a/apps/web/app/(ee)/api/track/open/route.ts b/apps/web/app/(ee)/api/track/open/route.tsindex 73734e3a65..788eb04c79 100644--- a/apps/web/app/(ee)/api/track/open/route.ts+++ b/apps/web/app/(ee)/api/track/open/route.ts@@ -26,20 +26,6 @@ export const POST = withAxiom(async (req) => {await parseRequestBody(req),);- const isBot = detectBot(req);- if (isBot) {- console.log(`Open tracking not recorded ❌ – Bot detected.`, {- isBot,- });- return NextResponse.json(- trackOpenResponseSchema.parse({- clickId: null,- link: null,- }),- { headers: COMMON_CORS_HEADERS },- );- }-const ip = process.env.VERCEL === "1" ? ipAddress(req) : LOCALHOST_IP;const identityHash = await getIdentityHash(req);@@ -121,6 +107,25 @@ export const POST = withAxiom(async (req) => {});}+ const isBot = detectBot(req);+ if (isBot) {+ console.log(`Open tracking not recorded ❌ – Bot detected.`, {+ isBot,+ });+ return NextResponse.json(+ trackOpenResponseSchema.parse({+ clickId: null,+ link: {+ id: cachedLink.id,+ domain,+ key,+ url: cachedLink.url,+ },+ }),+ { headers: COMMON_CORS_HEADERS },+ );+ }+// if there's no cached clickId, track the click eventif (!cachedClickId) {await recordClick({diff --git a/apps/web/lib/zod/schemas/opens.ts b/apps/web/lib/zod/schemas/opens.tsindex 8b6765aa6b..973689af3f 100644--- a/apps/web/lib/zod/schemas/opens.ts+++ b/apps/web/lib/zod/schemas/opens.ts@@ -30,7 +30,7 @@ export const trackOpenResponseSchema = z.object({.string().nullable().describe(- "The click ID of the associated open event (or the prior click that led the user to the app store for probabilistic tracking). This will be `null` if the open event was not associated with a link (e.g. a direct download from the app store). Learn more: https://d.to/ddl",+ "The click ID of the associated open event (or the prior click that led the user to the app store for probabilistic tracking). This will be `null` if the open event was not associated with a deep link (e.g. a direct download from the app store), or if the open event was performed by a bot (no click recorded). Learn more: https://d.to/ddl",),link: z.object({