Package com.mixpanel.android.mpmetrics
Class MPConfig
java.lang.Object
com.mixpanel.android.mpmetrics.MPConfig
Stores global configuration options for the Mixpanel library. You can enable and disable configuration
options using <meta-data> tags inside of the <application> tag in your AndroidManifest.xml.
All settings are optional, and default to reasonable recommended values. Most users will not have to
set any options.
Mixpanel understands the following options:
- com.mixpanel.android.MPConfig.EnableDebugLogging
- A boolean value. If true, emit more detailed log messages. Defaults to false
- com.mixpanel.android.MPConfig.BulkUploadLimit
- An integer count of messages, the maximum number of messages to queue before an upload attempt. This value should be less than 50.
- com.mixpanel.android.MPConfig.FlushInterval
- An integer number of milliseconds, the maximum time to wait before an upload if the bulk upload limit isn't reached.
- com.mixpanel.android.MPConfig.FlushBatchSize
- Maximum number of events/updates to send in a single network request
- com.mixpanel.android.MPConfig.FlushOnBackground
- A boolean value. If false, the library will not flush the event and people queues when the app goes into the background. Defaults to true.
- com.mixpanel.android.MPConfig.DebugFlushInterval
- An integer number of milliseconds, the maximum time to wait before an upload if the bulk upload limit isn't reached in debug mode.
- com.mixpanel.android.MPConfig.DataExpiration
- An integer number of milliseconds, the maximum age of records to send to Mixpanel. Corresponds to Mixpanel's server-side limit on record age.
- com.mixpanel.android.MPConfig.MinimumDatabaseLimit
- An integer number of bytes. Mixpanel attempts to limit the size of its persistent data queue based on the storage capacity of the device, but will always allow queuing below this limit. Higher values will take up more storage even when user storage is very full.
- com.mixpanel.android.MPConfig.MaximumDatabaseLimit
- An integer number of bytes, the maximum size limit to the Mixpanel database.
- com.mixpanel.android.MPConfig.ResourcePackageName
- A string java package name. Defaults to the package name of the Application. Users should set if the package name of their R class is different from the application package name due to application id settings.
- com.mixpanel.android.MPConfig.DisableAppOpenEvent
- A boolean value. If true, do not send an "$app_open" event when the MixpanelAPI object is created for the first time. Defaults to true - the $app_open event will not be sent by default.
- com.mixpanel.android.MPConfig.DisableExceptionHandler
- A boolean value. If true, do not automatically capture app crashes. "App Crashed" events won't show up on Mixpanel. Defaults to false.
- com.mixpanel.android.MPConfig.EventsEndpoint
- A string URL. If present, the library will attempt to send events to this endpoint rather than to the default Mixpanel endpoint.
- com.mixpanel.android.MPConfig.PeopleEndpoint
- A string URL. If present, the library will attempt to send people updates to this endpoint rather than to the default Mixpanel endpoint.
- com.mixpanel.android.MPConfig.GroupsEndpoint
- A string URL. If present, the library will attempt to send group updates to this endpoint rather than to the default Mixpanel endpoint.
- com.mixpanel.android.MPConfig.MinimumSessionDuration
- An integer number. The minimum session duration (ms) that is tracked in automatic events. Defaults to 10000 (10 seconds).
- com.mixpanel.android.MPConfig.SessionTimeoutDuration
- An integer number. The maximum session duration (ms) that is tracked in automatic events. Defaults to Integer.MAX_VALUE (no maximum session duration).
- com.mixpanel.android.MPConfig.UseIpAddressForGeolocation
- A boolean value. If true, Mixpanel will automatically determine city, region and country data using the IP address of the client.Defaults to true.
- com.mixpanel.android.MPConfig.RemoveLegacyResidualFiles
- A boolean value. If true, Mixpanel will remove the residual files from legacy versions such as images produced by deprecated Messages and Experiment features. Defaults to false.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
long
boolean
boolean
int
int
boolean
static MPConfig
getInstance
(android.content.Context context, String instanceName) Retrieves a new instance of MPConfig with configuration settings loaded from the provided context.int
int
int
boolean
int
boolean
void
setEnableLogging
(boolean enableLogging) void
setFlushBatchSize
(int flushBatchSize) void
setMaximumDatabaseLimit
(int maximumDatabaseLimit) void
setOfflineMode
(OfflineMode offlineMode) OfflineMode
allows Mixpanel to be in-sync with client offline internal logic.void
setProxyServerInteractor
(ProxyServerInteractor interactor) void
setServerURL
(String serverURL) void
setServerURL
(String serverURL, ProxyServerInteractor interactor) void
setSSLSocketFactory
(SSLSocketFactory factory) The MixpanelAPI will use the system default SSL socket settings under ordinary circumstances.void
setTrackAutomaticEvents
(boolean trackAutomaticEvents) void
setUseIpAddressForGeolocation
(boolean useIpAddressForGeolocation) toString()
-
Field Details
-
VERSION
- See Also:
-
DEBUG
public static boolean DEBUG
-
-
Method Details
-
getInstance
Retrieves a new instance of MPConfig with configuration settings loaded from the provided context. This method creates a new instance each time it is called, allowing for multiple configurations within the same application. Since version 7.4.0, MPConfig is no longer a Singleton, in favor of supporting multiple, distinct configurations for different Mixpanel instances. This change allows greater flexibility in scenarios where different parts of an application require different Mixpanel configurations, such as different endpoints or settings. It's important for users of this method to manage the lifecycle of the returned MPConfig instances themselves. Each call will result in a new configuration instance based on the application's metadata, and it's the responsibility of the caller to maintain any necessary references to these instances to use them later in their application.- Parameters:
context
- The context used to load Mixpanel configuration. It's recommended to provide an ApplicationContext to avoid potential memory leaks.- Returns:
- A new instance of MPConfig with settings loaded from the context's application metadata.
-
setSSLSocketFactory
The MixpanelAPI will use the system default SSL socket settings under ordinary circumstances. That means it will ignore settings you associated with the default SSLSocketFactory in the schema registry or in underlying HTTP libraries. If you'd prefer for Mixpanel to use your own SSL settings, you'll need to call setSSLSocketFactory early in your code, like this<pre> MPConfig.getInstance(context).setSSLSocketFactory(someCustomizedSocketFactory); </pre>
Your settings will be globally available to all Mixpanel instances, and will be used for all SSL connections in the library. The call is thread safe, but should be done before your first call to MixpanelAPI.getInstance to insure that the library never uses it's default. The given socket factory may be used from multiple threads, which is safe for the system SSLSocketFactory class, but if you pass a subclass you should ensure that it is thread-safe before passing it to Mixpanel.- Parameters:
factory
- an SSLSocketFactory that
-
setOfflineMode
OfflineMode
allows Mixpanel to be in-sync with client offline internal logic. If you want to integrate your own logic with Mixpanel you'll need to callsetOfflineMode(OfflineMode)
early in your code, like this<pre> MPConfig.getInstance(context).setOfflineMode(OfflineModeImplementation); </pre>
Your settings will be globally available to all Mixpanel instances, and will be used across all the library. The call is thread safe, but should be done before your first call to MixpanelAPI.getInstance to insure that the library never uses it's default. The givenOfflineMode
may be used from multiple threads, you should ensure that your implementation is thread-safe before passing it to Mixpanel.- Parameters:
offlineMode
- client offline implementation to use on Mixpanel
-
getBulkUploadLimit
public int getBulkUploadLimit() -
getFlushInterval
public int getFlushInterval() -
getFlushOnBackground
public boolean getFlushOnBackground() -
getFlushBatchSize
public int getFlushBatchSize() -
setFlushBatchSize
public void setFlushBatchSize(int flushBatchSize) -
getDataExpiration
public long getDataExpiration() -
getMinimumDatabaseLimit
public int getMinimumDatabaseLimit() -
getMaximumDatabaseLimit
public int getMaximumDatabaseLimit() -
setMaximumDatabaseLimit
public void setMaximumDatabaseLimit(int maximumDatabaseLimit) -
getInstanceName
-
getDisableAppOpenEvent
public boolean getDisableAppOpenEvent() -
getEventsEndpoint
-
getTrackAutomaticEvents
public boolean getTrackAutomaticEvents() -
setServerURL
-
setServerURL
-
getPeopleEndpoint
-
getGroupsEndpoint
-
getMinimumSessionDuration
public int getMinimumSessionDuration() -
getSessionTimeoutDuration
public int getSessionTimeoutDuration() -
getDisableExceptionHandler
public boolean getDisableExceptionHandler() -
getRemoveLegacyResidualFiles
public boolean getRemoveLegacyResidualFiles() -
setUseIpAddressForGeolocation
public void setUseIpAddressForGeolocation(boolean useIpAddressForGeolocation) -
setEnableLogging
public void setEnableLogging(boolean enableLogging) -
setTrackAutomaticEvents
public void setTrackAutomaticEvents(boolean trackAutomaticEvents) -
getResourcePackageName
-
getSSLSocketFactory
-
getOfflineMode
-
getProxyServerInteractor
-
setProxyServerInteractor
-
toString
-