-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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: Add weighted mean for retention insights #28302
Changes from all commits
34cc9f5
233f8f9
e1030a5
7155b6e
b100bfd
d96e974
551dbdf
9e66471
b5b4ca0
6eed407
2ac2550
e291ebc
19c51bb
7c24c03
9317a95
d46831b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { LemonSelect } from '@posthog/lemon-ui' | ||
import { useActions, useValues } from 'kea' | ||
import { RETENTION_MEAN_NONE } from 'lib/constants' | ||
import { insightLogic } from 'scenes/insights/insightLogic' | ||
import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic' | ||
|
||
export type RetentionMeanType = 'simple' | 'weighted' | typeof RETENTION_MEAN_NONE | ||
|
||
export function RetentionMeanDropdown(): JSX.Element | null { | ||
const { insightProps, canEditInsight } = useValues(insightLogic) | ||
|
||
const { retentionFilter } = useValues(insightVizDataLogic(insightProps)) | ||
const { updateInsightFilter } = useActions(insightVizDataLogic(insightProps)) | ||
|
||
const showMean = retentionFilter?.showMean || RETENTION_MEAN_NONE | ||
|
||
if (!canEditInsight) { | ||
return null | ||
} | ||
|
||
return ( | ||
<LemonSelect | ||
className="w-44" | ||
size="small" | ||
value={showMean} | ||
onChange={(showMean) => { | ||
updateInsightFilter({ showMean }) | ||
}} | ||
options={[ | ||
{ | ||
value: RETENTION_MEAN_NONE, | ||
labelInMenu: 'No mean calculation', | ||
label: 'No mean calculation', | ||
}, | ||
{ | ||
value: 'simple', | ||
labelInMenu: 'Simple mean', | ||
label: 'Simple mean', | ||
tooltip: | ||
'Calculates the average retention rate across all cohorts by giving equal weight to each cohort, regardless of its size.', | ||
}, | ||
{ | ||
value: 'weighted', | ||
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. Do you think we could add a tooltip here that just describes what this is in slightly more words? Not sure - do you think it's more clear if these modes are called Or do you think the current "Mean" and "weight mean" are more clear? 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 simple mean and weighted mean are more clear. Even if someone doesn't know what a weighted mean is, it's something they can look up. I do think it might be helpful to have a concise tooltip though. Not sure what the copy should be, I'll sleep on it and add this in the AM. |
||
labelInMenu: 'Weighted mean', | ||
label: 'Weighted mean', | ||
tooltip: | ||
'Calculates the average retention rate by giving more weight to larger cohorts, accounting for different cohort sizes in the final mean.', | ||
}, | ||
]} | ||
/> | ||
) | ||
} |
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.
style: consider adding type safety for showMean parameter to ensure it matches RetentionMeanType