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.
For more information on configuring data privacy in mobile applications, see Configure data privacy settings for mobile applications.
While Dynatrace offers numerous data privacy settings, it is your responsibility to properly configure these settings and implement appropriate consent mechanisms to protect your users' personal data.
The Dynatrace Flutter plugin supports three data collection levels that determine what information is captured and sent to Dynatrace.
The possible values for the data collection level are:
OffPerformanceUserBehaviorUser opt-in mode requires explicit user consent before collecting monitoring data. When enabled, no monitoring data is collected until the user grants consent.
When user opt-in mode is enabled, the following defaults apply until the user sets their preferences:
Off (no monitoring data is sent).false (crash reports are not sent).These defaults apply until the user sets their preferences for the first time. Once set, preferences are stored and restored automatically on subsequent launches.
User opt-in mode is optional. Without it, the agent collects data and reports crashes by default, without requiring user consent. When enabled, your application must provide a consent UI to the end user; until the user explicitly grants consent, no data is collected and crash reporting remains off.
Enabling user opt-in mode requires two steps:
dynatrace.config.yaml file to add the opt-in flag and rebuild your application.To complete step 2, update your dynatrace.config.yaml file:
Android:
android:config:"dynatrace {configurations {defaultConfig {userOptIn true}}}"
iOS:
ios:config:"<key>DTXUserOptIn</key><true/>"
After updating the configuration, run dart run dynatrace_flutter_plugin to regenerate the native configuration files and apply the changes.
If userOptIn is omitted from the configuration, it defaults to false; opt-in mode is disabled and data collection proceeds according to your other configuration settings.
Dynatrace does not provide a consent dialog UI. You must implement your own consent banner or dialog within your application. The dialog should:
When the user makes a consent decision, apply their preferences using the privacy API:
import 'package:dynatrace_flutter_plugin/dynatrace_flutter_plugin.dart';// Full monitoringDynatrace().applyUserPrivacyOptions(UserPrivacyOptions(DataCollectionLevel.UserBehavior, true),);// Performance monitoring, no crash reportingDynatrace().applyUserPrivacyOptions(UserPrivacyOptions(DataCollectionLevel.Performance, false),);// User declined — revoke all consentDynatrace().applyUserPrivacyOptions(UserPrivacyOptions(DataCollectionLevel.Off, false),);
Use the privacy API to get and apply user privacy preferences.
Retrieve the current privacy settings:
import 'package:dynatrace_flutter_plugin/dynatrace_flutter_plugin.dart';Future<void> checkPrivacySettings() async {final options = await Dynatrace().getUserPrivacyOptions();print('Data collection level: ${options.dataCollectionLevel}');print('Crash reporting enabled: ${options.crashReportingOptedIn}');}
If called before the agent has started, getUserPrivacyOptions returns default values: DataCollectionLevel.Off and crash reporting false. These are not the user's stored preferences; call this method only after the agent has finished starting.
Set the user's privacy preferences:
import 'package:dynatrace_flutter_plugin/dynatrace_flutter_plugin.dart';// Grant full consentDynatrace().applyUserPrivacyOptions(UserPrivacyOptions(DataCollectionLevel.UserBehavior, true),);// Grant performance monitoring only, no crash reportingDynatrace().applyUserPrivacyOptions(UserPrivacyOptions(DataCollectionLevel.Performance, false),);// Revoke all consentDynatrace().applyUserPrivacyOptions(UserPrivacyOptions(DataCollectionLevel.Off, false),);
UserPrivacyOptions accepts two parameters:
| Parameter | Type | Description |
|---|---|---|
|
| Controls what monitoring data is collected. |
|
| Whether crash reports are sent. |
When you apply new privacy options, a new session is created with the specified settings. The settings are stored and automatically applied to future sessions.
applyUserPrivacyOptions only takes effect when user opt-in mode is enabled (userOptIn true in your configuration). Calling this API without opt-in mode enabled has no effect and produces no error.
Calling applyUserPrivacyOptions before Dynatrace().start() has completed has no effect. Call it only after the agent has finished starting.
You can also modify existing privacy options:
import 'package:dynatrace_flutter_plugin/dynatrace_flutter_plugin.dart';Future<void> updatePrivacySettings() async {final privacyOptions = await Dynatrace().getUserPrivacyOptions();// Modify the optionsprivacyOptions.crashReportingOptedIn = false;privacyOptions.dataCollectionLevel = DataCollectionLevel.Performance;// Apply the modified optionsDynatrace().applyUserPrivacyOptions(privacyOptions);}
When submitting your app to the App Store or Google Play, you may need to complete a privacy questionnaire. For information on what data OneAgent captures, see: