The New RUM Experience introduces a set of advanced APIs that allow you to send custom events, modify event data, track exceptions, monitor HTTP requests, and manage view contexts in your React Native application. These APIs provide more granular control over the data captured by Dynatrace and are designed for the next generation RUM capabilities.
Before you can send event or session properties from your application, you must first define them in the Dynatrace web UI. Any properties that are not pre-configured will be discarded.
To define a new property:
Experience Vitals, select the frontend for which you want to add the property.cart.total_value).string, boolean, or number.Dynatrace automatically prefixes your field name with event_properties. or session_properties. based on the property type you selected. For example, a field name of cart.total_value will become event_properties.cart.total_value.
Use sendEvent() to report custom events with properties using the EventData class. Property keys must be prefixed with event_properties..
import { Dynatrace, EventData } from '@dynatrace/react-native-plugin';// Send a custom event with propertiesDynatrace.sendEvent(new EventData().addEventProperty("event_properties.button_clicked", "login_button").addEventProperty("event_properties.user_type", "premium").addEventProperty("event_properties.attempt_count", 3).withDuration(250));
Allowed properties:
event_properties.*Property limits:
Field naming rules:
event_properties. prefix).Valid examples:
event_properties.checkout_stepevent_properties.cart_valueevent_properties.user_tierFor information on sending session properties, see User and session management.
Event modifiers allow you to intercept and modify events before they're sent to Dynatrace. Use them to add common properties, filter sensitive data, or enrich events with additional context. Event modifiers apply to all event types, including custom events, session properties, exceptions, and HTTP events.
If multiple event modifiers are added, they are executed in the order they were added.
import { Dynatrace, IEventModifier } from '@dynatrace/react-native-plugin';// Create an event modifierconst myModifier: IEventModifier = {modifyEvent(event) {// Add common properties to all eventsevent["event_properties.app_build"] = "1.2.3";event["event_properties.environment"] = "production";return event;}};// Add the modifierDynatrace.addEventModifier(myModifier);
Return null to discard an event:
import { Dynatrace, IEventModifier } from '@dynatrace/react-native-plugin';const filterModifier: IEventModifier = {modifyEvent(event) {// Discard events from test usersif (event["event_properties.is_test_user"] === true) {return null;}return event;}};Dynatrace.addEventModifier(filterModifier);
import { Dynatrace, IEventModifier } from '@dynatrace/react-native-plugin';const redactionModifier: IEventModifier = {modifyEvent(event) {// Redact email addresses from custom propertiesif (event["event_properties.user_email"]) {event["event_properties.user_email"] = "[REDACTED]";}return event;}};Dynatrace.addEventModifier(redactionModifier);
import { Dynatrace } from '@dynatrace/react-native-plugin';// Remove the modifier when no longer neededDynatrace.removeEventModifier(myModifier);
null from a modifier discards the event and prevents subsequent modifiers from executingEvent modifiers have restrictions on which fields can be modified to ensure data integrity.
Most fields and namespaces can't be modified in any way (added, removed or overridden), while others are open for modification.
event_properties.*—custom event properties.session_properties.*—session properties (only on session property events).url.full—full URL for HTTP request events.exception.stack_trace—stack trace for exception events.All other reserved fields and namespaces cannot be modified.
Attempting to modify read-only fields will have no effect. The original values are preserved.
import { Dynatrace, IEventModifier } from '@dynatrace/react-native-plugin';const featureFlags = {checkout_v2: true,new_payment_flow: false,enhanced_search: true};const featureFlagModifier: IEventModifier = {modifyEvent(event) {for (const [key, value] of Object.entries(featureFlags)) {event[`event_properties.ff_${key}`] = value;}return event;}};Dynatrace.addEventModifier(featureFlagModifier);
import { Dynatrace, IEventModifier } from '@dynatrace/react-native-plugin';const enrichmentModifier: IEventModifier = {modifyEvent(event) {// Add experiment tracking to checkout eventsif (event["event_properties.checkout_step"]) {event["event_properties.experiment_id"] = "checkout_flow_v2";event["event_properties.variant"] = "treatment_a";}return event;}};Dynatrace.addEventModifier(enrichmentModifier);
import { Dynatrace, IEventModifier } from '@dynatrace/react-native-plugin';import { Platform } from 'react-native';const environmentModifier: IEventModifier = {modifyEvent(event) {// Add environment contextevent["event_properties.build_type"] = __DEV__ ? "debug" : "release";event["event_properties.platform"] = Platform.OS;return event;}};Dynatrace.addEventModifier(environmentModifier);
null discards the event and prevents future modifier functions from being executed.event_properties.* fields and Send session property events for session_properties.* fields, including naming rules, length limits, and allowed characters.