mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Roll back session insert.
This commit is contained in:
parent
f794b5674b
commit
d43ab3e559
@ -1,12 +1,27 @@
|
|||||||
import { secret, uuid, isUuid } from 'lib/crypto';
|
import { isUuid, secret, uuid } from 'lib/crypto';
|
||||||
import { getClientInfo, getJsonBody } from 'lib/detect';
|
import { getClientInfo, getJsonBody } from 'lib/detect';
|
||||||
import { parseToken } from 'next-basics';
|
import { parseToken } from 'next-basics';
|
||||||
import { CollectRequestBody, NextApiRequestCollect } from 'pages/api/send';
|
import { CollectRequestBody, NextApiRequestCollect } from 'pages/api/send';
|
||||||
import { createSession } from 'queries';
|
import { createSession } from 'queries';
|
||||||
import cache from './cache';
|
import cache from './cache';
|
||||||
|
import clickhouse from './clickhouse';
|
||||||
import { loadSession, loadWebsite } from './load';
|
import { loadSession, loadWebsite } from './load';
|
||||||
|
|
||||||
export async function findSession(req: NextApiRequestCollect) {
|
export async function findSession(req: NextApiRequestCollect): Promise<{
|
||||||
|
id: any;
|
||||||
|
websiteId: string;
|
||||||
|
hostname: string;
|
||||||
|
browser: string;
|
||||||
|
os: any;
|
||||||
|
device: string;
|
||||||
|
screen: string;
|
||||||
|
language: string;
|
||||||
|
country: any;
|
||||||
|
subdivision1: any;
|
||||||
|
subdivision2: any;
|
||||||
|
city: any;
|
||||||
|
ownerId: string;
|
||||||
|
}> {
|
||||||
const { payload } = getJsonBody<CollectRequestBody>(req);
|
const { payload } = getJsonBody<CollectRequestBody>(req);
|
||||||
|
|
||||||
if (!payload) {
|
if (!payload) {
|
||||||
@ -53,6 +68,25 @@ export async function findSession(req: NextApiRequestCollect) {
|
|||||||
|
|
||||||
const sessionId = uuid(websiteId, hostname, ip, userAgent);
|
const sessionId = uuid(websiteId, hostname, ip, userAgent);
|
||||||
|
|
||||||
|
// Clickhouse does not require session lookup
|
||||||
|
if (clickhouse.enabled) {
|
||||||
|
return {
|
||||||
|
id: sessionId,
|
||||||
|
websiteId,
|
||||||
|
hostname,
|
||||||
|
browser,
|
||||||
|
os: os as any,
|
||||||
|
device,
|
||||||
|
screen,
|
||||||
|
language,
|
||||||
|
country,
|
||||||
|
subdivision1,
|
||||||
|
subdivision2,
|
||||||
|
city,
|
||||||
|
ownerId: website.userId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Find session
|
// Find session
|
||||||
let session = await loadSession(sessionId);
|
let session = await loadSession(sessionId);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user