mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Fixed visit logic.
This commit is contained in:
parent
aaf8b1935f
commit
edd72cd6e3
1 changed files with 5 additions and 3 deletions
|
|
@ -118,12 +118,14 @@ export async function POST(request: Request) {
|
|||
}
|
||||
|
||||
// Visit info
|
||||
const now = Math.floor(new Date().getTime() / 1000);
|
||||
let visitId = cache?.visitId || uuid(sessionId, visitSalt());
|
||||
const iat = Math.floor(new Date().getTime() / 1000);
|
||||
let iat = cache?.iat || now;
|
||||
|
||||
// Expire visit after 30 minutes
|
||||
if (cache?.iat && iat - cache?.iat > 1800) {
|
||||
if (now - iat > 1800) {
|
||||
visitId = uuid(sessionId, visitSalt());
|
||||
iat = now;
|
||||
}
|
||||
|
||||
if (type === COLLECTION_TYPE.event) {
|
||||
|
|
@ -187,5 +189,5 @@ export async function POST(request: Request) {
|
|||
|
||||
const token = createToken({ websiteId, sessionId, visitId, iat }, secret());
|
||||
|
||||
return json(token);
|
||||
return json({ cache: token });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue