mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 22:57:12 +01:00
Updated session event data save.
This commit is contained in:
parent
0a4eb05196
commit
b79ed9dee6
3 changed files with 97 additions and 29 deletions
|
|
@ -7,7 +7,7 @@ import kafka from 'lib/kafka';
|
|||
import prisma from 'lib/prisma';
|
||||
import { DynamicData } from 'lib/types';
|
||||
|
||||
export async function saveEventData(args: {
|
||||
export async function saveEventData(data: {
|
||||
websiteId: string;
|
||||
eventId: string;
|
||||
sessionId?: string;
|
||||
|
|
@ -17,8 +17,8 @@ export async function saveEventData(args: {
|
|||
createdAt?: string;
|
||||
}) {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(args),
|
||||
[CLICKHOUSE]: () => clickhouseQuery(args),
|
||||
[PRISMA]: () => relationalQuery(data),
|
||||
[CLICKHOUSE]: () => clickhouseQuery(data),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -63,19 +63,21 @@ async function clickhouseQuery(data: {
|
|||
|
||||
const jsonKeys = flattenJSON(eventData);
|
||||
|
||||
const messages = jsonKeys.map(a => ({
|
||||
website_id: websiteId,
|
||||
session_id: sessionId,
|
||||
event_id: eventId,
|
||||
url_path: urlPath,
|
||||
event_name: eventName,
|
||||
event_key: a.key,
|
||||
string_value: getStringValue(a.value, a.dataType),
|
||||
number_value: a.dataType === DATA_TYPE.number ? a.value : null,
|
||||
date_value: a.dataType === DATA_TYPE.date ? getDateFormat(a.value) : null,
|
||||
data_type: a.dataType,
|
||||
created_at: createdAt,
|
||||
}));
|
||||
const messages = jsonKeys.map(({ key, value, dataType }) => {
|
||||
return {
|
||||
website_id: websiteId,
|
||||
session_id: sessionId,
|
||||
event_id: eventId,
|
||||
url_path: urlPath,
|
||||
event_name: eventName,
|
||||
data_key: key,
|
||||
data_type: dataType,
|
||||
string_value: getStringValue(value, dataType),
|
||||
number_value: dataType === DATA_TYPE.number ? value : null,
|
||||
date_value: dataType === DATA_TYPE.date ? getDateFormat(value) : null,
|
||||
created_at: createdAt,
|
||||
};
|
||||
});
|
||||
|
||||
await sendMessages(messages, 'event_data');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue