React Native SDK ⁠-⁠ patchNetwork method

This method patches XHR and Fetch apis to intercept network requests.

import OR from '@openreplay/react-native'

OR.patchNetwork(
    global,
		(url) => url.includes('openreplaydomain'),
    { mode: 'fetch' }
)
  • context: globalThis: current context of the app (to get fetch/xhr from)
  • isServiceURL: (url: string) => boolean: function that checks if current request should be tracked (false) or skipped (true)
  • options: Partial<Options>: options object
  • ignoreHeaders: Array<string> | boolean: headers to ignore (default: ['cookie', 'set-cookie', 'authorization'])
  • capturePayload: boolean: whether to capture request payload (default: false)
  • sanitizer: data: RequestResponseData) => RequestResponseData: function that sanitizes request/response (default: undefined)
  • mode: 'fetch' | 'xhr' | 'all': which api to patch (default: 'fetch')

Note: React-Native fetch are using XHR under the hood (at the moment of writing), so using “all” can lead to duplicated requests in the recording

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