Dynatrace provides privacy settings that allow you to control the amount of data collected from your users. These settings help ensure compliance with data protection regulations such as GDPR while still providing valuable insights into application performance. OneAgent supports privacy-first data collection by allowing developers to configure the level of data collection and crash reporting based on user consent, control data collection levels, enable or disable crash reporting, and apply user privacy options dynamically at runtime.
OneAgent supports three levels of data collection, defined by the DataCollectionLevel.
| Level | Description |
|---|---|
OFF | No data is collected. |
PERFORMANCE | Collects performance-related data, such as app crashes and ANRs. |
USER_BEHAVIOR | Collects both performance data and user behavior data, such as user actions. |
Configure the data collection level using the applyUserPrivacyOptions API.
import com.dynatrace.android.agent.Dynatraceimport com.dynatrace.android.agent.conf.UserPrivacyOptionsimport com.dynatrace.android.agent.conf.DataCollectionLevelval privacyOptions = Dynatrace.getUserPrivacyOptions()val updatedOptions = privacyOptions.newBuilder().withDataCollectionLevel(DataCollectionLevel.PERFORMANCE).build()Dynatrace.applyUserPrivacyOptions(updatedOptions)
Crash reporting is enabled by default but can be controlled dynamically based on user consent. When enabled, OneAgent collects crash data to help developers diagnose and fix issues in their applications.
Use the applyUserPrivacyOptions API to enable or disable crash reporting:
import com.dynatrace.android.agent.Dynatraceimport com.dynatrace.android.agent.conf.UserPrivacyOptionsval privacyOptions = Dynatrace.getUserPrivacyOptions()val updatedOptions = privacyOptions.newBuilder().withCrashReportingOptedIn(true) // Enable crash reporting.build()Dynatrace.applyUserPrivacyOptions(updatedOptions)
The applyUserPrivacyOptions API allows you to dynamically update privacy settings at runtime. This is useful for implementing user consent dialogs or privacy settings screens.
import com.dynatrace.android.agent.Dynatraceimport com.dynatrace.android.agent.conf.UserPrivacyOptionsimport com.dynatrace.android.agent.conf.DataCollectionLevelval privacyOptions = Dynatrace.getUserPrivacyOptions()val updatedOptions = privacyOptions.newBuilder().withDataCollectionLevel(DataCollectionLevel.USER_BEHAVIOR).withCrashReportingOptedIn(false).build()Dynatrace.applyUserPrivacyOptions(updatedOptions)
The User Opt-In feature allows developers to comply with privacy regulations by explicitly obtaining user consent before collecting data or enabling crash reporting. This feature ensures that users have control over their data and can make informed decisions about their privacy.
When the User Opt-In feature is enabled, OneAgent does not collect any data or enable crash reporting until the user explicitly provides consent. Developers can use the applyUserPrivacyOptions API to update the privacy settings based on the user's preferences.
If the User Opt-In feature is not implemented, OneAgent defaults to the following settings:
OFF.By implementing the User Opt-In feature, developers can ensure compliance with privacy regulations and provide users with greater control over their data.
To enable user opt-in mode, update your Gradle configuration:
Gradle plugin configuration:
dynatrace {configurations {defaultConfig {userOptIn true}}}
Manual startup configuration:
DynatraceConfigurationBuilder("<YourApplicationID>", "<ProvidedBeaconURL>").withUserOptIn(true).buildConfiguration()
Dynatrace doesn't provide a consent dialog UI. You must implement your own consent banner or dialog within your application. The dialog should:
For more information about privacy and security settings, refer to: