From 1bdaf4aca2c22466b8c8f7acd3275997fbad7807 Mon Sep 17 00:00:00 2001 From: Brian Cao Date: Mon, 10 Jul 2023 15:30:34 -0700 Subject: [PATCH] Always record string. --- lib/kafka.ts | 4 ++-- queries/analytics/eventData/saveEventData.ts | 15 +++------------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/lib/kafka.ts b/lib/kafka.ts index 3d3e281c..8f5bb87f 100644 --- a/lib/kafka.ts +++ b/lib/kafka.ts @@ -61,8 +61,8 @@ async function getProducer(): Promise { return producer; } -function getDateFormat(date): string { - return dateFormat(date, 'UTC:yyyy-mm-dd HH:MM:ss'); +function getDateFormat(date, format?): string { + return dateFormat(date, format ? format : 'UTC:yyyy-mm-dd HH:MM:ss'); } async function sendMessage( diff --git a/queries/analytics/eventData/saveEventData.ts b/queries/analytics/eventData/saveEventData.ts index 0ccc9421..9a7aa406 100644 --- a/queries/analytics/eventData/saveEventData.ts +++ b/queries/analytics/eventData/saveEventData.ts @@ -36,13 +36,8 @@ async function relationalQuery(data: { id: uuid(), websiteEventId: eventId, websiteId, - key: a.key, - stringValue: - a.dynamicDataType === DATA_TYPE.string || - a.dynamicDataType === DATA_TYPE.boolean || - a.dynamicDataType === DATA_TYPE.array - ? a.value - : null, + eventKey: a.key, + stringValue: a.value.toString(), numericValue: a.dynamicDataType === DATA_TYPE.number ? a.value : null, dateValue: a.dynamicDataType === DATA_TYPE.date ? new Date(a.value) : null, dataType: a.dynamicDataType, @@ -76,11 +71,7 @@ async function clickhouseQuery(data: { event_name: eventName, event_key: a.key, string_value: - a.dynamicDataType === DATA_TYPE.string || - a.dynamicDataType === DATA_TYPE.boolean || - a.dynamicDataType === DATA_TYPE.array - ? a.value - : null, + a.dynamicDataType === DATA_TYPE.date ? getDateFormat(a.value, 'isoDateTime') : a.value, number_value: a.dynamicDataType === DATA_TYPE.number ? a.value : null, date_value: a.dynamicDataType === DATA_TYPE.date ? getDateFormat(a.value) : null, data_type: a.dynamicDataType,