0

hi i am using A/B testing with growthbook i added a feature stroke-care_page

enter image description here

inside this feature i added two Experiment rule with 50%-50% coverage enter image description here

In Code in _app.js

const growthbook = new GrowthBook({
  enableDevMode: true,
  trackingCallback: (experiment, result) => {
    console.log(" ~ file: _app.js ~ experiment", experiment)
    console.log(" ~ file: _app.js ~ result", result)
  },
});

useEffect(()=>{
fetchData()
},[])

const fetchData = async () => {
  const machine_id = getMachineId()
    fetch(FEATURES_ENDPOINT)
      .then((res) => res.json())
      .then((json) => {
        growthbook.setFeatures(json.features);
      });

    growthbook.setAttributes({
      id: "user",
      loggedIn: true,
      deviceId: machine_id,
      employee: true,
      company: "ABC",
      browser: navigator.userAgent
    });
}

in page.js

growthbook's hook useFeature() hook to get value of a feature

const feature = useFeature("stroke-care_page");

useEffect(() => { 
 if (feature.source === "experiment") 
 { 
  setGrowthbookContent(feature.value)           
 } 
}, [feature.source])

but sometime feature.source returnning defaultValue

its should return experiment always

and i try to log conosle.log(feature) its value this sometime

enter image description here

**expected value ** sometime is work fine

enter image description here

i dont know why growthbook work like this?

skyboyer
  • 22,209
  • 7
  • 57
  • 64
Vishnu
  • 11
  • 2
  • Not sure what the question is) And it's not clear what is the purpose of the checking feature.source at all. And this source-changing behavior feels expected, because it really uses default values before Growthbook loaded the features\experiments. – Eugene Tusmenko Jun 12 '23 at 09:58
  • hi i am using A/B testing with growthbook and adding a feature with 2 experiments and it will be return one feature base on id but its is not retuning any experiment value... – Vishnu Jun 12 '23 at 10:03
  • @Vishnu This is really not enough to reproduce the issue. Please create a [mcve]. – Yury Tarabanko Jun 12 '23 at 10:09

0 Answers0