Package com.mparticle
Class MParticleOptions.Builder
- java.lang.Object
-
- com.mparticle.MParticleOptions.Builder
-
- Enclosing class:
- MParticleOptions
public static class MParticleOptions.Builder extends java.lang.Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MParticleOptions.Builder
androidIdDisabled(boolean disabled)
Deprecated.This method has been replaced as the behavior has been inverted - Android ID collection is now disabled by default.MParticleOptions.Builder
androidIdEnabled(boolean enabled)
By default, the SDK will NOT collect Android Id for the purpose of anonymous analytics.MParticleOptions.Builder
attributionListener(AttributionListener attributionListener)
Register a callback for when an attribution is received.MParticleOptions
build()
Builds this Builder into an MParticleOptions object which can be used to start the SDK.MParticleOptions.Builder
configMaxAgeSeconds(int configMaxAge)
Set a maximum threshold for stored configuration age.MParticleOptions.Builder
configuration(Configuration configuration)
Register aConfiguration
n.MParticleOptions.Builder
credentials(java.lang.String apiKey, java.lang.String apiSecret)
Register an Api Key and Secret to be used for the SDK.MParticleOptions.Builder
dataplan(java.lang.String dataplanId, java.lang.Integer dataplanVersion)
MParticleOptions.Builder
dataplanOptions(MParticleOptions.DataplanOptions dataplanOptions)
Set theMParticleOptions.DataplanOptions
.MParticleOptions.Builder
devicePerformanceMetricsDisabled(boolean disabled)
Disable CPU and memory usage collection.MParticleOptions.Builder
enableUncaughtExceptionLogging(boolean enable)
Enable or disable mParticle exception handling to automatically log events on uncaught exceptions.MParticleOptions.Builder
environment(MParticle.Environment environment)
Indicate a knownMParticle.Environment
the Application will be running in.MParticleOptions.Builder
identify(IdentityApiRequest identifyRequest)
Register an IdentityApiRequest which will be passed to anIdentityApi.identify(IdentityApiRequest)
request when the SDK starts in order to interact with the results of this call, without registering a global listener inIdentityApi.addIdentityStateListener(IdentityStateListener)
, register a BaseIdentityTask withidentifyTask(BaseIdentityTask)
.MParticleOptions.Builder
identifyTask(BaseIdentityTask task)
Register an BaseIdentityTask, which can be used to interact with the asynchronous results of anidentify(IdentityApiRequest)
request.MParticleOptions.Builder
identityConnectionTimeout(int identityConnectionTimeout)
Set the user connection timeout interval.MParticleOptions.Builder
installType(MParticle.InstallType installType)
Indicate a knownMParticle.InstallType
.MParticleOptions.Builder
locationTrackingDisabled()
Disables Location tracking.MParticleOptions.Builder
locationTrackingEnabled(java.lang.String provider, long minTime, long minDistance)
Enables location tracking given a provider and update frequency criteria.MParticleOptions.Builder
logLevel(MParticle.LogLevel logLevel)
Set the minimum log level for the SDK.MParticleOptions.Builder
networkOptions(NetworkOptions networkOptions)
MParticleOptions.Builder
operatingSystem(MParticle.OperatingSystem operatingSystem)
Set the Operating System.MParticleOptions.Builder
pushRegistration(java.lang.String instanceId, java.lang.String senderId)
Manually log a push registration.MParticleOptions.Builder
sessionTimeout(int sessionTimeout)
Set the user session timeout interval.MParticleOptions.Builder
uploadInterval(int uploadInterval)
Set the upload interval period to control how frequently uploads occur.
-
-
-
Method Detail
-
credentials
@NonNull public MParticleOptions.Builder credentials(@NonNull java.lang.String apiKey, @NonNull java.lang.String apiSecret)
Register an Api Key and Secret to be used for the SDK. This is a required field, and your app will not function properly if you do not provide a valid Key and Secret.- Parameters:
apiKey
- the Api KeyapiSecret
- the Api Secret- Returns:
- the instance of the builder, for chaining calls
-
installType
@NonNull public MParticleOptions.Builder installType(@NonNull MParticle.InstallType installType)
Indicate a knownMParticle.InstallType
. If this method is not used, a default type of MParticle.InstallType.AutoDetect will be used.- Parameters:
installType
-- Returns:
- the instance of the builder, for chaining calls
- See Also:
MParticle.InstallType
-
environment
@NonNull public MParticleOptions.Builder environment(@NonNull MParticle.Environment environment)
Indicate a knownMParticle.Environment
the Application will be running in. If this method is not used. a default Environment of MParticle.Environment.AutoDetect will be used.- Parameters:
environment
-- Returns:
-
identify
@NonNull public MParticleOptions.Builder identify(@NonNull IdentityApiRequest identifyRequest)
Register an IdentityApiRequest which will be passed to anIdentityApi.identify(IdentityApiRequest)
request when the SDK starts in order to interact with the results of this call, without registering a global listener inIdentityApi.addIdentityStateListener(IdentityStateListener)
, register a BaseIdentityTask withidentifyTask(BaseIdentityTask)
. If this method is not called, an Identify request using the most recent current user will be used, or if this is a first-run, and empty request will be used.- Parameters:
identifyRequest
-- Returns:
- the instance of the builder, for chaining calls
- See Also:
IdentityApiRequest
-
identifyTask
@NonNull public MParticleOptions.Builder identifyTask(@NonNull BaseIdentityTask task)
Register an BaseIdentityTask, which can be used to interact with the asynchronous results of anidentify(IdentityApiRequest)
request.- Parameters:
task
-- Returns:
- the instance of the builder, for chaining calls
- See Also:
BaseIdentityTask
-
devicePerformanceMetricsDisabled
@NonNull public MParticleOptions.Builder devicePerformanceMetricsDisabled(boolean disabled)
Disable CPU and memory usage collection.- Parameters:
disabled
-- Returns:
- the instance of the builder, for chaining calls
-
androidIdDisabled
@NonNull @Deprecated public MParticleOptions.Builder androidIdDisabled(boolean disabled)
Deprecated.This method has been replaced as the behavior has been inverted - Android ID collection is now disabled by default.Use
androidIdEnabled(boolean)
instead. By default, the SDK will NOT collect Android Id for the purpose of anonymous analytics. If you're not using an mParticle integration that consumes Android ID and you would like to collect it, use this API to enable collection.- Parameters:
disabled
- false to enable collection (true by default)- Returns:
- the instance of the builder, for chaining calls
-
androidIdEnabled
@NonNull public MParticleOptions.Builder androidIdEnabled(boolean enabled)
By default, the SDK will NOT collect Android Id for the purpose of anonymous analytics. If you're not using an mParticle integration that consumes Android ID and you would like to collect it, use this API to enable collection- Parameters:
enabled
- true to enable collection (false by default)- Returns:
- the instance of the builder, for chaining calls
-
uploadInterval
@NonNull public MParticleOptions.Builder uploadInterval(int uploadInterval)
Set the upload interval period to control how frequently uploads occur.- Parameters:
uploadInterval
- the number of seconds between uploads- Returns:
- the instance of the builder, for chaining calls
-
sessionTimeout
@NonNull public MParticleOptions.Builder sessionTimeout(int sessionTimeout)
Set the user session timeout interval. A session has ended once the application has been in the background for more than this timeout.- Parameters:
sessionTimeout
- Session timeout in seconds- Returns:
- the instance of the builder, for chaining calls
-
configMaxAgeSeconds
@NonNull public MParticleOptions.Builder configMaxAgeSeconds(int configMaxAge)
Set a maximum threshold for stored configuration age. When the SDK starts, before we attempt to fetch a fresh config from the server, we will load the most recent previous config from disk. when configMaxAge is set, we will check the timestamp on that config and, if it's age is greater than the threshold, instead of loading it we will delete it and wait for the fresh config to arrive. This field is especially useful if your application often updates the kit/forwarding logic and has a portion of user's who experience prolonged network interruptions. In these cases, a reasonable configMaxAge will prevent those users from potentially using very forwarding logic- Parameters:
configMaxAge
- the upper limit for config age, in seconds- Returns:
- the instance of the builder, for chaining calls
-
enableUncaughtExceptionLogging
@NonNull public MParticleOptions.Builder enableUncaughtExceptionLogging(boolean enable)
Enable or disable mParticle exception handling to automatically log events on uncaught exceptions.- Returns:
- the instance of the builder, for chaining calls
-
logLevel
@NonNull public MParticleOptions.Builder logLevel(@NonNull MParticle.LogLevel logLevel)
Set the minimum log level for the SDK. The log level is used to moderate the amount of messages that are printed by the SDK to the console. Note that while the SDK is in the Production, log messages at or above this level will be printed.- Parameters:
logLevel
- the preferred level of logging- Returns:
- the instance of the builder, for chaining calls
- See Also:
MParticle.LogLevel
-
attributionListener
@NonNull public MParticleOptions.Builder attributionListener(@Nullable AttributionListener attributionListener)
Register a callback for when an attribution is received.- Parameters:
attributionListener
- an instance of the AttributionListener callback- Returns:
- the instance of the builder, for chaining calls
- See Also:
AttributionListener
-
locationTrackingDisabled
@NonNull public MParticleOptions.Builder locationTrackingDisabled()
Disables Location tracking.- Returns:
- the instance of the builder, for chaining calls
-
locationTrackingEnabled
@NonNull public MParticleOptions.Builder locationTrackingEnabled(@NonNull java.lang.String provider, long minTime, long minDistance)
Enables location tracking given a provider and update frequency criteria. The provider must be available and the correct permissions must have been requested within your application's manifest XML file.- Parameters:
provider
- the provider keyminTime
- the minimum time (in milliseconds) to trigger an updateminDistance
- the minimum distance (in meters) to trigger an update- Returns:
- the instance of the builder, for chaining calls
-
pushRegistration
@NonNull public MParticleOptions.Builder pushRegistration(@NonNull java.lang.String instanceId, @NonNull java.lang.String senderId)
Manually log a push registration.- Parameters:
instanceId
- the Instance Id of the push tokensenderId
- the Sender Id of the push token- Returns:
- the instance of the builder, for chaining calls
-
identityConnectionTimeout
@NonNull public MParticleOptions.Builder identityConnectionTimeout(int identityConnectionTimeout)
Set the user connection timeout interval. A connection to the server closes after this timeout expires, for each call.- Parameters:
identityConnectionTimeout
- the connection timeout for Identity server calls, in seconds- Returns:
- the instance of the builder, for chaining calls
-
networkOptions
@NonNull public MParticleOptions.Builder networkOptions(@Nullable NetworkOptions networkOptions)
-
dataplan
@NonNull public MParticleOptions.Builder dataplan(@Nullable java.lang.String dataplanId, @Nullable java.lang.Integer dataplanVersion)
-
operatingSystem
@NonNull public MParticleOptions.Builder operatingSystem(MParticle.OperatingSystem operatingSystem)
Set the Operating System. Defaults toMParticle.OperatingSystem.ANDROID
- Parameters:
operatingSystem
-- Returns:
-
dataplanOptions
@NonNull public MParticleOptions.Builder dataplanOptions(MParticleOptions.DataplanOptions dataplanOptions)
Set theMParticleOptions.DataplanOptions
. This object is used to load a dataplan for the purpose of blocking unplanned attributes and/or events from being forwarded to kit integrations. When set, this will override any block settings that have been configured in the mParticle dashboard.- Parameters:
dataplanOptions
-- Returns:
-
configuration
public MParticleOptions.Builder configuration(Configuration configuration)
Register aConfiguration
n. Various implementations of Configuration can modify the behavior of the SDK at runtime.- Parameters:
configuration
-
-
build
@NonNull public MParticleOptions build()
Builds this Builder into an MParticleOptions object which can be used to start the SDK.- Returns:
- MParticleOptions instance
-
-