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
Updated maxmind lookup.
Mike Cao88227b6b290c
diff --git a/package.json b/package.jsonindex 3693ecf42..cc1f591bf 100644--- a/package.json+++ b/package.json@@ -100,7 +100,7 @@"isbot": "^5.1.16","jsonwebtoken": "^9.0.2","kafkajs": "^2.1.0",- "maxmind": "^4.3.6",+ "maxmind": "^4.3.24","md5": "^2.3.0","next": "15.0.4","node-fetch": "^3.2.8",diff --git a/src/lib/detect.ts b/src/lib/detect.tsindex 9f1e04b74..cd91069e4 100644--- a/src/lib/detect.ts+++ b/src/lib/detect.ts@@ -12,7 +12,7 @@ import {IP_ADDRESS_HEADERS,} from './constants';-let lookup;+const MAXMIND = 'maxmind';export function getIpAddress(headers: Headers) {const customHeader = process.env.CLIENT_IP_HEADER;@@ -121,13 +121,13 @@ export async function getLocation(ip: string = '', headers: Headers) {}// Database lookup- if (!lookup) {+ if (!global[MAXMIND]) {const dir = path.join(process.cwd(), 'geo');- lookup = await maxmind.open(path.resolve(dir, 'GeoLite2-City.mmdb'));+ global[MAXMIND] = await maxmind.open(path.resolve(dir, 'GeoLite2-City.mmdb'));}- const result = lookup.get(ip);+ const result = global[MAXMIND].get(ip);if (result) {const country = result.country?.iso_code ?? result?.registered_country?.iso_code;diff --git a/yarn.lock b/yarn.lockindex 225298a97..32b7d338f 100644--- a/yarn.lock+++ b/yarn.lock@@ -7822,10 +7822,10 @@ mathml-tag-names@^2.1.3:resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3"integrity sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg==-maxmind@^4.3.6:- version "4.3.23"- resolved "https://registry.yarnpkg.com/maxmind/-/maxmind-4.3.23.tgz#e6920149c6104cdf0272d378ce3adf9837dc98f5"- integrity sha512-AMm4Eem0J0Y1EQJRVSdi2xevw5bJgUDd+lHyQwu0PvGUtK/4uOb8/uidmsrRZ/ST90UfF48H4ShAeFFWKvZ7bw==+maxmind@^4.3.24:+ version "4.3.24"+ resolved "https://registry.yarnpkg.com/maxmind/-/maxmind-4.3.24.tgz#c67a4278777210c857434fa8e82bdd6774e5e661"+ integrity sha512-dexrLcjfS2xDGOvdV8XcfQYmyQVpGidMwEG2ld19lXlsB+i+lXRWPzQi81HfwRXR4hxzFr5gT0oAIFyqAAb/Ww==dependencies:mmdb-lib "2.1.1"tiny-lru "11.2.11"