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.
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:
OffPerformanceUserBehaviorUser 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.
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).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:
Use the privacy API to get and apply user privacy preferences.
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);}
Set the user's privacy preferences:
import { Dynatrace, DataCollectionLevel, UserPrivacyOptions } from '@dynatrace/react-native-plugin';// Grant full consentDynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true));// Grant performance monitoring only, no crash reportingDynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.Performance, false));// Revoke all consentDynatrace.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.
You can also modify existing privacy options:
import { Dynatrace } from '@dynatrace/react-native-plugin';async function updatePrivacySettings() {const privacyOptions = await Dynatrace.getUserPrivacyOptions();// Modify the optionsprivacyOptions.crashReportingOptedIn = false;privacyOptions.dataCollectionLevel = DataCollectionLevel.Performance;// Apply the modified optionsDynatrace.applyUserPrivacyOptions(privacyOptions);}
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 iOSDynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true),Platform.Ios);// Apply privacy settings only on AndroidDynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true),Platform.Android);
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);
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: