Skip to content

feat(experiments): attach a primary metric in the create experiment wizard#7780

Open
Zaimwa9 wants to merge 14 commits into
mainfrom
feat/experiment-wizard-primary-metric
Open

feat(experiments): attach a primary metric in the create experiment wizard#7780
Zaimwa9 wants to merge 14 commits into
mainfrom
feat/experiment-wizard-primary-metric

Conversation

@Zaimwa9

@Zaimwa9 Zaimwa9 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Wires up the Measurement step of the Create Experiment wizard so a primary metric can be attached when creating an experiment.

  • Select one existing metric (paginated list of 5 + search), or create a new metric inline via a centred modal without leaving the wizard.
  • Pick the expected direction, prefilled from the metric's own direction.
  • The metric is required to launch; it's sent inline in the create payload (backend support landed in feat(experimentation): accept inline metrics on experiment creation #7770).
  • Review step summarises the attached metric and chosen direction, and the experiments list shows the attached primary metric.

How did you test this code?

Manually, against a local API + warehouse:

  1. Open Experiments → Create experiment, complete Setup.
  2. On Measurement, search/select a metric (add >5 to see paging), confirm the Primary badge and direction prefill.
  3. Use Create Metric to add one inline; confirm it auto-selects.
  4. Launch and verify the experiment is created with the metric attached, and that it appears in the experiments list's Primary Metric column.
  5. Confirm launch is blocked until a metric + direction are chosen.

Plus npm run typecheck and eslint on the touched files.

@Zaimwa9 Zaimwa9 requested a review from a team as a code owner June 15, 2026 09:42
@Zaimwa9 Zaimwa9 requested review from gagantrivedi and talissoncosta and removed request for a team June 15, 2026 09:42
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview, Comment Jun 15, 2026 11:57am
flagsmith-frontend-staging Ready Ready Preview, Comment Jun 15, 2026 11:57am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Jun 15, 2026 11:57am

Request Review

@github-actions github-actions Bot added front-end Issue related to the React Front End Dashboard feature New feature or request labels Jun 15, 2026
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-7780 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-7780 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-7780 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-7780 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-7780 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-7780 Finished ✅ Results

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  33.1 seconds
commit  483b171
info  🔄 Run: #17490 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  19 passed

Details

stats  19 tests across 15 suites
duration  1 minute, 9 seconds
commit  483b171
info  🔄 Run: #17490 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  44.1 seconds
commit  483b171
info  🔄 Run: #17490 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  55.1 seconds
commit  483b171
info  🔄 Run: #17490 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  32.9 seconds
commit  ccdbdd3
info  🔄 Run: #17493 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  44.1 seconds
commit  ccdbdd3
info  🔄 Run: #17493 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  1 minute, 13 seconds
commit  ccdbdd3
info  🔄 Run: #17493 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  54.7 seconds
commit  ccdbdd3
info  🔄 Run: #17493 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  32.9 seconds
commit  1a41e93
info  🔄 Run: #17495 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  45.1 seconds
commit  1a41e93
info  🔄 Run: #17495 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  45.7 seconds
commit  1a41e93
info  🔄 Run: #17495 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  43.5 seconds
commit  1a41e93
info  🔄 Run: #17495 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  33.9 seconds
commit  0a4b592
info  🔄 Run: #17497 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  43.1 seconds
commit  0a4b592
info  🔄 Run: #17497 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  35.6 seconds
commit  0a4b592
info  🔄 Run: #17497 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  1 minute, 8 seconds
commit  0a4b592
info  🔄 Run: #17497 (attempt 1)

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

@Zaimwa9

Zaimwa9 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new CenteredModal component, enhances SelectableCard and ContentCard with additional layout options, and integrates a measurement step into the experiment creation wizard to allow selecting a primary metric and its expected direction. It also optimizes warehouse connection queries by adding an option to exclude event stats and prevents selecting feature flags already associated with active experiments. The review feedback highlights critical issues, including a mismatch in cache keys during pessimistic updates, a loading state (isEnabling) that gets stuck on successful warehouse connection creation, a hardcoded page size limit of 100 when checking for active experiments, and a potential runtime crash due to a missing defensive check on experiment.feature.

Comment thread frontend/common/services/useWarehouseConnection.ts Outdated
Comment on lines +53 to +56
const { data: experimentsData } = useGetExperimentsQuery(
{ environmentId, page: 1, page_size: 100 },
{ skip: !environmentId },
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The query for experiments is hardcoded with page_size: 100. If an environment has more than 100 experiments, active experiments beyond the first page will be excluded from the results, allowing users to select a feature flag that is already associated with an active experiment. Consider fetching all active experiments or implementing this validation on the backend.

@Zaimwa9 Zaimwa9 Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

true but theoritcal, for now deferred

Comment thread frontend/web/components/experiments/steps/SetupStep.tsx
@Zaimwa9

Zaimwa9 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ability to select a primary metric and define its expected direction during the experiment creation wizard. It also adds a reusable CenteredModal component, updates UI cards (SelectableCard and ContentCard) to support tags and descriptions, and prevents users from selecting feature flags that are already associated with active experiments. The review feedback highlights three key issues: the need to validate the final Review step in the wizard to disable the launch button when previous steps are invalid, fixing a state desynchronization issue when clearing the expected direction dropdown, and increasing the hardcoded page size when querying existing experiments to avoid missing active flags.

Comment thread frontend/web/components/experiments/CreateExperimentWizard.tsx
Comment thread frontend/web/components/experiments/steps/MeasurementStep.tsx
Comment thread frontend/web/components/experiments/steps/SetupStep.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants