mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
add redis placeholder
This commit is contained in:
parent
f1e0814f4b
commit
10cc6616c5
2 changed files with 12 additions and 40 deletions
|
|
@ -1,6 +1,8 @@
|
|||
import { getWebsiteByUuid, getSessionByUuid, createSession } from 'queries';
|
||||
import { getJsonBody, getClientInfo } from 'lib/request';
|
||||
import { uuid, isValidUuid, parseToken } from 'lib/crypto';
|
||||
import { runAnalyticsQuery } from 'lib/db';
|
||||
import { RELATIONAL, CLICKHOUSE } from 'lib/constants';
|
||||
|
||||
export async function getSession(req) {
|
||||
const { payload } = getJsonBody(req);
|
||||
|
|
@ -9,7 +11,6 @@ export async function getSession(req) {
|
|||
throw new Error('Invalid request');
|
||||
}
|
||||
|
||||
const { website: website_uuid, hostname, screen, language } = payload;
|
||||
const cache = req.headers['x-umami-cache'];
|
||||
|
||||
if (cache) {
|
||||
|
|
@ -20,24 +21,30 @@ export async function getSession(req) {
|
|||
}
|
||||
}
|
||||
|
||||
const { website: website_uuid, hostname, screen, language } = payload;
|
||||
|
||||
if (!isValidUuid(website_uuid)) {
|
||||
throw new Error(`Invalid website: ${website_uuid}`);
|
||||
}
|
||||
|
||||
const { userAgent, browser, os, ip, country, device } = await getClientInfo(req, payload);
|
||||
|
||||
const website = await getWebsiteByUuid(website_uuid);
|
||||
|
||||
if (!website) {
|
||||
throw new Error(`Website not found: ${website_uuid}`);
|
||||
}
|
||||
|
||||
const { userAgent, browser, os, ip, country, device } = await getClientInfo(req, payload);
|
||||
|
||||
const { website_id } = website;
|
||||
const session_uuid = uuid(website_id, hostname, ip, userAgent);
|
||||
|
||||
let session = await getSessionByUuid(session_uuid);
|
||||
// logic placeholder for redis
|
||||
runAnalyticsQuery({
|
||||
[RELATIONAL]: () => {},
|
||||
[CLICKHOUSE]: () => {},
|
||||
});
|
||||
|
||||
console.log('session here!: ', session);
|
||||
let session = await getSessionByUuid(session_uuid);
|
||||
|
||||
if (!session) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue