: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { Meta, StoryObj } from '@storybook/react'
import { makeDelay } from 'lib/utils/async'
import { mswDecorator } from '~/mocks/browser'
import EXPERIMENT_FREQUENTIST_FIVE_VARIANTS from '~/mocks/fixtures/api/experiments/experiment_frequentist_five_variants.json'
import FUNNEL_METRIC_RESULT from '~/mocks/fixtures/api/experiments/experiment_frequentist_five_variants_funnel_metric_result.json'
import MEAN_METRIC_RESULT from '~/mocks/fixtures/api/experiments/experiment_frequentist_five_variants_mean_metric_result.json'
import EXPOSURE_QUERY_RESULT from '~/mocks/fixtures/api/experiments/exposure_query_result.json'
import { NodeKind } from '~/queries/schema/schema-general'
import { App } from '~/scenes/App'
import { urls } from '~/scenes/urls'
import { recalculationMocks, resultsByMetricType } from './recalculationMocks'
const RECALCULATION = recalculationMocks(
EXPERIMENT_FREQUENTIST_FIVE_VARIANTS,
resultsByMetricType(EXPERIMENT_FREQUENTIST_FIVE_VARIANTS, {
mean: MEAN_METRIC_RESULT,
funnel: FUNNEL_METRIC_RESULT,
})
)
const meta: Meta = {
component: App,
title: 'Scenes-App/Experiments',
parameters: {
layout: 'fullscreen',
viewMode: 'story',
mockDate: '2025-01-27',
pageUrl: urls.experiment(EXPERIMENT_FREQUENTIST_FIVE_VARIANTS.id),
},
decorators: [
mswDecorator({
get: {
...RECALCULATION.get,
[`/api/projects/:team_id/experiments/${EXPERIMENT_FREQUENTIST_FIVE_VARIANTS.id}/`]:
EXPERIMENT_FREQUENTIST_FIVE_VARIANTS,
[`/api/projects/:team_id/experiment_holdouts`]: [],
[`/api/projects/:team_id/experiment_saved_metrics/`]: [],
[`/api/projects/:team_id/feature_flags/${EXPERIMENT_FREQUENTIST_FIVE_VARIANTS.feature_flag.id}/`]: {},
[`/api/projects/:team_id/feature_flags/${EXPERIMENT_FREQUENTIST_FIVE_VARIANTS.feature_flag.id}/status/`]:
{},
[`/api/environments/:team_id/default_release_conditions/`]: [],
},
post: {
...RECALCULATION.post,
// Exposures still load through experimentLogic; metric results come from the recalculation run.
'/api/environments/:team_id/query/:kind': async ({ request }) => {
const body = (await request.json()) as Record<string, any>
return body.query.kind === NodeKind.ExperimentExposureQuery ? [200, EXPOSURE_QUERY_RESULT] : [404]
},
},
}),
],
}
export default meta
type Story = StoryObj<{}>
// Small delay to ensure charts render completely
export const ExperimentFrequentistFiveVariants: Story = { play: makeDelay(500) }