Privacy and data collection

  • Latest Dynatrace
  • Explanation
  • 1-min read
  • Published Jan 12, 2025

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's your responsibility to properly configure these settings and implement appropriate consent mechanisms to protect your users' personal data.

Data collection levels

The Dynatrace React Native 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, the agent starts with minimal data collection 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).

Enable user opt-in mode

To enable user opt-in mode, update your dynatrace.config.js file:

Android:

module.exports = {
android: {
config: `
dynatrace {
configurations {
defaultConfig {
userOptIn true
}
}
}
`
}
}

iOS:

module.exports = {
ios: {
config: `
<key>DTXUserOptIn</key>
<true/>
`
}
}

After updating the configuration, run npx instrumentDynatrace to apply the changes.

Dynatrace doesn't 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.

Privacy API

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

Get current privacy options

Retrieve the current privacy settings:

import { Dynatrace } from '@dynatrace/react-native-plugin';
async function checkPrivacySettings() {
const options = await Dynatrace.getUserPrivacyOptions();
console.log('Data collection level:', options.dataCollectionLevel);
console.log('Crash reporting enabled:', options.crashReportingOptedIn);
}

Apply privacy options

Set the user's privacy preferences:

import { Dynatrace, DataCollectionLevel, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
// Grant full consent
Dynatrace.applyUserPrivacyOptions(
new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true)
);
// Grant performance monitoring only, no crash reporting
Dynatrace.applyUserPrivacyOptions(
new UserPrivacyOptions(DataCollectionLevel.Performance, false)
);
// Revoke all consent
Dynatrace.applyUserPrivacyOptions(
new UserPrivacyOptions(DataCollectionLevel.Off, false)
);

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.

Modify existing privacy options

You can also modify existing privacy options:

import { Dynatrace } from '@dynatrace/react-native-plugin';
async function updatePrivacySettings() {
const privacyOptions = await Dynatrace.getUserPrivacyOptions();
// Modify the options
privacyOptions.crashReportingOptedIn = false;
privacyOptions.dataCollectionLevel = DataCollectionLevel.Performance;
// Apply the modified options
Dynatrace.applyUserPrivacyOptions(privacyOptions);
}

Platform-specific privacy options

You can apply privacy options for a specific platform using the optional platform parameter:

import { Dynatrace, DataCollectionLevel, UserPrivacyOptions, Platform } from '@dynatrace/react-native-plugin';
// Apply privacy settings only on iOS
Dynatrace.applyUserPrivacyOptions(
new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true),
Platform.Ios
);
// Apply privacy settings only on Android
Dynatrace.applyUserPrivacyOptions(
new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true),
Platform.Android
);

Action name privacy

In addition to data collection levels, you can hide button and touchable names to protect user privacy:

module.exports = {
react: {
input: {
actionNamePrivacy: true,
}
}
}

When enabled, UI element names are hidden (for example, "Touch on Button" instead of "Touch on Login"). Setting dtActionName property directly on a component overrides this setting and will use again the custom defined name.

This can also be configured via the manual startup API:

import { Dynatrace, ConfigurationBuilder } from '@dynatrace/react-native-plugin';
const config = new ConfigurationBuilder("beaconUrl", "applicationId")
.withActionNamePrivacy(true)
.buildConfiguration();
await Dynatrace.start(config);

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:

Related tags
Digital Experience