MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / _wrapFetch

Function _wrapFetch

packages/browser/src/integrations/httpclient.ts:283–302  ·  view source on GitHub ↗

* Wraps `fetch` function to capture request and response data

(client: Client, options: HttpClientOptions)

Source from the content-addressed store, hash-verified

281 * Wraps `fetch` function to capture request and response data
282 */
283function _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

Callers 1

setupFunction · 0.85

Calls 4

getClientFunction · 0.90
supportsNativeFetchFunction · 0.85
_fetchResponseHandlerFunction · 0.85

Tested by

no test coverage detected