The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Fixed TS errors & primaryDomain bug
Steven Teyd366d068ce41
diff --git a/components/app/modals/add-edit-domain-modal.tsx b/components/app/modals/add-edit-domain-modal.tsxindex 44b51ee200..9238fb2a6b 100644--- a/components/app/modals/add-edit-domain-modal.tsx+++ b/components/app/modals/add-edit-domain-modal.tsx@@ -310,6 +310,7 @@ function AddEditDomainModal({<Switchfn={() => setData((prev) => ({ ...prev, primary: !primary }))}checked={primary}+ disabled={props && domains.length === 1}/></div>diff --git a/lib/tinybird.ts b/lib/tinybird.tsindex ae67da1619..07cc5af03c 100644--- a/lib/tinybird.ts+++ b/lib/tinybird.ts@@ -25,11 +25,11 @@ export async function recordClick(timestamp: new Date(Date.now()).toISOString(),domain,key: key || "_root",- country: geo.country || "Unknown",- city: geo.city || "Unknown",- region: geo.region || "Unknown",- latitude: geo.latitude || "Unknown",- longitude: geo.longitude || "Unknown",+ country: geo?.country || "Unknown",+ city: geo?.city || "Unknown",+ region: geo?.region || "Unknown",+ latitude: geo?.latitude || "Unknown",+ longitude: geo?.longitude || "Unknown",ua: ua.ua || "Unknown",browser: ua.browser.name || "Unknown",browser_version: ua.browser.version || "Unknown",@@ -42,7 +42,7 @@ export async function recordClick(device_model: ua.device.model || "Unknown",cpu_architecture: ua.cpu?.architecture || "Unknown",bot: ua.isBot,- referer: getDomainWithoutWWW(referer) || "(direct)",+ referer: referer ? getDomainWithoutWWW(referer) : "(direct)",referer_url: referer || "(direct)",}),headers: {@@ -53,16 +53,18 @@ export async function recordClick(// increment the click count for the link if key is specified (not root click)// also increment the usage count for the project, and then we have a cron that will reset it at the start of new billing cycle// TODO: might wanna include root clicks in the usage count as well?- ...(key && [- conn.execute(- "UPDATE Link SET clicks = clicks + 1 WHERE domain = ? AND `key` = ?",- [domain, key],- ),- conn.execute(- "UPDATE Project p JOIN Domain d ON p.id = d.projectId SET p.usage = p.usage + 1 WHERE d.slug = ?",- [domain],- ),- ]),+ ...(key && conn+ ? [+ conn.execute(+ "UPDATE Link SET clicks = clicks + 1 WHERE domain = ? AND `key` = ?",+ [domain, key],+ ),+ conn.execute(+ "UPDATE Project p JOIN Domain d ON p.id = d.projectId SET p.usage = p.usage + 1 WHERE d.slug = ?",+ [domain],+ ),+ ]+ : []),]);}