Class LDConfig.Builder

  • Enclosing class:
    LDConfig

    public static class LDConfig.Builder
    extends java.lang.Object
    A builder that helps construct LDConfig objects. Builder calls can be chained, enabling the following pattern:
     LDConfig config = new LDConfig.Builder()
              .mobileKey("mobile-key")
              .evaluationReasons(true)
              .build();
     
    • Constructor Detail

      • Builder

        public Builder()
    • 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 in privateAttributes(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 with LDUser.Builder methods like LDUser.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 unless stream(boolean) is set to true. When set, it will also change the default value for eventsFlushIntervalMillis(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 with wrapperName(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 when LDClient.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
      • 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 is LDLogLevel.INFO, meaning that INFO, WARN, and ERROR levels are enabled, but DEBUG is disabled. To enable DEBUG 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)
      • build

        public LDConfig build()
        Returns the configured LDConfig object.
        Returns:
        the configuration