-
Notifications
You must be signed in to change notification settings - Fork 7
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: wrap vercel flags #903
Conversation
ajwootto
commented
Jul 23, 2024
•
edited
Loading
edited
- create a helper in Next SDK that wraps the Vercel "flag" function to make it "feature /variation" aware
- when you call the returned wrapped function with a variable key and default value, it figures out from the main config which feature that variable belongs to. It then calls the Vercel "flag" function using the feature as the "key" and obtaining a variation id for that feature
- it also provides "options" for the toolbar which are the list of variations in the feature
- this allows someone using the toolbar to select an override for a feature and its variation, which is then used to alter the values of all the variables in that feature, but the code can continue to use variable keys for evaluation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
@@ -20,3 +22,8 @@ export const { | |||
}, | |||
options: { enableStreaming: false }, | |||
}) | |||
|
|||
export const getFlag = setupDevCycleVercelFlagHelper({ |
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.
Why as a separate import and not a part of setupDevCycle()
?
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.
because it depends on the @vercel/flags
package which I wanted to make an optional dependency. So the idea is that if you want to use it with Vercel, you install their flags package and import this helper from @devcycle/nextjs-sdk/vercel
where it expects the package to be available.
|
||
const getFlag = flag<string | null>({ | ||
key: featureForVariable.key, | ||
defaultValue: null, |
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.
why no default here?
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.
because this is serving the variation of the feature that should be used to obtain the flag value. The default for that should be "no variation" which is interpreted by the code further down as "use the variable's default"
@ajwootto is this PR still valid? |
no |