Add sdk and sdkVersion dimension columns to usage events#25
Conversation
Add two event-only SDK dimensions in Metric::EVENT_COLUMNS and Metric::getEventSchema(): sdk (originating SDK name, e.g. web, flutter, console, cli) and sdkVersion (e.g. 14.0.0). Both are optional strings. In the ClickHouse adapter both map to LowCardinality(Nullable(String)) with CODEC(ZSTD(3)). Existing tables auto-materialize the columns on setup() via the ADD COLUMN IF NOT EXISTS path; gauges are unchanged and the columns are not added to the primary key or indexes. Extends the Metric EVENT_COLUMNS/schema unit tests, the pure-unit column-type mapping test, and the live ClickHouse schema test.
Greptile SummaryThis PR adds two event-only dimension columns —
Confidence Score: 5/5Safe to merge — additive schema change with no gauge-table or primary-key impact, and the ADD COLUMN IF NOT EXISTS migration path is already in place. All six files change in lockstep: EVENT_COLUMNS, the event schema, both ClickHouse column-type lists, and every corresponding test are updated together. The gauge tables and existing indexes are untouched. The pattern is identical to the previously merged premium-geo dimensions and introduces no new logic paths. No files require special attention. The live ClickHouseSchemaTest was not run locally per the PR description, but its assertions are straightforward DDL string checks that follow the same form as existing passing tests. Important Files Changed
Reviews (1): Last reviewed commit: "Add sdk and sdkVersion dimension columns..." | Re-trigger Greptile |
Summary
Adds two new event-only dimension columns to usage events for CLO-4553:
sdk— the originating SDK name (e.g.web,flutter,console,cli)sdkVersion— the SDK version (e.g.14.0.0)Both are optional strings, present in
Metric::EVENT_COLUMNSandMetric::getEventSchema()only — they never appear in the gauge columns/schema.In the ClickHouse adapter both map to
LowCardinality(Nullable(String))withCODEC(ZSTD(3)). Existing tables auto-materialize the columns onsetup()viathe
ADD COLUMN IF NOT EXISTSpath; gauges are unchanged and the columns arenot added to the primary key or indexes.
Follows the exact pattern of the recent premium-geo dimensions change.
Changes
src/Usage/Metric.php— addsdk/sdkVersiontoEVENT_COLUMNS, the schema doc block, andgetEventSchema().src/Usage/Adapter/ClickHouse.php— add both to the low-cardinality and ZSTD codec lists.CHANGELOG.md— new0.11.0section.MetricTest,ClickHouseColumnTypeTest, andClickHouseSchemaTest.Testing
phpunit tests/Usage/MetricTest.php tests/Usage/Adapter/ClickHouseColumnTypeTest.php— 55 tests pass.composer lint(pint) andcomposer check(phpstan) pass.ClickHouseSchemaTestrequires a running ClickHouse and was not run locally.