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
Allow variant to be overridden from URL fragment #4127
Conversation
@@ -34,6 +36,12 @@ export function allocateVariant(win, experimentName, config) { | |||
assertName(experimentName); | |||
validateConfig(config); | |||
|
|||
// Variant can be overridden from URL fragment. | |||
const override = viewerFor(win).getParam(ATTR_PREFIX + experimentName); | |||
if (override && config.variants.hasOwnProperty(override)) { |
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.
For stronger safety, I suggest doing this in getVariantOverride_()
so invalid values never make it to the overrides map to start with.
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.
Sorry, I don't quite understand. Are you suggesting to extract a method named getVariantOverride_()
? Why would that be safer?
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.
sorry this comment was based on the code in #4079. I see that PR is closed. This is fine, ignore my previous comment.
Comment addressed. PTAL |
LGTM. |
#1411
A re-try to address comments in #4079