File: /home/cafsindia/snap.cafsinfotech.in/node_modules/@sentry/browser/esm/transports/utils.js.map
{"version":3,"file":"utils.js","sources":["../../../../src/transports/utils.ts"],"sourcesContent":["import { isNativeFetch, logger } from '@sentry/utils';\n\nimport { WINDOW } from '../helpers';\n\nlet cachedFetchImpl: FetchImpl | undefined = undefined;\n\nexport type FetchImpl = typeof fetch;\n\n/**\n * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.\n * Whenever someone wraps the Fetch API and returns the wrong promise chain,\n * this chain becomes orphaned and there is no possible way to capture it's rejections\n * other than allowing it bubble up to this very handler. eg.\n *\n * const f = window.fetch;\n * window.fetch = function () {\n * const p = f.apply(this, arguments);\n *\n * p.then(function() {\n * console.log('hi.');\n * });\n *\n * return p;\n * }\n *\n * `p.then(function () { ... })` is producing a completely separate promise chain,\n * however, what's returned is `p` - the result of original `fetch` call.\n *\n * This mean, that whenever we use the Fetch API to send our own requests, _and_\n * some ad-blocker blocks it, this orphaned chain will _always_ reject,\n * effectively causing another event to be captured.\n * This makes a whole process become an infinite loop, which we need to somehow\n * deal with, and break it in one way or another.\n *\n * To deal with this issue, we are making sure that we _always_ use the real\n * browser Fetch API, instead of relying on what `window.fetch` exposes.\n * The only downside to this would be missing our own requests as breadcrumbs,\n * but because we are already not doing this, it should be just fine.\n *\n * Possible failed fetch error messages per-browser:\n *\n * Chrome: Failed to fetch\n * Edge: Failed to Fetch\n * Firefox: NetworkError when attempting to fetch resource\n * Safari: resource blocked by content blocker\n */\nexport function getNativeFetchImplementation(): FetchImpl {\n if (cachedFetchImpl) {\n return cachedFetchImpl;\n }\n\n /* eslint-disable @typescript-eslint/unbound-method */\n\n // Fast path to avoid DOM I/O\n if (isNativeFetch(WINDOW.fetch)) {\n return (cachedFetchImpl = WINDOW.fetch.bind(WINDOW));\n }\n\n const document = WINDOW.document;\n let fetchImpl = WINDOW.fetch;\n // eslint-disable-next-line deprecation/deprecation\n if (document && typeof document.createElement === 'function') {\n try {\n const sandbox = document.createElement('iframe');\n sandbox.hidden = true;\n document.head.appendChild(sandbox);\n const contentWindow = sandbox.contentWindow;\n if (contentWindow && contentWindow.fetch) {\n fetchImpl = contentWindow.fetch;\n }\n document.head.removeChild(sandbox);\n } catch (e) {\n __DEBUG_BUILD__ &&\n logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);\n }\n }\n\n return (cachedFetchImpl = fetchImpl.bind(WINDOW));\n /* eslint-enable @typescript-eslint/unbound-method */\n}\n\n/** Clears cached fetch impl */\nexport function clearCachedFetchImplementation(): void {\n cachedFetchImpl = undefined;\n}\n"],"names":[],"mappings":";;;AAIA,IAAA,eAAA,GAAA,SAAA,CAAA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,4BAAA,GAAA;AACA,EAAA,IAAA,eAAA,EAAA;AACA,IAAA,OAAA,eAAA,CAAA;AACA,GAAA;AACA;AACA;AACA;AACA;AACA,EAAA,IAAA,aAAA,CAAA,MAAA,CAAA,KAAA,CAAA,EAAA;AACA,IAAA,QAAA,eAAA,GAAA,MAAA,CAAA,KAAA,CAAA,IAAA,CAAA,MAAA,CAAA,EAAA;AACA,GAAA;AACA;AACA,EAAA,MAAA,QAAA,GAAA,MAAA,CAAA,QAAA,CAAA;AACA,EAAA,IAAA,SAAA,GAAA,MAAA,CAAA,KAAA,CAAA;AACA;AACA,EAAA,IAAA,QAAA,IAAA,OAAA,QAAA,CAAA,aAAA,KAAA,UAAA,EAAA;AACA,IAAA,IAAA;AACA,MAAA,MAAA,OAAA,GAAA,QAAA,CAAA,aAAA,CAAA,QAAA,CAAA,CAAA;AACA,MAAA,OAAA,CAAA,MAAA,GAAA,IAAA,CAAA;AACA,MAAA,QAAA,CAAA,IAAA,CAAA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