Skip to content

Commit 8ea3d7e

Browse files
task(content analytics) #34710 : Fix naming and reference inconsistencies for Engagement Dashboard (#34711)
## Summary Fixes naming inconsistencies and several correctness issues in the Engagement Dashboard analytics infrastructure (ClickHouse schema and CubeJS cube definitions). ### CubeJS schema changes: - Renamed `contextSiteId` → `siteId` across all four cube definitions (`EngagementDaily`, `SessionsByBrowserDaily`, `SessionsByDeviceDaily`, `SessionsByLanguageDaily`) to align with the underlying `context_site_id` column convention ### ClickHouse schema fixes: - Fixed `utc_time` column type from `DateTime` to `DateTime64(3,'UTC')` to support millisecond-precision timestamps - Fixed `session_states_mv` aggregate functions — replaced `_timestamp` with `utc_time` across all `minState`, `maxState`, and `argMaxState` calls so session time windows and dimension states are correctly computed - Removed the redundant `context_site_id` String plain column from `session_states`; `context_site_id` is now exclusively tracked via its `argMax` aggregate state and properly materialized via `argMaxMerge(context_site_id_state)` in `session_facts_rmv` - Simplified session_states `ORDER BY from (customer_id, cluster_id, sessionid, context_site_id)` to `(customer_id, cluster_id, sessionid)` — site is a derived dimension, not a partitioning key - Extended `session_facts_rmv` rolling finalization window from 72 hours to 5 days to better handle late-arriving events - Updated `now()` to `now64(3, 'UTC')` in `session_facts_rmv` for consistent timestamp precision - Fixed `content_presents_in_conversion_mv` syntax — `REFRESH EVERY 15 MINUTE` and `APPEND TO` are now on separate lines for correctness - Added commented-out `REFRESH EVERY 30 SECOND` hints in `session_facts_rmv` and `content_presents_in_conversion_mv` for local development iteration - Normalized terminology: "rollup" → "roll-up" consistently throughout SQL comments and documentation ## Test plan - Deploy updated ClickHouse init SQL to a local analytics environment and verify all tables and materialized views are created without errors - Confirm CubeJS cube definitions compile successfully and the renamed siteId dimension resolves correctly in queries - Ingest test events and validate that session time windows (`min_ts`, `max_ts`) and dimension states (`context_site_id`, `user_agent`, `device_category`, `browser_family`, `language_id`) are populated correctly in `session_states` and `session_facts` - Verify `engagement_daily` and `sessions_by_*_daily` roll-ups refresh on schedule and return correctly aggregated data Fixes #34710
1 parent 52ceaed commit 8ea3d7e

5 files changed

Lines changed: 91 additions & 87 deletions

File tree

docker/docker-compose-examples/analytics/setup/config/dev/cube/schema/EngagementDaily.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ cube(`EngagementDaily`, {
172172
description: `Environment/cluster identifier (prod/stage/etc.). Filter when needed.`,
173173
},
174174

175-
contextSiteId: {
175+
siteId: {
176176
sql: `context_site_id`,
177177
type: `string`,
178178
title: `Site Id`,

docker/docker-compose-examples/analytics/setup/config/dev/cube/schema/SessionsByBrowserDaily.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ cube(`SessionsByBrowserDaily`, {
8484
description: `Environment/cluster identifier (prod/stage/etc.). Filter when needed.`,
8585
},
8686

87-
contextSiteId: {
87+
siteId: {
8888
sql: `context_site_id`,
8989
type: `string`,
9090
title: `Site Id`,

docker/docker-compose-examples/analytics/setup/config/dev/cube/schema/SessionsByDeviceDaily.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ cube(`SessionsByDeviceDaily`, {
9090
description: `Environment/cluster identifier (prod/stage/etc.). Filter when needed.`,
9191
},
9292

93-
contextSiteId: {
93+
siteId: {
9494
sql: `context_site_id`,
9595
type: `string`,
9696
title: `Site Id`,

docker/docker-compose-examples/analytics/setup/config/dev/cube/schema/SessionsByLanguageDaily.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
description: `Environment/cluster identifier (prod/stage/etc.). Filter when needed.`,
8686
},
8787

88-
contextSiteId: {
88+
siteId: {
8989
sql: `context_site_id`,
9090
type: `string`,
9191
title: `Site Id`,

0 commit comments

Comments
 (0)