Dynatrace provides comprehensive web request monitoring for React Native applications. HTTP requests are automatically tracked by the native agents (Android and iOS). You can also manually report requests from unsupported libraries and enrich request data with custom properties.
The Dynatrace native agents automatically capture web requests made by your React Native application. This includes requests from popular libraries like:
fetch APIXMLHttpRequestNo additional configuration is required. Once the Dynatrace plugin is configured, web requests are automatically tracked and timed.
For each web request, Dynatrace captures:
For HTTP libraries not supported by automatic instrumentation, or when you need more control, you can manually report HTTP requests using the New RUM Experience API.
Report a completed HTTP request with detailed information:
import { Dynatrace, HttpRequestEventData } from '@dynatrace/react-native-plugin';// Basic HTTP request eventconst requestEventData = new HttpRequestEventData('https://api.example.com/users', 'GET');Dynatrace.sendHttpRequestEvent(requestEventData);// HTTP request with additional detailsconst detailedRequestEventData = new HttpRequestEventData('https://api.example.com/data', 'POST').withStatusCode(200).addEventProperty('event_properties.headers.content_type', 'application/json');Dynatrace.sendHttpRequestEvent(detailedRequestEventData);
Parameters:
url—the URL of the HTTP request (required).method—the HTTP method (e.g., 'GET', 'POST', 'PUT', 'DELETE') (required).Enrich HTTP request events with custom properties:
import { Dynatrace, HttpRequestEventData } from '@dynatrace/react-native-plugin';async function fetchUserData(userId) {const url = `https://api.example.com/users/${userId}`;try {const response = await fetch(url);const requestEventData = new HttpRequestEventData(url, 'GET').withStatusCode(response.status).addEventProperty('event_properties.user_id', userId).addEventProperty('event_properties.cache_hit', response.headers.get('X-Cache-Hit') === 'true').addEventProperty('event_properties.api_version', 'v2');Dynatrace.sendHttpRequestEvent(requestEventData);} catch (error) {const requestEventData = new HttpRequestEventData(url, 'GET').withStatusCode(-1).addEventProperty('event_properties.error', error.message);Dynatrace.sendHttpRequestEvent(requestEventData);}}
HTTP request events can be enriched using event modifiers. This allows you to add custom properties, redact sensitive information, or filter requests before they are sent to Dynatrace.
import { Dynatrace, IEventModifier } from '@dynatrace/react-native-plugin';const httpModifier: IEventModifier = {modifyEvent(event) {// Add API version to all HTTP eventsif (event['http.request.method']) {event['event_properties.api_version'] = 'v2';}// Redact user IDs from URLsif (event['url.full']) {event['url.full'] = event['url.full'].replace(/\/users\/\w+\//, '/users/{id}/');}// Filter out health check requestsif (event['url.full'] && event['url.full'].includes('/health')) {return null; // Discard this event}return event;}};Dynatrace.addEventModifier(httpModifier);
For HTTP request events, the following fields can be modified:
url.full—the complete request URL.event_properties.*—custom properties with this prefix.Event modifiers apply to all event types, including HTTP requests sent via sendHttpRequestEvent(). For more details on event modifiers, see Event modifiers.