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

  • featuresCount can now be used as a filter with >, >=, < and <=, compiling to the featuresCountFrom/featuresCountTo args on duoUsageEvents
  • The backend range is inclusive, so strict operators shift the bound by one (> 5 compiles to featuresCountFrom: 6). Values are clamped to GraphQL Int bounds (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 featuresCount without 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 > 5

with 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

Merge request reports

Loading
Loading