javascript-sdk icon indicating copy to clipboard operation
javascript-sdk copied to clipboard

Expose usable method(s) to grab the user's variation for a feature test

Open DDChiang opened this issue 5 years ago • 1 comments

How would the enhancement work?

This is an idea proposal for exposing a getVariationForFeature-like method (s) directly on the optimizelyClientInstance so developers can quickly figure out and directly reference the variation the user is bucketed in for a Optimizely Fullstack feature test. Currently we must use a hack of seeing whether a feature is enabled for a user (via .isFeatureEnabled()) and what feature variables we set to differentiate between multiple different feature test variants (via .getFeatureVariableBoolean or getFeatureVariableString).

Similar to how the sdk has already exposed a method we can use to grab an AB experiment's variation, there'll probably be 2 separate methods that will:

  1. trigger/log the impression back to Optimizely and also return the variation
  2. only return the variation (won't create an impression)

-- Side note: I noticed in this codebase line referencing optimizelyInstance.getVariationForFeature that there already is a way to grab the feature test but it's not exposed as a method we can directly call off the Optimizely client instance.

When would the enhancement be useful?

Next release if possible! We have more feature tests coming in where it would be helpful to be able to directly reference a feature test variant in code, rather than "guess" the variant with more complicated code.

@optimizely/optimizely-sdk version: 3.5.0 (pretty much all current versions)

DDChiang avatar Mar 12 '20 00:03 DDChiang

@DDChiang, Do you still need this enhancement request? If so, I'll move it to our feature request/management system.

Thanks.

mikechu-optimizely avatar Aug 24 '23 14:08 mikechu-optimizely

Closing as inactive. Please reopen if needed.

raju-opti avatar Jul 02 '24 12:07 raju-opti