victorious-library-28522
10/30/2023, 7:07 AMconst growthbook = new GrowthBook({
apiHost: '<https://cdn.growthbook.io>',
clientKey: growthbookClientKey,
trackingCallback: (experiment, result) => {
ajaxPromise({
url: '/api/google-analytic/send-rd-event',
type: 'POST',
data: {
category: eventCategory.AB_TEST,
action: eventAction.EXPERIMENT_VIEWED,
label: experiment.key,
value: result.variationId,
},
});
},
});
And here is how i use the feature:
const feature_value = useFeatureValue(
AB_TEST_EXPERIMENTS.EDPRESSO_AA_TEST_ID,
'fallback',
);
React.useEffect(() => {
const loadFeatures = async () => {
await growthbook?.loadFeatures({
autoRefresh: true,
timeout: 2000,
});
};
try {
loadFeatures();
} catch (error) {
sendErrorEvent(error);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Note: I am using the react sdkrhythmic-agent-34208
10/30/2023, 7:07 AMfresh-football-47124
victorious-library-28522
10/31/2023, 6:40 AMrhythmic-agent-34208
11/01/2023, 8:14 PM