MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / switchToFetchProxy

Function switchToFetchProxy

packages/sveltekit/src/client/sdk.ts:66–77  ·  view source on GitHub ↗

* During server-side page load, we injected a that wraps `window.fetch` so that * before a `fetch` call is forwarded to the original `window.fetch`, a function we control * is also invoked. This function is put onto the global object (`window._sentryFetchProxy`) * so that we can access i

()

Source from the content-addressed store, hash-verified

64 * @returns the function that was previously on `window.fetch`.
65 */
66function switchToFetchProxy(): typeof fetch | undefined {
67 const globalWithSentryFetchProxy: WindowWithSentryFetchProxy = WINDOW;
68
69 // eslint-disable-next-line @typescript-eslint/unbound-method
70 const actualFetch = globalWithSentryFetchProxy.fetch;
71
72 if (globalWithSentryFetchProxy._sentryFetchProxy && actualFetch) {
73 globalWithSentryFetchProxy.fetch = globalWithSentryFetchProxy._sentryFetchProxy;
74 return actualFetch;
75 }
76 return undefined;
77}
78
79/**
80 * Restores the function @param actualFetch to `window.fetch`

Callers 1

initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected