Skip to content
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
14 changes: 12 additions & 2 deletions frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12596,9 +12596,19 @@
"description": "Control variant stats for this breakdown"
},
"breakdown_value": {
"description": "The breakdown values as an array (e.g., [\"MacOS\", \"Chrome\"] for multi-breakdown, [\"Chrome\"] for single)",
"description": "The breakdown values as an array (e.g., [\"MacOS\", \"Chrome\"] for multi-breakdown, [\"Chrome\"] for single) Although `BreakdownKeyType` could be an array, we only use the array form for the breakdown_value. The way `BreakdownKeyType` is defined is problematic. It should be treated as a primitive and allow for the types using it to define if it's and array or an optional value.",
"items": {
"$ref": "#/definitions/BreakdownKeyType"
"anyOf": [
{
"$ref": "#/definitions/integer"
},
{
"type": "string"
},
{
"type": "number"
}
]
},
"type": "array"
},
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/queries/schema/schema-general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3056,8 +3056,13 @@ export interface ExperimentVariantResultBayesian extends ExperimentStatsBaseVali
* For multiple breakdowns, values are in the same order as breakdownFilter.breakdowns.
*/
export interface ExperimentBreakdownResult {
/** The breakdown values as an array (e.g., ["MacOS", "Chrome"] for multi-breakdown, ["Chrome"] for single) */
breakdown_value: BreakdownKeyType[]
/**
* The breakdown values as an array (e.g., ["MacOS", "Chrome"] for multi-breakdown, ["Chrome"] for single)
* Although `BreakdownKeyType` could be an array, we only use the array form for the breakdown_value.
* The way `BreakdownKeyType` is defined is problematic. It should be treated as a primitive and allow
* for the types using it to define if it's and array or an optional value.
*/
breakdown_value: (integer | string | number)[]
/** Control variant stats for this breakdown */
baseline: ExperimentStatsBaseValidated
/** Test variant results with statistical comparisons for this breakdown */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
ExperimentStatsBaseValidated,
NewExperimentQueryResponse,
} from '~/queries/schema/schema-general'
import { BreakdownKeyType, Experiment, InsightType } from '~/types'
import { Experiment, InsightType } from '~/types'

import { experimentLogic } from '../../experimentLogic'
import { ChartEmptyState } from '../shared/ChartEmptyState'
Expand Down Expand Up @@ -549,7 +549,7 @@ export function MetricRowGroup({
} ${isAlternatingRow ? 'bg-bg-table' : 'bg-bg-light'}`}
>
{formatBreakdownLabel(
breakdownResult.breakdown_value as BreakdownKeyType,
breakdownResult.breakdown_value,
metric.breakdownFilter,
[],
undefined,
Expand Down Expand Up @@ -599,7 +599,7 @@ export function MetricRowGroup({
}}
>
{formatBreakdownLabel(
breakdownResult.breakdown_value as BreakdownKeyType,
breakdownResult.breakdown_value,
metric.breakdownFilter,
[],
undefined,
Expand Down
5 changes: 4 additions & 1 deletion posthog/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9338,10 +9338,13 @@ class ExperimentBreakdownResult(BaseModel):
extra="forbid",
)
baseline: ExperimentStatsBaseValidated = Field(..., description="Control variant stats for this breakdown")
breakdown_value: list[Optional[Union[int, str, float, list[Union[int, str, float]]]]] = Field(
breakdown_value: list[Union[str, float, int]] = Field(
...,
description=(
'The breakdown values as an array (e.g., ["MacOS", "Chrome"] for multi-breakdown, ["Chrome"] for single)'
" Although `BreakdownKeyType` could be an array, we only use the array form for the breakdown_value. The"
" way `BreakdownKeyType` is defined is problematic. It should be treated as a primitive and allow for the"
" types using it to define if it's and array or an optional value."
),
)
variants: Union[list[ExperimentVariantResultFrequentist], list[ExperimentVariantResultBayesian]] = Field(
Expand Down
Loading