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
REST API - Features Create & Update endpoints #1478
Conversation
Deploy preview for docs ready! ✅ Preview Built with commit 468b4d3. |
Your preview environment pr-1478-bttf has been deployed. Preview environment endpoints are available at: |
packages/back-end/src/api/openapi/payload-schemas/PostFeaturePayload.yaml
Outdated
Show resolved
Hide resolved
packages/back-end/src/api/openapi/payload-schemas/PostFeaturePayload.yaml
Outdated
Show resolved
Hide resolved
packages/back-end/src/api/openapi/payload-schemas/postFeature/FeatureRule.yaml
Outdated
Show resolved
Hide resolved
1c2d9df
to
de86f02
Compare
@bttf what is the priority of this item in your backlog ? |
@igorlovich Sorry for the delay. There have been extensive changes to our Features <> Experiments relationships. (And I've also been on vacation.) This is getting attention now. |
@jdorn Following our conversation re: license key checks, the most recent commit makes the following changes so that we always enforce license key checking for both internal API requests and REST API requests.
|
incomingEnvs: ApiFeatureEnvSettings | ||
): FeatureInterface["environmentSettings"] => { | ||
const existing = feature.environmentSettings; | ||
return Object.keys(incomingEnvs).reduce((acc, k) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the feature currently has environmentSettings for both dev
and production
, but the update call only specifies changes for production
? If I'm following the logic right, I think this will delete the existing dev
settings, which we don't want to do. Is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a feature has envSettings for both dev
and production
, and the update only includes production
, it will not override dev
. We use existing
to hold existing envSettings and use that as the initial value for acc
in the reduce fn, so we only overwrite what is supplied by the update. Additionally, if the update only includes the enabled
field for an envSetting (and doesn't specify the rules), we do not erase the rules but include the existing set of rules with the new enabled
value ... Let me know if that makes sense
growthbook/packages/back-end/src/services/features.ts
Lines 998 to 1011 in 66f92e3
return Object.keys(incomingEnvs).reduce((acc, k) => { | |
return { | |
...acc, | |
[k]: { | |
enabled: incomingEnvs[k].enabled ?? existing[k].enabled, | |
rules: incomingEnvs[k].rules | |
? fromApiEnvSettingsRulesToFeatureEnvSettingsRules( | |
feature, | |
incomingEnvs[k].rules | |
) | |
: existing[k].rules, | |
}, | |
}; | |
}, existing); |
@igorlovich This is now live. |
This PR adds two endpoints for Feature Flags
POST /features
(create)POST /features/:id
(update)Changes
PostFeaturePayload.yaml
UpdateFeaturePayload.yaml
postFeature/
subdirectory (necessary due to required fields differing vs. read operation)FeatureEnvironment.yaml
FeatureExperimentRule.yaml
FeatureForceRule.yaml
FeatureRolloutRule.yaml
FeatureRule.yaml
fromApiEnvSettingsRulesToFeatureEnvSettingsRules
createInterfaceEnvSettingsFromApiEnvSettings
updateInterfaceEnvSettingsFromApiEnvSettings
Screenshots
Create
Update