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 MetricRequiresDimension error, next to the existing FilterRequiresMetric one
  • Check lives in the AiUsageEvent analyzer's validate_query, same shape as the featuresCount filter check
  • The schema conformance sweep now adds the timestamp dimension 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 timestamp filter in the query doesn't satisfy the check, only the dimension does
  • timestamp, timestamp(weekly), and aliased timestamp as "Week" dimensions all satisfy it
  • Other metrics and other sources are unaffected
  • Full suite, clippy, and fmt are green

Related to #94 (closed)

Merge request reports

Loading
Loading