Skip to content

Conversation

@jurajmajerik
Copy link
Contributor

@jurajmajerik jurajmajerik commented Nov 20, 2025

Feature flag: experiments-new-calculator

Problem

Our running time calculator sucks isn't great.

Changes

  • Implemented a new calculator that uses existing experiment results as input.
  • It looks at the first primary metric in the list and uses the same methods based on the metric type.
  • It’s almost stateless - no kea logic, just a small local state for MDE, and pure functions for all estimations.

https://www.loom.com/share/96cce3083fa54eb7b3ad782ac0308e00

This is part 1 - automatic calculation based on results, which will be good enough for most users. Part 2 will add the option to calculate sample size using fully manual inputs (an “advanced” mode for experienced users).

How did you test this code?

Added unit tests for the new methods that replicate the kea logic tests of the existing calculator.

@jurajmajerik jurajmajerik requested a review from a team November 20, 2025 20:56
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

Comment on lines 264 to 266
if (!baselineValue) {
return { currentExposures: null, recommendedSampleSize: null, exposureRate: null, estimatedRemainingDays: null }
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: baselineValue of 0 is a valid value (e.g., 0% conversion rate), but here it's treated as falsy and returns null

Suggested change
if (!baselineValue) {
return { currentExposures: null, recommendedSampleSize: null, exposureRate: null, estimatedRemainingDays: null }
}
if (baselineValue === null) {
return { currentExposures: null, recommendedSampleSize: null, exposureRate: null, estimatedRemainingDays: null }
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: frontend/src/scenes/experiments/RunningTimeCalculatorNew/calculations.ts
Line: 264:266

Comment:
**logic:** `baselineValue` of 0 is a valid value (e.g., 0% conversion rate), but here it's treated as falsy and returns null

```suggestion
    if (baselineValue === null) {
        return { currentExposures: null, recommendedSampleSize: null, exposureRate: null, estimatedRemainingDays: null }
    }
```

How can I resolve this? If you propose a fix, please make it concise.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 21, 2025

Size Change: +56 B (0%)

Total Size: 3.43 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 3.43 MB +56 B (0%)

compressed-size-action

Copy link
Contributor

@rodrigoi rodrigoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a much better UX. A list of non-blocking things for now, or the future 😉 :

  • Divisions by zero. This was a problem that plagued the old calculator. I would recommend adding checks and tests to calculations.ts.
  • Modal Logic. Instead of adding to modalsLogic.ts, create a tiny logic to control the modal, like metricSourceModalLogic.tsx. Or search for *ModalLogic.ts in the codebase.
  • Running time logic. For RunningTimeNew.tsx, add logic because you have an effect.

plan-comes-together

jurajmajerik and others added 7 commits November 21, 2025 11:45
…lations.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…lations.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@jurajmajerik jurajmajerik enabled auto-merge (squash) November 21, 2025 11:25
@jurajmajerik jurajmajerik merged commit 28f4e31 into master Nov 21, 2025
136 checks passed
@jurajmajerik jurajmajerik deleted the experiments/new-running-time-calculator branch November 21, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants