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, 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).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.
Dynatrace doesn't 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 { Dynatrace, DataCollectionLevel, UserPrivacyOptions } from '@dynatrace/react-native-plugin';function onUserConsent(choice) {switch (choice) {case 'full':// Full monitoring including Session ReplayDynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true, true));break;case 'performance':// Performance monitoring, no crash reporting, no Session ReplayDynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.Performance, false, false));break;case 'declined':// User declined — revoke all consentDynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.Off, false, false));break;}}
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);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.
Set the user's privacy preferences:
import { Dynatrace, DataCollectionLevel, UserPrivacyOptions } from '@dynatrace/react-native-plugin';// Grant full consent including Session ReplayDynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true, true));// Grant performance monitoring only, no crash reporting, no Session ReplayDynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.Performance, false, false));// Revoke all consentDynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.Off, false, false));
UserPrivacyOptions accepts three parameters:
| Parameter | Type | Description |
|---|---|---|
|
| Controls what monitoring data is collected. |
|
| Whether crash reports are sent. |
|
| Whether Session Replay screen recording is allowed. Defaults to |
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.
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 optionsprivacyOptions.crashReportingOptedIn = false;privacyOptions.dataCollectionLevel = DataCollectionLevel.Performance;privacyOptions.screenRecordOptedIn = false;// 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, true),Platform.Ios);// Apply privacy settings only on AndroidDynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true, 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: