hi i am using A/B testing with growthbook
i added a feature stroke-care_page
inside this feature i added two Experiment rule
with 50%-50% coverage
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
**expected value ** sometime is work fine
i dont know why growthbook work like this?