Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Fix regions data

Steven Tey64ff69c3605e
diff --git a/apps/web/lib/tinybird/record-click.ts b/apps/web/lib/tinybird/record-click.ts
index bd56bfd2df..97b6b37c66 100644
--- a/apps/web/lib/tinybird/record-click.ts
+++ b/apps/web/lib/tinybird/record-click.ts
@@ -72,6 +72,10 @@ export async function recordClick({
process.env.VERCEL === "1"
? req.headers.get("x-vercel-ip-continent")
: LOCALHOST_GEO_DATA.continent;
+ const region =
+ process.env.VERCEL === "1"
+ ? req.headers.get("x-vercel-ip-country-region")
+ : LOCALHOST_GEO_DATA.region;
const geo =
process.env.VERCEL === "1" ? geolocation(req) : LOCALHOST_GEO_DATA;
const isEuCountry = geo.country && EU_COUNTRY_CODES.includes(geo.country);
@@ -96,9 +100,10 @@ export async function recordClick({
continent: continent || "",
country: geo.country || "Unknown",
city: geo.city || "Unknown",
- region: geo.region || "Unknown",
+ region: region || "Unknown",
latitude: geo.latitude || "Unknown",
longitude: geo.longitude || "Unknown",
+ vercel_region: geo.region || "Unknown",
device: capitalize(ua.device.type) || "Desktop",
device_vendor: ua.device.vendor || "Unknown",
device_model: ua.device.model || "Unknown",