Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(experiments): stop MCP dropping conversion window unit and funnel order (#103185)

Marcel Poelkerde1e5c879445
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 46cafdffc95b..0f5c9512cc60 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -24632,7 +24632,11 @@
},
"conversion_window": {
"$ref": "#/definitions/integer",
- "description": "Conversion window duration."
+ "description": "Only count metric events within this many units after the user's first exposure. Requires conversion_window_unit: a window without a unit is ignored and the metric counts events until the experiment ends. Omit both to count until the experiment ends."
+ },
+ "conversion_window_unit": {
+ "$ref": "#/definitions/FunnelConversionWindowTimeUnit",
+ "description": "Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or 'month'. Required when conversion_window is set."
},
"denominator": {
"$ref": "#/definitions/ExperimentApiEventSource",
@@ -24642,6 +24646,10 @@
"$ref": "#/definitions/ExperimentMetricOutlierHandling",
"description": "For ratio metrics: winsorization applied to the denominator aggregate. Leave unset for a binomial-style denominator, which is never clamped."
},
+ "funnel_order_type": {
+ "$ref": "#/definitions/StepOrderValue",
+ "description": "For funnel metrics: how the steps must occur. 'ordered' (default) or 'unordered'. Do not use 'strict': experiment funnels give wrong counts with it."
+ },
"goal": {
"$ref": "#/definitions/ExperimentMetricGoal",
"description": "Whether higher or lower values indicate success."
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index f1b6d49193ad..e4e1f5f7266e 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -5585,12 +5585,20 @@ export interface ExperimentApiMetric {
uuid?: string
/** Whether higher or lower values indicate success. */
goal?: ExperimentMetricGoal
- /** Conversion window duration. */
+ /** Only count metric events within this many units after the user's first exposure. Requires
+ * conversion_window_unit: a window without a unit is ignored and the metric counts events until
+ * the experiment ends. Omit both to count until the experiment ends. */
conversion_window?: integer
+ /** Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or 'month'. Required when
+ * conversion_window is set. */
+ conversion_window_unit?: FunnelConversionWindowTimeUnit
/** For mean metrics: event source. */
source?: ExperimentApiEventSource
/** For funnel metrics: array of EventsNode/ActionsNode steps. */
series?: ExperimentApiEventSource[]
+ /** For funnel metrics: how the steps must occur. 'ordered' (default) or 'unordered'. Do not use
+ * 'strict': experiment funnels give wrong counts with it. */
+ funnel_order_type?: StepOrderValue
/** For ratio metrics: numerator source. */
numerator?: ExperimentApiEventSource
/** For ratio metrics: denominator source. */
diff --git a/posthog/schema.py b/posthog/schema.py
index 4651730c4f35..a2899010fc36 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -5239,7 +5239,22 @@ class ExperimentApiMetric(BaseModel):
completion_event: ExperimentApiEventSource | None = Field(
default=None, description="For retention metrics: completion event."
)
- conversion_window: int | None = Field(default=None, description="Conversion window duration.")
+ conversion_window: int | None = Field(
+ default=None,
+ description=(
+ "Only count metric events within this many units after the user's first"
+ " exposure. Requires conversion_window_unit: a window without a unit is"
+ " ignored and the metric counts events until the experiment ends. Omit both"
+ " to count until the experiment ends."
+ ),
+ )
+ conversion_window_unit: FunnelConversionWindowTimeUnit | None = Field(
+ default=None,
+ description=(
+ "Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or"
+ " 'month'. Required when conversion_window is set."
+ ),
+ )
denominator: ExperimentApiEventSource | None = Field(
default=None, description="For ratio metrics: denominator source."
)
@@ -5250,6 +5265,14 @@ class ExperimentApiMetric(BaseModel):
" Leave unset for a binomial-style denominator, which is never clamped."
),
)
+ funnel_order_type: StepOrderValue | None = Field(
+ default=None,
+ description=(
+ "For funnel metrics: how the steps must occur. 'ordered' (default) or"
+ " 'unordered'. Do not use 'strict': experiment funnels give wrong counts"
+ " with it."
+ ),
+ )
goal: ExperimentMetricGoal | None = Field(
default=None, description="Whether higher or lower values indicate success."
)
diff --git a/products/experiments/backend/test/test_presentation_api.py b/products/experiments/backend/test/test_presentation_api.py
index 27fe752871ad..cb3710c1d535 100644
--- a/products/experiments/backend/test/test_presentation_api.py
+++ b/products/experiments/backend/test/test_presentation_api.py
@@ -16,6 +16,14 @@ from dateutil import parser
from parameterized import parameterized
from rest_framework import status
+from posthog.schema import (
+ ExperimentApiMetric,
+ ExperimentFunnelMetric,
+ ExperimentMeanMetric,
+ ExperimentRatioMetric,
+ ExperimentRetentionMetric,
+)
+
from posthog.auth import IDJagAccessTokenAuthentication, OAuthAccessTokenAuthentication, PersonalAPIKeyAuthentication
from posthog.constants import AvailableFeature
from posthog.models import Organization, OrganizationMembership, Team
@@ -8982,6 +8990,44 @@ class TestExperimentApiExposureCriteriaParity(unittest.TestCase):
)
+class TestExperimentApiMetricParity(unittest.TestCase):
+ """A field missing from the slim API metric schema is stripped by the generated write clients."""
+
+ INTENTIONALLY_OMITTED = {
+ # Server-computed or internal.
+ "fingerprint",
+ "response",
+ "version",
+ # Shared-metric linkage, set through the shared metric endpoints.
+ "isSharedMetric",
+ "sharedMetricId",
+ # Breakdowns are not exposed on the write schema yet.
+ "breakdownFilter",
+ "breakdownAttributionType",
+ "breakdownAttributionValue",
+ }
+
+ def test_api_schema_exposes_every_runtime_field(self) -> None:
+ runtime_fields: set[str] = set()
+ for metric_model in (
+ ExperimentMeanMetric,
+ ExperimentFunnelMetric,
+ ExperimentRatioMetric,
+ ExperimentRetentionMetric,
+ ):
+ runtime_fields |= set(metric_model.model_fields)
+
+ api_fields = set(ExperimentApiMetric.model_fields)
+ dropped = runtime_fields - api_fields - self.INTENTIONALLY_OMITTED
+ self.assertFalse(
+ dropped,
+ f"ExperimentApiMetric omits metric fields the runtime honors: {dropped}. "
+ "Generated write clients (MCP, frontend) strip these silently — add them to the slim API "
+ "type in frontend/src/queries/schema/schema-general.ts and rerun hogli build:schema, or "
+ "add them to INTENTIONALLY_OMITTED with a reason.",
+ )
+
+
class TestExperimentTags(APILicensedTest):
def _create_experiment(self, name: str, flag_key: str, tags: list[str] | None = None) -> dict:
payload: dict[str, Any] = {"name": name, "feature_flag_key": flag_key}
diff --git a/products/experiments/frontend/generated/api.schemas.ts b/products/experiments/frontend/generated/api.schemas.ts
index 138bbf099785..b37f1a2beb23 100644
--- a/products/experiments/frontend/generated/api.schemas.ts
+++ b/products/experiments/frontend/generated/api.schemas.ts
@@ -1376,6 +1376,18 @@ export interface ExperimentApiEventSourceApi {
properties?: EventPropertyFilterApi[] | null
}
+export type FunnelConversionWindowTimeUnitApi =
+ (typeof FunnelConversionWindowTimeUnitApi)[keyof typeof FunnelConversionWindowTimeUnitApi]
+
+export const FunnelConversionWindowTimeUnitApi = {
+ Second: 'second',
+ Minute: 'minute',
+ Hour: 'hour',
+ Day: 'day',
+ Week: 'week',
+ Month: 'month',
+} as const
+
export interface ExperimentMetricOutlierHandlingApi {
ignore_zeros?: boolean | null
/** Winsorization lower percentile bound, as a fraction in [0, 1] (e.g. 0.01 for the 1st percentile). */
@@ -1384,6 +1396,14 @@ export interface ExperimentMetricOutlierHandlingApi {
upper_bound_percentile?: number | null
}
+export type StepOrderValueApi = (typeof StepOrderValueApi)[keyof typeof StepOrderValueApi]
+
+export const StepOrderValueApi = {
+ Strict: 'strict',
+ Unordered: 'unordered',
+ Ordered: 'ordered',
+} as const
+
export type ExperimentMetricGoalApi = (typeof ExperimentMetricGoalApi)[keyof typeof ExperimentMetricGoalApi]
export const ExperimentMetricGoalApi = {
@@ -1400,18 +1420,6 @@ export const ExperimentMetricTypeApi = {
Retention: 'retention',
} as const
-export type FunnelConversionWindowTimeUnitApi =
- (typeof FunnelConversionWindowTimeUnitApi)[keyof typeof FunnelConversionWindowTimeUnitApi]
-
-export const FunnelConversionWindowTimeUnitApi = {
- Second: 'second',
- Minute: 'minute',
- Hour: 'hour',
- Day: 'day',
- Week: 'week',
- Month: 'month',
-} as const
-
export type StartHandlingApi = (typeof StartHandlingApi)[keyof typeof StartHandlingApi]
export const StartHandlingApi = {
@@ -1422,12 +1430,16 @@ export const StartHandlingApi = {
export interface ExperimentApiMetricApi {
/** For retention metrics: completion event. */
completion_event?: ExperimentApiEventSourceApi | null
- /** Conversion window duration. */
+ /** Only count metric events within this many units after the user's first exposure. Requires conversion_window_unit: a window without a unit is ignored and the metric counts events until the experiment ends. Omit both to count until the experiment ends. */
conversion_window?: number | null
+ /** Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or 'month'. Required when conversion_window is set. */
+ conversion_window_unit?: FunnelConversionWindowTimeUnitApi | null
/** For ratio metrics: denominator source. */
denominator?: ExperimentApiEventSourceApi | null
/** For ratio metrics: winsorization applied to the denominator aggregate. Leave unset for a binomial-style denominator, which is never clamped. */
denominator_outlier_handling?: ExperimentMetricOutlierHandlingApi | null
+ /** For funnel metrics: how the steps must occur. 'ordered' (default) or 'unordered'. Do not use 'strict': experiment funnels give wrong counts with it. */
+ funnel_order_type?: StepOrderValueApi | null
/** Whether higher or lower values indicate success. */
goal?: ExperimentMetricGoalApi | null
/** For mean metrics: exclude zero values when computing the winsorization percentile thresholds. */
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 6c5c55fb21c9..689f570c7f0f 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -37603,12 +37603,16 @@ export namespace Schemas {
export interface ExperimentApiMetric {
/** For retention metrics: completion event. */
completion_event?: ExperimentApiEventSource | null;
- /** Conversion window duration. */
+ /** Only count metric events within this many units after the user's first exposure. Requires conversion_window_unit: a window without a unit is ignored and the metric counts events until the experiment ends. Omit both to count until the experiment ends. */
conversion_window?: number | null;
+ /** Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or 'month'. Required when conversion_window is set. */
+ conversion_window_unit?: FunnelConversionWindowTimeUnit | null;
/** For ratio metrics: denominator source. */
denominator?: ExperimentApiEventSource | null;
/** For ratio metrics: winsorization applied to the denominator aggregate. Leave unset for a binomial-style denominator, which is never clamped. */
denominator_outlier_handling?: ExperimentMetricOutlierHandling | null;
+ /** For funnel metrics: how the steps must occur. 'ordered' (default) or 'unordered'. Do not use 'strict': experiment funnels give wrong counts with it. */
+ funnel_order_type?: StepOrderValue | null;
/** Whether higher or lower values indicate success. */
goal?: ExperimentMetricGoal | null;
/** For mean metrics: exclude zero values when computing the winsorization percentile thresholds. */
diff --git a/services/mcp/src/generated/experiments/api.ts b/services/mcp/src/generated/experiments/api.ts
index f2418e9542dd..1f42faf010e3 100644
--- a/services/mcp/src/generated/experiments/api.ts
+++ b/services/mcp/src/generated/experiments/api.ts
@@ -4734,7 +4734,15 @@ export const ExperimentsCreateBody = () => zod
conversion_window: zod
.union([zod.number(), zod.null()])
.optional()
- .describe('Conversion window duration.'),
+ .describe(
+ "Only count metric events within this many units after the user's first exposure. Requires conversion_window_unit: a window without a unit is ignored and the metric counts events until the experiment ends. Omit both to count until the experiment ends."
+ ),
+ conversion_window_unit: zod
+ .union([zod.enum(['second', 'minute', 'hour', 'day', 'week', 'month']), zod.null()])
+ .optional()
+ .describe(
+ "Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or 'month'. Required when conversion_window is set."
+ ),
denominator: zod
.union([
zod.object({
@@ -4921,6 +4929,12 @@ export const ExperimentsCreateBody = () => zod
.describe(
'For ratio metrics: winsorization applied to the denominator aggregate. Leave unset for a binomial-style denominator, which is never clamped.'
),
+ funnel_order_type: zod
+ .union([zod.enum(['strict', 'unordered', 'ordered']), zod.null()])
+ .optional()
+ .describe(
+ "For funnel metrics: how the steps must occur. 'ordered' (default) or 'unordered'. Do not use 'strict': experiment funnels give wrong counts with it."
+ ),
goal: zod
.union([zod.enum(['increase', 'decrease']), zod.null()])
.optional()
@@ -5756,7 +5770,15 @@ export const ExperimentsCreateBody = () => zod
conversion_window: zod
.union([zod.number(), zod.null()])
.optional()
- .describe('Conversion window duration.'),
+ .describe(
+ "Only count metric events within this many units after the user's first exposure. Requires conversion_window_unit: a window without a unit is ignored and the metric counts events until the experiment ends. Omit both to count until the experiment ends."
+ ),
+ conversion_window_unit: zod
+ .union([zod.enum(['second', 'minute', 'hour', 'day', 'week', 'month']), zod.null()])
+ .optional()
+ .describe(
+ "Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or 'month'. Required when conversion_window is set."
+ ),
denominator: zod
.union([
zod.object({
@@ -5943,6 +5965,12 @@ export const ExperimentsCreateBody = () => zod
.describe(
'For ratio metrics: winsorization applied to the denominator aggregate. Leave unset for a binomial-style denominator, which is never clamped.'
),
+ funnel_order_type: zod
+ .union([zod.enum(['strict', 'unordered', 'ordered']), zod.null()])
+ .optional()
+ .describe(
+ "For funnel metrics: how the steps must occur. 'ordered' (default) or 'unordered'. Do not use 'strict': experiment funnels give wrong counts with it."
+ ),
goal: zod
.union([zod.enum(['increase', 'decrease']), zod.null()])
.optional()
@@ -10657,7 +10685,15 @@ export const ExperimentsPartialUpdateBody = () => zod
conversion_window: zod
.union([zod.number(), zod.null()])
.optional()
- .describe('Conversion window duration.'),
+ .describe(
+ "Only count metric events within this many units after the user's first exposure. Requires conversion_window_unit: a window without a unit is ignored and the metric counts events until the experiment ends. Omit both to count until the experiment ends."
+ ),
+ conversion_window_unit: zod
+ .union([zod.enum(['second', 'minute', 'hour', 'day', 'week', 'month']), zod.null()])
+ .optional()
+ .describe(
+ "Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or 'month'. Required when conversion_window is set."
+ ),
denominator: zod
.union([
zod.object({
@@ -10844,6 +10880,12 @@ export const ExperimentsPartialUpdateBody = () => zod
.describe(
'For ratio metrics: winsorization applied to the denominator aggregate. Leave unset for a binomial-style denominator, which is never clamped.'
),
+ funnel_order_type: zod
+ .union([zod.enum(['strict', 'unordered', 'ordered']), zod.null()])
+ .optional()
+ .describe(
+ "For funnel metrics: how the steps must occur. 'ordered' (default) or 'unordered'. Do not use 'strict': experiment funnels give wrong counts with it."
+ ),
goal: zod
.union([zod.enum(['increase', 'decrease']), zod.null()])
.optional()
@@ -11679,7 +11721,15 @@ export const ExperimentsPartialUpdateBody = () => zod
conversion_window: zod
.union([zod.number(), zod.null()])
.optional()
- .describe('Conversion window duration.'),
+ .describe(
+ "Only count metric events within this many units after the user's first exposure. Requires conversion_window_unit: a window without a unit is ignored and the metric counts events until the experiment ends. Omit both to count until the experiment ends."
+ ),
+ conversion_window_unit: zod
+ .union([zod.enum(['second', 'minute', 'hour', 'day', 'week', 'month']), zod.null()])
+ .optional()
+ .describe(
+ "Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or 'month'. Required when conversion_window is set."
+ ),
denominator: zod
.union([
zod.object({
@@ -11866,6 +11916,12 @@ export const ExperimentsPartialUpdateBody = () => zod
.describe(
'For ratio metrics: winsorization applied to the denominator aggregate. Leave unset for a binomial-style denominator, which is never clamped.'
),
+ funnel_order_type: zod
+ .union([zod.enum(['strict', 'unordered', 'ordered']), zod.null()])
+ .optional()
+ .describe(
+ "For funnel metrics: how the steps must occur. 'ordered' (default) or 'unordered'. Do not use 'strict': experiment funnels give wrong counts with it."
+ ),
goal: zod
.union([zod.enum(['increase', 'decrease']), zod.null()])
.optional()
@@ -16559,7 +16615,15 @@ export const ExperimentsDuplicateCreateBody = () => zod
conversion_window: zod
.union([zod.number(), zod.null()])
.optional()
- .describe('Conversion window duration.'),
+ .describe(
+ "Only count metric events within this many units after the user's first exposure. Requires conversion_window_unit: a window without a unit is ignored and the metric counts events until the experiment ends. Omit both to count until the experiment ends."
+ ),
+ conversion_window_unit: zod
+ .union([zod.enum(['second', 'minute', 'hour', 'day', 'week', 'month']), zod.null()])
+ .optional()
+ .describe(
+ "Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or 'month'. Required when conversion_window is set."
+ ),
denominator: zod
.union([
zod.object({
@@ -16746,6 +16810,12 @@ export const ExperimentsDuplicateCreateBody = () => zod
.describe(
'For ratio metrics: winsorization applied to the denominator aggregate. Leave unset for a binomial-style denominator, which is never clamped.'
),
+ funnel_order_type: zod
+ .union([zod.enum(['strict', 'unordered', 'ordered']), zod.null()])
+ .optional()
+ .describe(
+ "For funnel metrics: how the steps must occur. 'ordered' (default) or 'unordered'. Do not use 'strict': experiment funnels give wrong counts with it."
+ ),
goal: zod
.union([zod.enum(['increase', 'decrease']), zod.null()])
.optional()
@@ -17581,7 +17651,15 @@ export const ExperimentsDuplicateCreateBody = () => zod
conversion_window: zod
.union([zod.number(), zod.null()])
.optional()
- .describe('Conversion window duration.'),
+ .describe(
+ "Only count metric events within this many units after the user's first exposure. Requires conversion_window_unit: a window without a unit is ignored and the metric counts events until the experiment ends. Omit both to count until the experiment ends."
+ ),
+ conversion_window_unit: zod
+ .union([zod.enum(['second', 'minute', 'hour', 'day', 'week', 'month']), zod.null()])
+ .optional()
+ .describe(
+ "Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or 'month'. Required when conversion_window is set."
+ ),
denominator: zod
.union([
zod.object({
@@ -17768,6 +17846,12 @@ export const ExperimentsDuplicateCreateBody = () => zod
.describe(
'For ratio metrics: winsorization applied to the denominator aggregate. Leave unset for a binomial-style denominator, which is never clamped.'
),
+ funnel_order_type: zod
+ .union([zod.enum(['strict', 'unordered', 'ordered']), zod.null()])
+ .optional()
+ .describe(
+ "For funnel metrics: how the steps must occur. 'ordered' (default) or 'unordered'. Do not use 'strict': experiment funnels give wrong counts with it."
+ ),
goal: zod
.union([zod.enum(['increase', 'decrease']), zod.null()])
.optional()
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json
index 28478d015029..7047ad367c07 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/experiment-update.json
@@ -6128,7 +6128,19 @@
"type": "null"
}
],
- "description": "Conversion window duration."
+ "description": "Only count metric events within this many units after the user's first exposure. Requires conversion_window_unit: a window without a unit is ignored and the metric counts events until the experiment ends. Omit both to count until the experiment ends."
+ },
+ "conversion_window_unit": {
+ "anyOf": [
+ {
+ "enum": ["second", "minute", "hour", "day", "week", "month"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or 'month'. Required when conversion_window is set."
},
"denominator": {
"anyOf": [
@@ -6414,6 +6426,18 @@
],
"description": "For ratio metrics: winsorization applied to the denominator aggregate. Leave unset for a binomial-style denominator, which is never clamped."
},
+ "funnel_order_type": {
+ "anyOf": [
+ {
+ "enum": ["strict", "unordered", "ordered"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "For funnel metrics: how the steps must occur. 'ordered' (default) or 'unordered'. Do not use 'strict': experiment funnels give wrong counts with it."
+ },
"goal": {
"anyOf": [
{
@@ -7801,7 +7825,19 @@
"type": "null"
}
],
- "description": "Conversion window duration."
+ "description": "Only count metric events within this many units after the user's first exposure. Requires conversion_window_unit: a window without a unit is ignored and the metric counts events until the experiment ends. Omit both to count until the experiment ends."
+ },
+ "conversion_window_unit": {
+ "anyOf": [
+ {
+ "enum": ["second", "minute", "hour", "day", "week", "month"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Unit for conversion_window: 'second', 'minute', 'hour', 'day', 'week' or 'month'. Required when conversion_window is set."
},
"denominator": {
"anyOf": [
@@ -8087,6 +8123,18 @@
],
"description": "For ratio metrics: winsorization applied to the denominator aggregate. Leave unset for a binomial-style denominator, which is never clamped."
},
+ "funnel_order_type": {
+ "anyOf": [
+ {
+ "enum": ["strict", "unordered", "ordered"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "For funnel metrics: how the steps must occur. 'ordered' (default) or 'unordered'. Do not use 'strict': experiment funnels give wrong counts with it."
+ },
"goal": {
"anyOf": [
{
diff --git a/services/mcp/tests/unit/experiments-metric-null-injection.test.ts b/services/mcp/tests/unit/experiments-metric-null-injection.test.ts
index 9ca38a34f11d..86bc292150fb 100644
--- a/services/mcp/tests/unit/experiments-metric-null-injection.test.ts
+++ b/services/mcp/tests/unit/experiments-metric-null-injection.test.ts
@@ -82,6 +82,21 @@ describe('experiment-update metric null injection', () => {
expect(injectedNullKeys(metric, parsedMetric)).toEqual([])
})
+ it('preserves a stored strict funnel order', () => {
+ // A narrower write schema would reject a stored strict metric, so the round trip fails
+ // before the request reaches the API.
+ const metric = {
+ kind: 'ExperimentMetric',
+ metric_type: 'funnel',
+ name: 'strict funnel',
+ series: [{ kind: 'EventsNode', event: '$pageview' }],
+ funnel_order_type: 'strict',
+ }
+ const parsed = updateSchema().parse({ id: 123, metrics: [metric] }) as Record<string, unknown>
+ const parsedMetric = (parsed.metrics as Record<string, unknown>[])[0]!
+ expect(parsedMetric).toHaveProperty('funnel_order_type', 'strict')
+ })
+
it('still preserves explicit nulls the caller sends', () => {
// conversion_window is a valid mean field; an explicit null must survive.
const metric = {