Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Added - The new configuration option `setEvaluationReasons(true)` causes LaunchDarkly to report information about how each feature flag value was determined; you can access this information with the new client methods `boolVariationDetail`, `stringVariationDetail`, etc. The new methods return an object that contains both the flag value and a "reason" object which will tell you, for instance, if the user was individually targeted for the flag or was matched by one of the flag's rules, or if the flag returned the default value due to an error. For more information, see the SDK Reference Guide on [evaluation reasons](https://docs.launchdarkly.com/docs/evaluation-reasons). - The new client method `getVersion()` returns the version string of the SDK. ### Fixed - Bug causing `boolVariation`, `intVariation`, and `floatVariation` to always return `null` if `fallback` argument was `null`. - Potential issue where environment versions for flag updates could compare incorrectly due to floating point coercion. - Summary events for unknown flags (flags evaluated without any stored value, variation, or version) now include the returned value as intended. - Inaccurate events caused by data for flag version and variation being unsynchronized with flag value. - Bug causing some events to be dropped from summary counts due to data race in sending and updating summary events. - Potential `ClassCastException` crash on some devices due to old version of OkHttp. - Improved documentation comments throughout. - Crash on migration when no primary mobile key is specified. ### Removed - CircleCI V1 config file
- Loading branch information
Showing
84 changed files
with
4,454 additions
and
2,452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...-android-client/src/androidTest/java/com/launchdarkly/android/DeleteFlagResponseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.launchdarkly.android; | ||
|
||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import com.google.gson.Gson; | ||
import com.launchdarkly.android.flagstore.Flag; | ||
import com.launchdarkly.android.flagstore.FlagBuilder; | ||
import com.launchdarkly.android.gson.GsonCache; | ||
import com.launchdarkly.android.response.DeleteFlagResponse; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNull; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class DeleteFlagResponseTest { | ||
|
||
private static final Gson gson = GsonCache.getGson(); | ||
|
||
@Test | ||
public void deleteFlagResponseKeyIsDeserialized() { | ||
final String jsonStr = "{\"key\": \"flag\"}"; | ||
final DeleteFlagResponse delete = gson.fromJson(jsonStr, DeleteFlagResponse.class); | ||
assertEquals("flag", delete.flagToUpdate()); | ||
} | ||
|
||
@Test | ||
public void testUpdateFlag() { | ||
// Create delete flag responses from json to verify version is deserialized | ||
final String jsonNoVersion = "{\"key\": \"flag\"}"; | ||
final String jsonLowVersion = "{\"key\": \"flag\", \"version\": 50}"; | ||
final String jsonHighVersion = "{\"key\": \"flag\", \"version\": 100}"; | ||
final DeleteFlagResponse deleteNoVersion = gson.fromJson(jsonNoVersion, DeleteFlagResponse.class); | ||
final DeleteFlagResponse deleteLowVersion = gson.fromJson(jsonLowVersion, DeleteFlagResponse.class); | ||
final DeleteFlagResponse deleteHighVersion = gson.fromJson(jsonHighVersion, DeleteFlagResponse.class); | ||
final Flag flagNoVersion = new FlagBuilder("flag").build(); | ||
final Flag flagLowVersion = new FlagBuilder("flag").version(50).build(); | ||
final Flag flagHighVersion = new FlagBuilder("flag").version(100).build(); | ||
|
||
assertNull(deleteNoVersion.updateFlag(null)); | ||
assertNull(deleteNoVersion.updateFlag(flagNoVersion)); | ||
assertNull(deleteNoVersion.updateFlag(flagLowVersion)); | ||
assertNull(deleteNoVersion.updateFlag(flagHighVersion)); | ||
assertNull(deleteLowVersion.updateFlag(null)); | ||
assertNull(deleteLowVersion.updateFlag(flagNoVersion)); | ||
assertEquals(flagLowVersion, deleteLowVersion.updateFlag(flagLowVersion)); | ||
assertEquals(flagHighVersion, deleteLowVersion.updateFlag(flagHighVersion)); | ||
assertNull(deleteHighVersion.updateFlag(null)); | ||
assertNull(deleteHighVersion.updateFlag(flagNoVersion)); | ||
assertNull(deleteHighVersion.updateFlag(flagLowVersion)); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...ly-android-client/src/androidTest/java/com/launchdarkly/android/EvaluationReasonTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.launchdarkly.android; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.JsonElement; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class EvaluationReasonTest { | ||
private static final Gson gson = new LDConfig.Builder().build().getFilteredEventGson(); | ||
|
||
@Test | ||
public void testOffReasonSerialization() { | ||
EvaluationReason reason = EvaluationReason.off(); | ||
String json = "{\"kind\":\"OFF\"}"; | ||
assertJsonEqual(json, gson.toJson(reason)); | ||
assertEquals("OFF", reason.toString()); | ||
} | ||
|
||
@Test | ||
public void testFallthroughSerialization() { | ||
EvaluationReason reason = EvaluationReason.fallthrough(); | ||
String json = "{\"kind\":\"FALLTHROUGH\"}"; | ||
assertJsonEqual(json, gson.toJson(reason)); | ||
assertEquals("FALLTHROUGH", reason.toString()); | ||
} | ||
|
||
@Test | ||
public void testTargetMatchSerialization() { | ||
EvaluationReason reason = EvaluationReason.targetMatch(); | ||
String json = "{\"kind\":\"TARGET_MATCH\"}"; | ||
assertJsonEqual(json, gson.toJson(reason)); | ||
assertEquals("TARGET_MATCH", reason.toString()); | ||
} | ||
|
||
@Test | ||
public void testRuleMatchSerialization() { | ||
EvaluationReason reason = EvaluationReason.ruleMatch(1, "id"); | ||
String json = "{\"kind\":\"RULE_MATCH\",\"ruleIndex\":1,\"ruleId\":\"id\"}"; | ||
assertJsonEqual(json, gson.toJson(reason)); | ||
assertEquals("RULE_MATCH(1,id)", reason.toString()); | ||
} | ||
|
||
@Test | ||
public void testPrerequisiteFailedSerialization() { | ||
EvaluationReason reason = EvaluationReason.prerequisiteFailed("key"); | ||
String json = "{\"kind\":\"PREREQUISITE_FAILED\",\"prerequisiteKey\":\"key\"}"; | ||
assertJsonEqual(json, gson.toJson(reason)); | ||
assertEquals("PREREQUISITE_FAILED(key)", reason.toString()); | ||
} | ||
|
||
@Test | ||
public void testErrorSerialization() { | ||
EvaluationReason reason = EvaluationReason.error(EvaluationReason.ErrorKind.EXCEPTION); | ||
String json = "{\"kind\":\"ERROR\",\"errorKind\":\"EXCEPTION\"}"; | ||
assertJsonEqual(json, gson.toJson(reason)); | ||
assertEquals("ERROR(EXCEPTION)", reason.toString()); | ||
} | ||
|
||
private void assertJsonEqual(String expectedString, String actualString) { | ||
JsonElement expected = gson.fromJson(expectedString, JsonElement.class); | ||
JsonElement actual = gson.fromJson(actualString, JsonElement.class); | ||
assertEquals(expected, actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.