Class AppMetricaConfig.Builder
- Enclosing class:
- AppMetricaConfig
AppMetricaConfig
object.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Creates instance ofAppMetricaConfig
handleFirstActivationAsUpdate
(boolean value) Whether first activation of AppMetrica should be considered as app update or new app install.withAdditionalConfig
(String key, Object config) Sets key - config datawithAdvIdentifiersTracking
(boolean enabled) Enables/disables including advertising identifiers like GAID, Huawei OAID within its reports.withAnrMonitoring
(boolean enabled) Whether to capture and send reports about ANRs automatically.withAnrMonitoringTimeout
(int timeout) The timeout in seconds at which the fact of ANR is recorded.withAppBuildNumber
(int appBuildNumber) Sets the application build number, if missing, the application version is read fromandroid:versionCode
fieldAndroidManifest.xml
file.withAppEnvironmentValue
(String key, String value) Sets key - value pair to be used as additional information, associated with your application runtime's environment.withAppOpenTrackingEnabled
(boolean enabled) Sets whether app open auto tracking is enabled.withAppVersion
(String appVersion) Sets the application version.withCrashReporting
(boolean enabled) Whether to capture and send reports about crashes automatically.withCrashTransformer
(ICrashTransformer crashTransformer) Custom crash transformer which is applied to crashes.withCustomHosts
(List<String> hosts) Sets the list of hosts.withDataSendingEnabled
(boolean value) Enables/disables data sending to the AppMetrica server.withDeviceType
(String deviceType) Sets size type of device based on screen size: phone, tablet, phablet, TV.withDispatchPeriodSeconds
(int dispatchPeriodSeconds) Sets timeout for sending reports.withErrorEnvironmentValue
(String key, String value) Sets key - value data to be used as additional information, associated with your unhandled exception and error reports.withLocation
(android.location.Location location) SetsLocation
to be used as location for reports of AppMetrica.withLocationTracking
(boolean enabled) Sets whether AppMetrica should include location information within its reports.withLogs()
Enable AppMetrica logging.withMaxReportsCount
(int maxReportsCount) Sets maximum buffer size for reports.withMaxReportsInDatabaseCount
(int value) Sets maximum number of reports to store in database.withNativeCrashReporting
(boolean enabled) Whether to capture and send reports about native crashes automatically.withPreloadInfo
(PreloadInfo preloadInfo) Setspreload info
for tracking preloaded appswithRevenueAutoTrackingEnabled
(boolean enabled) Enables/disables auto tracking of inapp purchases.withSessionsAutoTrackingEnabled
(boolean enabled) Sets whether sessions auto tracking is enabled.withSessionTimeout
(int sessionTimeout) By default, the session times out if the app is inactive for 10 seconds.withUserProfileID
(String userProfileID) Sets the ID of the user profile.
-
Method Details
-
withAppVersion
Sets the application version. It is optional value. By default, the app version is set in fieldandroid:versionName
of the AndroidManifest.xml file.EXAMPLE: 1.0
- Parameters:
appVersion
- Application version- Returns:
- the same
AppMetricaConfig.Builder
object. - Throws:
IllegalArgumentException
- IfappVersion
is null/empty.- See Also:
-
PackageInfo.versionName
-
withSessionTimeout
By default, the session times out if the app is inactive for 10 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
AppMetricaConfig.Builder
object.
-
withCrashReporting
Whether to capture and send reports about crashes automatically.NOTE: Default value is true
- Parameters:
enabled
-true
if we need to send reports about crashes, otherwisefalse
. In the case offalse
you can still send information about crashes viaAppMetrica.reportUnhandledException(Throwable)
method.- Returns:
- the same
AppMetricaConfig.Builder
object. - See Also:
-
withNativeCrashReporting
Whether to capture and send reports about native crashes automatically.NOTE: Default value is true
- Parameters:
enabled
-true
if we need to send reports about native crashes, otherwisefalse
.- Returns:
- the same
AppMetricaConfig.Builder
object. - See Also:
-
withLogs
Enable AppMetrica logging. Should be called before activation.- Returns:
- the same
AppMetricaConfig.Builder
object.
-
withLocation
SetsLocation
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
AppMetricaConfig.Builder
object. - See Also:
-
withLocationTracking
Sets whether AppMetrica should include location information within its reports.NOTE: Default value is false
- Parameters:
enabled
-true
to allow AppMetrica to record location information in reports, otherwisefalse
.- Returns:
- the same
AppMetricaConfig.Builder
object. - See Also:
-
withAdvIdentifiersTracking
Enables/disables including advertising identifiers like GAID, Huawei OAID within its reports.NOTE: Default value is true.
- Parameters:
enabled
-true
to allow AppMetrica to record advertising identifiers information in reports, otherwisefalse
.- Returns:
- the same
AppMetricaConfig.Builder
object. - See Also:
-
withPreloadInfo
Setspreload info
for tracking preloaded apps- Parameters:
preloadInfo
- instance ofPreloadInfo
- Returns:
- the same
AppMetricaConfig.Builder
object
-
handleFirstActivationAsUpdate
Whether first activation of AppMetrica should be considered as app update or new app install.- Parameters:
value
-true
if first call ofAppMetrica.activate(android.content.Context, io.appmetrica.analytics.AppMetricaConfig)
should be considered as app update,false
otherwise.- Returns:
- the same
AppMetricaConfig.Builder
object
-
withDataSendingEnabled
Enables/disables data 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 data, otherwisefalse
.- Returns:
- the same
AppMetricaConfig.Builder
object
-
withMaxReportsInDatabaseCount
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:
value
- 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
AppMetricaConfig.Builder
object.
-
withErrorEnvironmentValue
@NonNull public AppMetricaConfig.Builder withErrorEnvironmentValue(@NonNull String key, @Nullable 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 passnull
value.- Returns:
- the same
AppMetricaConfig.Builder
object
-
withUserProfileID
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
AppMetricaConfig.Builder
object - See Also:
-
withRevenueAutoTrackingEnabled
Enables/disables auto tracking of inapp purchases. Default value is true.- Parameters:
enabled
-true
to allow inapp purchases auto tracking, otherwisefalse
.- Returns:
- the same
AppMetricaConfig.Builder
object
-
withSessionsAutoTrackingEnabled
Sets whether sessions auto tracking is enabled.- Parameters:
enabled
- true if auto tracking should be enabled, false otherwise- Returns:
- the same
AppMetricaConfig.Builder
object. - See Also:
-
withAppOpenTrackingEnabled
Sets whether app open auto tracking is enabled. Default value is true.- Parameters:
enabled
- true if auto tracking should be enabled, false otherwise- Returns:
- the same
AppMetricaConfig.Builder
object. - See Also:
-
withAdditionalConfig
@NonNull public AppMetricaConfig.Builder withAdditionalConfig(@NonNull String key, @Nullable Object config) Sets key - config data- Parameters:
key
- the config key.config
- the config value.- Returns:
- the same
AppMetricaConfig.Builder
object.
-
withDeviceType
Sets size type of device based on screen size: phone, tablet, phablet, TV.- Parameters:
deviceType
- type of device. Some common-used types are listed inPredefinedDeviceTypes
class. One can find complete list in the official documentation.- Returns:
- the same
AppMetricaConfig.Builder
object.
-
withAppBuildNumber
Sets the application build number, if missing, the application version is read fromandroid:versionCode
fieldAndroidManifest.xml
file.EXAMPLE: 1
- Parameters:
appBuildNumber
- Application version code.- Returns:
- the same
AppMetricaConfig.Builder
object. - Throws:
IllegalArgumentException
- ifappBuildNumber
< 0- See Also:
-
PackageInfo.versionCode
-
withDispatchPeriodSeconds
Sets timeout for sending reports.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
AppMetricaConfig.Builder
object. - See Also:
-
withMaxReportsCount
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
AppMetricaConfig.Builder
object. - See Also:
-
withAppEnvironmentValue
@NonNull public AppMetricaConfig.Builder withAppEnvironmentValue(@NonNull String key, @Nullable 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 useAppMetrica.clearAppEnvironment()
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 passnull
value.- Returns:
- the same
AppMetricaConfig.Builder
object - See Also:
-
withCrashTransformer
@NonNull public AppMetricaConfig.Builder withCrashTransformer(@Nullable ICrashTransformer crashTransformer) Custom crash transformer which is applied to crashes.- Parameters:
crashTransformer
-ICrashTransformer
implementation to be applied.- Returns:
- the same
AppMetricaConfig.Builder
object.
-
withAnrMonitoring
Whether to capture and send reports about ANRs automatically.NOTE: Default value is false.
- Parameters:
enabled
-true
if we need to send reports about ANRs, otherwisefalse
.- Returns:
- the same
AppMetricaConfig.Builder
object.
-
withAnrMonitoringTimeout
The timeout in seconds at which the fact of ANR is recorded.- Parameters:
timeout
- the timeout in seconds at which the fact of ANR is recorded- Returns:
- the same
AppMetricaConfig.Builder
object.
-
withCustomHosts
Sets the list of hosts. This is optional value.- Parameters:
hosts
- non-empty host list.- Returns:
- the same
AppMetricaConfig.Builder
object.
-
build
Creates instance ofAppMetricaConfig
- Returns:
AppMetricaConfig
object
-