Class YandexMetricaConfig.Builder
- Enclosing class:
- YandexMetricaConfig
public static class YandexMetricaConfig.Builder
extends java.lang.Object
YandexMetricaConfig object.-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder(java.lang.String apiKey) -
Method Summary
Modifier and Type Method Description YandexMetricaConfigbuild()Creates instance ofYandexMetricaConfigYandexMetricaConfig.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)SetsLocationto 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)Setspreload infofor tracking preloaded appsYandexMetricaConfig.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 forYandexMetricaDefaultValues.DEFAULT_SESSION_TIMEOUT_SECONDSseconds.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 Details
-
Builder
protected Builder(@NonNull java.lang.String apiKey)
-
-
Method Details
-
withAppVersion
Sets the application version. It is optional value. By default, the app version is set in fieldandroid:versionNameof the AndroidManifest.xml file.EXAMPLE: 1.0
- Parameters:
appVersion- Application version- Returns:
- the same
YandexMetricaConfig.Builderobject. - Throws:
java.lang.IllegalArgumentException- IfappVersionis null/empty.- See Also:
PackageInfo.versionName
-
withSessionTimeout
By default, the session times out if the app is inactive forYandexMetricaDefaultValues.DEFAULT_SESSION_TIMEOUT_SECONDSseconds. 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.Builderobject.
-
withCrashReporting
Whether to capture and send reports about crashes automatically.NOTE: Default value is
YandexMetricaDefaultValues.DEFAULT_REPORTS_CRASHES_ENABLED- Parameters:
enabled-trueif we need to send reports about crashes, otherwisefalse. In the case offalseyou can still send information about crashes viaYandexMetrica.reportUnhandledException(Throwable)method.- Returns:
- the same
YandexMetricaConfig.Builderobject. - See Also:
(boolean)
-
withNativeCrashReporting
Whether to capture and send reports about native crashes automatically.NOTE: Default value is
YandexMetricaDefaultValues.DEFAULT_REPORTS_NATIVE_CRASHES_ENABLED- Parameters:
enabled-trueif we need to send reports about native crashes, otherwisefalse. In the case offalseyou can still send information about native crashes viaYandexMetrica.reportNativeCrash(String)method.- Returns:
- the same
YandexMetricaConfig.Builderobject. - See Also:
withCrashReporting(boolean)
-
withLogs
Enable AppMetrica logging. Should be called before activation.- Returns:
- the same
YandexMetricaConfig.Builderobject.
-
withLocation
@NonNull public YandexMetricaConfig.Builder withLocation(@Nullable android.location.Location location)SetsLocationto 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_LOCATIONimprove the quality of auto collected location.- Parameters:
location- location to be used for reports- Returns:
- the same
YandexMetricaConfig.Builderobject. - See Also:
withLocationTracking(boolean),YandexMetrica.setLocation(Location),YandexMetrica.setLocationTracking(boolean)
-
withLocationTracking
Sets whether AppMetrica should include location information within its reports.NOTE: Default value is false
- Parameters:
enabled-trueto allow Yandex Metrica to record location information in reports, otherwisefalse.- Returns:
- the same
YandexMetricaConfig.Builderobject. - See Also:
withLocation(Location),YandexMetrica.setLocationTracking(boolean),YandexMetrica.setLocation(Location)
-
withPreloadInfo
Setspreload infofor tracking preloaded apps- Parameters:
preloadInfo- instance ofPreloadInfo- Returns:
- the same
YandexMetricaConfig.Builderobject
-
handleFirstActivationAsUpdate
Whether first activation of AppMetrica should be considered as app update or new app install.- Parameters:
value-trueif first call ofYandexMetrica.activate(android.content.Context, com.yandex.metrica.YandexMetricaConfig)should be considered as app update,falseotherwise.- Returns:
- the same
YandexMetricaConfig.Builderobject
-
withStatisticsSending
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-trueto allow AppMetrica sending statistics, otherwisefalse.- Returns:
- the same
YandexMetricaConfig.Builderobject
-
withMaxReportsInDatabaseCount
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.Builderobject.
-
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 passnullvalue.- Returns:
- the same
YandexMetricaConfig.Builderobject
-
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.Builderobject - See Also:
YandexMetrica.setUserProfileID(String)
-
withRevenueAutoTrackingEnabled
Enables/disables auto tracking of inapp purchases. Default value isYandexMetricaDefaultValues.DEFAULT_REVENUE_AUTO_TRACKING_ENABLED.- Parameters:
enabled-trueto allow inapp purchases auto tracking, otherwisefalse.- Returns:
- the same
YandexMetricaConfig.Builderobject
-
withSessionsAutoTrackingEnabled
Sets whether sessions auto tracking is enabled.- Parameters:
enabled- true if auto tracking should be enabled, false otherwise- Returns:
- the same
YandexMetricaConfig.Builderobject. - See Also:
Default value is .
-
withAppOpenTrackingEnabled
Sets whether app open auto tracking is enabled. Default value isYandexMetricaDefaultValues.DEFAULT_APP_OPEN_TRACKING_ENABLED.- Parameters:
enabled- true if auto tracking should be enabled, false otherwise- Returns:
- the same
YandexMetricaConfig.Builderobject. - See Also:
Set this flag to true instead of reporting deeplinks manually from via NOTE: Auto tracking will only capture links that open activity. Those that are clicked on while activity is opened will be ignored. To track them call from
-
build
Creates instance ofYandexMetricaConfig- Returns:
YandexMetricaConfigobject
-