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.

chore(experiments): remove more legacy results leftovers (#120552)

Andersfe9b09873da9
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 238eb0e24551..ce8365cd8844 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -25980,54 +25980,6 @@
}
]
},
- "ExperimentMaxBayesianContext": {
- "additionalProperties": false,
- "properties": {
- "chance_to_win": {
- "type": "number"
- },
- "credible_interval": {
- "items": {
- "type": "number"
- },
- "maxItems": 2,
- "minItems": 2,
- "type": "array"
- },
- "key": {
- "type": "string"
- },
- "significant": {
- "type": "boolean"
- }
- },
- "required": ["key", "chance_to_win", "credible_interval", "significant"],
- "type": "object"
- },
- "ExperimentMaxFrequentistContext": {
- "additionalProperties": false,
- "properties": {
- "confidence_interval": {
- "items": {
- "type": "number"
- },
- "maxItems": 2,
- "minItems": 2,
- "type": "array"
- },
- "key": {
- "type": "string"
- },
- "p_value": {
- "type": "number"
- },
- "significant": {
- "type": "boolean"
- }
- },
- "required": ["key", "p_value", "confidence_interval", "significant"],
- "type": "object"
- },
"ExperimentMeanMetric": {
"additionalProperties": false,
"properties": {
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 5d123897baa4..59e6e5274d01 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -5686,20 +5686,6 @@ export interface ExperimentVariantFunnelsBaseStats {
failure_count: number
}
-export interface ExperimentMaxBayesianContext {
- key: string
- chance_to_win: number
- credible_interval: [number, number]
- significant: boolean
-}
-
-export interface ExperimentMaxFrequentistContext {
- key: string
- p_value: number
- confidence_interval: [number, number]
- significant: boolean
-}
-
export interface MaxExperimentVariantResultBayesian {
key: string
chance_to_win: number | null
diff --git a/frontend/src/scenes/experiments/ExperimentTabContent/RelatedExperimentsTable.tsx b/frontend/src/scenes/experiments/ExperimentTabContent/RelatedExperimentsTable.tsx
index 8e3d849dad9d..69835ed2fbba 100644
--- a/frontend/src/scenes/experiments/ExperimentTabContent/RelatedExperimentsTable.tsx
+++ b/frontend/src/scenes/experiments/ExperimentTabContent/RelatedExperimentsTable.tsx
@@ -8,7 +8,6 @@ import type { LemonTableColumn } from 'lib/lemon-ui/LemonTable/types'
import stringWithWBR from 'lib/utils/stringWithWBR'
import { urls } from 'scenes/urls'
-import { isLegacyExperiment } from '~/scenes/experiments/utils'
import type { Experiment } from '~/types'
import { ExperimentStatus } from '~/types'
@@ -68,7 +67,7 @@ export const RelatedExperimentsTable = ({
No-code
</LemonTag>
)}
- {isLegacyExperiment(experiment) && (
+ {experiment.is_legacy && (
<Tooltip
title="This experiment uses the legacy engine, so its results are no longer available."
docLink="https://posthog.com/docs/experiments/new-experimentation-engine"
diff --git a/frontend/src/scenes/experiments/MetricsView/new/MetricErrorState.tsx b/frontend/src/scenes/experiments/MetricsView/new/MetricErrorState.tsx
index 628022c7d311..d0a45b1522d9 100644
--- a/frontend/src/scenes/experiments/MetricsView/new/MetricErrorState.tsx
+++ b/frontend/src/scenes/experiments/MetricsView/new/MetricErrorState.tsx
@@ -8,7 +8,6 @@ import { LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu/LemonMenu'
import { urls } from 'scenes/urls'
import { parseErrorMessage } from '~/queries/query'
-import { ExperimentMetric } from '~/queries/schema/schema-general'
type MetricErrorStateProps = {
error: {
@@ -16,7 +15,6 @@ type MetricErrorStateProps = {
statusCode?: number
queryId?: string
}
- metric: ExperimentMetric
query?: Record<string, any>
onRetry?: () => void
/** Disables the "Try again" button (with a tooltip) while a recalculation is already in flight. */
diff --git a/frontend/src/scenes/experiments/MetricsView/new/MetricRowGroup.tsx b/frontend/src/scenes/experiments/MetricsView/new/MetricRowGroup.tsx
index 76c10666ff9c..5eb31c8e6b47 100644
--- a/frontend/src/scenes/experiments/MetricsView/new/MetricRowGroup.tsx
+++ b/frontend/src/scenes/experiments/MetricsView/new/MetricRowGroup.tsx
@@ -221,7 +221,6 @@ function CollapsibleBreakdownSection({
<ChartEmptyState
height={CELL_HEIGHT}
experimentStarted={isLaunched(experiment)}
- metric={metric}
query={query}
onRetry={onRetry}
retryDisabledReason={
@@ -910,7 +909,6 @@ export function MetricRowGroup({
<ChartEmptyState
height={noResultHeight}
experimentStarted={isLaunched(experiment)}
- metric={metric}
error={error}
query={debugQuery}
onRetry={error?.retriable === true ? handleRetry : undefined}
diff --git a/frontend/src/scenes/experiments/MetricsView/shared/ChartEmptyState.tsx b/frontend/src/scenes/experiments/MetricsView/shared/ChartEmptyState.tsx
index f6e210f8f141..9b02992b767e 100644
--- a/frontend/src/scenes/experiments/MetricsView/shared/ChartEmptyState.tsx
+++ b/frontend/src/scenes/experiments/MetricsView/shared/ChartEmptyState.tsx
@@ -6,7 +6,6 @@ import { MetricErrorState } from '../new/MetricErrorState'
interface ChartEmptyStateProps {
height: number
experimentStarted: boolean
- metric: any
error?: any
query?: Record<string, any>
onRetry?: () => void
@@ -18,7 +17,6 @@ export function ChartEmptyState({
height,
experimentStarted,
error,
- metric,
query,
onRetry,
retryDisabledReason,
@@ -48,11 +46,10 @@ export function ChartEmptyState({
<div
className="flex items-center justify-center w-full"
// eslint-disable-next-line react/forbid-dom-props
- style={error ? { minHeight: `${height}px` } : { height: `${height}px` }}
+ style={{ minHeight: `${height}px` }}
>
<MetricErrorState
error={error}
- metric={metric}
query={query}
onRetry={onRetry}
retryDisabledReason={retryDisabledReason}
diff --git a/frontend/src/scenes/experiments/MetricsView/shared/MetricTitle.tsx b/frontend/src/scenes/experiments/MetricsView/shared/MetricTitle.tsx
index c0bcc1a7f00b..93e5470f2c3f 100644
--- a/frontend/src/scenes/experiments/MetricsView/shared/MetricTitle.tsx
+++ b/frontend/src/scenes/experiments/MetricsView/shared/MetricTitle.tsx
@@ -1,36 +1,15 @@
import { Tooltip } from '@posthog/lemon-ui'
-import { NodeKind } from '~/queries/schema/schema-general'
+import { ExperimentMetric } from '~/queries/schema/schema-general'
import { getDefaultMetricTitle } from './utils'
-export const MetricTitle = ({ metric, singleLine }: { metric: any; singleLine?: boolean }): JSX.Element => {
- const shouldShowTooltip = (text: string): boolean => {
- // Show tooltip for longer text that might be clamped
- return text.length > 50
- }
+export const MetricTitle = ({ metric }: { metric: ExperimentMetric }): JSX.Element => {
+ const title = metric.name || getDefaultMetricTitle(metric)
+ // Use break-words for text with spaces, break-all for underscore-separated text
+ const breakClass = title.includes(' ') ? 'break-words' : 'break-all'
+ const element = <span className={`line-clamp-3 ${breakClass}`}>{title}</span>
- const getTextClassName = (text: string): string => {
- if (singleLine) {
- return 'truncate block'
- }
- // Use break-words for text with spaces, break-all for underscore-separated text
- const breakClass = text.includes(' ') ? 'break-words' : 'break-all'
- return `line-clamp-3 ${breakClass}`
- }
-
- const wrapWithTooltip = (text: string, element: JSX.Element): JSX.Element => {
- if (shouldShowTooltip(text)) {
- return <Tooltip title={text}>{element}</Tooltip>
- }
- return element
- }
-
- if (metric.kind === NodeKind.ExperimentMetric) {
- const title = metric.name || getDefaultMetricTitle(metric)
- const element = <span className={getTextClassName(title)}>{title}</span>
- return wrapWithTooltip(title, element)
- }
-
- return <span className={`text-secondary ${getTextClassName('Untitled metric')}`}>Untitled metric</span>
+ // Show tooltip for longer text that might be clamped
+ return title.length > 50 ? <Tooltip title={title}>{element}</Tooltip> : element
}
diff --git a/frontend/src/scenes/experiments/experimentLogic.tsx b/frontend/src/scenes/experiments/experimentLogic.tsx
index 60e322016e27..5e7647edc7ec 100644
--- a/frontend/src/scenes/experiments/experimentLogic.tsx
+++ b/frontend/src/scenes/experiments/experimentLogic.tsx
@@ -397,7 +397,6 @@ export interface experimentLogicValues {
statsMethod: ExperimentStatsMethod
unfreezeExposureLoading: boolean
unmodifiedExperiment: Experiment | null
- usesNewQueryRunner: boolean
variants: MultivariateFlagVariant[]
}
@@ -993,8 +992,7 @@ export interface experimentLogicMeta {
exposures: any,
exposuresLoading: boolean
) => ExposureChecksState
- usesNewQueryRunner: (experiment: Experiment) => boolean
- hasMinimumExposureForResults: (exposures: any, usesNewQueryRunner: boolean) => boolean
+ hasMinimumExposureForResults: (exposures: any) => boolean
exposureCriteria: (experiment: Experiment) => ExperimentExposureCriteria | undefined
hasMetrics: (experiment: Experiment) => boolean
browserNoMetricsWarning: (hasMetrics: boolean, isExperimentLaunched: boolean) => boolean
@@ -2660,9 +2658,10 @@ export const experimentLogic = kea<experimentLogicType>([
null as any,
{
loadExposures: async (refresh: boolean = false) => {
- const { experiment, usesNewQueryRunner } = values
+ const { experiment } = values
- if (!usesNewQueryRunner) {
+ // The legacy page shows no exposures, but its variant exclusion toggle still dispatches this.
+ if (isLegacyExperiment(experiment)) {
// A bare `return` would make kea error ("Reducer returned undefined")
return values.exposures
}
@@ -2876,34 +2875,9 @@ export const experimentLogic = kea<experimentLogicType>([
(isExperimentLaunched: boolean, exposures: any, exposuresLoading: boolean): ExposureChecksState =>
exposureChecksState(isExperimentLaunched, exposures, exposuresLoading),
],
- usesNewQueryRunner: [
- (s) => [s.experiment],
- (experiment: Experiment): boolean => {
- const hasLegacyMetrics = isLegacyExperiment(experiment)
-
- const allMetrics = [...experiment.metrics, ...experiment.metrics_secondary, ...experiment.saved_metrics]
- const hasExperimentMetrics = allMetrics.some((query) => query.kind === NodeKind.ExperimentMetric)
-
- if (hasExperimentMetrics) {
- return true
- }
-
- if (hasLegacyMetrics) {
- return false
- }
-
- // If the experiment has no experiment metrics, we use the new query runner
- return true
- },
- ],
hasMinimumExposureForResults: [
- (s) => [s.exposures, s.usesNewQueryRunner],
- (exposures: ExperimentExposureQueryResponse, usesNewQueryRunner: boolean): boolean => {
- // Not relevant for old metrics
- if (!usesNewQueryRunner) {
- return true
- }
-
+ (s) => [s.exposures],
+ (exposures: ExperimentExposureQueryResponse): boolean => {
if (!exposures || !exposures.total_exposures) {
return false
}
diff --git a/frontend/src/scenes/saved-insights/insightTypesMetadata.tsx b/frontend/src/scenes/saved-insights/insightTypesMetadata.tsx
index 949782af79a3..8682809042af 100644
--- a/frontend/src/scenes/saved-insights/insightTypesMetadata.tsx
+++ b/frontend/src/scenes/saved-insights/insightTypesMetadata.tsx
@@ -400,14 +400,14 @@ export const QUERY_TYPES_METADATA: Record<NodeKind, InsightTypeMetadata> = {
inMenu: false,
},
[NodeKind.ExperimentTrendsQuery]: {
- name: 'Experiment Trends Result',
- description: 'View experiment trend result.',
+ name: 'Legacy experiment trends metric',
+ description: 'Trends metric from the legacy experiments engine. Its results are no longer available.',
icon: IconFlask,
inMenu: false,
},
[NodeKind.ExperimentFunnelsQuery]: {
- name: 'Experiment Funnels Result',
- description: 'View experiment funnel result.',
+ name: 'Legacy experiment funnel metric',
+ description: 'Funnel metric from the legacy experiments engine. Its results are no longer available.',
icon: IconFlask,
inMenu: false,
},
diff --git a/posthog/schema.py b/posthog/schema.py
index 1afc131c48ca..000d05fc1bfd 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -1605,26 +1605,6 @@ class ExperimentExposureTimeSeries(BaseModel):
variant: str
-class ExperimentMaxBayesianContext(BaseModel):
- model_config = ConfigDict(
- extra="forbid",
- )
- chance_to_win: float
- credible_interval: list[float] = Field(..., max_length=2, min_length=2)
- key: str
- significant: bool
-
-
-class ExperimentMaxFrequentistContext(BaseModel):
- model_config = ConfigDict(
- extra="forbid",
- )
- confidence_interval: list[float] = Field(..., max_length=2, min_length=2)
- key: str
- p_value: float
- significant: bool
-
-
class ExperimentMetricOutlierHandling(BaseModel):
model_config = ConfigDict(
extra="forbid",
diff --git a/posthog/test/repo_invariants/signals_scout_tool_citations_baseline.txt b/posthog/test/repo_invariants/signals_scout_tool_citations_baseline.txt
index 8488a6ce2b28..b619781fb072 100644
--- a/posthog/test/repo_invariants/signals_scout_tool_citations_baseline.txt
+++ b/posthog/test/repo_invariants/signals_scout_tool_citations_baseline.txt
@@ -10,6 +10,7 @@ dashboard-insights-run
data-catalog-metric-run
engineering-analytics-sources
execute-sql
+experiment-migrate
experiment-stats
experiment-timeseries-results
external-data-sync-logs
diff --git a/products/experiments/skills/diagnosing-experiment-health/references/empty-experiment.md b/products/experiments/skills/diagnosing-experiment-health/references/empty-experiment.md
index cd7b88d6819c..f9e4831a7c09 100644
--- a/products/experiments/skills/diagnosing-experiment-health/references/empty-experiment.md
+++ b/products/experiments/skills/diagnosing-experiment-health/references/empty-experiment.md
@@ -351,18 +351,16 @@ When only a part of the audience gets no variant, the question is who: A10 in `b
Only the exposure event decides a person's variant.
Metric events are matched to that person and need no flag property, for every metric type.
A user who adds `$feature/<flag-key>` to metric events changes nothing in the results.
+A legacy experiment shows no results at all (E13 in `mid-run-changes.md`).
Where the property does matter:
-- **Legacy experiments** (E13 in `mid-run-changes.md`) attributed metric events by `$feature/<flag-key>`. They no longer show results, so migrate them instead.
- **A custom exposure event** needs it (B4).
- **The user's own insight or SQL** that filters or breaks down by `$feature/<flag-key>`.
It undercounts events from a server SDK, which adds the property only when the capture call is given the evaluated flags or asked to evaluate them `[MEDIUM]`.
It also overcounts in the other direction: the property is on events of everyone whose SDK holds the flag's value, including people who were never exposed, so it is not a filter for participants.
-**Verify directly.** `is_legacy` in `experiment-get`.
-It is true when any primary, secondary or shared metric is legacy.
-When it is false, look elsewhere for a missing conversion: B2 (ids), B8 (order), D1 in `numbers-vs-sql.md` (scope).
+**Verify directly.** A missing conversion has another cause: B2 (ids), B8 (order), D1 in `numbers-vs-sql.md` (scope).
Part of the public docs still asks for the property on metric events.
The exposures page states the current rule.
diff --git a/products/signals/skills/signals-scout-experiments/SKILL.md b/products/signals/skills/signals-scout-experiments/SKILL.md
index 339eb81b244c..2dc76c5ac852 100644
--- a/products/signals/skills/signals-scout-experiments/SKILL.md
+++ b/products/signals/skills/signals-scout-experiments/SKILL.md
@@ -71,7 +71,7 @@ Then orient on experiments specifically:
1. `experiment-list {"status": "running", "order": "-start_date"}` — cheap: returns id, name, status, dates, `feature_flag_key` per experiment. Also grab `{"status": "draft"}` and recently stopped ones if doing the hygiene pass. **Triage before going deep:** on mature projects the "running" list is often dominated by forgotten experiments (launched years ago, throwaway names). Reserve the per-experiment exposure analysis for the validity-watch set — experiments launched in the last ~90 days or known-active from scratchpad memory (cap ~10 per run; rotate if more). Older running experiments go straight to the zombie bundle without exposure SQL.
2. `experiment-get {id}` on running candidates only — you need the linked flag's `filters.multivariate.variants` (the configured split) and `filters.groups[].rollout_percentage`, `exposure_criteria` (custom exposure event? `multiple_variant_handling`?), `running_time_calculation.recommended_running_time`, `stats_config.method`, and the linked `feature_flag` (active state, `filters.groups[].variant` forced-variant overrides). The full object is large (metrics arrays, flag filters) — never bulk-fetch every experiment; running experiments only, and lean on scratchpad memory for ones you've profiled before.
-3. `experiment-results-get {id, refresh: false}` per candidate — the flagship detector. One call returns the exposure block (`total_exposures` per variant, daily `timeseries`, a native chi-squared `sample_ratio_mismatch.p_value` and `bias_risk.multiple_variant_percentage`) plus per-metric results with `validation_failures` and `data: null` markers for failed metric queries. Read the exposure block and validation fields; **skip the per-metric stats** (movement is not your business) — with many metrics the response is heavy. Legacy experiments (`ExperimentTrendsQuery` / `ExperimentFunnelsQuery` metrics) aren't supported by this tool — fall back to the exposure SQL below.
+3. `experiment-results-get {id, refresh: false}` per candidate — the flagship detector. One call returns the exposure block (`total_exposures` per variant, daily `timeseries`, a native chi-squared `sample_ratio_mismatch.p_value` and `bias_risk.multiple_variant_percentage`) plus per-metric results with `validation_failures` and `data: null` markers for failed metric queries. Read the exposure block and validation fields; **skip the per-metric stats** (movement is not your business) — with many metrics the response is heavy. Skip this call and the exposure audit when `experiment-get` shows `is_legacy: true`: a legacy experiment shows no results at all, so report it under lifecycle drift (below).
Drop to `execute-sql` only for diagnosis: dating an onset, per-person fragmentation, custom-exposure drill-downs. **Timezone footgun:** HogQL string timestamp literals parse in the _project_ timezone, not UTC — a UTC `start_date` literal can shift the window by hours and fake a dormant experiment. Use `now() - INTERVAL N DAY` for recency windows.
@@ -103,7 +103,7 @@ Two caveats before trusting a clean p-value:
- It tests against the **current** configured split. If variants were redistributed mid-run, post-edit balance can look clean while pre-edit data is contaminated — check the flag history (below) whenever `feature_flag.version` is high.
- It says nothing about `$multiple` — read `bias_risk.multiple_variant_percentage` as its own check (below).
-When the tool can't serve the experiment (legacy metrics) or you need to date an onset, fall back to the exposure SQL. Read the default exposure event off `experiment-get`'s `resolved_exposure_event` (`$feature_flag_called` or `$experiment_exposure` — resolved server-side, same properties either way). When it is `$feature_flag_called`, also read `$experiment_exposure` (`event IN ('$feature_flag_called', '$experiment_exposure')`), and count persons, not rows:
+When you need to date an onset, fall back to the exposure SQL. Read the default exposure event off `experiment-get`'s `resolved_exposure_event` (`$feature_flag_called` or `$experiment_exposure` — resolved server-side, same properties either way). When it is `$feature_flag_called`, also read `$experiment_exposure` (`event IN ('$feature_flag_called', '$experiment_exposure')`), and count persons, not rows:
```sql
SELECT
@@ -192,7 +192,8 @@ Also `advanced-activity-logs-list {scopes: ["Experiment"], item_ids: [<id>]}` fo
Cheap hygiene pass over the full list — P3 recommendations, not anomalies; bundle them into one finding rather than one per experiment:
-- **Zombie:** running well past its useful life — exposures far above `running_time_calculation.recommended_sample_size` (often the cleaner test; `recommended_running_time` can be 0/absent), or > 60 days with a plateaued exposure curve. The data is as good as it will get; recommend deciding. For high-stakes calls, `experiment-timeseries-results` (needs `metric_uuid` + `fingerprint` from the experiment's `metrics` array) shows whether the primary metric has been stable for weeks — a sustained flat answer strengthens "decide now".
+- **Zombie:** running well past its useful life — exposures far above `running_time_calculation.recommended_sample_size` (often the cleaner test; `recommended_running_time` can be 0/absent), or > 60 days with a plateaued exposure curve. The data is as good as it will get; recommend deciding. For high-stakes calls, `experiment-timeseries-results` (needs `metric_uuid` + `fingerprint` from the experiment's `metrics` array) shows whether the primary metric has been stable for weeks — a sustained flat answer strengthens "decide now". A legacy zombie has no answer to decide on, so it takes the next rule instead.
+- **Legacy:** a running experiment with `is_legacy: true` in `experiment-get` shows no results at all. Recommend migrating it with `experiment-migrate`, or ending it.
- **Stopped but contaminating:** `end_date` set weeks ago, linked flag still `active` with a multivariate split (no variant shipped to 100%). Users still see random variants of a concluded test; recommend ship-variant or flag cleanup.
- **Stale drafts:** drafts untouched > 30 days — lowest priority, mention only in a bundle, never alone.