* Wraps `fetch` function to capture request and response data
(client: Client, options: HttpClientOptions)
| 281 | * Wraps `fetch` function to capture request and response data |
| 282 | */ |
| 283 | function _wrapFetch(client: Client, options: HttpClientOptions): void { |
| 284 | if (!supportsNativeFetch()) { |
| 285 | return; |
| 286 | } |
| 287 | |
| 288 | addFetchInstrumentationHandler(handlerData => { |
| 289 | if (getClient() !== client) { |
| 290 | return; |
| 291 | } |
| 292 | |
| 293 | const { response, args, error, virtualError } = handlerData; |
| 294 | const [requestInfo, requestInit] = args as [RequestInfo, RequestInit | undefined]; |
| 295 | |
| 296 | if (!response) { |
| 297 | return; |
| 298 | } |
| 299 | |
| 300 | _fetchResponseHandler(options, requestInfo, response as Response, requestInit, error || virtualError); |
| 301 | }, false); |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Wraps XMLHttpRequest to capture request and response data |
no test coverage detected