React Native SDK - networkRequest method

Details about the networkRequest method from OpenReplay's React Native SDK

React Native SDK ⁠-⁠ networkRequest method

Records a network request manually. Use it for requests that patchNetwork() doesn’t see, such as requests made from native code or by a custom client.

import OR from '@openreplay/react-native'

OR.tracker.networkRequest(
  'https://api.example.com/users',
  'POST',
  JSON.stringify({ headers: {}, body: { username: 'demo' } }),
  JSON.stringify({ headers: {}, body: { id: 1, username: 'demo' } }),
  201,
  150
)
  • url: string: The request URL.
  • method: 'GET' | 'POST' | 'PUT' | 'DELETE': The HTTP method.
  • requestJSON: string: JSON string with the request data, in the shape { headers, body } that patchNetwork() sends.
  • responseJSON: string: JSON string with the response data, in the same { headers, body } shape.
  • status: number: The HTTP status code.
  • duration: number: The request duration in milliseconds.

Nothing is sanitized here: strip secrets from headers and bodies before passing them.

This method doesn’t return any values, the request will be visible in the replay’s network tab.

If you have any questions about this process, feel free to reach out to us on our Slack .