Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
{"version":3,"file":"lazyLoadIntegration.js","sources":["../../../../src/utils/lazyLoadIntegration.ts"],"sourcesContent":["import { SDK_VERSION, getClient } from '@sentry/core';\nimport type { IntegrationFn } from '@sentry/types';\nimport type { BrowserClient } from '../client';\nimport { WINDOW } from '../helpers';\n\n// This is a map of integration function method to bundle file name.\nconst LazyLoadableIntegrations = {\n replayIntegration: 'replay',\n replayCanvasIntegration: 'replay-canvas',\n feedbackIntegration: 'feedback',\n feedbackModalIntegration: 'feedback-modal',\n feedbackScreenshotIntegration: 'feedback-screenshot',\n captureConsoleIntegration: 'captureconsole',\n contextLinesIntegration: 'contextlines',\n linkedErrorsIntegration: 'linkederrors',\n debugIntegration: 'debug',\n dedupeIntegration: 'dedupe',\n extraErrorDataIntegration: 'extraerrordata',\n httpClientIntegration: 'httpclient',\n reportingObserverIntegration: 'reportingobserver',\n rewriteFramesIntegration: 'rewriteframes',\n sessionTimingIntegration: 'sessiontiming',\n browserProfilingIntegration: 'browserprofiling',\n} as const;\n\nconst WindowWithMaybeIntegration = WINDOW as {\n Sentry?: Partial>;\n};\n\n/**\n * Lazy load an integration from the CDN.\n * Rejects if the integration cannot be loaded.\n */\nexport async function lazyLoadIntegration(name: keyof typeof LazyLoadableIntegrations): Promise {\n const bundle = LazyLoadableIntegrations[name];\n\n // `window.Sentry` is only set when using a CDN bundle, but this method can also be used via the NPM package\n const sentryOnWindow = (WindowWithMaybeIntegration.Sentry = WindowWithMaybeIntegration.Sentry || {});\n\n if (!bundle) {\n throw new Error(`Cannot lazy load integration: ${name}`);\n }\n\n // Bail if the integration already exists\n const existing = sentryOnWindow[name];\n // The `feedbackIntegration` is loaded by default in the CDN bundles,\n // so we need to differentiate between the real integration and the shim.\n // if only the shim exists, we still want to lazy load the real integration.\n if (typeof existing === 'function' && !('_isShim' in existing)) {\n return existing;\n }\n\n const url = getScriptURL(bundle);\n const script = WINDOW.document.createElement('script');\n script.src = url;\n script.crossOrigin = 'anonymous';\n script.referrerPolicy = 'origin';\n\n const waitForLoad = new Promise((resolve, reject) => {\n script.addEventListener('load', () => resolve());\n script.addEventListener('error', reject);\n });\n\n WINDOW.document.body.appendChild(script);\n\n try {\n await waitForLoad;\n } catch {\n throw new Error(`Error when loading integration: ${name}`);\n }\n\n const integrationFn = sentryOnWindow[name];\n\n if (typeof integrationFn !== 'function') {\n throw new Error(`Could not load integration: ${name}`);\n }\n\n return integrationFn;\n}\n\nfunction getScriptURL(bundle: string): string {\n const client = getClient();\n const options = client && client.getOptions();\n const baseURL = (options && options.cdnBaseUrl) || 'https://browser.sentry-cdn.com';\n\n return new URL(`/${SDK_VERSION}/${bundle}.min.js`, baseURL).toString();\n}\n"],"names":["WINDOW","getClient","SDK_VERSION"],"mappings":";;;;;AAKA;AACA,MAAM,2BAA2B;AACjC,EAAE,iBAAiB,EAAE,QAAQ;AAC7B,EAAE,uBAAuB,EAAE,eAAe;AAC1C,EAAE,mBAAmB,EAAE,UAAU;AACjC,EAAE,wBAAwB,EAAE,gBAAgB;AAC5C,EAAE,6BAA6B,EAAE,qBAAqB;AACtD,EAAE,yBAAyB,EAAE,gBAAgB;AAC7C,EAAE,uBAAuB,EAAE,cAAc;AACzC,EAAE,uBAAuB,EAAE,cAAc;AACzC,EAAE,gBAAgB,EAAE,OAAO;AAC3B,EAAE,iBAAiB,EAAE,QAAQ;AAC7B,EAAE,yBAAyB,EAAE,gBAAgB;AAC7C,EAAE,qBAAqB,EAAE,YAAY;AACrC,EAAE,4BAA4B,EAAE,mBAAmB;AACnD,EAAE,wBAAwB,EAAE,eAAe;AAC3C,EAAE,wBAAwB,EAAE,eAAe;AAC3C,EAAE,2BAA2B,EAAE,kBAAkB;AACjD,CAAE,EAAA;AACF;AACA,MAAM,0BAAA,GAA6BA,cAAO;;AAE1C,CAAA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,mBAAmB,CAAC,IAAI,EA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