mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 23:27:12 +01:00
Added session data display.
This commit is contained in:
parent
f32bf0a2e0
commit
b3e6e52473
23 changed files with 239 additions and 34 deletions
41
src/queries/analytics/sessions/getSessionData.ts
Normal file
41
src/queries/analytics/sessions/getSessionData.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import prisma from 'lib/prisma';
|
||||
import clickhouse from 'lib/clickhouse';
|
||||
import { runQuery, PRISMA, CLICKHOUSE } from 'lib/db';
|
||||
|
||||
export async function getSessionData(...args: [websiteId: string, sessionId: string]) {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(...args),
|
||||
[CLICKHOUSE]: () => clickhouseQuery(...args),
|
||||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(websiteId: string, sessionId: string) {
|
||||
return prisma.client.sessionData.findMany({
|
||||
where: {
|
||||
id: sessionId,
|
||||
websiteId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function clickhouseQuery(websiteId: string, sessionId: string) {
|
||||
const { rawQuery } = clickhouse;
|
||||
|
||||
return rawQuery(
|
||||
`
|
||||
select
|
||||
website_id as websiteId,
|
||||
session_id as sessionId,
|
||||
data_key as dataKey,
|
||||
data_type as dataType,
|
||||
string_value as stringValue,
|
||||
number_value as numberValue,
|
||||
date_value as dateValue,
|
||||
created_at as createdAt
|
||||
from session_data
|
||||
where website_id = {websiteId:UUID}
|
||||
and session_id = {sessionId:UUID}
|
||||
`,
|
||||
{ websiteId, sessionId },
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue