Expose experiment context_keys in the experiments API
What does this MR do and why?
Exposes each experiment's declared context_keys on the GET /experiments list API, via a new top-level context array on the Experiment entity.
Previously the API serialized the Feature::Definition but not the experiment class's context_keys, so consumers had no way to know which context an experiment expects (user, namespace, project, actor). As a result the Experiment Dashboard could only force/read/clear assignments for the current user. This unblocks it to target arbitrary users/namespaces/projects.
How to set up and validate locally
-
As a GitLab team member (SaaS mode), call:
curl --header "PRIVATE-TOKEN: <token>" \ "http://gdk.test:3000/api/v4/experiments" -
Each item includes a
contextarray — for example"context": ["user"]fornull_hypothesis, and"context": []for experiment flags without a registered class.
References
Closes #607813 (closed)
Related to #591174 (closed)
Related to https://gitlab.com/gitlab-org/growth/experiment-dashboard/-/work_items/5
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.