Skip to content

armgit / umami

Public Imported from GitHub
0

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.

add support for CloudFront headers in getLocation

Michael Wallner8df72c55e564
diff --git a/src/lib/detect.ts b/src/lib/detect.ts
index 2e6a067dd..526ea2dfc 100644
--- a/src/lib/detect.ts
+++ b/src/lib/detect.ts
@@ -119,6 +119,19 @@ export async function getLocation(ip: string = '', headers: Headers, hasPayloadI
city,
};
}
+
+ // CloudFront headers
+ if (headers.get('cloudfront-viewer-country')) {
+ const country = decodeHeader(headers.get('cloudfront-viewer-country'));
+ const region = decodeHeader(headers.get('cloudfront-viewer-country-region'));
+ const city = decodeHeader(headers.get('cloudfront-viewer-city'));
+
+ return {
+ country,
+ region: getRegionCode(country, region),
+ city,
+ };
+ }
}
// Database lookup