slowly adding into dashboard + accurate tracking

This commit is contained in:
Nisarg 2021-10-11 11:40:54 -07:00
parent ae8d458126
commit 5d14effbd9
2 changed files with 14 additions and 5 deletions

View file

@ -1,7 +1,8 @@
import requestIp from 'request-ip';
import { browserName, detectOS } from 'detect-browser';
import isLocalhost from 'is-localhost-ip';
import geoip from 'fast-geoip';
import { WebServiceClient } from '@maxmind/geoip2-node';
const client = new WebServiceClient(process.env.MAXMIND_ID, process.env.MAXMIND_KEY);
import {
DESKTOP_OS,
@ -59,12 +60,12 @@ export async function getLocation(req, ip) {
return;
}
const result = await geoip.lookup(ip);
const result = await client.city(ip);
return {
country: result?.country,
region: result?.region,
city: result?.city,
country: result?.country.isoCode,
region: result?.subdivisions?.[0]?.names?.en,
city: result?.city?.names?.en,
};
}