slowly adding into dashboard + accurate tracking
parent
ae8d458126
commit
5d14effbd9
|
@ -82,6 +82,14 @@ export default function WebsiteDetails({ websiteId }) {
|
|||
label: <FormattedMessage id="metrics.countries" defaultMessage="Countries" />,
|
||||
value: resolve({ view: 'country' }),
|
||||
},
|
||||
{
|
||||
label: <FormattedMessage id="metrics.region" defaultMessage="Region" />,
|
||||
value: resolve({ view: 'region' }),
|
||||
},
|
||||
{
|
||||
label: <FormattedMessage id="metrics.city" defaultMessage="City" />,
|
||||
value: resolve({ view: 'city' }),
|
||||
},
|
||||
{
|
||||
label: <FormattedMessage id="metrics.events" defaultMessage="Events" />,
|
||||
value: resolve({ view: 'event' }),
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue