Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Fixed vercel region issues.
Mike Cao4ea3eec98cc8
diff --git a/lib/detect.ts b/lib/detect.tsindex 01e6c9a6d..868d0a806 100644--- a/lib/detect.ts+++ b/lib/detect.ts@@ -63,10 +63,15 @@ export async function getLocation(ip, req) {}if (req.headers['x-vercel-ip-country']) {+ const country = req.headers['x-vercel-ip-country'];+ const region = req.headers['x-vercel-ip-country-region'];+ const city = req.headers['x-vercel-ip-city'];+return {- country: req.headers['x-vercel-ip-country'],- subdivision1: req.headers['x-vercel-ip-country-region'],- city: decodeURIComponent(req.headers['x-vercel-ip-city']),+ country,+ // Vercel documentation says they return only region, but that is not always the case+ subdivision1: region.includes('-') ? region : `${country}-${region}`,+ city: decodeURIComponent(city),};}