Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(workflows): describe the cohort split warning as relative weights (#97639)

Harley Alexanderc0970aa1342c
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/StepRandomCohortBranch.tsx b/products/workflows/frontend/Workflows/hogflows/steps/StepRandomCohortBranch.tsx
index b7ae9c91b231..feb1d24e1a7c 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/StepRandomCohortBranch.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/steps/StepRandomCohortBranch.tsx
@@ -120,7 +120,6 @@ export function StepRandomCohortBranchConfiguration({
const percentages = cohorts.map((cohort) => cohort.percentage)
const totalPercentage = percentages.reduce((sum, percentage) => sum + percentage, 0)
const isBalanced = cohortPercentagesAddUp(percentages)
- const shortfall = 100 - totalPercentage
return (
<div className="flex flex-col gap-3">
@@ -156,9 +155,7 @@ export function StepRandomCohortBranchConfiguration({
{cohorts.length > 0 && !isBalanced && (
<div className="text-sm text-orange-600">
- {shortfall > 0
- ? `These add up to ${formatPercentage(totalPercentage)}%. The remaining ${formatPercentage(shortfall)}% will go to the last cohort.`
- : `These add up to ${formatPercentage(totalPercentage)}%. Later cohorts will get less than their share, and some may never be used.`}
+ {`These add up to ${formatPercentage(totalPercentage)}%. Traffic is split in proportion to these values, so 10% and 10% sends half to each. To hold back a share of traffic, add a cohort for it.`}
</div>
)}
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/utils.test.ts b/products/workflows/frontend/Workflows/hogflows/steps/utils.test.ts
index d9dc086fd851..148799441a2a 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/utils.test.ts
+++ b/products/workflows/frontend/Workflows/hogflows/steps/utils.test.ts
@@ -256,7 +256,7 @@ describe('utils', () => {
describe('cohortPercentagesAddUp', () => {
// Both directions of this have bitten: comparing against 100 exactly reports the balance
// button's own output as unbalanced, while a tolerance wide enough to cover a hundredth of a
- // percent hides shortfalls the runtime really does reroute to the last cohort.
+ // percent hides totals that really do miss 100.
it.each([2, 3, 7, 8, 30, 99])('accepts the even split produced for %i cohorts', (count) => {
expect(cohortPercentagesAddUp(normalizeCohortPercentages(count))).toBe(true)
})
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/utils.ts b/products/workflows/frontend/Workflows/hogflows/steps/utils.ts
index 83b8c6bbed0d..a74beebe289c 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/utils.ts
+++ b/products/workflows/frontend/Workflows/hogflows/steps/utils.ts
@@ -53,11 +53,9 @@ export function removeBranchEdge(branchEdges: HogFlowEdge[], conditionIndex: num
* Percentages for an even N-way cohort split, summing to exactly 100.
*
* Shares are allocated in hundredths of a percent rather than whole percents, because whole percents
- * can't divide 100 evenly for most counts and the runtime routes any shortfall to the last cohort
- * (see getRandomCohort). Allocating in whole percents therefore gave 30 cohorts ten shares of 4% and
- * twenty of 3%, so a third of the branches carried 33% more than the rest. The leftover hundredths
- * are spread one each across the leading cohorts, which keeps every share within 0.01 of its fair
- * value.
+ * can't divide 100 evenly for most counts, and a total that misses 100 trips the editor's warning
+ * even though the runtime splits by relative weight. The leftover hundredths are spread one each
+ * across the leading cohorts, which keeps every share within 0.01 of its fair value.
*/
export function normalizeCohortPercentages(count: number): number[] {
if (count <= 0) {