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.

Merge branch 'master' into jajaja

Mike Cao5ed1d710cbbb
diff --cc src/lib/detect.ts
index cb7674a46,ae750469b..f2c9d9fbe
--- a/src/lib/detect.ts
+++ b/src/lib/detect.ts
@@@ -122,15 -121,15 +122,15 @@@ export async function getLocation(ip: s
}
// Database lookup
- if (!global[MAXMIND]) {
+ if (!globalThis[MAXMIND]) {
const dir = path.join(process.cwd(), 'geo');
- global[MAXMIND] = await maxmind.open(path.resolve(dir, 'GeoLite2-City.mmdb'));
+ globalThis[MAXMIND] = await maxmind.open(
+ process.env.GEOLITE_DB_PATH || path.resolve(dir, 'GeoLite2-City.mmdb'),
+ );
}
- const result = globalThis[MAXMIND].get(ip);
- // When the client IP is extracted from headers, sometimes the value includes a port
- const cleanIp = ip?.split(':')[0];
- const result = global[MAXMIND].get(cleanIp);
++ const result = globalThis[MAXMIND].get(ip?.split(':')[0]);
if (result) {
const country = result.country?.iso_code ?? result?.registered_country?.iso_code;