mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
add redis placeholder
This commit is contained in:
parent
f1e0814f4b
commit
10cc6616c5
@ -1,6 +1,8 @@
|
|||||||
import { getWebsiteByUuid, getSessionByUuid, createSession } from 'queries';
|
import { getWebsiteByUuid, getSessionByUuid, createSession } from 'queries';
|
||||||
import { getJsonBody, getClientInfo } from 'lib/request';
|
import { getJsonBody, getClientInfo } from 'lib/request';
|
||||||
import { uuid, isValidUuid, parseToken } from 'lib/crypto';
|
import { uuid, isValidUuid, parseToken } from 'lib/crypto';
|
||||||
|
import { runAnalyticsQuery } from 'lib/db';
|
||||||
|
import { RELATIONAL, CLICKHOUSE } from 'lib/constants';
|
||||||
|
|
||||||
export async function getSession(req) {
|
export async function getSession(req) {
|
||||||
const { payload } = getJsonBody(req);
|
const { payload } = getJsonBody(req);
|
||||||
@ -9,7 +11,6 @@ export async function getSession(req) {
|
|||||||
throw new Error('Invalid request');
|
throw new Error('Invalid request');
|
||||||
}
|
}
|
||||||
|
|
||||||
const { website: website_uuid, hostname, screen, language } = payload;
|
|
||||||
const cache = req.headers['x-umami-cache'];
|
const cache = req.headers['x-umami-cache'];
|
||||||
|
|
||||||
if (cache) {
|
if (cache) {
|
||||||
@ -20,24 +21,30 @@ export async function getSession(req) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { website: website_uuid, hostname, screen, language } = payload;
|
||||||
|
|
||||||
if (!isValidUuid(website_uuid)) {
|
if (!isValidUuid(website_uuid)) {
|
||||||
throw new Error(`Invalid website: ${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);
|
const website = await getWebsiteByUuid(website_uuid);
|
||||||
|
|
||||||
if (!website) {
|
if (!website) {
|
||||||
throw new Error(`Website not found: ${website_uuid}`);
|
throw new Error(`Website not found: ${website_uuid}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { userAgent, browser, os, ip, country, device } = await getClientInfo(req, payload);
|
||||||
|
|
||||||
const { website_id } = website;
|
const { website_id } = website;
|
||||||
const session_uuid = uuid(website_id, hostname, ip, userAgent);
|
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) {
|
if (!session) {
|
||||||
try {
|
try {
|
||||||
|
@ -93,38 +93,3 @@ export default async (req, res) => {
|
|||||||
|
|
||||||
return send(res, token);
|
return send(res, token);
|
||||||
};
|
};
|
||||||
|
|
||||||
// async function relational(req, res) {
|
|
||||||
// await useSession(req, res);
|
|
||||||
|
|
||||||
// const {
|
|
||||||
// session: { website_id, session_id, session_uuid },
|
|
||||||
// } = req;
|
|
||||||
|
|
||||||
// const { type, payload } = getJsonBody(req);
|
|
||||||
|
|
||||||
// let { url, referrer, event_name, event_data } = payload;
|
|
||||||
|
|
||||||
// if (process.env.REMOVE_TRAILING_SLASH) {
|
|
||||||
// url = removeTrailingSlash(url);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const event_uuid = uuid();
|
|
||||||
|
|
||||||
// if (type === 'pageview') {
|
|
||||||
// await savePageView(website_id, { session_id, session_uuid, url, referrer });
|
|
||||||
// } else if (type === 'event') {
|
|
||||||
// await saveEvent(website_id, {
|
|
||||||
// event_uuid,
|
|
||||||
// session_id,
|
|
||||||
// session_uuid,
|
|
||||||
// url,
|
|
||||||
// event_name,
|
|
||||||
// event_data,
|
|
||||||
// });
|
|
||||||
// } else {
|
|
||||||
// return badRequest(res);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// function clickhouse() {}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user