Skip to content

Commit

Permalink
feat(experiment): add details for "Not significant" (#21596)
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajmajerik authored Apr 17, 2024
1 parent 880fb70 commit 1cc3d5a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
14 changes: 12 additions & 2 deletions frontend/src/scenes/experiments/ExperimentView/components.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '../Experiment.scss'

import { IconCheck, IconX } from '@posthog/icons'
import { LemonBanner, LemonButton, LemonDivider, LemonTag, LemonTagType, Link } from '@posthog/lemon-ui'
import { LemonBanner, LemonButton, LemonDivider, LemonTag, LemonTagType, Link, Tooltip } from '@posthog/lemon-ui'
import { Empty } from 'antd'
import { useActions, useValues } from 'kea'
import { AnimationType } from 'lib/animations/animations'
Expand Down Expand Up @@ -41,11 +41,21 @@ export function VariantTag({ variantKey }: { variantKey: string }): JSX.Element
}

export function ResultsTag(): JSX.Element {
const { areResultsSignificant } = useValues(experimentLogic)
const { areResultsSignificant, significanceDetails } = useValues(experimentLogic)
const result: { color: LemonTagType; label: string } = areResultsSignificant
? { color: 'success', label: 'Significant' }
: { color: 'primary', label: 'Not significant' }

if (significanceDetails) {
return (
<Tooltip title={significanceDetails}>
<LemonTag className="cursor-pointer" type={result.color}>
<b className="uppercase">{result.label}</b>
</LemonTag>
</Tooltip>
)
}

return (
<LemonTag type={result.color}>
<b className="uppercase">{result.label}</b>
Expand Down
27 changes: 27 additions & 0 deletions frontend/src/scenes/experiments/experimentLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ export const experimentLogic = kea<experimentLogicType>([
return experimentResults?.significant || false
},
],
// TODO: remove with the old UI
significanceBannerDetails: [
(s) => [s.experimentResults],
(experimentResults): string | ReactElement => {
Expand Down Expand Up @@ -819,6 +820,32 @@ export const experimentLogic = kea<experimentLogicType>([
return ''
},
],
significanceDetails: [
(s) => [s.experimentResults],
(experimentResults): string => {
if (experimentResults?.significance_code === SignificanceCode.HighLoss) {
return `This is because the expected loss in conversion is greater than 1% (current value is ${(
(experimentResults?.expected_loss || 0) * 100
)?.toFixed(2)}%).`
}

if (experimentResults?.significance_code === SignificanceCode.HighPValue) {
return `This is because the p value is greater than 0.05 (current value is ${
experimentResults?.p_value?.toFixed(3) || 1
}).`
}

if (experimentResults?.significance_code === SignificanceCode.LowWinProbability) {
return 'This is because the win probability of all test variants combined is less than 90%.'
}

if (experimentResults?.significance_code === SignificanceCode.NotEnoughExposure) {
return 'This is because we need at least 100 people per variant to declare significance.'
}

return ''
},
],
recommendedExposureForCountData: [
(s) => [s.minimumDetectableChange],
(mde) =>
Expand Down

0 comments on commit 1cc3d5a

Please sign in to comment.