Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

update to isoutc string value.

Brian Cao3749e2a70d1d
diff --git a/db/clickhouse/migrations/01_edit_keys.sql b/db/clickhouse/migrations/01_edit_keys.sql
index 952151ec0..483a56501 100644
--- a/db/clickhouse/migrations/01_edit_keys.sql
+++ b/db/clickhouse/migrations/01_edit_keys.sql
@@ -6,4 +6,15 @@ ALTER TABLE "event_data" RENAME COLUMN "event_data_type" TO "data_type";
-- add job_id
ALTER TABLE "website_event" ADD COLUMN "job_id" UUID AFTER "created_at";
-ALTER TABLE "event_data" ADD COLUMN "job_id" UUID AFTER "created_at";
\ No newline at end of file
+ALTER TABLE "event_data" ADD COLUMN "job_id" UUID AFTER "created_at";
+
+-- update event_data string
+alter table umami.event_data
+update string_value = number_value
+where number_value is not null
+ and string_value is null;
+
+alter table umami.event_data
+update string_value = replaceOne(concat(CAST(toDateTime(date_value, 'UTC'), 'String'),'Z'), ' ', 'T')
+where date_value is not null
+ and string_value is null;
\ No newline at end of file
diff --git a/queries/analytics/eventData/saveEventData.ts b/queries/analytics/eventData/saveEventData.ts
index 9a7aa4067..c889955fe 100644
--- a/queries/analytics/eventData/saveEventData.ts
+++ b/queries/analytics/eventData/saveEventData.ts
@@ -71,7 +71,7 @@ async function clickhouseQuery(data: {
event_name: eventName,
event_key: a.key,
string_value:
- a.dynamicDataType === DATA_TYPE.date ? getDateFormat(a.value, 'isoDateTime') : a.value,
+ a.dynamicDataType === DATA_TYPE.date ? getDateFormat(a.value, 'isoUtcDateTime') : 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,