3.0.0
[3.0.0] - 2021-05-07
This major version has an accompanying Migration Guide. Please see the guide for more information on updating to this version of the SDK, as the following is just a summary of the changes.
Usages of Gson
provided types have been removed from the public API, replacing JsonElement
with LDValue
provided by the SDK. LDValue
can represent the same values as a JsonElement
, but has a diferent API. See the API documentation for a detailed reference.
Added
LDConfig.Builder
customization:- The
autoAliasingOptOut
configuration option that is used to control the new automatic aliasing behavior of theidentify
method; by settingautoAliasingOptOut
to true,identify
will not automatically generate alias events. - The
headerTransform
configuration option that supersedes the previousadditionalHeaders
configuration option by allowing fully dynamic updating of headers for requests the SDK makes to the LaunchDarkly service. - The
privateAttributes
configuration option that replacessetPrivateAttributeNames
, specifying the private attributes as varargUserAttribute
arguments rather than aSet<String>
. This allows easily specifying built-in attributes.
- The
LDUser(String)
constructor that creates a fully default user.- New accessors for
LDUser
getAttribute(UserAttribute)
for programmatically retrieving attribute values.getCustomAttributes()
for retrieving the currently set custom attributes.getPrivateAttributes()
for retrieving the attributes set to be private on this user.isAttributePrivate(UserAttribute)
for checking if a given attribute is private.- Getters for all built-in attributes, e.g.
getName()
- New
LDUser.Builder
methods overloads forcustom
andprivateCustom
:custom(String, boolean)
andprivateCustom(String, boolean)
for setting custom attributes to boolean values.custom(String, int)
,privateCustom(String, int)
,custom(String, double)
, andprivateCustom(String, double)
for setting custom attributes to numeric values.custom(String, LDValue)
andprivateCustom(String, LDValue)
for setting custom attributes to arbitrary data.
- The
UserAttribute
class, which provides a less error-prone way to refer to user attribute names in configuration. This class can also be used to get arbitrary attribute LDClient
functionality:- The
alias
method that is used to associate two user objects for analytics purposes with an alias event. jsonValueVariation
andjsonValueVariationDetail
. These are equivalent to the removedjsonVariation
andjsonVariationDetail
other than usingLDValue
instead ofJsonElement
.trackData(String, LDValue)
which replacestrack(String, JsonElement)
. Other than changing to useLDValue
the behavior is the same.trackMetric(String, LDValue, double)
which replacestrack(String, JsonElement, Double)
. This also usesLDValue
rather thanJsonElement
, and requires a metric value. Otherwise usetrackData
.
- The
- The
LDGson
andLDJackson
classes, which allow SDK classes likeLDUser
to be easily converted to or from JSON using the popular Gson and Jackson frameworks. EvaluationDetail.fromValue
andEvaluationDetail.error
factory methods.LDHeaderUpdater
interface for the newheaderTransform
configuration option.
Fixed
- Fixed an issue where the SDK could log error level messages when attempting to send diagnostic events without an internet connection. The SDK will no longer attempt to send diagnostic events when an internet connection is known to be unavailable, and will not log an error level message if the connection fails. Thanks to @valeriyo for reporting (#107).
- Fixed an issue where
LDUser
instances created before callingLDClient.init
without specifying a key would have the keyUNKNOWN_ANDROID
rather than a device unique key. - Fixed an issue where flags listeners would be informed of changes to unchanged flags whenever the SDK receives an entire flag set (on a new stream connection, a poll request, or any stream updates behind a relay proxy).
- Fixed an issue where a
NullPointerException
is thrown ifLDClient.close()
is called multiple times. - Improved the proguard/R8 configuration to allow more optimization. Thanks to @valeriyo for requesting (#106)
- Fixed a potential issue where the SDK could cause additional throttling on requests to the backend service when previously throttled requests had been cancelled before completion.
Changed (requirements/dependencies/build)
- Migrated from using the Android Support Libraries to using AndroidX from Jetpack. Using AndroidX requires the
android.useAndroidX
Android Gradle plugin flag to be set totrue
in your application'sgradle.properties
file. If your application previously set theandroid.enableJetifier
Android Gradle plugin flag totrue
in it'sgradle.properties
file soley for the LaunchDarkly SDK, this flag can now be removed. Thanks to everyone who requested this enhancement (#103). - The minimum Android API version has been raised from API level 16 (Android 4.1 Jelly Bean) to API level 21 (Android 5.0 Lollipop).
- The SDK no longer has a dependency on Google Play Services. This dependency was only used on pre-21 Android API levels to improve TLS 1.2 compatibility, as the minimum Android version has been raised to 21, the dependency is no longer necessary.
- The SDK is now built with modern Gradle (6.7, Android plugin 4.1.3) and uses Java 8.
Changed (API)
- Package names have changed: the main SDK classes are now in
com.launchdarkly.sdk
andcom.launchdarkly.sdk.android
. - All
LDConfig.Builder
setters have been renamed to remove theset
prefix, e.g.LDConfig.Builder.setMobileKey
has been renamed toLDConfig.Builder.mobileKey
. LDClient
API changes:boolVariation
andintVariation
no longer use nullable object types for argument and return values, instead using primitive types, e.g.Boolean boolVariation(String, Boolean)
becameboolean boolVariation(String, boolean)
.boolVariationDetail
andintVariationDetail
no longer use nullable object types for argument values, instead using primitive types, e.g.boolVariationDetail(String, Boolean)
becameboolVariationDetail(String, boolean)
.floatVariation
andfloatVariationDetail
have been changed to have the same behavior as the removeddoubleVariation
anddoubleVariationDetail
.allFlags()
now returnsMap<String, LDValue>
rather thanMap<String, ?>
. Rather than the returnedMap
containingBoolean
,Float
, andString
typed objects, with JSON values represented as strings, theMap
containsLDValue
typed objects which return the source type (including complex types such as JSON arrays and objects).
EvaluationDetail.getVariationIndex()
now returnsint
instead ofInteger
. No variation index is now represented as the constantEvaluationReason.NO_VARIATION
.EvaluationReason
is now a single concrete class rather than an abstract base class. Usages of the sub-classes can be replaced with the base class.
Changed (behavioral)
- The default polling domain (configurable with
LDConfig.Builder.pollUri
) has changed fromapp.launchdarkly.com
toclientsdk.launchdarkly.com
. - The default
eventsUri
used to send events to the service has changed fromhttps://mobile.launchdarkly.com/mobile
tohttps://mobile.launchdarkly.com
. The SDK will now append the expected endpoint path (/mobile
) to the configuredUri
, which is more consistent with other LaunchDarkly SDKs. - For compatibility with older SDK behavior, the
LDClient.stringVariation
method could be used to retrieve JSON flags in a serialized representation. This compatibility behavior has been removed, and attempts to request a JSON valued flag usingstringVariation
will behave the same as other mismatched type variation calls. - The
LDClient.identify
method will now automatically generate an alias event when switching from an anonymous to a known user. This event associates the two users for analytics purposes as they most likely represent a single person. This behavior can be disabled with theautoAliasingOptOut
configuration option. - All log messages are now tagged
LaunchDarklySdk
for easier filtering. Thanks to @valeriyo for the suggestion (#113). LDUser
now overridesequals
,hashCode
, andtoString
with appropriate implementations.LDUser.Builder.country(String)
andLDUser.Builder.privateCountry(String)
no longer attempt to look up the country from the providedString
(attempting to match it as an ISO-3166-1 alpha-2, alpha-3 code; or a country name) and set the country to the resultant IOS-3166-1 alpha-2 only if successful. The SDK no longer gives this attribute special behavior, and sets the user's country attribute directly as the providedString
.
Removed
LDConfig.Builder
:setBaseUri(Uri)
has been removed. Please usesetPollUri(Uri)
instead.setAdditionalHeaders(Map<String,String>)
has been removed. Please useheaderTransform(LDHeaderUpdater)
instead.setPrivateAttributeNames(Set<String>)
has been removed. Please useprivateAttributes(UserAttribute...)
instead.
LDUser.Builder
:country(LDCountryCode)
andprivateCountry(LDCountryCode)
have been removed. Usecountry(String)
orprivateCountry(String)
to set the country value on a user.custom(String, Number)
andprivateCustom(String, Number)
have been removed. Use the(String, int)
or(String, double)
overloads instead.custom(String, Boolean)
andprivateCustom(String, Boolean)
have been removed. Usecustom(String, boolean)
orprivateCustom(String, boolean)
instead.custom(String, List<String>)
,LDUser.customString(String, List<String>)
,LDUser.privateCustomString(String, List<String>)
. Usecustom(String, LDValue)
andprivateCustom(String, LDValue)
instead.customNumber(String, List<Number>)
andLDUser.privateCustomNumber(String, List<Number>)
. Usecustom(String, LDValue)
andprivateCustom(String, LDValue)
instead.
LDClient
:doubleVariation
anddoubleVariationDetail
have been removed. UsefloatVariation
andfloatVariationDetail
instead.jsonVariation
andjsonVariationDetail
have been removed. UsejsonValueVariation
andjsonValueVariationDetail
instead.track(String, JsonElement)
andtrack(String, JsonElement, Double)
overloads have been removed, please use the designated methodstrackData(String, LDValue)
andtrackMetric(String, LDValue, double)
instead.
- The public constructor for
EvaluationDetail
has been hidden. Use the new factory methodsEvaluationDetail.fromValue
andEvaluationDetail.error
instead. - The concrete sub-classes of
EvaluationReason
have been removed in favor of makingEvaluationReason
a concrete class. The accessors on the sub-classes have been moved to the base class. Instead of usinginstanceOf
to determine the type, usegetKind()
. LDCountryCode
has been removed as no SDK APIs use this class.- All classes and interfaces in the
com.launchdarkly.sdk.android.flagstore
,com.launchdarkly.sdk.android.gson
,com.launchdarkly.sdk.android.response
, andcom.launchdarkly.sdk.android.tls
packages. These classes and interfaces were not intended for external use. Debounce
,FeatureFlagFetcher
,SummaryEventSharedPreferences
,UserSummaryEventSharedPreferences
, andUtil
incom.launchdarkly.sdk.android
. These deprecated classes and interfaces were not intended for external use.