Class LDConfig.Builder
- java.lang.Object
-
- com.launchdarkly.sdk.android.LDConfig.Builder
-
- Enclosing class:
- LDConfig
public static class LDConfig.Builder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LDConfig.Builder
allAttributesPrivate()
Specifies that user attributes (other than the key) should be hidden from LaunchDarkly.LDConfig.Builder
autoAliasingOptOut(boolean autoAliasingOptOut)
Enable this opt-out to disable sending an automatic alias event whenLDClient.identify(LDUser)
is called with a non-anonymous user when the current user is anonymous.LDConfig.Builder
backgroundPollingIntervalMillis(int backgroundPollingIntervalMillis)
Sets how often the client will poll for flag updates when your application is in the background.LDConfig
build()
Returns the configuredLDConfig
object.LDConfig.Builder
connectionTimeoutMillis(int connectionTimeoutMillis)
Sets the timeout when connecting to LaunchDarkly.LDConfig.Builder
diagnosticOptOut(boolean diagnosticOptOut)
Set to true to opt out of sending diagnostics data.LDConfig.Builder
diagnosticRecordingIntervalMillis(int diagnosticRecordingIntervalMillis)
Sets the interval at which periodic diagnostic data is sent.LDConfig.Builder
disableBackgroundUpdating(boolean disableBackgroundUpdating)
Sets whether feature flag updates should be disabled when your app is in the background.LDConfig.Builder
evaluationReasons(boolean evaluationReasons)
If enabled, LaunchDarkly will provide additional information about how flag values were calculated.LDConfig.Builder
eventsCapacity(int eventsCapacity)
Set the capacity of the event buffer.LDConfig.Builder
eventsFlushIntervalMillis(int eventsFlushIntervalMillis)
Sets the maximum amount of time to wait in between sending analytics events to LaunchDarkly.LDConfig.Builder
eventsUri(android.net.Uri eventsUri)
Set the events URI for sending analytics to LaunchDarkly.LDConfig.Builder
headerTransform(LDHeaderUpdater headerTransform)
Provides a callback for dynamically modifying headers used on requests to the LaunchDarkly service.LDConfig.Builder
inlineUsersInEvents(boolean inlineUsersInEvents)
If enabled, events to the server will be created containing the entire User object.LDConfig.Builder
maxCachedUsers(int maxCachedUsers)
Sets the maximum number of users to cache the flag values for locally in the device's SharedPreferences.LDConfig.Builder
mobileKey(java.lang.String mobileKey)
Sets the key for authenticating with LaunchDarkly.LDConfig.Builder
offline(boolean offline)
Disables all network calls from the LaunchDarkly client.LDConfig.Builder
pollingIntervalMillis(int pollingIntervalMillis)
Sets the interval in between feature flag updates, when streaming mode is disabled.LDConfig.Builder
pollUri(android.net.Uri pollUri)
Set the base URI for polling requests to LaunchDarkly.LDConfig.Builder
privateAttributes(UserAttribute... privateAttributes)
Marks a set of attributes private.LDConfig.Builder
secondaryMobileKeys(java.util.Map<java.lang.String,java.lang.String> secondaryMobileKeys)
Sets the secondary keys for authenticating to additional LaunchDarkly environments.LDConfig.Builder
stream(boolean enabled)
Enables or disables real-time streaming flag updates.LDConfig.Builder
streamUri(android.net.Uri streamUri)
Set the stream URI for connecting to the flag update stream.LDConfig.Builder
useReport(boolean useReport)
Sets the flag for choosing the REPORT api call.LDConfig.Builder
wrapperName(java.lang.String wrapperName)
For use by wrapper libraries to set an identifying name for the wrapper being used.LDConfig.Builder
wrapperVersion(java.lang.String wrapperVersion)
For use by wrapper libraries to report the version of the library in use.
-
-
-
Method Detail
-
allAttributesPrivate
public LDConfig.Builder allAttributesPrivate()
Specifies that user attributes (other than the key) should be hidden from LaunchDarkly. If this is set, all user attribute values will be private, not just the attributes specified inprivateAttributes(UserAttribute...)
.- Returns:
- the builder
-
privateAttributes
public LDConfig.Builder privateAttributes(UserAttribute... privateAttributes)
Marks a set of attributes private. Any users sent to LaunchDarkly with this configuration active will have attributes with these names removed. This can also be specified on a per-user basis withLDUser.Builder
methods likeLDUser.Builder.privateName(String)
.- Parameters:
privateAttributes
- a set of names that will be removed from user data sent to LaunchDarkly- Returns:
- the builder
-
mobileKey
public LDConfig.Builder mobileKey(java.lang.String mobileKey)
Sets the key for authenticating with LaunchDarkly. This is required unless you're using the client in offline mode.- Parameters:
mobileKey
- Get this from the LaunchDarkly web app under Team Settings.- Returns:
- the builder
-
secondaryMobileKeys
public LDConfig.Builder secondaryMobileKeys(java.util.Map<java.lang.String,java.lang.String> secondaryMobileKeys)
Sets the secondary keys for authenticating to additional LaunchDarkly environments.- Parameters:
secondaryMobileKeys
- A map of identifying names to unique mobile keys to access secondary environments- Returns:
- the builder
-
useReport
public LDConfig.Builder useReport(boolean useReport)
Sets the flag for choosing the REPORT api call. The default is GET. Do not use unless advised by LaunchDarkly.- Parameters:
useReport
- true if HTTP requests should use the REPORT verb- Returns:
- the builder
-
pollUri
public LDConfig.Builder pollUri(android.net.Uri pollUri)
Set the base URI for polling requests to LaunchDarkly. You probably don't need to set this unless instructed by LaunchDarkly.- Parameters:
pollUri
- the URI of the main LaunchDarkly service- Returns:
- the builder
-
eventsUri
public LDConfig.Builder eventsUri(android.net.Uri eventsUri)
Set the events URI for sending analytics to LaunchDarkly. You probably don't need to set this unless instructed by LaunchDarkly.- Parameters:
eventsUri
- the URI of the LaunchDarkly analytics event service- Returns:
- the builder
-
streamUri
public LDConfig.Builder streamUri(android.net.Uri streamUri)
Set the stream URI for connecting to the flag update stream. You probably don't need to set this unless instructed by LaunchDarkly.- Parameters:
streamUri
- the URI of the LaunchDarkly streaming service- Returns:
- the builder
-
eventsCapacity
public LDConfig.Builder eventsCapacity(int eventsCapacity)
Set the capacity of the event buffer. The client buffers up to this many events in memory before flushing. If the capacity is exceeded before the buffer is flushed, events will be discarded. Increasing the capacity means that events are less likely to be discarded, at the cost of consuming more memory.The default value is
LDConfig.DEFAULT_EVENTS_CAPACITY
.- Parameters:
eventsCapacity
- the capacity of the event buffer- Returns:
- the builder
- See Also:
eventsFlushIntervalMillis(int)
-
eventsFlushIntervalMillis
public LDConfig.Builder eventsFlushIntervalMillis(int eventsFlushIntervalMillis)
Sets the maximum amount of time to wait in between sending analytics events to LaunchDarkly.The default value is
LDConfig.DEFAULT_FLUSH_INTERVAL_MILLIS
.- Parameters:
eventsFlushIntervalMillis
- the interval between event flushes, in milliseconds- Returns:
- the builder
- See Also:
eventsCapacity(int)
-
connectionTimeoutMillis
public LDConfig.Builder connectionTimeoutMillis(int connectionTimeoutMillis)
Sets the timeout when connecting to LaunchDarkly.The default value is
LDConfig.DEFAULT_CONNECTION_TIMEOUT_MILLIS
.- Parameters:
connectionTimeoutMillis
- the connection timeout, in milliseconds- Returns:
- the builder
-
stream
public LDConfig.Builder stream(boolean enabled)
Enables or disables real-time streaming flag updates. By default, streaming is enabled. When disabled, an efficient caching polling mechanism is used.- Parameters:
enabled
- true if streaming should be enabled- Returns:
- the builder
-
pollingIntervalMillis
public LDConfig.Builder pollingIntervalMillis(int pollingIntervalMillis)
Sets the interval in between feature flag updates, when streaming mode is disabled. This is ignored unlessstream(boolean)
is set totrue
. When set, it will also change the default value foreventsFlushIntervalMillis(int)
to the same value.The default value is
LDConfig.DEFAULT_POLLING_INTERVAL_MILLIS
.- Parameters:
pollingIntervalMillis
- the feature flag polling interval, in milliseconds- Returns:
- the builder
-
backgroundPollingIntervalMillis
public LDConfig.Builder backgroundPollingIntervalMillis(int backgroundPollingIntervalMillis)
Sets how often the client will poll for flag updates when your application is in the background.The default value is
LDConfig.DEFAULT_BACKGROUND_POLLING_INTERVAL_MILLIS
.- Parameters:
backgroundPollingIntervalMillis
- the feature flag polling interval when in the background, in milliseconds- Returns:
- the builder
-
disableBackgroundUpdating
public LDConfig.Builder disableBackgroundUpdating(boolean disableBackgroundUpdating)
Sets whether feature flag updates should be disabled when your app is in the background.The default value is false (flag updates will be done in the background).
- Parameters:
disableBackgroundUpdating
- true if the client should skip updating flags when in the background- Returns:
- the builder
-
offline
public LDConfig.Builder offline(boolean offline)
Disables all network calls from the LaunchDarkly client.This can also be specified after the client has been created, using
LDClientInterface.setOffline()
.The default value is true (the client will make network calls).
- Parameters:
offline
- true if the client should run in offline mode- Returns:
- the builder
-
inlineUsersInEvents
public LDConfig.Builder inlineUsersInEvents(boolean inlineUsersInEvents)
If enabled, events to the server will be created containing the entire User object. If disabled, events to the server will be created without the entire User object, including only the user key instead; the rest of the user properties will still be included in Identify events.Defaults to false in order to reduce network bandwidth.
- Parameters:
inlineUsersInEvents
- true if all user properties should be included in events- Returns:
- the builder
-
evaluationReasons
public LDConfig.Builder evaluationReasons(boolean evaluationReasons)
If enabled, LaunchDarkly will provide additional information about how flag values were calculated. The additional information will then be available through the client's "detail" methods (LDClientInterface.boolVariationDetail(String, boolean)
, etc.). Since this increases the size of network requests, the default is false (detail information will not be sent).- Parameters:
evaluationReasons
- true if detail/reason information should be made available- Returns:
- the builder
-
diagnosticOptOut
public LDConfig.Builder diagnosticOptOut(boolean diagnosticOptOut)
Set to true to opt out of sending diagnostics data. Unless the diagnosticOptOut field is set to true, the client will send some diagnostics data to the LaunchDarkly servers in order to assist in the development of future SDK improvements. These diagnostics consist of an initial payload containing some details of SDK in use, the SDK's configuration, and the platform the SDK is being run on; as well as payloads sent periodically with information on irregular occurrences such as dropped events.- Parameters:
diagnosticOptOut
- true if you want to opt out of sending any diagnostics data.- Returns:
- the builder
-
diagnosticRecordingIntervalMillis
public LDConfig.Builder diagnosticRecordingIntervalMillis(int diagnosticRecordingIntervalMillis)
Sets the interval at which periodic diagnostic data is sent. The default is every 15 minutes (900,000 milliseconds) and the minimum value is 300,000 (5 minutes).- Parameters:
diagnosticRecordingIntervalMillis
- the diagnostics interval in milliseconds- Returns:
- the builder
- See Also:
for more information on the diagnostics data being sent.
-
wrapperName
public LDConfig.Builder wrapperName(java.lang.String wrapperName)
For use by wrapper libraries to set an identifying name for the wrapper being used. This will be sent in User-Agent headers during requests to the LaunchDarkly servers to allow recording metrics on the usage of these wrapper libraries.- Parameters:
wrapperName
- An identifying name for the wrapper library- Returns:
- the builder
-
wrapperVersion
public LDConfig.Builder wrapperVersion(java.lang.String wrapperVersion)
For use by wrapper libraries to report the version of the library in use. If the wrapper name has not been set withwrapperName(String)
this field will be ignored. Otherwise the version string will be included in the User-Agent headers along with the wrapperName during requests to the LaunchDarkly servers.- Parameters:
wrapperVersion
- Version string for the wrapper library- Returns:
- the builder
-
maxCachedUsers
public LDConfig.Builder maxCachedUsers(int maxCachedUsers)
Sets the maximum number of users to cache the flag values for locally in the device's SharedPreferences.Note that the active user is not considered part of this limit, as it will always be served from the backing SharedPreferences.
- Parameters:
maxCachedUsers
- The maximum number of users to cache, negative values represent allowing an unlimited number of cached users.- Returns:
- the builder
-
autoAliasingOptOut
public LDConfig.Builder autoAliasingOptOut(boolean autoAliasingOptOut)
Enable this opt-out to disable sending an automatic alias event whenLDClient.identify(LDUser)
is called with a non-anonymous user when the current user is anonymous.- Parameters:
autoAliasingOptOut
- Whether the automatic aliasing feature should be disabled- Returns:
- the builder
-
headerTransform
public LDConfig.Builder headerTransform(LDHeaderUpdater headerTransform)
Provides a callback for dynamically modifying headers used on requests to the LaunchDarkly service.- Parameters:
headerTransform
- the transformation to apply to requests- Returns:
- the builder
-
-