-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(experiments): secondary metrics table (#21164)
- Loading branch information
1 parent
92e17ce
commit db30fef
Showing
13 changed files
with
422 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
frontend/src/scenes/experiments/ExperimentView/NoResultsEmptyState.tsx
This file was deleted.
Oops, something went wrong.
106 changes: 49 additions & 57 deletions
106
frontend/src/scenes/experiments/ExperimentView/Overview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,87 @@ | ||
import '../Experiment.scss' | ||
|
||
import { LemonDivider } from '@posthog/lemon-ui' | ||
import { useValues } from 'kea' | ||
import { getSeriesColor } from 'lib/colors' | ||
import { capitalizeFirstLetter } from 'lib/utils' | ||
|
||
import { InsightType } from '~/types' | ||
|
||
import { experimentLogic } from '../experimentLogic' | ||
import { VariantTag } from './components' | ||
|
||
export function Overview(): JSX.Element { | ||
const { | ||
experimentResults, | ||
getIndexForVariant, | ||
experimentInsightType, | ||
sortedConversionRates, | ||
highestProbabilityVariant, | ||
getHighestProbabilityVariant, | ||
areResultsSignificant, | ||
conversionRateForVariant, | ||
} = useValues(experimentLogic) | ||
|
||
function SignificanceText(): JSX.Element { | ||
return ( | ||
<> | ||
<span>Your results are </span> | ||
<span className="font-semibold">{`${areResultsSignificant ? 'significant' : 'not significant'}`}.</span> | ||
</> | ||
) | ||
} | ||
function WinningVariantText(): JSX.Element { | ||
const winningVariant = getHighestProbabilityVariant(experimentResults) | ||
|
||
if (experimentInsightType === InsightType.FUNNELS) { | ||
const winningVariant = sortedConversionRates[0] | ||
const secondBestVariant = sortedConversionRates[1] | ||
const difference = winningVariant.conversionRate - secondBestVariant.conversionRate | ||
if (experimentInsightType === InsightType.FUNNELS) { | ||
const winningConversionRate = conversionRateForVariant(experimentResults, winningVariant || '') | ||
const controlConversionRate = conversionRateForVariant(experimentResults, 'control') | ||
const difference = parseFloat(winningConversionRate) - parseFloat(controlConversionRate) | ||
|
||
return ( | ||
<div> | ||
<h2 className="font-semibold text-lg">Summary</h2> | ||
if (difference === 0) { | ||
return ( | ||
<span> | ||
<b>No variant is winning</b> at this moment. | ||
</span> | ||
) | ||
} | ||
|
||
return ( | ||
<div className="items-center inline-flex flex-wrap"> | ||
<div | ||
className="w-2 h-2 rounded-full mr-1" | ||
// eslint-disable-next-line react/forbid-dom-props | ||
style={{ backgroundColor: getSeriesColor(winningVariant.index + 1) }} | ||
/> | ||
<span className="font-semibold">{capitalizeFirstLetter(winningVariant.key)}</span> | ||
<VariantTag variantKey={winningVariant || ''} /> | ||
<span> is winning with a conversion rate </span> | ||
<span className="font-semibold text-success items-center"> | ||
increase of {`${difference.toFixed(2)}%`} | ||
</span> | ||
<span> percentage points (vs </span> | ||
<div | ||
className="w-2 h-2 rounded-full mr-1" | ||
// eslint-disable-next-line react/forbid-dom-props | ||
style={{ | ||
backgroundColor: getSeriesColor(secondBestVariant.index + 1), | ||
}} | ||
/> | ||
<span className="font-semibold">{capitalizeFirstLetter(secondBestVariant.key)}</span> | ||
<VariantTag variantKey="control" /> | ||
<span>). </span> | ||
<SignificanceText /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
) | ||
} | ||
|
||
const index = getIndexForVariant(experimentResults, highestProbabilityVariant || '') | ||
if (highestProbabilityVariant && index !== null && experimentResults) { | ||
const { probability } = experimentResults | ||
const index = getIndexForVariant(experimentResults, winningVariant || '') | ||
if (winningVariant && index !== null && experimentResults) { | ||
const { probability } = experimentResults | ||
|
||
return ( | ||
<div> | ||
<h2 className="font-semibold text-lg">Overview</h2> | ||
<LemonDivider /> | ||
<div className="items-center inline-flex"> | ||
<div | ||
className="w-2 h-2 rounded-full mr-1" | ||
// eslint-disable-next-line react/forbid-dom-props | ||
style={{ | ||
backgroundColor: getSeriesColor(index + 2), | ||
}} | ||
/> | ||
<span className="font-semibold">{capitalizeFirstLetter(highestProbabilityVariant)}</span> | ||
return ( | ||
<div className="items-center inline-flex flex-wrap"> | ||
<VariantTag variantKey={winningVariant} /> | ||
<span> is winning with a </span> | ||
<span className="font-semibold text-success items-center"> | ||
{`${(probability[highestProbabilityVariant] * 100).toFixed(2)}% probability`} | ||
{`${(probability[winningVariant] * 100).toFixed(2)}% probability`} | ||
</span> | ||
<span>of being best. </span> | ||
<SignificanceText /> | ||
</div> | ||
) | ||
} | ||
|
||
return <></> | ||
} | ||
|
||
function SignificanceText(): JSX.Element { | ||
return ( | ||
<div className="flex-wrap"> | ||
<span>Your results are </span> | ||
<span className="font-semibold">{`${areResultsSignificant ? 'significant' : 'not significant'}`}.</span> | ||
</div> | ||
) | ||
} | ||
|
||
return <></> | ||
return ( | ||
<div> | ||
<h2 className="font-semibold text-lg">Summary</h2> | ||
<div className="items-center inline-flex flex-wrap"> | ||
<WinningVariantText /> | ||
<SignificanceText /> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.