RUM React Native Advanced Configuration


If you have not set up the SDK yet, follow the in-app setup instructions or refer to the React Native RUM setup documentation.

Manual instrumentation

If automatic instrumentation doesn’t suit your needs, you can manually create RUM Events and Logs:

import {
} from '@datadog/mobile-react-native';

// Initialize the SDK
const config = new DdSdkReactNativeConfiguration(
    true, // track user interactions (such as a tap on buttons)
    true, // track XHR resources
    true // track errors

// Send logs (use the debug, info, warn, or error methods)
DdLogs.debug('Lorem ipsum dolor sit amet…', {});'Lorem ipsum dolor sit amet…', {});
DdLogs.warn('Lorem ipsum dolor sit amet…', {});
DdLogs.error('Lorem ipsum dolor sit amet…', {});

// Track RUM Views manually
DdRum.startView('<view-key>', 'View Name', {},;
DdRum.stopView('<view-key>', { custom: 42 },;

// Track RUM Actions manually
DdRum.addAction(RumActionType.TAP, 'button name', {},;
// Or in case of continuous action
DdRum.startAction(RumActionType.TAP, 'button name', {},;
// To stop action above

// Add custom timings

// Track RUM Errors manually
DdRum.addError('<message>', ErrorSource.SOURCE, '<stacktrace>', {},;

// Track RUM Resource manually
DdRum.stopResource('<res-key>', 200, 'xhr', (size = 1337), {},;

// Send spans manually
const spanId = await DdTrace.startSpan('foo', { custom: 42 },;
DdTrace.finishSpan(spanId, { custom: 21 },;

Resource timings

Resource tracking provides the following timings:

  • First Byte: The time between the scheduled request and the first byte of the response. This includes time for the request preparation on the native level, network latency, and the time it took the server to prepare the response.
  • Download: The time it took to receive a response.

Further reading