mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 20:15:41 +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';
|
} from 'next-basics';
|
||||||
import { COLLECTION_TYPE, HOSTNAME_REGEX, IP_REGEX } from 'lib/constants';
|
import { COLLECTION_TYPE, HOSTNAME_REGEX, IP_REGEX } from 'lib/constants';
|
||||||
import { secret, visitSalt, uuid } from 'lib/crypto';
|
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 { useCors, useSession, useValidate } from 'lib/middleware';
|
||||||
import { CollectionType, YupRequest } from 'lib/types';
|
import { CollectionType, YupRequest } from 'lib/types';
|
||||||
import { saveEvent, saveSessionData } from 'queries';
|
import { saveEvent, saveSessionData } from 'queries';
|
||||||
|
|
@ -137,6 +137,8 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
||||||
urlPath = urlPath.replace(/(.+)\/$/, '$1');
|
urlPath = urlPath.replace(/(.+)\/$/, '$1');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ip = req.body?.payload?.ip || getIpAddress(req);
|
||||||
|
|
||||||
await saveEvent({
|
await saveEvent({
|
||||||
urlPath,
|
urlPath,
|
||||||
urlQuery,
|
urlQuery,
|
||||||
|
|
@ -149,6 +151,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
||||||
...session,
|
...session,
|
||||||
sessionId: session.id,
|
sessionId: session.id,
|
||||||
tag,
|
tag,
|
||||||
|
ip,
|
||||||
});
|
});
|
||||||
} else if (type === COLLECTION_TYPE.identify) {
|
} else if (type === COLLECTION_TYPE.identify) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ export async function saveEvent(args: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
'X-Forwarded-For': args.ip,
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
fingerprint: args.sessionId,
|
fingerprint: args.sessionId,
|
||||||
|
|
@ -53,6 +54,7 @@ export async function saveEvent(args: {
|
||||||
device: args.device,
|
device: args.device,
|
||||||
screen: args.screen,
|
screen: args.screen,
|
||||||
language: args.language,
|
language: args.language,
|
||||||
|
ip: args.ip,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue