Finish event_data relational.

This commit is contained in:
Brian Cao 2023-03-23 12:28:57 -07:00
parent f1f602b42d
commit 2343949d3e
12 changed files with 133 additions and 122 deletions

View file

@ -40,11 +40,13 @@ async function relationalQuery(data: {
eventName?: string;
eventData?: any;
}) {
const { websiteId, id: sessionId, urlPath, urlQuery, eventName, pageTitle } = data;
const { websiteId, id: sessionId, urlPath, urlQuery, eventName, eventData, pageTitle } = data;
const website = await cache.fetchWebsite(websiteId);
const websiteEventId = uuid();
return prisma.client.websiteEvent.create({
const websiteEvent = prisma.client.websiteEvent.create({
data: {
id: uuid(),
id: websiteEventId,
websiteId,
sessionId,
urlPath: urlPath?.substring(0, URL_LENGTH),
@ -54,6 +56,20 @@ async function relationalQuery(data: {
eventName: eventName?.substring(0, EVENT_NAME_LENGTH),
},
});
if (eventData) {
await saveEventData({
websiteId,
sessionId,
eventId: websiteEventId,
revId: website?.revId,
urlPath: urlPath?.substring(0, URL_LENGTH),
eventName: eventName?.substring(0, EVENT_NAME_LENGTH),
eventData,
});
}
return websiteEvent;
}
async function clickhouseQuery(data: {