mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Allow setting visitor IP when registering event through API
This commit is contained in:
parent
784237bfab
commit
ebb29b8207
3 changed files with 5 additions and 2 deletions
|
|
@ -203,6 +203,7 @@ export const UUID_REGEX =
|
|||
/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/;
|
||||
export const HOSTNAME_REGEX =
|
||||
/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/;
|
||||
export const IP_REGEX = /^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\.(?!$)|$)){4}$/;
|
||||
|
||||
export const DESKTOP_SCREEN_WIDTH = 1920;
|
||||
export const LAPTOP_SCREEN_WIDTH = 1024;
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ export async function getLocation(ip, req) {
|
|||
|
||||
export async function getClientInfo(req: NextApiRequestCollect, { screen }) {
|
||||
const userAgent = req.headers['user-agent'];
|
||||
const ip = getIpAddress(req);
|
||||
const ip = req.body.payload.ip || getIpAddress(req);
|
||||
const location = await getLocation(ip, req);
|
||||
const country = location?.country;
|
||||
const subdivision1 = location?.subdivision1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue