Loading
feat(ai_usage_events): support featuresCount range filters
Adds range filtering on featuresCount to the AI usage events analytics source. This was deferred from !449 (merged) because it needs the filter-requires-metric validation.
Related to #94 (closed).
What
featuresCountcan now be used as a filter with>,>=,<and<=, compiling to thefeaturesCountFrom/featuresCountToargs onduoUsageEvents- The backend range is inclusive, so strict operators shift the bound by one (
> 5compiles tofeaturesCountFrom: 6). Values are clamped to GraphQLIntbounds (32-bit) since that's the wire type, so out-of-range literals compile to a schema-valid query instead of failing =and!=are rejected since the backend only exposes the From/To range args- Filtering by
featuresCountwithout also selecting it as a metric is now a compile error. The backend rejects that case anyway, so we fail early with a clearer message. Aliased selections (featuresCount as "n") count
Stacked on !449 (merged)
Targets rhunt/94-ai-usage-event-analytics-source while !449 (merged) is open; retarget to main once it merges. Merge bottom-up.
How to test
Compile an analytics query with featuresCount selected as a metric and a range filter, e.g.
type = aiusageevent and featuresCount > 5with metrics: featuresCount in the context, and check the generated GraphQL contains featuresCountFrom: 6. Dropping featuresCount from the metrics list should produce the compile error instead.
Edited by Robert Hunt