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" />,
|
label: <FormattedMessage id="metrics.countries" defaultMessage="Countries" />,
|
||||||
value: resolve({ view: 'country' }),
|
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" />,
|
label: <FormattedMessage id="metrics.events" defaultMessage="Events" />,
|
||||||
value: resolve({ view: 'event' }),
|
value: resolve({ view: 'event' }),
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import requestIp from 'request-ip';
|
import requestIp from 'request-ip';
|
||||||
import { browserName, detectOS } from 'detect-browser';
|
import { browserName, detectOS } from 'detect-browser';
|
||||||
import isLocalhost from 'is-localhost-ip';
|
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 {
|
import {
|
||||||
DESKTOP_OS,
|
DESKTOP_OS,
|
||||||
|
@ -59,12 +60,12 @@ export async function getLocation(req, ip) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await geoip.lookup(ip);
|
const result = await client.city(ip);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
country: result?.country,
|
country: result?.country.isoCode,
|
||||||
region: result?.region,
|
region: result?.subdivisions?.[0]?.names?.en,
|
||||||
city: result?.city,
|
city: result?.city?.names?.en,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue