-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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(experiments): holdout groups UI #25772
Changes from 17 commits
af17ad1
c003b75
90626b9
3fd49d1
27b0e90
5a5850d
ccbe969
8828df8
3ce742e
e6b7b88
fc5d0ce
adeba07
67b14a1
336b1b6
1850c15
3b37e8b
94508b7
020d24f
e5bf641
81d2600
23f406c
145915f
8b0ca4a
a2802a9
fb86847
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { IconInfo } from '@posthog/icons' | ||
import { LemonSelect, Tooltip } from '@posthog/lemon-ui' | ||
import { useActions, useValues } from 'kea' | ||
|
||
import { experimentLogic } from '../experimentLogic' | ||
|
||
export function HoldoutSelector(): JSX.Element { | ||
const { experiment, holdouts, isExperimentRunning } = useValues(experimentLogic) | ||
const { setExperiment, updateExperiment } = useActions(experimentLogic) | ||
|
||
const holdoutOptions = holdouts.map((holdout) => ({ | ||
value: holdout.id, | ||
label: holdout.name, | ||
})) | ||
holdoutOptions.unshift({ value: null, label: 'No holdout' }) | ||
|
||
return ( | ||
<div className="mt-3"> | ||
<div className="inline-flex space-x-1"> | ||
<h4 className="font-semibold mb-0">Holdout group</h4> | ||
<Tooltip title="Exclude a stable group of users from the experiment. This cannot be changed once the experiment is launched."> | ||
<IconInfo className="text-muted-alt text-base" /> | ||
</Tooltip> | ||
</div> | ||
<div className="mt-1"> | ||
<LemonSelect | ||
disabledReason={ | ||
isExperimentRunning && | ||
!experiment.end_date && | ||
'The holdout group cannot be changed once the experiment is launched.' | ||
} | ||
size="xsmall" | ||
options={holdoutOptions} | ||
value={experiment.holdout || null} | ||
onChange={(value) => { | ||
setExperiment({ | ||
...experiment, | ||
holdout: value, | ||
}) | ||
updateExperiment({ holdout: value }) | ||
}} | ||
data-attr="experiment-holdout-selector" | ||
/> | ||
</div> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,8 +52,23 @@ export function VariantTag({ | |
}): JSX.Element { | ||
const { experimentResults, getIndexForVariant } = useValues(experimentLogic({ experimentId })) | ||
|
||
if (variantKey.startsWith('holdout-')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i guess we should disable user created variants starting with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this check should be good enough for now: https://github.com/PostHog/posthog/pull/25772/files#diff-ac20870bd5fba7ae95bc9fde57e9108900e26f210382221cc1466059172748f3R55 Can add validation later if we run into issues |
||
return ( | ||
<span className="flex items-center space-x-2"> | ||
<div | ||
className="w-2 h-2 rounded-full mr-0.5" | ||
// eslint-disable-next-line react/forbid-dom-props | ||
style={{ | ||
backgroundColor: getExperimentInsightColour(getIndexForVariant(experimentResults, variantKey)), | ||
}} | ||
/> | ||
<LemonTag type="option">{variantKey}</LemonTag> | ||
</span> | ||
) | ||
} | ||
|
||
return ( | ||
<span className="flex items-center space-x-1"> | ||
<span className="flex items-center space-x-2"> | ||
<div | ||
className="w-2 h-2 rounded-full mr-0.5" | ||
// eslint-disable-next-line react/forbid-dom-props | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't this be the entire
holdout
object?