Enclosing class:
YandexMetricaConfig


public static class YandexMetricaConfig.Builder
extends java.lang.Object
Builds a new YandexMetricaConfig object.

Constructor Summary

Constructors
ModifierConstructor and Description
protected Builder(java.lang.String apiKey) 

Method Summary

All Methods
Instance Methods
Concrete Methods
Modifier and TypeMethod and Description
YandexMetricaConfigbuild()
Creates instance of YandexMetricaConfig
YandexMetricaConfig.BuilderhandleFirstActivationAsUpdate(boolean value)
Whether first activation of AppMetrica should be considered as app update or new app install.
YandexMetricaConfig.BuilderwithAppOpenTrackingEnabled(boolean enabled)
Sets whether app open auto tracking is enabled.
YandexMetricaConfig.BuilderwithAppVersion(java.lang.String appVersion)
Sets the application version.
YandexMetricaConfig.BuilderwithCrashReporting(boolean enabled)
Whether to capture and send reports about crashes automatically.
YandexMetricaConfig.BuilderwithErrorEnvironmentValue(java.lang.String key, java.lang.String value)
Sets key - value data to be used as additional information, associated with your unhandled exception and error reports.
YandexMetricaConfig.BuilderwithLocation(android.location.Location location)
Sets Location to be used as location for reports of AppMetrica.
YandexMetricaConfig.BuilderwithLocationTracking(boolean enabled)
Sets whether AppMetrica should include location information within its reports.
YandexMetricaConfig.BuilderwithLogs()
Enable AppMetrica logging.
YandexMetricaConfig.BuilderwithMaxReportsInDatabaseCount(int value)
Sets maximum number of reports to store in database.
YandexMetricaConfig.BuilderwithNativeCrashReporting(boolean enabled)
Whether to capture and send reports about native crashes automatically.
YandexMetricaConfig.BuilderwithPreloadInfo(PreloadInfo preloadInfo)
Sets preload info for tracking preloaded apps
YandexMetricaConfig.BuilderwithRevenueAutoTrackingEnabled(boolean enabled)
Enables/disables auto tracking of inapp purchases.
YandexMetricaConfig.BuilderwithSessionsAutoTrackingEnabled(boolean enabled)
Sets whether sessions auto tracking is enabled.
YandexMetricaConfig.BuilderwithSessionTimeout(int sessionTimeout)
By default, the session times out if the app is inactive for YandexMetricaDefaultValues.DEFAULT_SESSION_TIMEOUT_SECONDS seconds.
YandexMetricaConfig.BuilderwithStatisticsSending(boolean value)
Enables/disables statistics sending to the AppMetrica server.
YandexMetricaConfig.BuilderwithUserProfileID(java.lang.String userProfileID)
Sets the ID of the user profile.

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Builder

protected Builder(@NonNull
                  java.lang.String apiKey)

Method Detail

withAppVersion

@NonNull
public YandexMetricaConfig.Builder withAppVersion(@Nullable
                                                           java.lang.String appVersion)
Sets the application version. It is optional value. By default, the app version is set in field android:versionName of the AndroidManifest.xml file.

EXAMPLE: 1.0

Parameters:
appVersion - Application version
Returns:
the same YandexMetricaConfig.Builder object.
Throws:
java.lang.IllegalArgumentException - If appVersion is null/empty.
See Also:
PackageInfo.versionName

withSessionTimeout

@NonNull
public YandexMetricaConfig.Builder withSessionTimeout(int sessionTimeout)
By default, the session times out if the app is inactive for YandexMetricaDefaultValues.DEFAULT_SESSION_TIMEOUT_SECONDS seconds. To change this time limit, pass the builder.withSessionTimeout(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 AppMetrica, means the following (see example):

EXAMPLE: Let the duration of sessions 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 YandexMetricaConfig.Builder object.

withCrashReporting

@NonNull
public YandexMetricaConfig.Builder withCrashReporting(boolean enabled)
Whether to capture and send reports about crashes automatically.

NOTE: Default value is YandexMetricaDefaultValues.DEFAULT_REPORTS_CRASHES_ENABLED

Parameters:
enabled - true if we need to send reports about crashes, otherwise false. In the case of false you can still send information about crashes via YandexMetrica.reportUnhandledException(Throwable) method.
Returns:
the same YandexMetricaConfig.Builder object.
See Also:
(boolean)

withNativeCrashReporting

@NonNull
public YandexMetricaConfig.Builder withNativeCrashReporting(boolean enabled)
Whether to capture and send reports about native crashes automatically.

NOTE: Default value is YandexMetricaDefaultValues.DEFAULT_REPORTS_NATIVE_CRASHES_ENABLED

Parameters:
enabled - true if we need to send reports about native crashes, otherwise false. In the case of false you can still send information about native crashes via YandexMetrica.reportNativeCrash(String) method.
Returns:
the same YandexMetricaConfig.Builder object.
See Also:
withCrashReporting(boolean)

withLogs

@NonNull
public YandexMetricaConfig.Builder withLogs()
Enable AppMetrica logging. Should be called before activation.
Returns:
the same YandexMetricaConfig.Builder object.

withLocation

@NonNull
public YandexMetricaConfig.Builder withLocation(@Nullable
                                                         android.location.Location location)
Sets Location to be used as location for reports of AppMetrica.

If location is set using this method, it will be used instead of auto collected location.

NOTE: Permissions: Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION improve the quality of auto collected location.

Parameters:
location - location to be used for reports
Returns:
the same YandexMetricaConfig.Builder object.
See Also:
withLocationTracking(boolean), YandexMetrica.setLocation(Location), YandexMetrica.setLocationTracking(boolean)

withLocationTracking

@NonNull
public YandexMetricaConfig.Builder withLocationTracking(boolean enabled)
Sets whether AppMetrica should include location information within its reports.

NOTE: Default value is

Parameters:
enabled - true to allow Yandex Metrica to record location information in reports, otherwise false.
Returns:
the same YandexMetricaConfig.Builder object.
See Also:
withLocation(Location), YandexMetrica.setLocationTracking(boolean), YandexMetrica.setLocation(Location)

withPreloadInfo

@NonNull
public YandexMetricaConfig.Builder withPreloadInfo(@Nullable
                                                            PreloadInfo preloadInfo)
Sets preload info for tracking preloaded apps
Parameters:
preloadInfo - instance of PreloadInfo
Returns:
the same YandexMetricaConfig.Builder object

handleFirstActivationAsUpdate

@NonNull
public YandexMetricaConfig.Builder handleFirstActivationAsUpdate(boolean value)
Whether first activation of AppMetrica should be considered as app update or new app install.
Parameters:
value - true if first call of YandexMetrica.activate(android.content.Context, com.yandex.metrica.YandexMetricaConfig) should be considered as app update, false otherwise.
Returns:
the same YandexMetricaConfig.Builder object

withStatisticsSending

@NonNull
public YandexMetricaConfig.Builder withStatisticsSending(boolean value)
Enables/disables statistics sending to the AppMetrica server. By default, the sending is enabled.

NOTE: Disabling this option also turns off data sending from the reporters that initialized for different apiKey.

Parameters:
value - true to allow AppMetrica sending statistics, otherwise false.
Returns:
the same YandexMetricaConfig.Builder object

withMaxReportsInDatabaseCount

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

NOTE: Default value is YandexMetricaDefaultValues.DEFAULT_MAX_REPORTS_IN_DATABASE_COUNT

Parameters:
value - Max number of reports to store in database. Must be in range [YandexMetricaDefaultValues.DEFAULT_MAX_REPORTS_COUNT_LOWER_BOUND; YandexMetricaDefaultValues.DEFAULT_MAX_REPORTS_COUNT_UPPER_BOUND]. If not, closest possible value will be used.
Returns:
the same YandexMetricaConfig.Builder object.

withErrorEnvironmentValue

@NonNull
public YandexMetricaConfig.Builder withErrorEnvironmentValue(@NonNull
                                                                      java.lang.String key,
                                                                      @Nullable
                                                                      java.lang.String value)
Sets key - value data to be used as additional information, associated with your unhandled exception and error reports.
Parameters:
key - the environment key.
value - the environment value. To remove pair from environment pass null value.
Returns:
the same YandexMetricaConfig.Builder object

withUserProfileID

@NonNull
public YandexMetricaConfig.Builder withUserProfileID(@Nullable
                                                              java.lang.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 YandexMetricaConfig.Builder object
See Also:
YandexMetrica.setUserProfileID(String)

withRevenueAutoTrackingEnabled

@NonNull
public YandexMetricaConfig.Builder withRevenueAutoTrackingEnabled(boolean enabled)
Enables/disables auto tracking of inapp purchases. Default value is YandexMetricaDefaultValues.DEFAULT_REVENUE_AUTO_TRACKING_ENABLED.
Parameters:
enabled - true to allow inapp purchases auto tracking, otherwise false.
Returns:
the same YandexMetricaConfig.Builder object

withSessionsAutoTrackingEnabled

@NonNull
public YandexMetricaConfig.Builder withSessionsAutoTrackingEnabled(boolean enabled)
Sets whether sessions auto tracking is enabled.
Parameters:
enabled - true if auto tracking should be enabled, false otherwise
Returns:
the same YandexMetricaConfig.Builder object.
See Also:
Default value is {@link YandexMetricaDefaultValues#DEFAULT_SESSIONS_AUTO_TRACKING_ENABLED}.

build

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