Skip to content

feat(experimentation): accept inline metrics on experiment creation#7770

Merged
Zaimwa9 merged 4 commits into
mainfrom
feat/experiment-inline-metrics-api
Jun 15, 2026
Merged

feat(experimentation): accept inline metrics on experiment creation#7770
Zaimwa9 merged 4 commits into
mainfrom
feat/experiment-inline-metrics-api

Conversation

@Zaimwa9

@Zaimwa9 Zaimwa9 commented Jun 12, 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

POST /environments/{env_key}/experiments/ now accepts an optional
metrics: [{"metric": <id>, "expected_direction": <choice>}] list, so an experiment
and its metrics are created in a single transaction.

  • Validation mirrors the nested attach endpoint: metrics must belong to the experiment's
    environment, duplicates are rejected, and metrics is rejected on PATCH.
  • Experiment list/retrieve responses now include the attached metrics (read-only),
    prefetched to avoid N+1 queries.
  • The field is optional — existing API consumers are unaffected.

How did you test this code?

  • New 7 tests.

@Zaimwa9 Zaimwa9 requested a review from a team as a code owner June 12, 2026 13:05
@Zaimwa9 Zaimwa9 requested review from khvn26 and removed request for a team June 12, 2026 13:05
@Zaimwa9 Zaimwa9 requested a review from gagantrivedi June 12, 2026 13:05
@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

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

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Jun 15, 2026 8:55am
flagsmith-frontend-preview Ignored Ignored Preview Jun 15, 2026 8:55am
flagsmith-frontend-staging Ignored Ignored Preview Jun 15, 2026 8:55am

Request Review

@github-actions github-actions Bot added api Issue related to the REST API feature New feature or request labels Jun 12, 2026
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

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

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.57%. Comparing base (a65d175) to head (34201ae).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7770   +/-   ##
=======================================
  Coverage   98.56%   98.57%           
=======================================
  Files        1460     1460           
  Lines       56361    56443   +82     
=======================================
+ Hits        55554    55636   +82     
  Misses        807      807           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 12, 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  846e4b0
info  🔄 Run: #17466 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  45.8 seconds
commit  846e4b0
info  🔄 Run: #17466 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  40.5 seconds
commit  846e4b0
info  🔄 Run: #17466 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  41.5 seconds
commit  846e4b0
info  🔄 Run: #17466 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  37.9 seconds
commit  d9e4669
info  🔄 Run: #17468 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  40.8 seconds
commit  d9e4669
info  🔄 Run: #17468 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  33.5 seconds
commit  d9e4669
info  🔄 Run: #17468 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  43 seconds
commit  d9e4669
info  🔄 Run: #17468 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  40.8 seconds
commit  d594844
info  🔄 Run: #17483 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  44.9 seconds
commit  d594844
info  🔄 Run: #17483 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  32.9 seconds
commit  d594844
info  🔄 Run: #17483 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  1 minute, 9 seconds
commit  d594844
info  🔄 Run: #17483 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  39.7 seconds
commit  34201ae
info  🔄 Run: #17486 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  44 seconds
commit  34201ae
info  🔄 Run: #17486 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  34 seconds
commit  34201ae
info  🔄 Run: #17486 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  42 seconds
commit  34201ae
info  🔄 Run: #17486 (attempt 1)

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

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

@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jun 12, 2026
@Zaimwa9 Zaimwa9 removed the request for review from khvn26 June 15, 2026 07:42
…iment-inline-metrics-api

# Conflicts:
#	api/experimentation/serializers.py
#	api/tests/unit/experimentation/test_experiment_views.py
@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 inline creation and validation of metrics within experiments, and adds an option to exclude event stats when listing warehouse connections. Feedback suggests scoping the Metric queryset in the serializer to the current environment to avoid performance issues, and making the 'exclude_event_stats' query parameter check case-insensitive for improved robustness.

Comment thread api/experimentation/serializers.py Outdated
Comment thread api/experimentation/views.py Outdated
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jun 15, 2026
@Zaimwa9 Zaimwa9 merged commit 4c4a992 into main Jun 15, 2026
32 checks passed
@Zaimwa9 Zaimwa9 deleted the feat/experiment-inline-metrics-api branch June 15, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants