-
Notifications
You must be signed in to change notification settings - Fork 74
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
feat: strategy variants #482
Conversation
@@ -74,40 +74,56 @@ export default class UnleashClient extends EventEmitter { | |||
feature: FeatureInterface | undefined, | |||
context: Context, | |||
fallback: Function, | |||
): boolean { | |||
): [boolean, VariantDefinition | undefined] { |
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.
in addition to boolean true/false was want to know the actual variant that the strategy resolved to if it was provided.
@@ -169,25 +185,33 @@ export default class UnleashClient extends EventEmitter { | |||
fallbackVariant?: Variant, | |||
): Variant { | |||
const fallback = fallbackVariant || getDefaultVariant(); | |||
if ( | |||
typeof feature === 'undefined' || |
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.
this is too early since variants can be on the strategy
Should should bump SDK compatibility in the future? It will allow us to add warnings if you're using old SDKs with new Variants.
|
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.
Okay wow, that's cool, spec tests pass and all!
Yeah! Needs a spec test before we do that though |
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.
LGTM
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [unleash-client](https://togithub.com/Unleash/unleash-client-node) | [`4.1.0-beta.5` -> `4.1.0`](https://renovatebot.com/diffs/npm/unleash-client/4.1.0-beta.5/4.1.0) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>Unleash/unleash-client-node (unleash-client)</summary> ### [`v4.1.0`](https://togithub.com/Unleash/unleash-client-node/releases/tag/v4.1.0) [Compare Source](https://togithub.com/Unleash/unleash-client-node/compare/v4.1.0-beta.5...v4.1.0) #### What's Changed - feat: strategy variants by [@​kwasniew](https://togithub.com/kwasniew) in [https://github.com/Unleash/unleash-client-node/pull/482](https://togithub.com/Unleash/unleash-client-node/pull/482) - fix: remove unused segment fields by [@​kwasniew](https://togithub.com/kwasniew) in [https://github.com/Unleash/unleash-client-node/pull/489](https://togithub.com/Unleash/unleash-client-node/pull/489) - feat: expose config type by [@​kwasniew](https://togithub.com/kwasniew) in [https://github.com/Unleash/unleash-client-node/pull/491](https://togithub.com/Unleash/unleash-client-node/pull/491) - fix:fetch lib with its deps by [@​kwasniew](https://togithub.com/kwasniew) in [https://github.com/Unleash/unleash-client-node/pull/492](https://togithub.com/Unleash/unleash-client-node/pull/492) - fix: force get variant is back by [@​kwasniew](https://togithub.com/kwasniew) in [https://github.com/Unleash/unleash-client-node/pull/493](https://togithub.com/Unleash/unleash-client-node/pull/493) - refactor: strategy variants inside strategy by [@​kwasniew](https://togithub.com/kwasniew) in [https://github.com/Unleash/unleash-client-node/pull/494](https://togithub.com/Unleash/unleash-client-node/pull/494) - feat: variant on enabled toggle metrics by [@​kwasniew](https://togithub.com/kwasniew) in [https://github.com/Unleash/unleash-client-node/pull/495](https://togithub.com/Unleash/unleash-client-node/pull/495) - chore(deps): update dependency nock to v13.3.2 by [@​renovate](https://togithub.com/renovate) in [https://github.com/Unleash/unleash-client-node/pull/488](https://togithub.com/Unleash/unleash-client-node/pull/488) - chore(deps): update dependency eslint to v8.45.0 by [@​renovate](https://togithub.com/renovate) in [https://github.com/Unleash/unleash-client-node/pull/490](https://togithub.com/Unleash/unleash-client-node/pull/490) - chore(deps): update typescript-eslint monorepo to v5.62.0 by [@​renovate](https://togithub.com/renovate) in [https://github.com/Unleash/unleash-client-node/pull/483](https://togithub.com/Unleash/unleash-client-node/pull/483) - chore(deps): update dependency eslint-config-airbnb-typescript to v17.1.0 by [@​renovate](https://togithub.com/renovate) in [https://github.com/Unleash/unleash-client-node/pull/487](https://togithub.com/Unleash/unleash-client-node/pull/487) - chore(deps): update dependency eslint-plugin-prettier to v5 by [@​renovate](https://togithub.com/renovate) in [https://github.com/Unleash/unleash-client-node/pull/485](https://togithub.com/Unleash/unleash-client-node/pull/485) - feat: version bump non beta by [@​kwasniew](https://togithub.com/kwasniew) in [https://github.com/Unleash/unleash-client-node/pull/496](https://togithub.com/Unleash/unleash-client-node/pull/496) **Full Changelog**: Unleash/unleash-client-node@v4.0.2...v4.1.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/Unleash/unleash). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4yNC4yIiwidXBkYXRlZEluVmVyIjoiMzYuMjQuMiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
About the changes
Adding support for strategy variants.
Background: Unleash supports feature environment variants. This PR adds variants capability per strategy which is more flexible and easier to understand/implement. It makes it possible to use constraints and segments for variants.
How it's implemented?
If a strategy has a corresponding variant param it's used over the feature environment variant.
Important files
Discussion points
I'm thinking if we should have env var or config param to enable this new capability in addition to variant params detection.