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 Deprecated Methods Modifier and Type Method Description LDConfig.Builder
allAttributesPrivate()
Deprecated.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)
Deprecated.LDConfig
build()
Returns the configuredLDConfig
object.LDConfig.Builder
connectionTimeoutMillis(int connectionTimeoutMillis)
Deprecated.LDConfig.Builder
dataSource(ComponentConfigurer<DataSource> dataSourceConfigurer)
Sets the configuration of the component that receives feature flag data from LaunchDarkly.LDConfig.Builder
diagnosticOptOut(boolean diagnosticOptOut)
Set to true to opt out of sending diagnostics data.LDConfig.Builder
diagnosticRecordingIntervalMillis(int diagnosticRecordingIntervalMillis)
Deprecated.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
events(ComponentConfigurer<EventProcessor> eventsConfigurer)
Sets the implementation ofEventProcessor
to be used for processing analytics events.LDConfig.Builder
eventsCapacity(int eventsCapacity)
Deprecated.Useevents(ComponentConfigurer)
andEventProcessorBuilder.capacity(int)
instead.LDConfig.Builder
eventsFlushIntervalMillis(int eventsFlushIntervalMillis)
Deprecated.LDConfig.Builder
eventsUri(android.net.Uri eventsUri)
Deprecated.LDConfig.Builder
headerTransform(LDHeaderUpdater headerTransform)
Deprecated.LDConfig.Builder
http(ComponentConfigurer<HttpConfiguration> httpConfigurer)
Sets the SDK's networking configuration, using a configuration builder.LDConfig.Builder
inlineUsersInEvents(boolean inlineUsersInEvents)
Deprecated.Useevents(ComponentConfigurer)
andEventProcessorBuilder.inlineUsers(boolean)
instead.LDConfig.Builder
logAdapter(LDLogAdapter logAdapter)
Specifies the implementation of logging to use.LDConfig.Builder
loggerName(java.lang.String loggerName)
Specifies a custom logger name/tag for the SDK.LDConfig.Builder
logLevel(LDLogLevel logLevel)
Specifies the lowest level of logging to enable.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)
Deprecated.LDConfig.Builder
pollUri(android.net.Uri pollUri)
Deprecated.LDConfig.Builder
privateAttributes(UserAttribute... privateAttributes)
Deprecated.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
serviceEndpoints(ServiceEndpointsBuilder serviceEndpointsBuilder)
Sets the base service URIs used by SDK components.LDConfig.Builder
stream(boolean enabled)
Deprecated.UsedataSource(ComponentConfigurer)
with eitherComponents.streamingDataSource()
orComponents.pollingDataSource()
instead.LDConfig.Builder
streamUri(android.net.Uri streamUri)
Deprecated.LDConfig.Builder
useReport(boolean useReport)
Deprecated.Usehttp(ComponentConfigurer)
andHttpConfigurationBuilder.useReport(boolean)
instead.LDConfig.Builder
wrapperName(java.lang.String wrapperName)
Deprecated.LDConfig.Builder
wrapperVersion(java.lang.String wrapperVersion)
Deprecated.
-
-
-
Method Detail
-
allAttributesPrivate
@Deprecated public LDConfig.Builder allAttributesPrivate()
Deprecated.Deprecated method for specifying that all user attributes other than the key should be hidden from LaunchDarkly.The preferred way to set this option now is with
EventProcessorBuilder
. Any settings there will override this deprecated method.- Returns:
- the builder
-
privateAttributes
@Deprecated public LDConfig.Builder privateAttributes(UserAttribute... privateAttributes)
Deprecated.Deprecated method for marking a set of attributes as private.The preferred way to set this option now is with
EventProcessorBuilder
. Any settings there will override this deprecated method.This can also be specified on a per-user basis with
LDUser.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
@Deprecated public LDConfig.Builder useReport(boolean useReport)
Deprecated.Usehttp(ComponentConfigurer)
andHttpConfigurationBuilder.useReport(boolean)
instead.Deprecated method for specifying whether to use the HTTP REPORT method.The preferred way to set this option now is with
HttpConfigurationBuilder
. Any settings there will override this deprecated method.- Parameters:
useReport
- true if HTTP requests should use the REPORT verb- Returns:
- the builder
-
pollUri
@Deprecated public LDConfig.Builder pollUri(android.net.Uri pollUri)
Deprecated.Deprecated method for setting the base URI of the polling service.The preferred way to set this option now is with
ServiceEndpointsBuilder
. Any settings there will override this deprecated method.- Parameters:
pollUri
- the URI of the LaunchDarkly polling service- Returns:
- the builder
-
eventsUri
@Deprecated public LDConfig.Builder eventsUri(android.net.Uri eventsUri)
Deprecated.Deprecated method for setting the base URI of the events service.The preferred way to set this option now is with
ServiceEndpointsBuilder
. Any settings there will override this deprecated method.- Parameters:
eventsUri
- the URI of the LaunchDarkly events service- Returns:
- the builder
-
streamUri
@Deprecated public LDConfig.Builder streamUri(android.net.Uri streamUri)
Deprecated.Deprecated method for setting the base URI of the streaming service.The preferred way to set this option now is with
ServiceEndpointsBuilder
. Any settings there will override this deprecated method.- Parameters:
streamUri
- the URI of the LaunchDarkly streaming service- Returns:
- the builder
-
dataSource
public LDConfig.Builder dataSource(ComponentConfigurer<DataSource> dataSourceConfigurer)
Sets the configuration of the component that receives feature flag data from LaunchDarkly.The default is
Components.streamingDataSource()
; you may instead useComponents.pollingDataSource()
. See those methods for details on how to configure them with options that are specific to streaming or polling mode.Setting
offline(boolean)
totrue
will supersede this setting and completely disable network requests.// Setting custom options when using streaming mode LDConfig config = new LDConfig.Builder() .dataSource( Components.streamingDataSource() .initialReconnectDelayMillis(100) ) .build(); // Using polling mode instead of streaming, and setting custom options for polling LDConfig config = new LDConfig.Builder() .dataSource( Components.pollingDataSource() .pollingIntervalMillis(60_000) ) .build();
- Parameters:
dataSourceConfigurer
- the data source configuration builder- Returns:
- the main configuration builder
- Since:
- 3.3.0
- See Also:
Components.streamingDataSource()
,Components.pollingDataSource()
-
events
public LDConfig.Builder events(ComponentConfigurer<EventProcessor> eventsConfigurer)
Sets the implementation ofEventProcessor
to be used for processing analytics events.The default is
Components.sendEvents()
with no custom options. You may instead callComponents.sendEvents()
and then set custom options for event processing; or, disable events withComponents.noEvents()
; or, choose to use a custom implementation (for instance, a test fixture).Setting
offline(boolean)
totrue
will supersede this setting and completely disable network requests.// Setting custom event processing options LDConfig config = new LDConfig.Builder() .events(Components.sendEvents().capacity(100)) .build(); // Disabling events LDConfig config = new LDConfig.Builder() .events(Components.noEvents()) .build();
- Parameters:
eventsConfigurer
- the events configuration builder- Returns:
- the main configuration builder
- Since:
- 3.3.0
- See Also:
Components.sendEvents()
,Components.noEvents()
-
http
public LDConfig.Builder http(ComponentConfigurer<HttpConfiguration> httpConfigurer)
Sets the SDK's networking configuration, using a configuration builder. This builder is obtained fromComponents.httpConfiguration()
, and has methods for setting individual HTTP-related properties.LDConfig config = new LDConfig.Builder() .http(Components.httpConfiguration().connectTimeoutMillis(5000)) .build();
- Parameters:
httpConfigurer
- the HTTP configuration builder- Returns:
- the main configuration builder
- Since:
- 3.3.0
- See Also:
Components.httpConfiguration()
-
serviceEndpoints
public LDConfig.Builder serviceEndpoints(ServiceEndpointsBuilder serviceEndpointsBuilder)
Sets the base service URIs used by SDK components.This object is a configuration builder obtained from
Components.serviceEndpoints()
, which has methods for setting each external endpoint to a custom URI.LDConfig config = new LDConfig.Builder().mobileKey("key") .serviceEndpoints( Components.serviceEndpoints().relayProxy("http://my-relay-proxy-host") );
- Parameters:
serviceEndpointsBuilder
- a configuration builder object returned byComponents.serviceEndpoints()
- Returns:
- the builder
- Since:
- 3.3.0
-
eventsCapacity
@Deprecated public LDConfig.Builder eventsCapacity(int eventsCapacity)
Deprecated.Useevents(ComponentConfigurer)
andEventProcessorBuilder.capacity(int)
instead.Deprecated method for setting the capacity of the event buffer.The preferred way to set this option now is with
EventProcessorBuilder
. Any settings there will override this deprecated method.The default value is
EventProcessorBuilder.DEFAULT_CAPACITY
.- Parameters:
eventsCapacity
- the capacity of the event buffer- Returns:
- the builder
- See Also:
eventsFlushIntervalMillis(int)
-
eventsFlushIntervalMillis
@Deprecated public LDConfig.Builder eventsFlushIntervalMillis(int eventsFlushIntervalMillis)
Deprecated.Deprecated method for setting the maximum amount of time to wait in between sending analytics events to LaunchDarkly.The preferred way to set this option now is with
EventProcessorBuilder
. Any settings there will override this deprecated method.The default value is
EventProcessorBuilder.DEFAULT_FLUSH_INTERVAL_MILLIS
.- Parameters:
eventsFlushIntervalMillis
- the interval between event flushes, in milliseconds- Returns:
- the builder
- See Also:
eventsCapacity(int)
-
connectionTimeoutMillis
@Deprecated public LDConfig.Builder connectionTimeoutMillis(int connectionTimeoutMillis)
Deprecated.Deprecated method for setting the connection timeout.The preferred way to set this option now is with
HttpConfigurationBuilder
. Any settings there will override this deprecated method.- Parameters:
connectionTimeoutMillis
- the connection timeout, in milliseconds- Returns:
- the builder
-
stream
@Deprecated public LDConfig.Builder stream(boolean enabled)
Deprecated.UsedataSource(ComponentConfigurer)
with eitherComponents.streamingDataSource()
orComponents.pollingDataSource()
instead.Deprecated method for enabling or disabling real-time streaming flag updates.The preferred way to set this option now is with
StreamingDataSourceBuilder
. Any settings there will override this deprecated method. Setting this option tofalse
is equivalent to callingbuilder.dataSource(Components.pollingDataSource())
.By default, streaming is enabled.
- Parameters:
enabled
- true if streaming should be enabled- Returns:
- the builder
-
pollingIntervalMillis
@Deprecated public LDConfig.Builder pollingIntervalMillis(int pollingIntervalMillis)
Deprecated.Deprecated method for setting the interval in between feature flag updates, when streaming mode is disabled.The preferred way to set this option now is with
PollingDataSourceBuilder
. Any settings there will override this deprecated method.The default value is
PollingDataSourceBuilder.DEFAULT_POLL_INTERVAL_MILLIS
.- Parameters:
pollingIntervalMillis
- the feature flag polling interval, in milliseconds- Returns:
- the builder
-
backgroundPollingIntervalMillis
@Deprecated public LDConfig.Builder backgroundPollingIntervalMillis(int backgroundPollingIntervalMillis)
Deprecated.Deprecated method for setting how often the client will poll for flag updates when your application is in the background.The preferred way to set this option now is with
StreamingDataSourceBuilder
orPollingDataSourceBuilder
(depending on whether you want the SDK to use streaming or polling when it is in the foreground). Any settings there will override this deprecated method.The default value is
LDConfig.DEFAULT_BACKGROUND_POLL_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
@Deprecated public LDConfig.Builder inlineUsersInEvents(boolean inlineUsersInEvents)
Deprecated.Useevents(ComponentConfigurer)
andEventProcessorBuilder.inlineUsers(boolean)
instead.Deprecated method for specifying whether events sent to the server will always include the full user object.The preferred way to set this option now is with
EventProcessorBuilder
. Any settings there will override this deprecated method.This 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
@Deprecated public LDConfig.Builder diagnosticRecordingIntervalMillis(int diagnosticRecordingIntervalMillis)
Deprecated.Deprecatd method for setting the interval at which periodic diagnostic data is sent.The preferred way to set this option now is with
EventProcessorBuilder
. Any settings there will override this deprecated method.- Parameters:
diagnosticRecordingIntervalMillis
- the diagnostics interval in milliseconds- Returns:
- the builder
- See Also:
diagnosticOptOut(boolean)
-
wrapperName
@Deprecated public LDConfig.Builder wrapperName(java.lang.String wrapperName)
Deprecated.Deprecated method for setting a wrapper library name to include in User-Agent headers.The preferred way to set this option now is with
HttpConfigurationBuilder
. Any settings there will override this deprecated method.- Parameters:
wrapperName
- an identifying name for the wrapper library- Returns:
- the builder
-
wrapperVersion
@Deprecated public LDConfig.Builder wrapperVersion(java.lang.String wrapperVersion)
Deprecated.Deprecated method for setting a wrapper library version to include in User-Agent headers.The preferred way to set this option now is with
HttpConfigurationBuilder
. Any settings there will override this deprecated method.- Parameters:
wrapperVersion
- a 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
@Deprecated public LDConfig.Builder headerTransform(LDHeaderUpdater headerTransform)
Deprecated.Deprecated method for dynamically modifying request headers.The preferred way to set this option now is with
HttpConfigurationBuilder
. Any settings there will override this deprecated method.- Parameters:
headerTransform
- the transformation to apply to requests- Returns:
- the builder
-
logAdapter
public LDConfig.Builder logAdapter(LDLogAdapter logAdapter)
Specifies the implementation of logging to use.The
com.launchdarkly.logging
API defines theLDLogAdapter
interface to specify where log output should be sent. By default, it is set toLDTimberLogging.adapter()
, meaning that output will be sent to the Timber framework and controlled by whatever Timber configuration the application has created. You may change this toLDAndroidLogging.adapter()
to bypass Timber and use Android native logging directly; or, use theLogs
factory methods, or a custom implementation, to handle log output differently.Specifying
logAdapter(Logs.none())
completely disables log output.For more about logging adapters, see the SDK reference guide and the API documentation for
com.launchdarkly.logging
.- Parameters:
logAdapter
- anLDLogAdapter
for the desired logging implementation- Returns:
- the builder
- Since:
- 3.2.0
- See Also:
logLevel(LDLogLevel)
,loggerName(String)
,LDTimberLogging
,LDAndroidLogging
,Logs
-
logLevel
public LDConfig.Builder logLevel(LDLogLevel logLevel)
Specifies the lowest level of logging to enable.This is only applicable when using an implementation of logging that does not have its own external filter/configuration mechanism, such as
LDAndroidLogging
. It adds a log level filter so that log messages at lower levels are suppressed. The default isLDLogLevel.INFO
, meaning thatINFO
,WARN
, andERROR
levels are enabled, butDEBUG
is disabled. To enableDEBUG
level as well:LDConfig config = new LDConfig.Builder() .logAdapter(LDAndroidLogging.adapter()) .level(LDLogLevel.DEBUG) .build();
Or, to raise the logging threshold so that only WARN and ERROR levels are enabled, and DEBUG and INFO are disabled:
LDConfig config = new LDConfig.Builder() .logAdapter(LDAndroidLogging.adapter()) .level(LDLogLevel.WARN) .build();
When using
LDTimberLogging
, Timber has its own mechanism for determining whether to enable debug-level logging, so this method has no effect.- Parameters:
logLevel
- the lowest level of logging to enable- Returns:
- the builder
- Since:
- 3.2.0
- See Also:
logAdapter(LDLogAdapter)
,loggerName(String)
-
loggerName
public LDConfig.Builder loggerName(java.lang.String loggerName)
Specifies a custom logger name/tag for the SDK.When using Timber or native Android logging, this becomes the tag for all SDK log output. If you have specified a different logging implementation with
logAdapter(LDLogAdapter)
, the meaning of the logger name depends on the logging framework.If not specified, the default is "LaunchDarklySdk".
- Parameters:
loggerName
- the logger name or tag- Returns:
- the builder
- Since:
- 3.2.0
- See Also:
logAdapter(LDLogAdapter)
,logLevel(LDLogLevel)
-
-