square-restaurant-38765
07/17/2023, 12:24 AMJSONObject userAttributesObj = new JSONObject();
userAttributesObj.put("id", userid);
String userAttributesJson = userAttributesObj.toString();
JSONParser parser = new JSONParser();
String featuresJson = ((JSONObject) parser.parse(response.body())).get("features").toString();
GBContext context = GBContext
.builder()
.featuresJson(featuresJson)
.attributesJson(userAttributesJson)
.build();
GrowthBook growthBook = new GrowthBook(context);
Integer value = growthBook.getFeatureValue("discount", 1);
We are setting user and feature attributes and checking the discount value for that unique user.
Question 1 - Is the called running an experiment ?
I checked Growthbook docs online where there was this way of running an inline experiment
Experiment<Float> donutPriceExperiment = Experiment
.<Float>builder()
.conditionJson("{\"employee\": true}")
.build();
ExperimentResult<Float> donutPriceExperimentResult = growthBook.run(donutPriceExperiment);
Float donutPrice = donutPriceExperimentResult.getValue();
This way has a .run() function which runs the experiment.
Question 2 - If this is the way to run the experiment, then what is happening in first way ? What does running an experiment really means ?
Question 3 - The experiment results (i.e each user cohort details) are being saved i believe since thats why same value is being returned for a same user everytime. If yes, isn’t there any way to use the same data for analysis purpose ? Why do we need to explicitly send events to other sources like Segment and then use the Growthbook UI for analysis.fresh-football-47124
square-restaurant-38765
07/17/2023, 10:15 AMfresh-football-47124
square-restaurant-38765
07/18/2023, 7:34 AMGrowthBook growthBook = new GrowthBook(context);
Integer value = growthBook.getFeatureValue("discount", 1);
after this we can just send event with the value we got here !!