Class YandexMetricaConfig.Builder
- Constructor Summary
- Method Summary
- Methods inherited from class java.lang.Object
- Constructor Detail
- Method Detail
- withAppVersion
- withSessionTimeout
- withCrashReporting
- withNativeCrashReporting
- withLogs
- withLocation
- withLocationTracking
- withPreloadInfo
- handleFirstActivationAsUpdate
- withStatisticsSending
- withMaxReportsInDatabaseCount
- withErrorEnvironmentValue
- withUserProfileID
- withRevenueAutoTrackingEnabled
- withSessionsAutoTrackingEnabled
- withAppOpenTrackingEnabled
- build
- Enclosing class:
- YandexMetricaConfig
public static class YandexMetricaConfig.Builder
extends java.lang.Object
YandexMetricaConfig
object.Constructor Summary
Modifier | Constructor and Description |
---|---|
protected | Builder(java.lang.String apiKey) |
Method Summary
Modifier and Type | Method and Description |
---|---|
YandexMetricaConfig | build()
Creates instance of
YandexMetricaConfig |
YandexMetricaConfig.Builder | handleFirstActivationAsUpdate(boolean value)
Whether first activation of AppMetrica should be considered as app update or new app install.
|
YandexMetricaConfig.Builder | withAppOpenTrackingEnabled(boolean enabled)
Sets whether app open auto tracking is enabled.
|
YandexMetricaConfig.Builder | withAppVersion(java.lang.String appVersion)
Sets the application version.
|
YandexMetricaConfig.Builder | withCrashReporting(boolean enabled)
Whether to capture and send reports about crashes automatically.
|
YandexMetricaConfig.Builder | withErrorEnvironmentValue(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.Builder | withLocation(android.location.Location location)
Sets
Location to be used as location for reports of AppMetrica. |
YandexMetricaConfig.Builder | withLocationTracking(boolean enabled)
Sets whether AppMetrica should include location information within its reports.
|
YandexMetricaConfig.Builder | withLogs()
Enable AppMetrica logging.
|
YandexMetricaConfig.Builder | withMaxReportsInDatabaseCount(int value)
Sets maximum number of reports to store in database.
|
YandexMetricaConfig.Builder | withNativeCrashReporting(boolean enabled)
Whether to capture and send reports about native crashes automatically.
|
YandexMetricaConfig.Builder | withPreloadInfo(PreloadInfo preloadInfo)
Sets
preload info for tracking preloaded apps |
YandexMetricaConfig.Builder | withRevenueAutoTrackingEnabled(boolean enabled)
Enables/disables auto tracking of inapp purchases.
|
YandexMetricaConfig.Builder | withSessionsAutoTrackingEnabled(boolean enabled)
Sets whether sessions auto tracking is enabled.
|
YandexMetricaConfig.Builder | withSessionTimeout(int sessionTimeout)
By default, the session times out if the app is inactive for
YandexMetricaDefaultValues.DEFAULT_SESSION_TIMEOUT_SECONDS seconds. |
YandexMetricaConfig.Builder | withStatisticsSending(boolean value)
Enables/disables statistics sending to the AppMetrica server.
|
YandexMetricaConfig.Builder | withUserProfileID(java.lang.String userProfileID)
Sets the ID of the user profile.
|
Method Detail
withAppVersion
@NonNull public YandexMetricaConfig.Builder withAppVersion(@Nullable java.lang.String appVersion)
android:versionName
of the AndroidManifest.xml file. EXAMPLE: 1.0
- Parameters:
appVersion
- Application version- Returns:
- the same
YandexMetricaConfig.Builder
object. - Throws:
java.lang.IllegalArgumentException
- IfappVersion
is null/empty.- See Also:
PackageInfo.versionName
withSessionTimeout
@NonNull public YandexMetricaConfig.Builder withSessionTimeout(int sessionTimeout)
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)
NOTE: Default value is YandexMetricaDefaultValues.DEFAULT_REPORTS_CRASHES_ENABLED
- Parameters:
enabled
-true
if we need to send reports about crashes, otherwisefalse
. In the case offalse
you can still send information about crashes viaYandexMetrica.reportUnhandledException(Throwable)
method.- Returns:
- the same
YandexMetricaConfig.Builder
object. - See Also:
(boolean)
withNativeCrashReporting
@NonNull public YandexMetricaConfig.Builder withNativeCrashReporting(boolean enabled)
NOTE: Default value is YandexMetricaDefaultValues.DEFAULT_REPORTS_NATIVE_CRASHES_ENABLED
- Parameters:
enabled
-true
if we need to send reports about native crashes, otherwisefalse
. In the case offalse
you can still send information about native crashes viaYandexMetrica.reportNativeCrash(String)
method.- Returns:
- the same
YandexMetricaConfig.Builder
object. - See Also:
withCrashReporting(boolean)
withLogs
@NonNull public YandexMetricaConfig.Builder withLogs()
- Returns:
- the same
YandexMetricaConfig.Builder
object.
withLocation
@NonNull public YandexMetricaConfig.Builder withLocation(@Nullable android.location.Location location)
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)
NOTE: Default value is
- Parameters:
enabled
-true
to allow Yandex Metrica to record location information in reports, otherwisefalse
.- 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)
preload info
for tracking preloaded apps- Parameters:
preloadInfo
- instance ofPreloadInfo
- Returns:
- the same
YandexMetricaConfig.Builder
object
handleFirstActivationAsUpdate
@NonNull public YandexMetricaConfig.Builder handleFirstActivationAsUpdate(boolean value)
- Parameters:
value
-true
if first call ofYandexMetrica.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)
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, otherwisefalse
.- Returns:
- the same
YandexMetricaConfig.Builder
object
withMaxReportsInDatabaseCount
@NonNull public YandexMetricaConfig.Builder withMaxReportsInDatabaseCount(int value)
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)
- Parameters:
key
- the environment key.value
- the environment value. To remove pair from environment passnull
value.- Returns:
- the same
YandexMetricaConfig.Builder
object
withUserProfileID
@NonNull public YandexMetricaConfig.Builder withUserProfileID(@Nullable java.lang.String userProfileID)
- 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)
YandexMetricaDefaultValues.DEFAULT_REVENUE_AUTO_TRACKING_ENABLED
.- Parameters:
enabled
-true
to allow inapp purchases auto tracking, otherwisefalse
.- Returns:
- the same
YandexMetricaConfig.Builder
object
withSessionsAutoTrackingEnabled
@NonNull public YandexMetricaConfig.Builder withSessionsAutoTrackingEnabled(boolean 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}.
withAppOpenTrackingEnabled
@NonNull public YandexMetricaConfig.Builder withAppOpenTrackingEnabled(boolean enabled)
YandexMetricaDefaultValues.DEFAULT_APP_OPEN_TRACKING_ENABLED
.- Parameters:
enabled
- true if auto tracking should be enabled, false otherwise- Returns:
- the same
YandexMetricaConfig.Builder
object. - See Also:
Set this flag to true instead of reporting deeplinks manually from {@link android.app.Activity#onCreate(android.os.Bundle)} via {@link com.yandex.metrica.YandexMetrica#reportAppOpen(android.app.Activity)} 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 {@link YandexMetrica#reportAppOpen(android.content.Intent)} from {@link android.app.Activity#onNewIntent(android.content.Intent)}
build
@NonNull public YandexMetricaConfig build()
YandexMetricaConfig
- Returns:
YandexMetricaConfig
object