Try it free

Privacy and data collection

  • Latest Dynatrace
  • Explanation
  • 1-min read

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.

Data collection levels

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:

  • Off
  • Performance
  • UserBehavior

User opt-in mode

User opt-in mode requires explicit user consent before collecting monitoring data. When enabled, no monitoring data is collected until the user grants consent.

Default behavior

When user opt-in mode is enabled, the following defaults apply until the user sets their preferences:

  • Data collection level: Off (no monitoring data is sent).
  • Crash reporting: 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.

Enable user opt-in mode

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:

  1. Turn on Enable user opt-in mode in your application's data privacy settings in the Dynatrace tenant. See Enable opt-in mode for instructions.
  2. Update your 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.

Implement a consent dialog

Dynatrace does not provide a consent dialog UI. You must implement your own consent banner or dialog within your application. The dialog should:

  • Explain what data will be collected.
  • Allow users to choose their preferred data collection level.
  • Allow users to enable or disable crash reporting.
  • Provide a way for users to change their preferences later.

When the user makes a consent decision, apply their preferences using the privacy API:

import 'package:dynatrace_flutter_plugin/dynatrace_flutter_plugin.dart';
// Full monitoring
Dynatrace().applyUserPrivacyOptions(
UserPrivacyOptions(DataCollectionLevel.UserBehavior, true),
);
// Performance monitoring, no crash reporting
Dynatrace().applyUserPrivacyOptions(
UserPrivacyOptions(DataCollectionLevel.Performance, false),
);
// User declined — revoke all consent
Dynatrace().applyUserPrivacyOptions(
UserPrivacyOptions(DataCollectionLevel.Off, false),
);

Privacy API

Use the privacy API to get and apply user privacy preferences.

Get current privacy options

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.

Apply privacy options

Set the user's privacy preferences:

import 'package:dynatrace_flutter_plugin/dynatrace_flutter_plugin.dart';
// Grant full consent
Dynatrace().applyUserPrivacyOptions(
UserPrivacyOptions(DataCollectionLevel.UserBehavior, true),
);
// Grant performance monitoring only, no crash reporting
Dynatrace().applyUserPrivacyOptions(
UserPrivacyOptions(DataCollectionLevel.Performance, false),
);
// Revoke all consent
Dynatrace().applyUserPrivacyOptions(
UserPrivacyOptions(DataCollectionLevel.Off, false),
);

UserPrivacyOptions accepts two parameters:

ParameterTypeDescription

dataCollectionLevel

DataCollectionLevel

Controls what monitoring data is collected.

crashReportingOptedIn

bool

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.

Modify existing privacy options

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 options
privacyOptions.crashReportingOptedIn = false;
privacyOptions.dataCollectionLevel = DataCollectionLevel.Performance;
// Apply the modified options
Dynatrace().applyUserPrivacyOptions(privacyOptions);
}

App store privacy questionnaire

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:

  • Android privacy information
  • iOS privacy information
Related tags
Digital Experience