Commit 8ea3d7e
authored
## 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
- db/clickhouse/init-scripts
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
0 commit comments