Hello, We are implementing growthbook with nuxtjs....
# announcements
l
Hello, We are implementing growthbook with nuxtjs. We encounter problem of how to switch between variations. It seems that
growthbook.forceVariation
does not work. Is there some other way to force variation? When initializing the feature information is:
Copy code
{
  "value": true,
  "on": true,
  "off": false,
  "source": "experiment",
  "ruleId": "",
  "experiment": {
    "variations": [
      true,
      false
    ],
    "key": "webtest-feature",
    "weights": [
      0.5,
      0.5
    ],
    "hashAttribute": "session_id"
  },
  "experimentResult": {
    "inExperiment": true,
    "variationId": 0,
    "value": true,
    "hashAttribute": "session_id",
    "hashValue": "45274132-7196-4e23-8f8c-ceece9fc9d16"
  }
}
After
growthbook.forceVariation('webtest-feature', 1)
it seems to be:
Copy code
{
  "value": true,
  "on": true,
  "off": false,
  "source": "defaultValue",
  "ruleId": ""
}
f
The
forceVariation
method doesn't work for experiments run through feature flags. As soon as you force a variation, you are no longer "included" in the experiment and the rule will be skipped. There is the
setForcedFeatures
method instead which lets you directly override the value of a feature.
Copy code
growthbook.setForcedFeatures(new Map([
  ['webtest-feature', false]
]))
I can see how this is super confusing though. I think we can change it so that
forceVariation
does work for features, which should be more intuitive
l
Thanks, would make sense! Also, note in documentation would be helpful 😉