checkpoint

This commit is contained in:
Brian Cao 2022-07-29 22:30:09 -07:00
parent 3e2c098c05
commit 8f934c7e6c
14 changed files with 73 additions and 63 deletions

View file

@ -14,33 +14,36 @@ export async function saveEvent(...args) {
});
}
async function relationalQuery(website_id, { session_id, url, event_type, event_value }) {
async function relationalQuery(website_id, { session_id, url, event_name, event_data }) {
const data = {
website_id,
session_id,
url: url?.substr(0, URL_LENGTH),
event_name: event_name?.substr(0, 50),
};
if (event_data) {
data.eventData = {
create: {
eventData: event_data,
},
};
}
return runQuery(
prisma.event.create({
data: {
website_id,
session_id,
url: url?.substr(0, URL_LENGTH),
event_type: event_type?.substr(0, 50),
event_value: event_value?.substr(0, 50),
},
data,
}),
);
}
async function clickhouseQuery(website_id, { session_uuid, url, event_type, event_value }) {
const params = [
website_id,
session_uuid,
url?.substr(0, URL_LENGTH),
event_type?.substr(0, 50),
event_value?.substr(0, 50),
];
async function clickhouseQuery(website_id, { session_uuid, url, event_name }) {
const params = [website_id, session_uuid, url?.substr(0, URL_LENGTH), event_name?.substr(0, 50)];
return rawQueryClickhouse(
`
insert into umami_dev.event (created_at, website_id, session_uuid, url, event_type, event_value)
values (${getDateFormatClickhouse(new Date())}, $1, $2, $3, $4, $5);`,
insert into umami_dev.event (created_at, website_id, session_uuid, url, event_name)
values (${getDateFormatClickhouse(new Date())}, $1, $2, $3, $4);`,
params,
);
}