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.

Use new geo folder.

Mike Cao05933ff1d2ce
diff --git a/.gitignore b/.gitignore
index 566dc61b5..84ac5e600 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,8 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
-/node_modules
-/.pnp
+node_modules
+.pnp
.pnp.js
# testing
@@ -16,14 +16,14 @@
# production
/build
/public/script.js
-/public/geo
+/geo
# misc
.DS_Store
.idea
*.iml
*.log
-/.vscode/
+.vscode
# debug
npm-debug.log*
diff --git a/lib/detect.js b/lib/detect.js
index d332170d4..083584d9a 100644
--- a/lib/detect.js
+++ b/lib/detect.js
@@ -63,7 +63,9 @@ export async function getLocation(ip) {
// Database lookup
if (!lookup) {
- lookup = await maxmind.open(path.resolve('node_modules/.geo/GeoLite2-Country.mmdb'));
+ const dir = path.join(process.cwd(), 'geo');
+
+ lookup = await maxmind.open(path.resolve(dir, 'GeoLite2-City.mmdb'));
}
const result = lookup.get(ip);
diff --git a/scripts/build-geo.js b/scripts/build-geo.js
index f4c5f62de..8cb5a971c 100644
--- a/scripts/build-geo.js
+++ b/scripts/build-geo.js
@@ -7,16 +7,17 @@ const https = require('https');
const zlib = require('zlib');
const tar = require('tar');
-let url =
- 'https://raw.githubusercontent.com/GitSquared/node-geolite2-redist/master/redist/GeoLite2-Country.tar.gz';
+const db = 'GeoLite2-City';
+
+let url = `https://raw.githubusercontent.com/GitSquared/node-geolite2-redist/master/redist/${db}.tar.gz`;
if (process.env.MAXMIND_LICENSE_KEY) {
url =
`https://download.maxmind.com/app/geoip_download` +
- `?edition_id=GeoLite2-City&license_key=${process.env.MAXMIND_LICENSE_KEY}&suffix=tar.gz`;
+ `?edition_id=${db}&license_key=${process.env.MAXMIND_LICENSE_KEY}&suffix=tar.gz`;
}
-const dest = path.resolve(__dirname, '../node_modules/.geo');
+const dest = path.resolve(__dirname, '../geo');
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);