Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: v2 filters in explore #1783

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeFilterable } from './util'
import type { BasicExploreFilter, BasicExploreQuery } from './basic'
import type { BasicExploreFilter, BasicExploreInFilterV2, BasicExploreQuery } from './basic'
import { basicExploreAggregations, queryableBasicExploreDimensions } from './basic'

export const queryableExploreDimensions = [
Expand All @@ -19,6 +19,10 @@ export interface ExploreFilter extends Omit<BasicExploreFilter, 'dimension'> {
dimension: FilterableExploreDimensions
}

export interface ExploreInFilterV2 extends Omit<BasicExploreInFilterV2, 'field'> {
field: FilterableExploreDimensions
}

export const exploreAggregations = [
...basicExploreAggregations,
'response_latency_p99',
Expand All @@ -44,8 +48,10 @@ export const exploreAggregations = [

export type ExploreAggregations = typeof exploreAggregations[number]

export type ExploreFilterAll = ExploreFilter | ExploreInFilterV2

export interface ExploreQuery extends Omit<BasicExploreQuery, 'metrics' | 'dimensions' | 'filters'> {
metrics?: ExploreAggregations[]
dimensions?: QueryableExploreDimensions[]
filters?: ExploreFilter[]
filters?: ExploreFilterAll[]
}
10 changes: 8 additions & 2 deletions packages/analytics/analytics-utilities/src/types/explore/ai.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeFilterable } from './util'
import type { BasicExploreFilter, BasicExploreQuery } from './basic'
import type { BasicExploreFilter, BasicExploreInFilterV2, BasicExploreQuery } from './basic'

export const queryableAiExploreDimensions = [
'control_plane',
Expand Down Expand Up @@ -27,6 +27,10 @@ export interface AiExploreFilter extends Omit<BasicExploreFilter, 'dimension'> {
dimension: FilterableAiExploreDimensions
}

export interface AiExploreInFilterV2 extends Omit<BasicExploreInFilterV2, 'field'> {
field: FilterableAiExploreDimensions
}

export const aiExploreAggregations = [
'total_tokens',
'prompt_tokens',
Expand All @@ -42,9 +46,11 @@ export const aiExploreAggregations = [

export type AiExploreAggregations = typeof aiExploreAggregations[number]

export type AiExploreFilterAll = AiExploreFilter | AiExploreInFilterV2

export interface AiExploreQuery extends Omit<BasicExploreQuery, 'metrics' | 'dimensions' | 'filters'> {
metrics?: AiExploreAggregations[]
dimensions?: QueryableAiExploreDimensions[]
filters?: AiExploreFilter[]
filters?: AiExploreFilterAll[]
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export interface BasicExploreFilter {
values: (string | number | null)[]
}

export interface BasicExploreInFilterV2 {
operator: ExploreFilterTypesV2
field: FilterableBasicExploreDimensions
value: (string | number | null)[]
}

export const basicExploreAggregations = [
'active_services',
'request_count',
Expand All @@ -35,10 +41,12 @@ export const basicExploreAggregations = [

export type BasicExploreAggregations = typeof basicExploreAggregations[number]

export type BasicExploreFilterAll = BasicExploreFilter | BasicExploreInFilterV2

export interface BasicExploreQuery {
metrics?: BasicExploreAggregations[]
dimensions?: QueryableBasicExploreDimensions[]
filters?: BasicExploreFilter[]
filters?: BasicExploreFilterAll[]
granularity?: GranularityValues
time_range?: TimeRangeV4
limit?: number
Expand Down
Loading