Loading
feat(ai_usage_events): require timestamp dimension for retention metrics
What does this MR do and why?
Adds a compiler check for the AiUsageEvent analytics source: returningUsersCount and previousPeriodUsersCount can only be selected as metrics when the timestamp dimension is also selected.
The backend already rejects these queries when they run, but the compiler let them through, so users only found out after the query hit the server. This came up in review on the docs MR: gitlab!249118 (comment 3658791464)
- New
MetricRequiresDimensionerror, next to the existingFilterRequiresMetricone - Check lives in the AiUsageEvent analyzer's
validate_query, same shape as thefeaturesCountfilter check - The schema conformance sweep now adds the
timestampdimension when compiling the two retention metrics, since that's the query a user would actually write
The error reads:
`returningUsersCount` cannot be selected as a metric for AI usage events analytics queries unless `timestamp` is also selected as a dimension.Validation
- Error fires for each retention metric on its own, aliased, mixed with valid metrics, with no dimensions at all, and when the metric is also the sort field
- A
timestampfilter in the query doesn't satisfy the check, only the dimension does timestamp,timestamp(weekly), and aliasedtimestamp as "Week"dimensions all satisfy it- Other metrics and other sources are unaffected
- Full suite, clippy, and fmt are green
Related to #94 (closed)