@@ -64,7 +64,6 @@ public class LaunchdarklyReactNativeClientModule extends ReactContextBaseJavaMod
6464 * option, see @see ConfigEntryType for more. The internal setter is a String name of the setter
6565 * method used to pass the parsed configuration value into a LDConfig builder used for LDClient
6666 * setup.
67- * </p>
6867 */
6968 enum ConfigMapping {
7069 CONFIG_MOBILE_KEY ("mobileKey" , ConfigEntryType .String , "setMobileKey" ),
@@ -80,7 +79,8 @@ enum ConfigMapping {
8079 CONFIG_STREAM ("stream" , ConfigEntryType .Boolean , "setStream" ),
8180 CONFIG_DISABLE_BACKGROUND_UPDATING ("disableBackgroundUpdating" , ConfigEntryType .Boolean , "setDisableBackgroundUpdating" ),
8281 CONFIG_OFFLINE ("offline" , ConfigEntryType .Boolean , "setOffline" ),
83- CONFIG_PRIVATE_ATTRIBUTES ("privateAttributeNames" , ConfigEntryType .StringSet , "setPrivateAttributeNames" );
82+ CONFIG_PRIVATE_ATTRIBUTES ("privateAttributeNames" , ConfigEntryType .StringSet , "setPrivateAttributeNames" ),
83+ CONFIG_EVALUATION_REASONS ("evaluationReasons" , ConfigEntryType .Boolean , "setEvaluationReasons" );
8484
8585 final String key ;
8686 final ConfigEntryType type ;
@@ -115,7 +115,6 @@ void loadFromMap(ReadableMap map, LDConfig.Builder builder) {
115115 * ReadableMap as well as any additional conversion needed before setting the internal LDUser
116116 * option, @see ConfigEntryType for more. The internal setter is a String name of the setter
117117 * method used to pass the parsed configuration value into a LDUser builder.
118- * </p>
119118 */
120119 enum UserConfigMapping {
121120 USER_ANONYMOUS ("anonymous" , ConfigEntryType .Boolean , "anonymous" , null ),
@@ -164,6 +163,8 @@ void loadFromMap(ReadableMap map, LDUser.Builder builder, Set<String> privateAtt
164163 private Map <String , LDStatusListener > connectionModeListeners = new HashMap <>();
165164 private Map <String , LDAllFlagsListener > allFlagsListeners = new HashMap <>();
166165
166+ private static Gson gson = new Gson ();
167+
167168 public LaunchdarklyReactNativeClientModule (ReactApplicationContext reactContext ) {
168169 super (reactContext );
169170 }
@@ -267,7 +268,6 @@ public void run() {
267268 *
268269 * <p>
269270 * This will look for all configuration values specified in {@link ConfigMapping}.
270- * </p>
271271 *
272272 * @param options A ReadableMap of configuration options
273273 * @return A LDConfig.Builder configured with options
@@ -287,7 +287,6 @@ private LDConfig.Builder configBuild(ReadableMap options) {
287287 *
288288 * <p>
289289 * This will look for all configuration values specified in {@link UserConfigMapping}.
290- * </p>
291290 *
292291 * @param options A ReadableMap of configuration options
293292 * @return A LDUser.Builder configured with options
@@ -567,7 +566,10 @@ public void boolVariationDetail(String flagKey, Promise promise) {
567566 @ ReactMethod
568567 public void boolVariationDetailFallback (String flagKey , Boolean fallback , Promise promise ) {
569568 try {
570- promise .resolve (ldClient .boolVariationDetail (flagKey , fallback ));
569+ EvaluationDetail <Boolean > detailResult = ldClient .boolVariationDetail (flagKey , fallback );
570+ JsonObject jsonObject = gson .toJsonTree (detailResult ).getAsJsonObject ();
571+ WritableMap detailMap = fromJsonObject (jsonObject );
572+ promise .resolve (detailMap );
571573 } catch (Exception e ) {
572574 promise .resolve (fallback );
573575 }
@@ -581,7 +583,10 @@ public void intVariationDetail(String flagKey, Promise promise) {
581583 @ ReactMethod
582584 public void intVariationDetailFallback (String flagKey , Integer fallback , Promise promise ) {
583585 try {
584- promise .resolve (ldClient .intVariationDetail (flagKey , fallback ));
586+ EvaluationDetail <Integer > detailResult = ldClient .intVariationDetail (flagKey , fallback );
587+ JsonObject jsonObject = gson .toJsonTree (detailResult ).getAsJsonObject ();
588+ WritableMap detailMap = fromJsonObject (jsonObject );
589+ promise .resolve (detailMap );
585590 } catch (Exception e ) {
586591 promise .resolve (fallback );
587592 }
@@ -595,7 +600,10 @@ public void floatVariationDetail(String flagKey, Promise promise) {
595600 @ ReactMethod
596601 public void floatVariationDetailFallback (String flagKey , Float fallback , Promise promise ) {
597602 try {
598- promise .resolve (ldClient .floatVariationDetail (flagKey , fallback ));
603+ EvaluationDetail <Float > detailResult = ldClient .floatVariationDetail (flagKey , fallback );
604+ JsonObject jsonObject = gson .toJsonTree (detailResult ).getAsJsonObject ();
605+ WritableMap detailMap = fromJsonObject (jsonObject );
606+ promise .resolve (detailMap );
599607 } catch (Exception e ) {
600608 promise .resolve (fallback );
601609 }
@@ -609,7 +617,10 @@ public void stringVariationDetail(String flagKey, Promise promise) {
609617 @ ReactMethod
610618 public void stringVariationDetailFallback (String flagKey , String fallback , Promise promise ) {
611619 try {
612- promise .resolve (ldClient .stringVariationDetail (flagKey , fallback ));
620+ EvaluationDetail <String > detailResult = ldClient .stringVariationDetail (flagKey , fallback );
621+ JsonObject jsonObject = gson .toJsonTree (detailResult ).getAsJsonObject ();
622+ WritableMap detailMap = fromJsonObject (jsonObject );
623+ promise .resolve (detailMap );
613624 } catch (Exception e ) {
614625 promise .resolve (fallback );
615626 }
@@ -762,7 +773,6 @@ public void allFlags(Promise promise) {
762773 * <p>
763774 * Separately typed methods are necessary at the React Native bridging layer requires that
764775 * bridged method types disambiguate the value type.
765- * </p>
766776 *
767777 * @param eventName Name of the event to track
768778 * @param data The Double data to attach to the tracking event
@@ -777,7 +787,6 @@ public void trackNumber(String eventName, Double data) {
777787 * <p>
778788 * Separately typed methods are necessary at the React Native bridging layer requires that
779789 * bridged method types disambiguate the value type.
780- * </p>
781790 *
782791 * @param eventName Name of the event to track
783792 * @param data The Boolean data to attach to the tracking event
@@ -792,7 +801,6 @@ public void trackBool(String eventName, Boolean data) {
792801 * <p>
793802 * Separately typed methods are necessary at the React Native bridging layer requires that
794803 * bridged method types disambiguate the value type.
795- * </p>
796804 *
797805 * @param eventName Name of the event to track
798806 * @param data The String data to attach to the tracking event
@@ -807,7 +815,6 @@ public void trackString(String eventName, String data) {
807815 * <p>
808816 * Separately typed methods are necessary at the React Native bridging layer requires that
809817 * bridged method types disambiguate the value type.
810- * </p>
811818 *
812819 * @param eventName Name of the event to track
813820 * @param data The Array data to attach to the tracking event
@@ -822,7 +829,6 @@ public void trackArray(String eventName, ReadableArray data) {
822829 * <p>
823830 * Separately typed methods are necessary at the React Native bridging layer requires that
824831 * bridged method types disambiguate the value type.
825- * </p>
826832 *
827833 * @param eventName Name of the event to track
828834 * @param data The Map(Object) data to attach to the tracking event
@@ -1027,7 +1033,7 @@ public void registerCurrentConnectionModeListener(String listenerId) {
10271033 @ Override
10281034 public void onConnectionModeChanged (ConnectionInformation connectionInfo ) {
10291035 WritableMap result = Arguments .createMap ();
1030- result .putString ("connectionMode" , new Gson () .toJson (connectionInfo ));
1036+ result .putString ("connectionMode" , gson .toJson (connectionInfo ));
10311037
10321038 getReactApplicationContext ()
10331039 .getJSModule (DeviceEventManagerModule .RCTDeviceEventEmitter .class )
@@ -1056,7 +1062,7 @@ public void registerAllFlagsListener(String listenerId) {
10561062 @ Override
10571063 public void onChange (List <String > flagKeys ) {
10581064 WritableMap result = Arguments .createMap ();
1059- result .putString ("flagKeys" , new Gson () .toJson (flagKeys ));
1065+ result .putString ("flagKeys" , gson .toJson (flagKeys ));
10601066
10611067 getReactApplicationContext ()
10621068 .getJSModule (DeviceEventManagerModule .RCTDeviceEventEmitter .class )
@@ -1081,7 +1087,6 @@ public void unregisterAllFlagsListener(String listenerId) {
10811087 * <p>
10821088 * This will recursively convert internal ReadableMaps and ReadableArrays into JsonObjects and
10831089 * JsonArrays.
1084- * </p>
10851090 *
10861091 * @param readableMap A ReadableMap to be converted to a JsonObject
10871092 * @return A JsonObject containing the converted elements from the ReadableMap.
@@ -1128,7 +1133,6 @@ private static JsonObject toJsonObject(ReadableMap readableMap) {
11281133 * <p>
11291134 * This will recursively convert internal ReadableMaps and ReadableArrays into JsonObjects and
11301135 * JsonArrays.
1131- * </p>
11321136 *
11331137 * @param readableArray A ReadableArray to be converted to a JsonArray
11341138 * @return A JsonArray containing the converted elements from the ReadableArray
@@ -1172,7 +1176,6 @@ private static JsonArray toJsonArray(ReadableArray readableArray) {
11721176 * <p>
11731177 * This will recursively convert internal JsonObjects and JsonArrays into WritableMaps and
11741178 * WritableArrays.
1175- * </p>
11761179 *
11771180 * @param jsonArray A JsonArray to be converted into a WritableArray
11781181 * @return A WritableArray containing converted elements from the JsonArray
@@ -1209,7 +1212,6 @@ private static WritableArray fromJsonArray(JsonArray jsonArray) {
12091212 * <p>
12101213 * This will recursively convert internal JsonObjects and JsonArrays into WritableMaps and
12111214 * WritableArrays.
1212- * </p>
12131215 *
12141216 * @param jsonObject A JsonObject to be converted into a WritableMap
12151217 * @return A WritableMap containing converted elements from the jsonObject
@@ -1265,7 +1267,6 @@ interface ConvertFromReadable<T> {
12651267 * Each type of config entry has a base ReadableType for checking that a ReadableMap contains an
12661268 * entry of the correct type, as well as an implementation of ConvertFromReadable for retrieving
12671269 * and converting a ReadableMap entry into a non base type for configuration processing.
1268- * </p>
12691270 */
12701271 enum ConfigEntryType implements ConvertFromReadable {
12711272 String (ReadableType .String ) {
0 commit comments