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(experiment): advice banners #21433

Merged
merged 15 commits into from
Apr 16, 2024
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion frontend/src/scenes/experiments/ExperimentView/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ProgressStatus } from '~/types'
import { StatusTag } from '../Experiment'
import { experimentLogic } from '../experimentLogic'
import { getExperimentStatus } from '../experimentsLogic'
import { ResultsTag } from './components'
import { ActionBanner, ResultsTag } from './components'

export function Info(): JSX.Element {
const { experiment } = useValues(experimentLogic)
Expand Down Expand Up @@ -102,6 +102,7 @@ export function Info(): JSX.Element {
compactButtons
/>
</div>
<ActionBanner />
</div>
)
}
86 changes: 85 additions & 1 deletion frontend/src/scenes/experiments/ExperimentView/components.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../Experiment.scss'

import { LemonButton, LemonDivider, LemonTable, LemonTag, LemonTagType } from '@posthog/lemon-ui'
import { LemonBanner, LemonButton, LemonDivider, LemonTable, LemonTag, LemonTagType, Link } from '@posthog/lemon-ui'
import { Empty } from 'antd'
import { useActions, useValues } from 'kea'
import { AnimationType } from 'lib/animations/animations'
Expand All @@ -10,6 +10,7 @@ import { dayjs } from 'lib/dayjs'
import { More } from 'lib/lemon-ui/LemonButton/More'
import { capitalizeFirstLetter } from 'lib/utils'
import { useEffect, useState } from 'react'
import { urls } from 'scenes/urls'

import { filtersToQueryNode } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'
import { Query } from '~/queries/Query/Query'
Expand Down Expand Up @@ -232,3 +233,86 @@ export function PageHeaderCustom(): JSX.Element {
/>
)
}

export function ActionBanner(): JSX.Element {
const {
experiment,
experimentResults,
experimentLoading,
experimentResultsLoading,
isExperimentRunning,
areResultsSignificant,
isExperimentStopped,
} = useValues(experimentLogic)

if (!experiment || experimentLoading || experimentResultsLoading) {
return <></>
}

// Draft
if (!isExperimentRunning) {
return (
<LemonBanner type="info" className="mt-4">
Your experiment is in draft mode. You can edit your variants, adjust release conditions, and test your{' '}
jurajmajerik marked this conversation as resolved.
Show resolved Hide resolved
<Link className="font-semibold" to="https://posthog.com/docs/experiments/testing-and-launching">
test your feature flag
</Link>
. Once everything works as expected, you can launch your experiment. From that point, any new experiment
events will be counted towards the results.
</LemonBanner>
)
}

// Running, results present, not significant
if (isExperimentRunning && experimentResults && !isExperimentStopped && !areResultsSignificant) {
jurajmajerik marked this conversation as resolved.
Show resolved Hide resolved
return (
<LemonBanner type="info" className="mt-4">
Your experiment is live and is collecting data, but hasn't yet reached the statistical significance
needed to make reliable decisions. It's important to wait for more data to avoid premature conclusions.
</LemonBanner>
)
}

// Running, results significant
if (isExperimentRunning && !isExperimentStopped && areResultsSignificant) {
return (
<LemonBanner type="success" className="mt-4">
Good news! Your experiment has gathered enough data to reach statistical significance, providing
jurajmajerik marked this conversation as resolved.
Show resolved Hide resolved
reliable results for decision making. Before taking any action, review relevant secondary metrics for
any unintended side effects. Once you're done, you can stop the experiment.
</LemonBanner>
)
}

// Stopped, results significant
if (isExperimentStopped && areResultsSignificant) {
return (
<LemonBanner type="success" className="mt-4">
You have stopped this experiment, and it is no longer collecting data. With significant results in hand,
you can now roll out the winning variant to all your users by adjusting the{' '}
<Link
target="_blank"
className="font-semibold"
to={experiment.feature_flag ? urls.featureFlag(experiment.feature_flag.id) : undefined}
>
{experiment.feature_flag?.key}
</Link>{' '}
feature flag.
</LemonBanner>
)
}

// Stopped, results not significant
if (isExperimentStopped && experimentResults && !areResultsSignificant) {
return (
<LemonBanner type="info" className="mt-4">
You have stopped this experiment, and it is no longer collecting data. Because your results are not
significant, we don't recommend drawing any conclusions from them. You can reset the experiment
(deleting the data collected so far) and restart the experiment at any point again. If this experiment
is no longer relevant, you can archive it.
jurajmajerik marked this conversation as resolved.
Show resolved Hide resolved
</LemonBanner>
)
}

return <></>
}
Loading