The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fetch tags in link.clicked webhook
Steven Tey8b3953c85b4d
diff --git a/apps/web/lib/tinybird/record-click.ts b/apps/web/lib/tinybird/record-click.tsindex 0810b18013..10a856cded 100644--- a/apps/web/lib/tinybird/record-click.ts+++ b/apps/web/lib/tinybird/record-click.ts@@ -213,9 +213,30 @@ async function sendLinkClickWebhooks({return;}- const link = await conn- .execute("SELECT * FROM Link WHERE id = ?", [linkId])- .then((res) => res.rows[0]);+ const [link, tagsResult] = await Promise.all([+ conn+ .execute(`SELECT * FROM Link WHERE id = ?`, [linkId])+ .then((res) => res.rows[0]),+ conn+ .execute(+ `+ SELECT t.id, t.name, t.color+ FROM LinkTag lt+ JOIN Tag t ON lt.tagId = t.id+ WHERE lt.linkId = ?+ ORDER BY lt.createdAt ASC+ `,+ [linkId],+ )+ .then((res) => ({+ tags: res.rows.map((tag) => ({ tag })),+ })),+ ]);++ const finalLink = {+ ...link,+ ...tagsResult,+ };await sendWebhooks({trigger: "link.clicked",@@ -223,7 +244,7 @@ async function sendLinkClickWebhooks({// @ts-ignore – bot & qr should be booleandata: transformClickEventData({...clickData,- link: transformLink(link as ExpandedLink),+ link: transformLink(finalLink as ExpandedLink),}),});}