mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 03:55:37 +01:00
ip
This commit is contained in:
parent
9245fb5d80
commit
2ceeac20e0
2 changed files with 6 additions and 1 deletions
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from 'next-basics';
|
||||
import { COLLECTION_TYPE, HOSTNAME_REGEX, IP_REGEX } from 'lib/constants';
|
||||
import { secret, visitSalt, uuid } from 'lib/crypto';
|
||||
import { hasBlockedIp } from 'lib/detect';
|
||||
import { getIpAddress, hasBlockedIp } from 'lib/detect';
|
||||
import { useCors, useSession, useValidate } from 'lib/middleware';
|
||||
import { CollectionType, YupRequest } from 'lib/types';
|
||||
import { saveEvent, saveSessionData } from 'queries';
|
||||
|
|
@ -137,6 +137,8 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||
urlPath = urlPath.replace(/(.+)\/$/, '$1');
|
||||
}
|
||||
|
||||
const ip = req.body?.payload?.ip || getIpAddress(req);
|
||||
|
||||
await saveEvent({
|
||||
urlPath,
|
||||
urlQuery,
|
||||
|
|
@ -149,6 +151,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||
...session,
|
||||
sessionId: session.id,
|
||||
tag,
|
||||
ip,
|
||||
});
|
||||
} else if (type === COLLECTION_TYPE.identify) {
|
||||
if (!data) {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ export async function saveEvent(args: {
|
|||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Forwarded-For': args.ip,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
fingerprint: args.sessionId,
|
||||
|
|
@ -53,6 +54,7 @@ export async function saveEvent(args: {
|
|||
device: args.device,
|
||||
screen: args.screen,
|
||||
language: args.language,
|
||||
ip: args.ip,
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue