save visit id and fix event id

This commit is contained in:
Viet-Tien Ngoc 2024-08-05 11:52:51 +07:00
parent 04ea0bc68d
commit 971ccb6e41
3 changed files with 8 additions and 3 deletions

View file

@ -136,7 +136,7 @@ async function rawQuery<T = unknown>(
format: 'JSONEachRow',
});
return resultSet.json();
return resultSet.json() as T;
}
async function findUnique(data: any[]) {

View file

@ -11,6 +11,7 @@ export async function saveEventData(data: {
websiteId: string;
eventId: string;
sessionId?: string;
visitId?: string;
urlPath?: string;
eventName?: string;
eventData: DynamicData;
@ -52,12 +53,13 @@ async function clickhouseQuery(data: {
websiteId: string;
eventId: string;
sessionId?: string;
visitId?: string;
urlPath?: string;
eventName?: string;
eventData: DynamicData;
createdAt?: string;
}) {
const { websiteId, sessionId, eventId, urlPath, eventName, eventData, createdAt } = data;
const { websiteId, sessionId, visitId, eventId, urlPath, eventName, eventData, createdAt } = data;
const { getDateFormat, sendMessages } = kafka;
@ -68,6 +70,7 @@ async function clickhouseQuery(data: {
website_id: websiteId,
session_id: sessionId,
event_id: eventId,
visitId: visitId,
url_path: urlPath,
event_name: eventName,
data_key: key,

View file

@ -83,6 +83,7 @@ async function relationalQuery(data: {
await saveEventData({
websiteId,
sessionId,
visitId,
eventId: websiteEventId,
urlPath: urlPath?.substring(0, URL_LENGTH),
eventName: eventName?.substring(0, EVENT_NAME_LENGTH),
@ -143,7 +144,7 @@ async function clickhouseQuery(data: {
website_id: websiteId,
session_id: sessionId,
visit_id: visitId,
event_id: uuid(),
event_id: eventId,
country: country,
subdivision1:
country && subdivision1
@ -170,6 +171,7 @@ async function clickhouseQuery(data: {
await saveEventData({
websiteId,
sessionId,
visitId,
eventId,
urlPath: urlPath?.substring(0, URL_LENGTH),
eventName: eventName?.substring(0, EVENT_NAME_LENGTH),