8000 feat(experiments): frequentist UI metric duplication by jurajmajerik · Pull Request #33631 · PostHog/posthog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(experiments): frequentist UI metric duplication #33631

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

Merged
merged 3 commits into from
Jun 13, 2025

Conversation

jurajmajerik
Copy link
Contributor

Changes

Added metric duplication in the new metrics UI.

As part of this, I'm proposing a refactor of where the duplication method lives. I think this method belongs in the Kea logic, since it operates directly on the logic value. Keeping it centralized helps keep things clean (while I’m still open to splitting experimentLogic into smaller logics). Happy to hear your thoughts @rodrigoi

How did you test this code?

👀

@jurajmajerik jurajmajerik requested a review from a team June 12, 2025 18:34
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.

PR Summary

Refactored metric duplication in experiments to centralize logic within Kea state management, moving away from utility functions to action-based duplication.

  • Moved duplicateMetric from utility function in DeltaChart.tsx to action in experimentLogic.tsx for better state management
  • Added duplication support in new metrics UI through MetricRow.tsx component
  • Simplified duplication interface to only require metricIndex and isSecondary parameters
  • Implemented proper naming for duplicated metrics, appending '(copy)' while handling unnamed metrics correctly

This follows single responsibility principle by centralizing metric duplication logic.

3 files reviewed, no comments
Edit PR Review Bot Settings | Greptile

Comment on lines +685 to +686
: originalMetric.kind === NodeKind.ExperimentMetric
? `${getDefaultMetricTitle(originalMetric)} (copy)`
Copy link
Contributor

Choose a reason for hiding this comment

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

The NodeKind enum is referenced in the duplicateMetric reducer but is missing an import. It was previously imported in DeltaChart.tsx but needs to be added to experimentLogic.tsx now that the duplication logic has been moved. Please add:

import { NodeKind } from '~/queries/schema/schema-general'

to the imports in experimentLogic.tsx to resolve this reference.

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor
github-actions bot commented Jun 12, 2025

Size Change: -2.54 kB (-0.14%)

Total Size: 1.83 MB

Filename Size Change
frontend/dist/toolbar.js 1.83 MB -2.54 kB (-0.14%)

compressed-size-action

@rodrigoi
Copy link
Contributor
Me dusting off my Redux knowledge
paul-mccartney-book-small

Keeping it centralized helps keep things clean (while I’m still open to splitting experimentLogic into smaller logics)

Not opposed to the move. I'm just hesitant to add more code to a module with 2000+ lines of code. The Experiment object is a complex type, with multiple JSON props that go nested to many levels. In traditional Redux, you'll probably have smaller, domain-specific actions/reducers/selectors (like a metric reducer, or a parameters reducer).

We could explore options to compose logic from these domain-specific logics, and metrics would probably be a good candidate to explore composition, maybe with a resultsLogic next.

One thing I would remove from the global state is all the modal booleans. The boilerplate is just not justifiable for how cheap a userState is inside a button.

Copy link
Contributor
@andehen andehen left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

I don't have a strong opinion in this specific case, the function is only used here. But I do like that we move towards simpler logic files, and move out logic to pure functions where it makes sense. It does make the logic files easier to read and work with.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@jurajmajerik jurajmajerik enabled auto-merge (squash) June 13, 2025 09:24
@jurajmajerik jurajmajerik merged commit 4dd5a56 into master Jun 13, 2025
100 checks passed
@jurajmajerik jurajmajerik deleted the experiments/frequentist-duplicate-metric branch June 13, 2025 10:09
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.

4 participants
0