From 65ebb26a700746d17a61d9cedb994b1fc651cdc1 Mon Sep 17 00:00:00 2001 From: Brian Cao Date: Sun, 30 Apr 2023 22:55:54 -0700 Subject: [PATCH] Fix boolean event data. --- components/pages/console/TestConsole.js | 2 ++ lib/eventData.ts | 1 + queries/analytics/event/getEvents.ts | 5 ++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/pages/console/TestConsole.js b/components/pages/console/TestConsole.js index 745bf94c..6c14c2c1 100644 --- a/components/pages/console/TestConsole.js +++ b/components/pages/console/TestConsole.js @@ -30,6 +30,8 @@ export function TestConsole() { window.umami.track('track-event-with-data', { data: { test: 'test-data', + boolean: true, + booleanError: 'true', time: new Date(), number: 1, time2: new Date().toISOString(), diff --git a/lib/eventData.ts b/lib/eventData.ts index 4588d081..aee1f9b4 100644 --- a/lib/eventData.ts +++ b/lib/eventData.ts @@ -49,6 +49,7 @@ function createKey(key, value, acc: { keyValues: any[]; parentKey: string }) { break; case 'boolean': eventDataType = EVENT_DATA_TYPE.boolean; + value = value ? 'true' : 'false'; break; case 'date': eventDataType = EVENT_DATA_TYPE.date; diff --git a/queries/analytics/event/getEvents.ts b/queries/analytics/event/getEvents.ts index b3853f2d..8197019d 100644 --- a/queries/analytics/event/getEvents.ts +++ b/queries/analytics/event/getEvents.ts @@ -1,7 +1,6 @@ -import prisma from 'lib/prisma'; import clickhouse from 'lib/clickhouse'; -import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db'; -import { EVENT_TYPE } from 'lib/constants'; +import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db'; +import prisma from 'lib/prisma'; export function getEvents(...args: [websiteId: string, startAt: Date, eventType: number]) { return runQuery({