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'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, 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).

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.

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 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.

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

import { Dynatrace, DataCollectionLevel, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
function onUserConsent(choice) {
switch (choice) {
case 'full':
// Full monitoring including Session Replay
Dynatrace.applyUserPrivacyOptions(
new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true, true)
);
break;
case 'performance':
// Performance monitoring, no crash reporting, no Session Replay
Dynatrace.applyUserPrivacyOptions(
new UserPrivacyOptions(DataCollectionLevel.Performance, false, false)
);
break;
case 'declined':
// User declined — revoke all consent
Dynatrace.applyUserPrivacyOptions(
new UserPrivacyOptions(DataCollectionLevel.Off, false, false)
);
break;
}
}

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);
console.log('Session Replay enabled:', options.screenRecordOptedIn);
}

If called before the agent has started, getUserPrivacyOptions returns default values: DataCollectionLevel.Off, crash reporting false, and Session Replay false. These are not the user's stored preferences; call this method only after Dynatrace.start() has completed.

Apply privacy options

Set the user's privacy preferences:

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

UserPrivacyOptions accepts three parameters:

ParameterTypeDescription

dataCollectionLevel

DataCollectionLevel

Controls what monitoring data is collected.

crashReportingOptedIn

boolean

Whether crash reports are sent.

screenRecordOptedIn

boolean

Whether Session Replay screen recording is allowed. Defaults to 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.

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.

Modify existing privacy options

You can also modify existing privacy options:

import { Dynatrace, DataCollectionLevel } from '@dynatrace/react-native-plugin';
async function updatePrivacySettings() {
const privacyOptions = await Dynatrace.getUserPrivacyOptions();
// Modify the options
privacyOptions.crashReportingOptedIn = false;
privacyOptions.dataCollectionLevel = DataCollectionLevel.Performance;
privacyOptions.screenRecordOptedIn = false;
// 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, true),
Platform.Ios
);
// Apply privacy settings only on Android
Dynatrace.applyUserPrivacyOptions(
new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true, 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:

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