Updated event handling.

This commit is contained in:
Mike Cao 2020-07-19 02:23:15 -07:00
parent 9f3acd1583
commit 9cb08956c0
7 changed files with 19 additions and 41 deletions

View file

@ -5,6 +5,7 @@ const prisma = new PrismaClient();
export async function runQuery(query) {
return query
.catch(e => {
console.error(e);
throw e;
})
.finally(async () => {
@ -69,9 +70,9 @@ export async function savePageView(website_id, session_id, url, referrer) {
);
}
export async function saveEvent(website_id, session_id, url, eventType, eventValue) {
export async function saveEvent(website_id, session_id, url, event_type, event_value) {
return runQuery(
prisma.pageview.create({
prisma.event.create({
data: {
website: {
connect: {
@ -84,8 +85,8 @@ export async function saveEvent(website_id, session_id, url, eventType, eventVal
},
},
url,
eventType,
eventValue,
event_type,
event_value,
},
}),
);