YandexMetricaConfig.Builder class

com.yandex.mertica

public class YandexMetrica.Builder

Builder class for YandexMetricaConfig.

Methods

YandexMetricaConfigbuild()

Creates an extended configuration object YandexMetricaConfig.

YandexMetricaConfig.BuilderhandleFirstActivationAsUpdate(boolean value)

Defines the first launch of the app as an update.

YandexMetricaConfig.BuilderwithAppVersion(@Nullable String appVersion)

Specifies the version of the application.

YandexMetricaConfig.BuilderwithCrashReporting(boolean enabled)

Enables/disables collecting and sending information about app crashes.

YandexMetricaConfig.BuilderwithInstalledAppCollecting(boolean enabled)

Enables/disables sending information about apps installed on the user's device.

YandexMetricaConfig.BuilderwithLocation(@Nullable Location location)

Sets custom location of the device.

YandexMetricaConfig.BuilderwithLocationTracking(boolean enabled)

Enables/disables sending location of the device.

YandexMetricaConfig.BuilderwithLogs()

Enables logging the activity of the AppMetrica library

YandexMetricaConfig.BuilderwithNativeCrashReporting(boolean enabled)

Enables/disables collecting and sending information about native app crashes.

YandexMetricaConfig.BuilderwithPreloadInfo(@Nullable PreloadInfo preloadInfo)

Sets the instance of the PreloadInfo class for tracking pre-installed apps. For more information, see Tracking pre-installed apps.

YandexMetricaConfig.BuilderwithSessionTimeout(int sessionTimeout)

Sets the session timeout in seconds.

YandexMetricaConfig.BuilderwithStatisticsSending(boolean value)

Enables/disables sending statistics to the AppMetrica server.

Method descriptions

build

public YandexMetricaConfig build()

Creates an extended configuration object YandexMetricaConfig.

Returns:

The instance of the YandexMetricaConfig class.

handleFirstActivationAsUpdate

public YandexMetricaConfig.Builder handleFirstActivationAsUpdate(boolean value)

Defines the first launch of the app as an update.

Attention. If the first launch of the app is defined as an update, the installation is not shown as a new installation in reports, and is not attributed to partners.
Parameters:
value

The flag indicating that the first launch of the app is an update (not an installation).

The default value is false.

Possible values:
  • true — The first launch is defined as an update.
  • false — The first launch is defined as a new installation.

Returns:

The instance of the YandexMetricaConfig.Builder class.

withAppVersion

public YandexMetricaConfig.Builder withAppVersion(@Nullable String appVersion)

Specifies the version of the application.

Parameters:
appVersion

App version.

withCrashReporting

public YandexMetricaConfig.Builder withCrashReporting(boolean enabled)

Enables/disables collecting and sending information about app crashes.

Parameters:
enabled

The flag indicating that sending app crashes is enabled.

The default value is true.

Possible values:
  • true — Sending information about crashes is enabled.
  • false — Sending information about crashes is disabled.

Returns:

The instance of the YandexMetricaConfig.Builder class.

withInstalledAppCollecting

public YandexMetricaConfig.Builder withInstalledAppCollecting(boolean enabled)

Enables/disables sending information about apps installed on the user's device.

Parameters:
enabled

The flag indicating that sending information about apps installed on the user's device is enabled.

The default value is false.

Possible values:
  • true — Sending information about installed apps is enabled.
  • false — Sending information about installed apps is disabled.

withLocation

public YandexMetricaConfig.Builder withLocation(@Nullable Location location)

Sets custom location of the device.

Parameters:
location

Information about the location of the device.

Returns:

The instance of the YandexMetricaConfig.Builder class.

withLocationTracking

public YandexMetricaConfig.Builder withLocationTracking(boolean enabled)

Enables/disables sending location of the device.

Parameters:
enabled

A flag indicating if sending information about the device location is enabled.

The default value is true.

Possible values:
  • true — Sending information about the device location is enabled.
  • false — Sending information about the location of the device is disabled.

Returns:

The instance of the YandexMetricaConfig.Builder class.

withLogs

public YandexMetricaConfig.Builder withLogs()

Enables logging the activity of the AppMetrica library

Returns:

The instance of the YandexMetricaConfig.Builder class.

withNativeCrashReporting

public YandexMetricaConfig.Builder withNativeCrashReporting(boolean enabled)

Enables/disables collecting and sending information about native app crashes.

Parameters:
enabled

The flag indicating that sending native app crashes is enabled.

The default value is true.

Possible values:
  • true — Sending information about native crashes is enabled.
  • false — Sending information about native crashes is disabled.

Returns:

The instance of the YandexMetricaConfig.Builder class.

withPreloadInfo

public YandexMetricaConfig.Builder withPreloadInfo(@Nullable PreloadInfo preloadInfo)

Sets the instance of the PreloadInfo class for tracking pre-installed apps. For more information, see Tracking pre-installed apps.

Parameters:
preloadInfo

The instance of the PreloadInfo class.

Returns:

The instance of the YandexMetricaConfig.Builder class.

withSessionTimeout

public YandexMetricaConfig.Builder withSessionTimeout(int sessionTimeout)

Sets the session timeout in seconds.

Parameters:
sessionTimeout

Session timeout in seconds.

The default value is 10 (minimum allowed value).

Returns:

The instance of the YandexMetricaConfig.Builder class.

withStatisticsSending

public YandexMetricaConfig.Builder withStatisticsSending(boolean value)

Enables/disables sending statistics to the AppMetrica server.

For more information about using the method, see Disable and enable sending statistics.

Note. Disabling sending also turns off sending data from all reporters that initialized with a different apiKey.
Parameters:
value

A flag indicating that sending statistics is enabled.

The default value is true.

Possible values:
  • true — Sending statistics is enabled.
  • false — Sending statistics is disabled.

Returns:

The instance of the YandexMetricaConfig.Builder class.