From 067354d9a093b67c09880b9319dd3adf1b3c7db2 Mon Sep 17 00:00:00 2001 From: Gavin Whelan Date: Thu, 14 Apr 2022 12:52:16 -0500 Subject: [PATCH] [sc-149512] Android reason fixes (#120) --- .../LaunchdarklyReactNativeClientModule.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/launchdarkly/reactnative/LaunchdarklyReactNativeClientModule.java b/android/src/main/java/com/launchdarkly/reactnative/LaunchdarklyReactNativeClientModule.java index 5797202..38b0ee1 100644 --- a/android/src/main/java/com/launchdarkly/reactnative/LaunchdarklyReactNativeClientModule.java +++ b/android/src/main/java/com/launchdarkly/reactnative/LaunchdarklyReactNativeClientModule.java @@ -434,19 +434,30 @@ private ObjectBuilder objectBuilderFromDetail(EvaluationDetail detail) { ObjectBuilder resultMap = LDValue.buildObject(); if (!detail.isDefaultValue()) { resultMap.put("variationIndex", detail.getVariationIndex()); + } else { + resultMap.put("variationIndex", LDValue.ofNull()); } EvaluationReason reason = detail.getReason(); + if (reason == null) { + resultMap.put("reason", LDValue.ofNull()); + return resultMap; + } ObjectBuilder reasonMap = LDValue.buildObject(); reasonMap.put("kind", reason.getKind().name()); switch (reason.getKind()) { case RULE_MATCH: reasonMap.put("ruleIndex", reason.getRuleIndex()); - if (reason.getRuleId() != null) { - reasonMap.put("ruleId", reason.getRuleId()); + reasonMap.put("ruleId", reason.getRuleId()); + if (reason.isInExperiment()) { + reasonMap.put("inExperiment", true); } break; case PREREQUISITE_FAILED: reasonMap.put("prerequisiteKey", reason.getPrerequisiteKey()); break; case ERROR: reasonMap.put("errorKind", reason.getErrorKind().name()); break; + case FALLTHROUGH: + if (reason.isInExperiment()) { + reasonMap.put("inExperiment", true); + } default: break; } resultMap.put("reason", reasonMap.build());