Class ReporterConfig.Builder

java.lang.Object
io.appmetrica.analytics.ReporterConfig.Builder
Enclosing class:
ReporterConfig

public static class ReporterConfig.Builder extends Object
Builds a new ReporterConfig object.
  • Method Details

    • withSessionTimeout

      @NonNull public ReporterConfig.Builder withSessionTimeout(int sessionTimeout)
      Set the timeout for expiring session.

      By default, the session times out if the app is inactive for 10 seconds. To change this time limit, pass to the IReporter.setSessionTimeout(int sessionTimeoutSeconds) method your time limit in seconds. The minimum acceptable value for the sessionTimeoutSeconds parameter is 10 seconds. If a value less than 10 is set, the value will automatically be 10 seconds.

      Under the duration of sessions, in the concept of Metrica, means the following (see example):

      EXAMPLE: Let the duration of session timeout is 2 minutes. Then, if interaction with your application started after 2 minutes of inactivity with the application, then a new session will be created, otherwise the session will continue.

      Parameters:
      sessionTimeout - Timeout in seconds.
      Returns:
      the same ReporterConfig.Builder object.
    • withLogs

      @NonNull public ReporterConfig.Builder withLogs()
      Enable logging for appropriate IReporter. Should be called before AppMetrica.getReporter(Context, String).
      Returns:
      the same ReporterConfig.Builder object.
    • withDataSendingEnabled

      @NonNull public ReporterConfig.Builder withDataSendingEnabled(boolean enabled)
      Enables/disables data sending to the AppMetrica server. By default, the sending is enabled.

      NOTE: Disabling this option doesn't affect data sending from the main apiKey and other reporters.

      Parameters:
      enabled - true to allow AppMetrica sending data, otherwise false.
      Returns:
      the same ReporterConfig.Builder object.
    • withMaxReportsInDatabaseCount

      @NonNull public ReporterConfig.Builder withMaxReportsInDatabaseCount(int maxReportsInDatabaseCount)
      Sets maximum number of reports to store in database. If this number is exceeded, some reports will be removed.

      NOTE: Default value is 1000

      Parameters:
      maxReportsInDatabaseCount - Max number of reports to store in database. Must be in range [100; 10000]. If not, closest possible value will be used.
      Returns:
      the same ReporterConfig.Builder object.
    • withUserProfileID

      @NonNull public ReporterConfig.Builder withUserProfileID(@Nullable String userProfileID)
      Sets the ID of the user profile. NOTE: The string value can contain up to 200 characters.
      Parameters:
      userProfileID - The custom user profile ID.
      Returns:
      the same ReporterConfig.Builder object
      See Also:
    • withMaxReportsCount

      @NonNull public ReporterConfig.Builder withMaxReportsCount(int maxReportsCount)
      Sets maximum buffer size for reports.

      NOTE: Default value is 7. If you set a non-positive value, then automatic sending will be disabled for the situation when the events buffer is full.

      Parameters:
      maxReportsCount - Max number of items/reports to automatically send reports.
      Returns:
      the same ReporterConfig.Builder object.
      See Also:
    • withDispatchPeriodSeconds

      @NonNull public ReporterConfig.Builder withDispatchPeriodSeconds(int dispatchPeriodSeconds)
      Timeout of events sending if the number of events is less than ReporterConfig.maxReportsCount.

      NOTE: Default value is 90. If you set a non-positive value, then automatic sending by timer will be disabled.

      Parameters:
      dispatchPeriodSeconds - Timeout in seconds to automatically send reports.
      Returns:
      the same ReporterConfig.Builder object.
      See Also:
    • withAppEnvironmentValue

      @NonNull public ReporterConfig.Builder withAppEnvironmentValue(String key, String value)
      Sets key - value pair to be used as additional information, associated with your application runtime's environment. This environment is unique for every unique APIKey and shared between processes. Application's environment persists to storage and retained between application launches. To reset environment use Pairs added to config builder, will be set right after metrica initialization.

      WARNING: Application's environment is a global permanent state and can't be changed too often. For frequently changed parameters use extended reportMessage methods.

      Parameters:
      key - the environment key.
      value - the environment value. To remove pair from environment pass null value.
      Returns:
      the same object
    • withAdditionalConfig

      @NonNull public ReporterConfig.Builder withAdditionalConfig(@NonNull String key, @Nullable Object config)
      Sets key - config data
      Parameters:
      key - the config key.
      config - the config value.
      Returns:
      the same ReporterConfig.Builder object.
    • build

      @NonNull public ReporterConfig build()
      Creates instance of ReporterConfig
      Returns:
      ReporterConfig object