mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 14:47:14 +01:00
Feat/um 305 unique session ch (#2065)
* Add session_data / session redis to CH. * Add mysql migration.
This commit is contained in:
parent
1038a54fe4
commit
b484286523
23 changed files with 405 additions and 300 deletions
|
|
@ -1,11 +1,11 @@
|
|||
import { Prisma } from '@prisma/client';
|
||||
import { EVENT_DATA_TYPE } from 'lib/constants';
|
||||
import { DYNAMIC_DATA_TYPE } from 'lib/constants';
|
||||
import { uuid } from 'lib/crypto';
|
||||
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
|
||||
import { flattenJSON } from 'lib/eventData';
|
||||
import { flattenJSON } from 'lib/dynamicData';
|
||||
import kafka from 'lib/kafka';
|
||||
import prisma from 'lib/prisma';
|
||||
import { EventData } from 'lib/types';
|
||||
import { DynamicData } from 'lib/types';
|
||||
|
||||
export async function saveEventData(args: {
|
||||
websiteId: string;
|
||||
|
|
@ -13,7 +13,7 @@ export async function saveEventData(args: {
|
|||
sessionId?: string;
|
||||
urlPath?: string;
|
||||
eventName?: string;
|
||||
eventData: EventData;
|
||||
eventData: DynamicData;
|
||||
createdAt?: string;
|
||||
}) {
|
||||
return runQuery({
|
||||
|
|
@ -25,7 +25,7 @@ export async function saveEventData(args: {
|
|||
async function relationalQuery(data: {
|
||||
websiteId: string;
|
||||
eventId: string;
|
||||
eventData: EventData;
|
||||
eventData: DynamicData;
|
||||
}): Promise<Prisma.BatchPayload> {
|
||||
const { websiteId, eventId, eventData } = data;
|
||||
|
||||
|
|
@ -36,16 +36,16 @@ async function relationalQuery(data: {
|
|||
id: uuid(),
|
||||
websiteEventId: eventId,
|
||||
websiteId,
|
||||
eventKey: a.key,
|
||||
eventStringValue:
|
||||
a.eventDataType === EVENT_DATA_TYPE.string ||
|
||||
a.eventDataType === EVENT_DATA_TYPE.boolean ||
|
||||
a.eventDataType === EVENT_DATA_TYPE.array
|
||||
key: a.key,
|
||||
stringValue:
|
||||
a.dynamicDataType === DYNAMIC_DATA_TYPE.string ||
|
||||
a.dynamicDataType === DYNAMIC_DATA_TYPE.boolean ||
|
||||
a.dynamicDataType === DYNAMIC_DATA_TYPE.array
|
||||
? a.value
|
||||
: null,
|
||||
eventNumericValue: a.eventDataType === EVENT_DATA_TYPE.number ? a.value : null,
|
||||
eventDateValue: a.eventDataType === EVENT_DATA_TYPE.date ? new Date(a.value) : null,
|
||||
eventDataType: a.eventDataType,
|
||||
numericValue: a.dynamicDataType === DYNAMIC_DATA_TYPE.number ? a.value : null,
|
||||
dateValue: a.dynamicDataType === DYNAMIC_DATA_TYPE.date ? new Date(a.value) : null,
|
||||
dataType: a.dynamicDataType,
|
||||
}));
|
||||
|
||||
return prisma.client.eventData.createMany({
|
||||
|
|
@ -59,7 +59,7 @@ async function clickhouseQuery(data: {
|
|||
sessionId?: string;
|
||||
urlPath?: string;
|
||||
eventName?: string;
|
||||
eventData: EventData;
|
||||
eventData: DynamicData;
|
||||
createdAt?: string;
|
||||
}) {
|
||||
const { websiteId, sessionId, eventId, urlPath, eventName, eventData, createdAt } = data;
|
||||
|
|
@ -75,15 +75,15 @@ async function clickhouseQuery(data: {
|
|||
url_path: urlPath,
|
||||
event_name: eventName,
|
||||
event_key: a.key,
|
||||
event_string_value:
|
||||
a.eventDataType === EVENT_DATA_TYPE.string ||
|
||||
a.eventDataType === EVENT_DATA_TYPE.boolean ||
|
||||
a.eventDataType === EVENT_DATA_TYPE.array
|
||||
string_value:
|
||||
a.dynamicDataType === DYNAMIC_DATA_TYPE.string ||
|
||||
a.dynamicDataType === DYNAMIC_DATA_TYPE.boolean ||
|
||||
a.dynamicDataType === DYNAMIC_DATA_TYPE.array
|
||||
? a.value
|
||||
: null,
|
||||
event_numeric_value: a.eventDataType === EVENT_DATA_TYPE.number ? a.value : null,
|
||||
event_date_value: a.eventDataType === EVENT_DATA_TYPE.date ? getDateFormat(a.value) : null,
|
||||
event_data_type: a.eventDataType,
|
||||
numeric_value: a.dynamicDataType === DYNAMIC_DATA_TYPE.number ? a.value : null,
|
||||
date_value: a.dynamicDataType === DYNAMIC_DATA_TYPE.date ? getDateFormat(a.value) : null,
|
||||
data_type: a.dynamicDataType,
|
||||
created_at: createdAt,
|
||||
}));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue