React Native SDK - patchNetwork method
This method patches XHR and Fetch apis to intercept network requests.
Signature
Section titled Signatureimport OR from '@openreplay/react-native'
OR.patchNetwork(
global,
(url) => url.includes('openreplaydomain'),
{ mode: 'fetch' }
)Parameters
Section titled Parameterscontext: 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
Options
Section titled OptionsignoreHeaders: 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