@@ -199,8 +199,7 @@ protected void activate(ArgumentsParser argumentsParser, @NonNull Result result)
199199
200200 try {
201201 Variation variation = optimizelyClient .activate (experimentKey , userId , attributes );
202- String variationKey = variation != null ? variation .getKey () : null ;
203- result .success (createResponse (Collections .singletonMap (RequestParameterKey .VARIATION_KEY , variationKey )));
202+ result .success (createResponse (Collections .singletonMap (RequestParameterKey .VARIATION_KEY , variation .getKey ())));
204203 } catch (Exception ex ) {
205204 result .success (createResponse (ex .getMessage ()));
206205 }
@@ -225,8 +224,7 @@ protected void getVariation(ArgumentsParser argumentsParser, @NonNull Result res
225224
226225 try {
227226 Variation variation = optimizelyClient .getVariation (experimentKey , userId , attributes );
228- String variationKey = variation != null ? variation .getKey () : null ;
229- result .success (createResponse (Collections .singletonMap (RequestParameterKey .VARIATION_KEY , variationKey )));
227+ result .success (createResponse (Collections .singletonMap (RequestParameterKey .VARIATION_KEY , variation .getKey ())));
230228 } catch (Exception ex ) {
231229 result .success (createResponse (ex .getMessage ()));
232230 }
@@ -276,9 +274,9 @@ protected void setForcedVariation(ArgumentsParser argumentsParser, @NonNull Resu
276274 }
277275
278276 String variationKey = argumentsParser .getVariationKey ();
279- optimizelyClient .setForcedVariation (experimentKey , userId , variationKey );
277+ Boolean success = optimizelyClient .setForcedVariation (experimentKey , userId , variationKey );
280278
281- result .success (createResponse ());
279+ result .success (createResponse (success ));
282280 }
283281
284282 protected void decide (ArgumentsParser argumentsParser , @ NonNull Result result ) {
@@ -532,10 +530,19 @@ protected void addNotificationListener(ArgumentsParser argumentsParser, @NonNull
532530 case NotificationType .ACTIVATE : {
533531 notificationId = optimizelyClient .getNotificationCenter ().addNotificationHandler (ActivateNotification .class , activateNotification -> {
534532 Map <String , Object > notificationMap = new HashMap <>();
535- notificationMap .put (ActivateListenerKeys .EXPERIMENT_KEY , activateNotification .getExperiment ().getKey ());
533+
534+ Map <String , String > experimentMap = new HashMap <>();
535+ experimentMap .put (ActivateListenerKeys .ID , activateNotification .getExperiment ().getId ());
536+ experimentMap .put (ActivateListenerKeys .KEY , activateNotification .getExperiment ().getKey ());
537+
538+ Map <String , String > variationMap = new HashMap <>();
539+ variationMap .put (ActivateListenerKeys .ID , activateNotification .getVariation ().getId ());
540+ variationMap .put (ActivateListenerKeys .KEY , activateNotification .getVariation ().getKey ());
541+
542+ notificationMap .put (ActivateListenerKeys .EXPERIMENT , experimentMap );
536543 notificationMap .put (ActivateListenerKeys .USER_ID , activateNotification .getUserId ());
537544 notificationMap .put (ActivateListenerKeys .ATTRIBUTES , activateNotification .getAttributes ());
538- notificationMap .put (ActivateListenerKeys .VARIATION_KEY , activateNotification . getVariation (). getKey () );
545+ notificationMap .put (ActivateListenerKeys .VARIATION , variationMap );
539546 invokeNotification (id , NotificationType .ACTIVATE , notificationMap );
540547 });
541548 break ;
@@ -599,6 +606,11 @@ private OptimizelyUserContext getUserContext(ArgumentsParser argumentsParser) {
599606 return response ;
600607 }
601608
609+ // Create response with success, empty reason and null object response
610+ private Map <String , ?> createResponse (Boolean success ) {
611+ return createResponse (success , null , "" );
612+ }
613+
602614 // Create response with empty reason and null object response when success is true
603615 private Map <String , ?> createResponse () {
604616 return createResponse (true , null , "" );
0 commit comments