@sentry/browser 11.0.0-alpha.0 → 11.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/npm/cjs/dev/client.js.map +1 -1
- package/build/npm/cjs/dev/helpers.js +2 -1
- package/build/npm/cjs/dev/helpers.js.map +1 -1
- package/build/npm/cjs/dev/index.js +7 -4
- package/build/npm/cjs/dev/index.js.map +1 -1
- package/build/npm/cjs/dev/integrations/bfcache.js +113 -0
- package/build/npm/cjs/dev/integrations/bfcache.js.map +1 -0
- package/build/npm/cjs/dev/integrations/breadcrumbs.js +1 -1
- package/build/npm/cjs/dev/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/cjs/dev/integrations/fetchStreamPerformance.js +11 -11
- package/build/npm/cjs/dev/integrations/fetchStreamPerformance.js.map +1 -1
- package/build/npm/cjs/dev/integrations/globalhandlers.js +2 -1
- package/build/npm/cjs/dev/integrations/globalhandlers.js.map +1 -1
- package/build/npm/cjs/dev/integrations/graphqlClient.js +3 -3
- package/build/npm/cjs/dev/integrations/graphqlClient.js.map +1 -1
- package/build/npm/cjs/dev/integrations/httpclient.js.map +1 -1
- package/build/npm/cjs/dev/integrations/reportingobserver.js +4 -1
- package/build/npm/cjs/dev/integrations/reportingobserver.js.map +1 -1
- package/build/npm/cjs/dev/integrations/spotlight.js +2 -1
- package/build/npm/cjs/dev/integrations/spotlight.js.map +1 -1
- package/build/npm/cjs/dev/integrations/view-hierarchy.js +2 -1
- package/build/npm/cjs/dev/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/cjs/dev/profiling/index.js.map +1 -1
- package/build/npm/cjs/dev/profiling/integration.js +21 -91
- package/build/npm/cjs/dev/profiling/integration.js.map +1 -1
- package/build/npm/cjs/dev/profiling/utils.js +0 -283
- package/build/npm/cjs/dev/profiling/utils.js.map +1 -1
- package/build/npm/cjs/dev/sdk.js +0 -4
- package/build/npm/cjs/dev/sdk.js.map +1 -1
- package/build/npm/cjs/dev/tracing/backgroundtab.js +5 -1
- package/build/npm/cjs/dev/tracing/backgroundtab.js.map +1 -1
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js +30 -86
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/dev/tracing/linkedTraces.js +3 -3
- package/build/npm/cjs/dev/tracing/linkedTraces.js.map +1 -1
- package/build/npm/cjs/dev/tracing/request.js +7 -9
- package/build/npm/cjs/dev/tracing/request.js.map +1 -1
- package/build/npm/cjs/dev/utils/detectBrowserExtension.js +2 -1
- package/build/npm/cjs/dev/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/cjs/dev/utils/lazyLoadIntegration.js +1 -0
- package/build/npm/cjs/dev/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/cjs/prod/client.js.map +1 -1
- package/build/npm/cjs/prod/helpers.js +2 -1
- package/build/npm/cjs/prod/helpers.js.map +1 -1
- package/build/npm/cjs/prod/index.js +7 -4
- package/build/npm/cjs/prod/index.js.map +1 -1
- package/build/npm/cjs/prod/integrations/bfcache.js +113 -0
- package/build/npm/cjs/prod/integrations/bfcache.js.map +1 -0
- package/build/npm/cjs/prod/integrations/breadcrumbs.js +1 -1
- package/build/npm/cjs/prod/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/cjs/prod/integrations/fetchStreamPerformance.js +11 -11
- package/build/npm/cjs/prod/integrations/fetchStreamPerformance.js.map +1 -1
- package/build/npm/cjs/prod/integrations/globalhandlers.js +2 -1
- package/build/npm/cjs/prod/integrations/globalhandlers.js.map +1 -1
- package/build/npm/cjs/prod/integrations/graphqlClient.js +3 -3
- package/build/npm/cjs/prod/integrations/graphqlClient.js.map +1 -1
- package/build/npm/cjs/prod/integrations/httpclient.js.map +1 -1
- package/build/npm/cjs/prod/integrations/reportingobserver.js +4 -1
- package/build/npm/cjs/prod/integrations/reportingobserver.js.map +1 -1
- package/build/npm/cjs/prod/integrations/spotlight.js +2 -1
- package/build/npm/cjs/prod/integrations/spotlight.js.map +1 -1
- package/build/npm/cjs/prod/integrations/view-hierarchy.js +2 -1
- package/build/npm/cjs/prod/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/cjs/prod/profiling/index.js.map +1 -1
- package/build/npm/cjs/prod/profiling/integration.js +21 -91
- package/build/npm/cjs/prod/profiling/integration.js.map +1 -1
- package/build/npm/cjs/prod/profiling/utils.js +0 -283
- package/build/npm/cjs/prod/profiling/utils.js.map +1 -1
- package/build/npm/cjs/prod/sdk.js +0 -4
- package/build/npm/cjs/prod/sdk.js.map +1 -1
- package/build/npm/cjs/prod/tracing/backgroundtab.js +5 -1
- package/build/npm/cjs/prod/tracing/backgroundtab.js.map +1 -1
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +30 -86
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/prod/tracing/linkedTraces.js +3 -3
- package/build/npm/cjs/prod/tracing/linkedTraces.js.map +1 -1
- package/build/npm/cjs/prod/tracing/request.js +7 -9
- package/build/npm/cjs/prod/tracing/request.js.map +1 -1
- package/build/npm/cjs/prod/utils/detectBrowserExtension.js +2 -1
- package/build/npm/cjs/prod/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/cjs/prod/utils/lazyLoadIntegration.js +1 -0
- package/build/npm/cjs/prod/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/esm/dev/client.js.map +1 -1
- package/build/npm/esm/dev/helpers.js +2 -1
- package/build/npm/esm/dev/helpers.js.map +1 -1
- package/build/npm/esm/dev/index.js +4 -4
- package/build/npm/esm/dev/integrations/bfcache.js +109 -0
- package/build/npm/esm/dev/integrations/bfcache.js.map +1 -0
- package/build/npm/esm/dev/integrations/breadcrumbs.js +2 -2
- package/build/npm/esm/dev/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/esm/dev/integrations/fetchStreamPerformance.js +3 -3
- package/build/npm/esm/dev/integrations/fetchStreamPerformance.js.map +1 -1
- package/build/npm/esm/dev/integrations/globalhandlers.js +2 -1
- package/build/npm/esm/dev/integrations/globalhandlers.js.map +1 -1
- package/build/npm/esm/dev/integrations/graphqlClient.js +5 -5
- package/build/npm/esm/dev/integrations/graphqlClient.js.map +1 -1
- package/build/npm/esm/dev/integrations/httpclient.js.map +1 -1
- package/build/npm/esm/dev/integrations/reportingobserver.js +4 -1
- package/build/npm/esm/dev/integrations/reportingobserver.js.map +1 -1
- package/build/npm/esm/dev/integrations/spotlight.js +2 -1
- package/build/npm/esm/dev/integrations/spotlight.js.map +1 -1
- package/build/npm/esm/dev/integrations/view-hierarchy.js +2 -1
- package/build/npm/esm/dev/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/esm/dev/package.json +1 -1
- package/build/npm/esm/dev/profiling/index.js.map +1 -1
- package/build/npm/esm/dev/profiling/integration.js +22 -92
- package/build/npm/esm/dev/profiling/integration.js.map +1 -1
- package/build/npm/esm/dev/profiling/utils.js +2 -272
- package/build/npm/esm/dev/profiling/utils.js.map +1 -1
- package/build/npm/esm/dev/sdk.js +0 -4
- package/build/npm/esm/dev/sdk.js.map +1 -1
- package/build/npm/esm/dev/tracing/backgroundtab.js +5 -1
- package/build/npm/esm/dev/tracing/backgroundtab.js.map +1 -1
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js +32 -87
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/dev/tracing/linkedTraces.js +3 -3
- package/build/npm/esm/dev/tracing/linkedTraces.js.map +1 -1
- package/build/npm/esm/dev/tracing/request.js +9 -11
- package/build/npm/esm/dev/tracing/request.js.map +1 -1
- package/build/npm/esm/dev/utils/detectBrowserExtension.js +2 -1
- package/build/npm/esm/dev/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/esm/dev/utils/lazyLoadIntegration.js +1 -0
- package/build/npm/esm/dev/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/esm/prod/client.js.map +1 -1
- package/build/npm/esm/prod/helpers.js +2 -1
- package/build/npm/esm/prod/helpers.js.map +1 -1
- package/build/npm/esm/prod/index.js +4 -4
- package/build/npm/esm/prod/integrations/bfcache.js +109 -0
- package/build/npm/esm/prod/integrations/bfcache.js.map +1 -0
- package/build/npm/esm/prod/integrations/breadcrumbs.js +2 -2
- package/build/npm/esm/prod/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/esm/prod/integrations/fetchStreamPerformance.js +3 -3
- package/build/npm/esm/prod/integrations/fetchStreamPerformance.js.map +1 -1
- package/build/npm/esm/prod/integrations/globalhandlers.js +2 -1
- package/build/npm/esm/prod/integrations/globalhandlers.js.map +1 -1
- package/build/npm/esm/prod/integrations/graphqlClient.js +5 -5
- package/build/npm/esm/prod/integrations/graphqlClient.js.map +1 -1
- package/build/npm/esm/prod/integrations/httpclient.js.map +1 -1
- package/build/npm/esm/prod/integrations/reportingobserver.js +4 -1
- package/build/npm/esm/prod/integrations/reportingobserver.js.map +1 -1
- package/build/npm/esm/prod/integrations/spotlight.js +2 -1
- package/build/npm/esm/prod/integrations/spotlight.js.map +1 -1
- package/build/npm/esm/prod/integrations/view-hierarchy.js +2 -1
- package/build/npm/esm/prod/integrations/view-hierarchy.js.map +1 -1
- package/build/npm/esm/prod/package.json +1 -1
- package/build/npm/esm/prod/profiling/index.js.map +1 -1
- package/build/npm/esm/prod/profiling/integration.js +22 -92
- package/build/npm/esm/prod/profiling/integration.js.map +1 -1
- package/build/npm/esm/prod/profiling/utils.js +2 -272
- package/build/npm/esm/prod/profiling/utils.js.map +1 -1
- package/build/npm/esm/prod/sdk.js +0 -4
- package/build/npm/esm/prod/sdk.js.map +1 -1
- package/build/npm/esm/prod/tracing/backgroundtab.js +5 -1
- package/build/npm/esm/prod/tracing/backgroundtab.js.map +1 -1
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js +32 -87
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/prod/tracing/linkedTraces.js +3 -3
- package/build/npm/esm/prod/tracing/linkedTraces.js.map +1 -1
- package/build/npm/esm/prod/tracing/request.js +9 -11
- package/build/npm/esm/prod/tracing/request.js.map +1 -1
- package/build/npm/esm/prod/utils/detectBrowserExtension.js +2 -1
- package/build/npm/esm/prod/utils/detectBrowserExtension.js.map +1 -1
- package/build/npm/esm/prod/utils/lazyLoadIntegration.js +1 -0
- package/build/npm/esm/prod/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/types/client.d.ts +22 -1
- package/build/npm/types/client.d.ts.map +1 -1
- package/build/npm/types/exports.d.ts +2 -2
- package/build/npm/types/exports.d.ts.map +1 -1
- package/build/npm/types/helpers.d.ts.map +1 -1
- package/build/npm/types/index.bundle.d.ts +2 -2
- package/build/npm/types/index.bundle.d.ts.map +1 -1
- package/build/npm/types/index.bundle.feedback.d.ts +2 -2
- package/build/npm/types/index.bundle.feedback.d.ts.map +1 -1
- package/build/npm/types/index.bundle.logs.metrics.d.ts +1 -1
- package/build/npm/types/index.bundle.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.replay.d.ts +2 -2
- package/build/npm/types/index.bundle.replay.d.ts.map +1 -1
- package/build/npm/types/index.bundle.replay.feedback.d.ts +2 -2
- package/build/npm/types/index.bundle.replay.feedback.d.ts.map +1 -1
- package/build/npm/types/index.bundle.replay.logs.metrics.d.ts +1 -1
- package/build/npm/types/index.bundle.replay.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.d.ts +5 -4
- package/build/npm/types/index.bundle.tracing.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts +4 -3
- package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.d.ts +5 -4
- package/build/npm/types/index.bundle.tracing.replay.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts +5 -4
- package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.feedback.logs.metrics.d.ts +4 -3
- package/build/npm/types/index.bundle.tracing.replay.feedback.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts +4 -3
- package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.d.ts +6 -5
- package/build/npm/types/index.d.ts.map +1 -1
- package/build/npm/types/integrations/bfcache.d.ts +42 -0
- package/build/npm/types/integrations/bfcache.d.ts.map +1 -0
- package/build/npm/types/integrations/breadcrumbs.d.ts.map +1 -1
- package/build/npm/types/integrations/graphqlClient.d.ts.map +1 -1
- package/build/npm/types/integrations/httpclient.d.ts.map +1 -1
- package/build/npm/types/integrations/interactions.d.ts +2 -0
- package/build/npm/types/integrations/interactions.d.ts.map +1 -0
- package/build/npm/types/integrations/reportingobserver.d.ts.map +1 -1
- package/build/npm/types/integrations/spotlight.d.ts.map +1 -1
- package/build/npm/types/integrations/view-hierarchy.d.ts.map +1 -1
- package/build/npm/types/profiling/index.d.ts.map +1 -1
- package/build/npm/types/profiling/integration.d.ts.map +1 -1
- package/build/npm/types/profiling/utils.d.ts +1 -74
- package/build/npm/types/profiling/utils.d.ts.map +1 -1
- package/build/npm/types/sdk.d.ts.map +1 -1
- package/build/npm/types/tracing/backgroundtab.d.ts.map +1 -1
- package/build/npm/types/tracing/browserTracingIntegration.d.ts +0 -19
- package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
- package/build/npm/types/tracing/linkedTraces.d.ts.map +1 -1
- package/build/npm/types/tracing/request.d.ts +1 -13
- package/build/npm/types/tracing/request.d.ts.map +1 -1
- package/build/npm/types/utils/detectBrowserExtension.d.ts.map +1 -1
- package/build/npm/types/utils/lazyLoadIntegration.d.ts +1 -1
- package/build/npm/types/utils/lazyLoadIntegration.d.ts.map +1 -1
- package/package.json +10 -9
- package/build/npm/cjs/dev/integrations/spanstreaming.js +0 -34
- package/build/npm/cjs/dev/integrations/spanstreaming.js.map +0 -1
- package/build/npm/cjs/dev/profiling/startProfileForSpan.js +0 -91
- package/build/npm/cjs/dev/profiling/startProfileForSpan.js.map +0 -1
- package/build/npm/cjs/prod/integrations/spanstreaming.js +0 -34
- package/build/npm/cjs/prod/integrations/spanstreaming.js.map +0 -1
- package/build/npm/cjs/prod/profiling/startProfileForSpan.js +0 -91
- package/build/npm/cjs/prod/profiling/startProfileForSpan.js.map +0 -1
- package/build/npm/esm/dev/integrations/spanstreaming.js +0 -31
- package/build/npm/esm/dev/integrations/spanstreaming.js.map +0 -1
- package/build/npm/esm/dev/profiling/startProfileForSpan.js +0 -89
- package/build/npm/esm/dev/profiling/startProfileForSpan.js.map +0 -1
- package/build/npm/esm/prod/integrations/spanstreaming.js +0 -31
- package/build/npm/esm/prod/integrations/spanstreaming.js.map +0 -1
- package/build/npm/esm/prod/profiling/startProfileForSpan.js +0 -89
- package/build/npm/esm/prod/profiling/startProfileForSpan.js.map +0 -1
- package/build/npm/types/integrations/spanstreaming.d.ts +0 -5
- package/build/npm/types/integrations/spanstreaming.d.ts.map +0 -1
- package/build/npm/types/profiling/startProfileForSpan.d.ts +0 -8
- package/build/npm/types/profiling/startProfileForSpan.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sources":["../../../../../src/tracing/request.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type {\n Client,\n HandlerDataXhr,\n RequestHookInfo,\n ResponseHookInfo,\n SentryWrappedXMLHttpRequest,\n Span,\n SpanTimeInput,\n} from '@sentry/core/browser';\nimport {\n addFetchInstrumentationHandler,\n getActiveSpan,\n getClient,\n getLocationHref,\n getTraceData,\n getUrlFragment,\n getUrlQuery,\n hasSpansEnabled,\n hasSpanStreamingEnabled,\n instrumentFetchRequest,\n parseUrl,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SentryNonRecordingSpan,\n setHttpStatus,\n spanIsIgnored,\n spanToJSON,\n startInactiveSpan,\n stringMatchesSomePattern,\n stripDataUrlContent,\n stripUrlQueryAndFragment,\n timestampInSeconds,\n} from '@sentry/core/browser';\nimport type { XhrHint } from '@sentry/browser-utils';\nimport { filterCollectedUrl, filterCollectedUrlQuery } from '@sentry/core';\nimport {\n addPerformanceInstrumentationHandler,\n addXhrInstrumentationHandler,\n parseXhrResponseHeaders,\n resourceTimingToSpanAttributes,\n SENTRY_XHR_DATA_KEY,\n} from '@sentry/browser-utils';\nimport type { BrowserClient } from '../client';\nimport { baggageHeaderHasSentryValues, createHeadersSafely, getFullURL, isPerformanceResourceTiming } from './utils';\nimport { HTTP_METHOD, SERVER_ADDRESS, URL_FRAGMENT, URL_FULL, URL_QUERY } from '@sentry/conventions/attributes';\n\n/** Options for Request Instrumentation */\nexport interface RequestInstrumentationOptions {\n /**\n * List of strings and/or Regular Expressions used to determine which outgoing requests will have `sentry-trace` and `baggage`\n * headers attached.\n *\n * **Default:** If this option is not provided, tracing headers will be attached to all outgoing requests.\n * If you are using a browser SDK, by default, tracing headers will only be attached to outgoing requests to the same origin.\n *\n * **Disclaimer:** Carelessly setting this option in browser environments may result into CORS errors!\n * Only attach tracing headers to requests to the same origin, or to requests to services you can control CORS headers of.\n * Cross-origin requests, meaning requests to a different domain, for example a request to `https://api.example.com/` while you're on `https://example.com/`, take special care.\n * If you are attaching headers to cross-origin requests, make sure the backend handling the request returns a `\"Access-Control-Allow-Headers: sentry-trace, baggage\"` header to ensure your requests aren't blocked.\n *\n * If you provide a `tracePropagationTargets` array, the entries you provide will be matched against the entire URL of the outgoing request.\n * If you are using a browser SDK, the entries will also be matched against the pathname of the outgoing requests.\n * This is so you can have matchers for relative requests, for example, `/^\\/api/` if you want to trace requests to your `/api` routes on the same domain.\n *\n * If any of the two match any of the provided values, tracing headers will be attached to the outgoing request.\n * Both, the string values, and the RegExes you provide in the array will match if they partially match the URL or pathname.\n *\n * Examples:\n * - `tracePropagationTargets: [/^\\/api/]` and request to `https://same-origin.com/api/posts`:\n * - Tracing headers will be attached because the request is sent to the same origin and the regex matches the pathname \"/api/posts\".\n * - `tracePropagationTargets: [/^\\/api/]` and request to `https://different-origin.com/api/posts`:\n * - Tracing headers will not be attached because the pathname will only be compared when the request target lives on the same origin.\n * - `tracePropagationTargets: [/^\\/api/, 'https://external-api.com']` and request to `https://external-api.com/v1/data`:\n * - Tracing headers will be attached because the request URL matches the string `'https://external-api.com'`.\n */\n tracePropagationTargets?: Array<string | RegExp>;\n\n /**\n * Flag to disable patching all together for fetch requests.\n *\n * Default: true\n */\n traceFetch: boolean;\n\n /**\n * Flag to disable patching all together for xhr requests.\n *\n * Default: true\n */\n traceXHR: boolean;\n\n /**\n * Flag to disable tracking of long-lived streams, like server-sent events (SSE) via fetch.\n * Do not enable this in case you have live streams or very long running streams.\n *\n * Disabled by default since it can lead to issues with streams using the `cancel()` api\n * (https://github.com/getsentry/sentry-javascript/issues/13950)\n *\n * Default: false\n *\n * @deprecated Use `fetchStreamPerformanceIntegration()` instead. Add it to your `integrations` array\n * to track the duration of streamed fetch response bodies.\n */\n trackFetchStreamPerformance: boolean;\n\n /**\n * If true, Sentry will capture http timings and add them to the corresponding http spans.\n *\n * Default: true\n */\n enableHTTPTimings: boolean;\n\n /**\n * This function will be called before creating a span for a request with the given url.\n * Return false if you don't want a span for the given url.\n *\n * Default: (url: string) => true\n */\n shouldCreateSpanForRequest?(this: void, url: string): boolean;\n\n /**\n * Is called when spans are started for outgoing requests.\n */\n onRequestSpanStart?(span: Span, requestInformation: RequestHookInfo): void;\n\n /**\n * Is called when spans end for outgoing requests, providing access to response headers.\n */\n onRequestSpanEnd?(span: Span, responseInformation: ResponseHookInfo): void;\n}\n\nexport const defaultRequestInstrumentationOptions: RequestInstrumentationOptions = {\n traceFetch: true,\n traceXHR: true,\n enableHTTPTimings: true,\n // oxlint-disable-next-line typescript/no-deprecated -- default for the deprecated option, kept until it is removed\n trackFetchStreamPerformance: false,\n};\n\n/** Registers span creators for xhr and fetch requests */\nexport function instrumentOutgoingRequests(client: Client, _options?: Partial<RequestInstrumentationOptions>): void {\n const {\n traceFetch,\n traceXHR,\n shouldCreateSpanForRequest,\n enableHTTPTimings,\n tracePropagationTargets,\n onRequestSpanStart,\n onRequestSpanEnd,\n } = {\n ...defaultRequestInstrumentationOptions,\n ..._options,\n };\n\n const shouldCreateSpan =\n typeof shouldCreateSpanForRequest === 'function' ? shouldCreateSpanForRequest : (_: string) => true;\n\n const shouldAttachHeadersWithTargets = (url: string): boolean => shouldAttachHeaders(url, tracePropagationTargets);\n\n const spans: Record<string, Span> = {};\n\n const propagateTraceparent = (client as BrowserClient).getOptions().propagateTraceparent;\n\n if (traceFetch) {\n addFetchInstrumentationHandler(handlerData => {\n const createdSpan = instrumentFetchRequest(handlerData, shouldCreateSpan, shouldAttachHeadersWithTargets, spans, {\n propagateTraceparent,\n onRequestSpanEnd,\n });\n\n // We cannot use `window.location` in the generic fetch instrumentation,\n // but we need it for reliable `server.address` attribute.\n // so we extend this in here\n if (createdSpan) {\n const fullUrl = getFullURL(handlerData.fetchData.url);\n const host = fullUrl ? parseUrl(fullUrl).host : undefined;\n const sanitizedFullUrl = fullUrl ? stripDataUrlContent(fullUrl) : undefined;\n createdSpan.setAttributes({\n [URL_FULL]: filterCollectedUrl(sanitizedFullUrl),\n 'server.address': host,\n });\n\n if (enableHTTPTimings) {\n addHTTPTimings(createdSpan, client);\n }\n\n onRequestSpanStart?.(createdSpan, { headers: handlerData.headers });\n }\n });\n }\n\n if (traceXHR) {\n addXhrInstrumentationHandler(handlerData => {\n const createdSpan = xhrCallback(\n handlerData,\n shouldCreateSpan,\n shouldAttachHeadersWithTargets,\n spans,\n propagateTraceparent,\n onRequestSpanEnd,\n );\n\n if (createdSpan) {\n if (enableHTTPTimings) {\n addHTTPTimings(createdSpan, client);\n }\n\n onRequestSpanStart?.(createdSpan, {\n headers: createHeadersSafely(handlerData.xhr.__sentry_xhr_v3__?.request_headers),\n });\n }\n });\n }\n}\n\n/**\n * The maximum time (ms) to wait for PerformanceResourceTiming data before ending the span.\n * Same approach is used by OTel's browser fetch instrumentation:\n * See {@link https://github.com/open-telemetry/opentelemetry-js/blob/30f94fe99339287b1e4d3c8bb90172c2523f06f4/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L352-L372}\n */\nconst HTTP_TIMING_WAIT_MS = 300;\n\n/**\n * Creates a temporary observer to listen to the next fetch/xhr resourcing timings,\n * so that when timings hit their per-browser limit they don't need to be removed.\n *\n * @param span A span that has yet to be finished, must contain `url.full` on data.\n */\nfunction addHTTPTimings(span: Span, client: Client): void {\n const url = spanToJSON(span).data[URL_FULL];\n\n if (!url || typeof url !== 'string') {\n return;\n }\n\n // Clean up the performance observer and other resources\n // We have to wait here because otherwise this cleans itself up before it is fully done.\n // Default (non-streaming): just deregister the observer.\n let onEntryFound = (): void => void setTimeout(unsubscribePerformanceObsever);\n\n // For streamed spans, we have to artificially delay the ending of the span until we\n // either receive the timing data, or HTTP_TIMING_WAIT_MS elapses.\n if (hasSpanStreamingEnabled(client)) {\n const originalEnd = span.end.bind(span);\n\n span.end = (endTimestamp?: SpanTimeInput) => {\n const capturedEndTimestamp = endTimestamp ?? timestampInSeconds();\n let isEnded = false;\n\n const endSpanAndCleanup = (): void => {\n if (isEnded) {\n return;\n }\n isEnded = true;\n setTimeout(unsubscribePerformanceObsever);\n originalEnd(capturedEndTimestamp);\n clearTimeout(fallbackTimeout);\n };\n\n onEntryFound = endSpanAndCleanup;\n\n // Fallback: always end the span after HTTP_TIMING_WAIT_MS even if no\n // PerformanceResourceTiming entry arrives (e.g. cross-origin without\n // Timing-Allow-Origin, or the browser didn't fire the observer in time).\n const fallbackTimeout = setTimeout(endSpanAndCleanup, HTTP_TIMING_WAIT_MS);\n };\n }\n\n const unsubscribePerformanceObsever = addPerformanceInstrumentationHandler('resource', ({ entries }) => {\n entries.forEach(entry => {\n if (isPerformanceResourceTiming(entry) && entry.name.endsWith(url)) {\n span.setAttributes(resourceTimingToSpanAttributes(entry));\n onEntryFound();\n }\n });\n });\n}\n\n/**\n * A function that determines whether to attach tracing headers to a request.\n * We only export this function for testing purposes.\n */\nexport function shouldAttachHeaders(\n targetUrl: string,\n tracePropagationTargets: (string | RegExp)[] | undefined,\n): boolean {\n // window.location.href not being defined is an edge case in the browser but we need to handle it.\n // Potentially dangerous situations where it may not be defined: Browser Extensions, Web Workers, patching of the location obj\n const href = getLocationHref();\n\n if (!href) {\n // If there is no window.location.origin, we default to only attaching tracing headers to relative requests, i.e. ones that start with `/`\n // BIG DISCLAIMER: Users can call URLs with a double slash (fetch(\"//example.com/api\")), this is a shorthand for \"send to the same protocol\",\n // so we need a to exclude those requests, because they might be cross origin.\n const isRelativeSameOriginRequest = !!targetUrl.match(/^\\/(?!\\/)/);\n if (!tracePropagationTargets) {\n return isRelativeSameOriginRequest;\n } else {\n return stringMatchesSomePattern(targetUrl, tracePropagationTargets);\n }\n } else {\n let resolvedUrl;\n let currentOrigin;\n\n // URL parsing may fail, we default to not attaching trace headers in that case.\n try {\n resolvedUrl = new URL(targetUrl, href);\n currentOrigin = new URL(href).origin;\n } catch {\n return false;\n }\n\n const isSameOriginRequest = resolvedUrl.origin === currentOrigin;\n if (!tracePropagationTargets) {\n return isSameOriginRequest;\n } else {\n return (\n stringMatchesSomePattern(resolvedUrl.toString(), tracePropagationTargets) ||\n (isSameOriginRequest && stringMatchesSomePattern(resolvedUrl.pathname, tracePropagationTargets))\n );\n }\n }\n}\n\n/**\n * Create and track xhr request spans\n *\n * @returns Span if a span was created, otherwise void.\n */\n// oxlint-disable-next-line complexity\nfunction xhrCallback(\n handlerData: HandlerDataXhr,\n shouldCreateSpan: (url: string) => boolean,\n shouldAttachHeaders: (url: string) => boolean,\n spans: Record<string, Span>,\n propagateTraceparent?: boolean,\n onRequestSpanEnd?: RequestInstrumentationOptions['onRequestSpanEnd'],\n): Span | undefined {\n const xhr = handlerData.xhr;\n const sentryXhrData = xhr?.[SENTRY_XHR_DATA_KEY];\n\n if (!xhr || xhr.__sentry_own_request__ || !sentryXhrData) {\n return undefined;\n }\n\n const { url, method } = sentryXhrData;\n\n const shouldCreateSpanResult = hasSpansEnabled() && shouldCreateSpan(url);\n\n // Handle XHR completion - clean up spans from the record\n if (handlerData.endTimestamp) {\n const spanId = xhr.__sentry_xhr_span_id__;\n if (!spanId) return;\n\n const span = spans[spanId];\n\n if (span) {\n if (shouldCreateSpanResult && sentryXhrData.status_code !== undefined) {\n setHttpStatus(span, sentryXhrData.status_code);\n span.end();\n\n onRequestSpanEnd?.(span, {\n headers: createHeadersSafely(parseXhrResponseHeaders(xhr as XMLHttpRequest & SentryWrappedXMLHttpRequest)),\n error: handlerData.error,\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete spans[spanId];\n }\n\n return undefined;\n }\n\n const fullUrl = getFullURL(url);\n const parsedUrl = fullUrl ? parseUrl(fullUrl) : parseUrl(url);\n const sanitizedFullUrl = fullUrl ? stripDataUrlContent(fullUrl) : undefined;\n\n const urlForSpanName = stripDataUrlContent(stripUrlQueryAndFragment(url));\n\n const client = getClient();\n const hasParent = !!getActiveSpan();\n // With span streaming, we always emit http.client spans, even without a parent span\n const shouldEmitSpan = hasParent || (!!client && hasSpanStreamingEnabled(client));\n\n const span =\n shouldCreateSpanResult && shouldEmitSpan\n ? startInactiveSpan({\n name: `${method} ${urlForSpanName}`,\n attributes: {\n type: 'xhr',\n // eslint-disable-next-line typescript/no-deprecated\n [HTTP_METHOD]: method,\n [URL_FULL]: filterCollectedUrl(sanitizedFullUrl),\n [SERVER_ADDRESS]: parsedUrl?.host,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.browser',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',\n [URL_QUERY]: filterCollectedUrlQuery(getUrlQuery(parsedUrl?.search)),\n [URL_FRAGMENT]: getUrlFragment(parsedUrl?.hash),\n },\n })\n : new SentryNonRecordingSpan();\n\n // If the span is ignored, we don't want to continue the trace from it (NonRecordingSpan) but rather\n // from the active span. Passing `undefined` here will make `getTraceData` use the active span instead.\n const spanForTraceHeaders = spanIsIgnored(span) && hasParent ? undefined : span;\n\n if (shouldCreateSpanResult && !shouldEmitSpan) {\n client?.recordDroppedEvent('no_parent_span', 'span');\n }\n\n xhr.__sentry_xhr_span_id__ = span.spanContext().spanId;\n spans[xhr.__sentry_xhr_span_id__] = span;\n\n if (shouldAttachHeaders(url)) {\n addTracingHeadersToXhrRequest(\n xhr,\n // If performance is disabled (TWP) or there's no active root span (pageload/navigation/interaction),\n // we do not want to use the span as base for the trace headers,\n // which means that the headers will be generated from the scope and the sampling decision is deferred\n hasSpansEnabled() && shouldEmitSpan ? spanForTraceHeaders : undefined,\n propagateTraceparent,\n );\n }\n\n if (client) {\n client.emit('beforeOutgoingRequestSpan', span, handlerData as XhrHint);\n }\n\n return span;\n}\n\nfunction addTracingHeadersToXhrRequest(\n xhr: SentryWrappedXMLHttpRequest,\n span?: Span,\n propagateTraceparent?: boolean,\n): void {\n const { 'sentry-trace': sentryTrace, baggage, traceparent } = getTraceData({ span, propagateTraceparent });\n\n if (sentryTrace) {\n setHeaderOnXhr(xhr, sentryTrace, baggage, traceparent);\n }\n}\n\nfunction setHeaderOnXhr(\n xhr: SentryWrappedXMLHttpRequest,\n sentryTraceHeader: string,\n sentryBaggageHeader: string | undefined,\n traceparentHeader: string | undefined,\n): void {\n const originalHeaders = xhr.__sentry_xhr_v3__?.request_headers;\n\n if (originalHeaders?.['sentry-trace'] || !xhr.setRequestHeader) {\n // bail if a sentry-trace header is already set\n return;\n }\n\n try {\n xhr.setRequestHeader('sentry-trace', sentryTraceHeader);\n\n if (traceparentHeader && !originalHeaders?.['traceparent']) {\n xhr.setRequestHeader('traceparent', traceparentHeader);\n }\n\n if (sentryBaggageHeader) {\n // only add our headers if\n // - no pre-existing baggage header exists\n // - or it is set and doesn't yet contain sentry values\n const originalBaggageHeader = originalHeaders?.['baggage'];\n if (!originalBaggageHeader || !baggageHeaderHasSentryValues(originalBaggageHeader)) {\n // From MDN: \"If this method is called several times with the same header, the values are merged into one single request header.\"\n // We can therefore simply set a baggage header without checking what was there before\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader\n xhr.setRequestHeader('baggage', sentryBaggageHeader);\n }\n }\n } catch {\n // Error: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.\n }\n}\n"],"names":["addFetchInstrumentationHandler","instrumentFetchRequest","getFullURL","parseUrl","stripDataUrlContent","URL_FULL","filterCollectedUrl","addXhrInstrumentationHandler","createHeadersSafely","spanToJSON","hasSpanStreamingEnabled","timestampInSeconds","addPerformanceInstrumentationHandler","isPerformanceResourceTiming","resourceTimingToSpanAttributes","getLocationHref","stringMatchesSomePattern","shouldAttachHeaders","SENTRY_XHR_DATA_KEY","hasSpansEnabled","span","setHttpStatus","parseXhrResponseHeaders","stripUrlQueryAndFragment","getClient","getActiveSpan","startInactiveSpan","HTTP_METHOD","SERVER_ADDRESS","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","URL_QUERY","filterCollectedUrlQuery","getUrlQuery","URL_FRAGMENT","getUrlFragment","SentryNonRecordingSpan","spanIsIgnored","getTraceData","baggageHeaderHasSentryValues"],"mappings":";;;;;;;;AAoIO,MAAM,oCAAA,GAAsE;AAAA,EACjF,UAAA,EAAY,IAAA;AAAA,EACZ,QAAA,EAAU,IAAA;AAAA,EACV,iBAAA,EAAmB,IAAA;AAAA;AAAA,EAEnB,2BAAA,EAA6B;AAC/B;AAGO,SAAS,0BAAA,CAA2B,QAAgB,QAAA,EAAyD;AAClH,EAAA,MAAM;AAAA,IACJ,UAAA;AAAA,IACA,QAAA;AAAA,IACA,0BAAA;AAAA,IACA,iBAAA;AAAA,IACA,uBAAA;AAAA,IACA,kBAAA;AAAA,IACA;AAAA,GACF,GAAI;AAAA,IACF,GAAG,oCAAA;AAAA,IACH,G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9D,IAAA;AAAA,EACF;AAEA,EAAA,IAAI;AACF,IAAA,GAAA,CAAI,gBAAA,CAAiB,gBAAgB,iBAAiB,CAAA;AAEtD,IAAA,IAAI,iBAAA,IAAqB,CAAC,eAAA,GAAkB,aAAa,CAAA,EAAG;AAC1D,MAAA,GAAA,CAAI,gBAAA,CAAiB,eAAe,iBAAiB,CAAA;AAAA,IACvD;AAEA,IAAA,IAAI,mBAAA,EAAqB;AAIvB,MAAA,MAAM,qBAAA,GAAwB,kBAAkB,SAAS,CAAA;AACzD,MAAA,IAAI,CAAC,qBAAA,IAAyB,CAACC,kCAAA,CAA6B,qBAAqB,CAAA,EAAG;AAIlF,QAAA,GAAA,CAAI,gBAAA,CAAiB,WAAW,mBAAmB,CAAA;AAAA,MACrD;AAAA,IACF;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;;;;;;"}
|
|
1
|
+
{"version":3,"file":"request.js","sources":["../../../../../src/tracing/request.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { Client, RequestHookInfo, ResponseHookInfo, Span, SpanTimeInput } from '@sentry/core/browser';\nimport {\n addFetchInstrumentationHandler,\n getActiveSpan,\n getClient,\n getTraceData,\n getUrlFragment,\n getUrlQuery,\n hasSpansEnabled,\n hasSpanStreamingEnabled,\n instrumentFetchRequest,\n matchesTracePropagationTargets,\n parseUrl,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SentryNonRecordingSpan,\n setHttpStatus,\n spanIsIgnored,\n spanToJSON,\n startInactiveSpan,\n stripDataUrlContent,\n stripUrlQueryAndFragment,\n timestampInSeconds,\n} from '@sentry/core/browser';\nimport type { HandlerDataXhr, SentryWrappedXMLHttpRequest, XhrHint } from '@sentry/browser-utils';\nimport { filterCollectedUrl, filterCollectedUrlQuery } from '@sentry/core';\nimport {\n addPerformanceInstrumentationHandler,\n addXhrInstrumentationHandler,\n getLocationHref,\n parseXhrResponseHeaders,\n resourceTimingToSpanAttributes,\n SENTRY_XHR_DATA_KEY,\n} from '@sentry/browser-utils';\nimport type { BrowserClient } from '../client';\nimport { baggageHeaderHasSentryValues, createHeadersSafely, getFullURL, isPerformanceResourceTiming } from './utils';\nimport { HTTP_REQUEST_METHOD, SERVER_ADDRESS, URL_FRAGMENT, URL_FULL, URL_QUERY } from '@sentry/conventions/attributes';\n\n/** Options for Request Instrumentation */\nexport interface RequestInstrumentationOptions {\n /**\n * List of strings and/or Regular Expressions used to determine which outgoing requests will have `sentry-trace` and `baggage`\n * headers attached.\n *\n * **Default:** If this option is not provided, tracing headers will be attached to all outgoing requests.\n * If you are using a browser SDK, by default, tracing headers will only be attached to outgoing requests to the same origin.\n *\n * **Disclaimer:** Carelessly setting this option in browser environments may result into CORS errors!\n * Only attach tracing headers to requests to the same origin, or to requests to services you can control CORS headers of.\n * Cross-origin requests, meaning requests to a different domain, for example a request to `https://api.example.com/` while you're on `https://example.com/`, take special care.\n * If you are attaching headers to cross-origin requests, make sure the backend handling the request returns a `\"Access-Control-Allow-Headers: sentry-trace, baggage\"` header to ensure your requests aren't blocked.\n *\n * If you provide a `tracePropagationTargets` array, the entries you provide will be matched against the entire URL of the outgoing request.\n * If you are using a browser SDK, the entries will also be matched against the pathname of the outgoing requests.\n * This is so you can have matchers for relative requests, for example, `/^\\/api/` if you want to trace requests to your `/api` routes on the same domain.\n *\n * If any of the two match any of the provided values, tracing headers will be attached to the outgoing request.\n * Both, the string values, and the RegExes you provide in the array will match if they partially match the URL or pathname.\n * Matching is case-insensitive, so `'myApi.com'` and `/^myApi\\.com/` both match a request to `https://myapi.com`.\n *\n * Examples:\n * - `tracePropagationTargets: [/^\\/api/]` and request to `https://same-origin.com/api/posts`:\n * - Tracing headers will be attached because the request is sent to the same origin and the regex matches the pathname \"/api/posts\".\n * - `tracePropagationTargets: [/^\\/api/]` and request to `https://different-origin.com/api/posts`:\n * - Tracing headers will not be attached because the pathname will only be compared when the request target lives on the same origin.\n * - `tracePropagationTargets: [/^\\/api/, 'https://external-api.com']` and request to `https://external-api.com/v1/data`:\n * - Tracing headers will be attached because the request URL matches the string `'https://external-api.com'`.\n */\n tracePropagationTargets?: Array<string | RegExp>;\n\n /**\n * Flag to disable patching all together for fetch requests.\n *\n * Default: true\n */\n traceFetch: boolean;\n\n /**\n * Flag to disable patching all together for xhr requests.\n *\n * Default: true\n */\n traceXHR: boolean;\n\n /**\n * If true, Sentry will capture http timings and add them to the corresponding http spans.\n *\n * Default: true\n */\n enableHTTPTimings: boolean;\n\n /**\n * This function will be called before creating a span for a request with the given url.\n * Return false if you don't want a span for the given url.\n *\n * Default: (url: string) => true\n */\n shouldCreateSpanForRequest?(this: void, url: string): boolean;\n\n /**\n * Is called when spans are started for outgoing requests.\n */\n onRequestSpanStart?(span: Span, requestInformation: RequestHookInfo): void;\n\n /**\n * Is called when spans end for outgoing requests, providing access to response headers.\n */\n onRequestSpanEnd?(span: Span, responseInformation: ResponseHookInfo): void;\n}\n\nexport const defaultRequestInstrumentationOptions: RequestInstrumentationOptions = {\n traceFetch: true,\n traceXHR: true,\n enableHTTPTimings: true,\n};\n\n/** Registers span creators for xhr and fetch requests */\nexport function instrumentOutgoingRequests(client: Client, _options?: Partial<RequestInstrumentationOptions>): void {\n const {\n traceFetch,\n traceXHR,\n shouldCreateSpanForRequest,\n enableHTTPTimings,\n tracePropagationTargets,\n onRequestSpanStart,\n onRequestSpanEnd,\n } = {\n ...defaultRequestInstrumentationOptions,\n ..._options,\n };\n\n const shouldCreateSpan =\n typeof shouldCreateSpanForRequest === 'function' ? shouldCreateSpanForRequest : (_: string) => true;\n\n const shouldAttachHeadersWithTargets = (url: string): boolean => shouldAttachHeaders(url, tracePropagationTargets);\n\n const spans: Record<string, Span> = {};\n\n const propagateTraceparent = (client as BrowserClient).getOptions().propagateTraceparent;\n\n if (traceFetch) {\n addFetchInstrumentationHandler(handlerData => {\n const createdSpan = instrumentFetchRequest(handlerData, shouldCreateSpan, shouldAttachHeadersWithTargets, spans, {\n propagateTraceparent,\n onRequestSpanEnd,\n });\n\n // We cannot use `window.location` in the generic fetch instrumentation,\n // but we need it for reliable `server.address` attribute.\n // so we extend this in here\n if (createdSpan) {\n const fullUrl = getFullURL(handlerData.fetchData.url);\n const host = fullUrl ? parseUrl(fullUrl).host : undefined;\n const sanitizedFullUrl = fullUrl ? stripDataUrlContent(fullUrl) : undefined;\n createdSpan.setAttributes({\n [URL_FULL]: filterCollectedUrl(sanitizedFullUrl),\n [SERVER_ADDRESS]: host,\n });\n\n if (enableHTTPTimings) {\n addHTTPTimings(createdSpan, client);\n }\n\n onRequestSpanStart?.(createdSpan, { headers: handlerData.headers });\n }\n });\n }\n\n if (traceXHR) {\n addXhrInstrumentationHandler(handlerData => {\n const createdSpan = xhrCallback(\n handlerData,\n shouldCreateSpan,\n shouldAttachHeadersWithTargets,\n spans,\n propagateTraceparent,\n onRequestSpanEnd,\n );\n\n if (createdSpan) {\n if (enableHTTPTimings) {\n addHTTPTimings(createdSpan, client);\n }\n\n onRequestSpanStart?.(createdSpan, {\n headers: createHeadersSafely(handlerData.xhr.__sentry_xhr_v3__?.request_headers),\n });\n }\n });\n }\n}\n\n/**\n * The maximum time (ms) to wait for PerformanceResourceTiming data before ending the span.\n * Same approach is used by OTel's browser fetch instrumentation:\n * See {@link https://github.com/open-telemetry/opentelemetry-js/blob/30f94fe99339287b1e4d3c8bb90172c2523f06f4/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L352-L372}\n */\nconst HTTP_TIMING_WAIT_MS = 300;\n\n/**\n * Creates a temporary observer to listen to the next fetch/xhr resourcing timings,\n * so that when timings hit their per-browser limit they don't need to be removed.\n *\n * @param span A span that has yet to be finished, must contain `url.full` on data.\n */\nfunction addHTTPTimings(span: Span, client: Client): void {\n const url = spanToJSON(span).attributes[URL_FULL];\n\n if (!url || typeof url !== 'string') {\n return;\n }\n\n // Clean up the performance observer and other resources\n // We have to wait here because otherwise this cleans itself up before it is fully done.\n // Default (non-streaming): just deregister the observer.\n let onEntryFound = (): void => void setTimeout(unsubscribePerformanceObsever);\n\n // For streamed spans, we have to artificially delay the ending of the span until we\n // either receive the timing data, or HTTP_TIMING_WAIT_MS elapses.\n if (hasSpanStreamingEnabled(client)) {\n const originalEnd = span.end.bind(span);\n\n span.end = (endTimestamp?: SpanTimeInput) => {\n const capturedEndTimestamp = endTimestamp ?? timestampInSeconds();\n let isEnded = false;\n\n const endSpanAndCleanup = (): void => {\n if (isEnded) {\n return;\n }\n isEnded = true;\n setTimeout(unsubscribePerformanceObsever);\n originalEnd(capturedEndTimestamp);\n clearTimeout(fallbackTimeout);\n };\n\n onEntryFound = endSpanAndCleanup;\n\n // Fallback: always end the span after HTTP_TIMING_WAIT_MS even if no\n // PerformanceResourceTiming entry arrives (e.g. cross-origin without\n // Timing-Allow-Origin, or the browser didn't fire the observer in time).\n const fallbackTimeout = setTimeout(endSpanAndCleanup, HTTP_TIMING_WAIT_MS);\n };\n }\n\n const unsubscribePerformanceObsever = addPerformanceInstrumentationHandler('resource', ({ entries }) => {\n entries.forEach(entry => {\n if (isPerformanceResourceTiming(entry) && entry.name.endsWith(url)) {\n span.setAttributes(resourceTimingToSpanAttributes(entry));\n onEntryFound();\n }\n });\n });\n}\n\n/**\n * A function that determines whether to attach tracing headers to a request.\n * We only export this function for testing purposes.\n */\nexport function shouldAttachHeaders(\n targetUrl: string,\n tracePropagationTargets: (string | RegExp)[] | undefined,\n): boolean {\n // window.location.href not being defined is an edge case in the browser but we need to handle it.\n // Potentially dangerous situations where it may not be defined: Browser Extensions, Web Workers, patching of the location obj\n const href = getLocationHref();\n\n if (!href) {\n // If there is no window.location.origin, we default to only attaching tracing headers to relative requests, i.e. ones that start with `/`\n // BIG DISCLAIMER: Users can call URLs with a double slash (fetch(\"//example.com/api\")), this is a shorthand for \"send to the same protocol\",\n // so we need a to exclude those requests, because they might be cross origin.\n const isRelativeSameOriginRequest = !!targetUrl.match(/^\\/(?!\\/)/);\n if (!tracePropagationTargets) {\n return isRelativeSameOriginRequest;\n } else {\n return matchesTracePropagationTargets(targetUrl, tracePropagationTargets);\n }\n } else {\n let resolvedUrl;\n let currentOrigin;\n\n // URL parsing may fail, we default to not attaching trace headers in that case.\n try {\n resolvedUrl = new URL(targetUrl, href);\n currentOrigin = new URL(href).origin;\n } catch {\n return false;\n }\n\n const isSameOriginRequest = resolvedUrl.origin === currentOrigin;\n if (!tracePropagationTargets) {\n return isSameOriginRequest;\n } else {\n return (\n matchesTracePropagationTargets(resolvedUrl.toString(), tracePropagationTargets) ||\n (isSameOriginRequest && matchesTracePropagationTargets(resolvedUrl.pathname, tracePropagationTargets))\n );\n }\n }\n}\n\n/**\n * Create and track xhr request spans\n *\n * @returns Span if a span was created, otherwise void.\n */\n// oxlint-disable-next-line complexity\nfunction xhrCallback(\n handlerData: HandlerDataXhr,\n shouldCreateSpan: (url: string) => boolean,\n shouldAttachHeaders: (url: string) => boolean,\n spans: Record<string, Span>,\n propagateTraceparent?: boolean,\n onRequestSpanEnd?: RequestInstrumentationOptions['onRequestSpanEnd'],\n): Span | undefined {\n const xhr = handlerData.xhr;\n const sentryXhrData = xhr?.[SENTRY_XHR_DATA_KEY];\n\n if (!xhr || xhr.__sentry_own_request__ || !sentryXhrData) {\n return undefined;\n }\n\n const { url, method } = sentryXhrData;\n\n const shouldCreateSpanResult = hasSpansEnabled() && shouldCreateSpan(url);\n\n // Handle XHR completion - clean up spans from the record\n if (handlerData.endTimestamp) {\n const spanId = xhr.__sentry_xhr_span_id__;\n if (!spanId) return;\n\n const span = spans[spanId];\n\n if (span) {\n if (shouldCreateSpanResult && sentryXhrData.status_code !== undefined) {\n setHttpStatus(span, sentryXhrData.status_code);\n span.end();\n\n onRequestSpanEnd?.(span, {\n headers: createHeadersSafely(parseXhrResponseHeaders(xhr as XMLHttpRequest & SentryWrappedXMLHttpRequest)),\n error: handlerData.error,\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete spans[spanId];\n }\n\n return undefined;\n }\n\n const fullUrl = getFullURL(url);\n const parsedUrl = fullUrl ? parseUrl(fullUrl) : parseUrl(url);\n const sanitizedFullUrl = fullUrl ? stripDataUrlContent(fullUrl) : undefined;\n\n const urlForSpanName = stripDataUrlContent(stripUrlQueryAndFragment(url));\n\n const client = getClient();\n const hasParent = !!getActiveSpan();\n // With span streaming, we always emit http.client spans, even without a parent span\n const shouldEmitSpan = hasParent || (!!client && hasSpanStreamingEnabled(client));\n\n const span =\n shouldCreateSpanResult && shouldEmitSpan\n ? startInactiveSpan({\n name: `${method} ${urlForSpanName}`,\n attributes: {\n type: 'xhr',\n // eslint-disable-next-line typescript/no-deprecated\n [HTTP_REQUEST_METHOD]: method,\n [URL_FULL]: filterCollectedUrl(sanitizedFullUrl),\n [SERVER_ADDRESS]: parsedUrl?.host,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.browser',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',\n [URL_QUERY]: filterCollectedUrlQuery(getUrlQuery(parsedUrl?.search)),\n [URL_FRAGMENT]: getUrlFragment(parsedUrl?.hash),\n },\n })\n : new SentryNonRecordingSpan();\n\n // If the span is ignored, we don't want to continue the trace from it (NonRecordingSpan) but rather\n // from the active span. Passing `undefined` here will make `getTraceData` use the active span instead.\n const spanForTraceHeaders = spanIsIgnored(span) && hasParent ? undefined : span;\n\n if (shouldCreateSpanResult && !shouldEmitSpan) {\n client?.recordDroppedEvent('no_parent_span', 'span');\n }\n\n xhr.__sentry_xhr_span_id__ = span.spanContext().spanId;\n spans[xhr.__sentry_xhr_span_id__] = span;\n\n if (shouldAttachHeaders(url)) {\n addTracingHeadersToXhrRequest(\n xhr,\n // If performance is disabled (TWP) or there's no active root span (pageload/navigation/interaction),\n // we do not want to use the span as base for the trace headers,\n // which means that the headers will be generated from the scope and the sampling decision is deferred\n hasSpansEnabled() && shouldEmitSpan ? spanForTraceHeaders : undefined,\n propagateTraceparent,\n );\n }\n\n if (client) {\n client.emit('beforeOutgoingRequestSpan', span, handlerData as XhrHint);\n }\n\n return span;\n}\n\nfunction addTracingHeadersToXhrRequest(\n xhr: SentryWrappedXMLHttpRequest,\n span?: Span,\n propagateTraceparent?: boolean,\n): void {\n const { 'sentry-trace': sentryTrace, baggage, traceparent } = getTraceData({ span, propagateTraceparent });\n\n if (sentryTrace) {\n setHeaderOnXhr(xhr, sentryTrace, baggage, traceparent);\n }\n}\n\nfunction setHeaderOnXhr(\n xhr: SentryWrappedXMLHttpRequest,\n sentryTraceHeader: string,\n sentryBaggageHeader: string | undefined,\n traceparentHeader: string | undefined,\n): void {\n const originalHeaders = xhr.__sentry_xhr_v3__?.request_headers;\n\n if (originalHeaders?.['sentry-trace'] || !xhr.setRequestHeader) {\n // bail if a sentry-trace header is already set\n return;\n }\n\n try {\n xhr.setRequestHeader('sentry-trace', sentryTraceHeader);\n\n if (traceparentHeader && !originalHeaders?.['traceparent']) {\n xhr.setRequestHeader('traceparent', traceparentHeader);\n }\n\n if (sentryBaggageHeader) {\n // only add our headers if\n // - no pre-existing baggage header exists\n // - or it is set and doesn't yet contain sentry values\n const originalBaggageHeader = originalHeaders?.['baggage'];\n if (!originalBaggageHeader || !baggageHeaderHasSentryValues(originalBaggageHeader)) {\n // From MDN: \"If this method is called several times with the same header, the values are merged into one single request header.\"\n // We can therefore simply set a baggage header without checking what was there before\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader\n xhr.setRequestHeader('baggage', sentryBaggageHeader);\n }\n }\n } catch {\n // Error: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.\n }\n}\n"],"names":["addFetchInstrumentationHandler","instrumentFetchRequest","getFullURL","parseUrl","stripDataUrlContent","URL_FULL","filterCollectedUrl","SERVER_ADDRESS","addXhrInstrumentationHandler","createHeadersSafely","spanToJSON","hasSpanStreamingEnabled","timestampInSeconds","addPerformanceInstrumentationHandler","isPerformanceResourceTiming","resourceTimingToSpanAttributes","getLocationHref","matchesTracePropagationTargets","shouldAttachHeaders","SENTRY_XHR_DATA_KEY","hasSpansEnabled","span","setHttpStatus","parseXhrResponseHeaders","stripUrlQueryAndFragment","getClient","getActiveSpan","startInactiveSpan","HTTP_REQUEST_METHOD","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","URL_QUERY","filterCollectedUrlQuery","getUrlQuery","URL_FRAGMENT","getUrlFragment","SentryNonRecordingSpan","spanIsIgnored","getTraceData","baggageHeaderHasSentryValues"],"mappings":";;;;;;;;AA+GO,MAAM,oCAAA,GAAsE;AAAA,EACjF,UAAA,EAAY,IAAA;AAAA,EACZ,QAAA,EAAU,IAAA;AAAA,EACV,iBAAA,EAAmB;AACrB;AAGO,SAAS,0BAAA,CAA2B,QAAgB,QAAA,EAAyD;AAClH,EAAA,MAAM;AAAA,IACJ,UAAA;AAAA,IACA,QAAA;AAAA,IACA,0BAAA;AAAA,IACA,iBAAA;AAAA,IACA,uBAAA;AAAA,IACA,kBAAA;AAAA,IACA;AAAA,GACF,GAAI;AAAA,IACF,GAAG,oCAAA;AAAA,IACH,GAAG;AAAA,GACL;AAEA,EAAA,MAAM,mBACJ,OAAO,0BAAA,KAA+B,UAAA,GAAa,0BAAA,GAA6B,CAAC,CAAA,KAAc,IAAA;AAEjG,EAAA,MAAM,8BAAA,GAAiC,CAAC,GAAA,KAAyB,mBAAA,CAAoB,KAAK,uBAAuB,CAAA;AAEjH,EAAA,MAAM,QAA8B,EAAC;AAErC,EAAA,MAAM,oBAAA,GAAwB,MAAA,CAAyB,UAAA,EAAW,CAAE,oBAAA;AAEpE,EAAA,IAAI,UAAA,EAAY;AACd,IAAAA,sCAAA,CAA+B,CAAA,WAAA,KAAe;AAC5C,MAAA,MAAM,WAAA,GAAcC,8BAAA,CAAuB,WAAA,EAAa,gBAAA,EAAkB,gCAAgC,KAAA,EAAO;AAAA,QAC/G,oBAAA;AAAA,QACA;AAAA,O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AA,CAAA,MAAQ;AAAA,EAER;AACF;;;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
+
const browserUtils = require('@sentry/browser-utils');
|
|
3
4
|
const browser = require('@sentry/core/browser');
|
|
4
5
|
const debugBuild = require('../debug-build.js');
|
|
5
6
|
const helpers = require('../helpers.js');
|
|
@@ -29,7 +30,7 @@ function _isEmbeddedBrowserExtension() {
|
|
|
29
30
|
if (!extensionObject?.runtime?.id) {
|
|
30
31
|
return false;
|
|
31
32
|
}
|
|
32
|
-
const href =
|
|
33
|
+
const href = browserUtils.getLocationHref();
|
|
33
34
|
const isDedicatedExtensionPage = helpers.WINDOW === helpers.WINDOW.top && /^(?:chrome-extension|moz-extension|ms-browser-extension|safari-web-extension):\/\//.test(href);
|
|
34
35
|
return !isDedicatedExtensionPage;
|
|
35
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectBrowserExtension.js","sources":["../../../../../src/utils/detectBrowserExtension.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"detectBrowserExtension.js","sources":["../../../../../src/utils/detectBrowserExtension.ts"],"sourcesContent":["import { getLocationHref } from '@sentry/browser-utils';\nimport { consoleSandbox } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\n\ntype ExtensionRuntime = {\n runtime?: {\n id?: string;\n };\n};\ntype ExtensionProperties = {\n chrome?: ExtensionRuntime;\n browser?: ExtensionRuntime;\n nw?: unknown;\n};\n\n/**\n * Returns true if the SDK is running in an embedded browser extension.\n * Stand-alone browser extensions (which do not share the same data as the main browser page) are fine.\n */\nexport function checkAndWarnIfIsEmbeddedBrowserExtension(): boolean {\n if (_isEmbeddedBrowserExtension()) {\n if (DEBUG_BUILD) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.error(\n '[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',\n );\n });\n }\n\n return true;\n }\n\n return false;\n}\n\nfunction _isEmbeddedBrowserExtension(): boolean {\n if (typeof WINDOW.window === 'undefined') {\n // No need to show the error if we're not in a browser window environment (e.g. service workers)\n return false;\n }\n\n const _window = WINDOW as typeof WINDOW & ExtensionProperties;\n\n // Running the SDK in NW.js, which appears like a browser extension but isn't, is also fine\n // see: https://github.com/getsentry/sentry-javascript/issues/12668\n if (_window.nw) {\n return false;\n }\n\n const extensionObject = _window['chrome'] || _window['browser'];\n\n if (!extensionObject?.runtime?.id) {\n return false;\n }\n\n const href = getLocationHref();\n\n // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage\n const isDedicatedExtensionPage =\n WINDOW === WINDOW.top &&\n /^(?:chrome-extension|moz-extension|ms-browser-extension|safari-web-extension):\\/\\//.test(href);\n\n return !isDedicatedExtensionPage;\n}\n"],"names":["DEBUG_BUILD","consoleSandbox","WINDOW","getLocationHref"],"mappings":";;;;;;;AAoBO,SAAS,wCAAA,GAAoD;AAClE,EAAA,IAAI,6BAA4B,EAAG;AACjC,IAAA,IAAIA,sBAAA,EAAa;AACf,MAAAC,sBAAA,CAAe,MAAM;AAEnB,QAAA,OAAA,CAAQ,KAAA;AAAA,UACN;AAAA,SACF;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAEA,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,2BAAA,GAAuC;AAC9C,EAAA,IAAI,OAAOC,cAAA,CAAO,MAAA,KAAW,WAAA,EAAa;AAExC,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,OAAA,GAAUA,cAAA;AAIhB,EAAA,IAAI,QAAQ,EAAA,EAAI;AACd,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,eAAA,GAAkB,OAAA,CAAQ,QAAQ,CAAA,IAAK,QAAQ,SAAS,CAAA;AAE9D,EAAA,IAAI,CAAC,eAAA,EAAiB,OAAA,EAAS,EAAA,EAAI;AACjC,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,OAAOC,4BAAA,EAAgB;AAG7B,EAAA,MAAM,2BACJD,cAAA,KAAWA,cAAA,CAAO,GAAA,IAClB,oFAAA,CAAqF,KAAK,IAAI,CAAA;AAEhG,EAAA,OAAO,CAAC,wBAAA;AACV;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyLoadIntegration.js","sources":["../../../../../src/utils/lazyLoadIntegration.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core/browser';\nimport { getClient, SDK_VERSION } from '@sentry/core/browser';\nimport type { BrowserClient } from '../client';\nimport { WINDOW } from '../helpers';\n\n// Single source of truth: as const array provides both the runtime list and the type.\n// Bundle file names are derived: strip 'Integration' suffix, lowercase.\n// Exceptions (hyphenated bundle names) are listed in HYPHENATED_BUNDLES.\nconst LAZY_LOADABLE_NAMES = [\n 'replayIntegration',\n 'replayCanvasIntegration',\n 'feedbackIntegration',\n 'feedbackModalIntegration',\n 'feedbackScreenshotIntegration',\n 'captureConsoleIntegration',\n 'contextLinesIntegration',\n 'linkedErrorsIntegration',\n 'dedupeIntegration',\n 'extraErrorDataIntegration',\n 'graphqlClientIntegration',\n 'httpClientIntegration',\n 'reportingObserverIntegration',\n 'rewriteFramesIntegration',\n 'browserProfilingIntegration',\n 'userTimingIntegration',\n 'moduleMetadataIntegration',\n] as const;\n\ntype ElementOf<T extends readonly unknown[]> = T[number];\ntype LazyLoadableIntegrationName = ElementOf<typeof LAZY_LOADABLE_NAMES>;\n\nconst HYPHENATED_BUNDLES: Partial<Record<LazyLoadableIntegrationName, string>> = {\n replayCanvasIntegration: 'replay-canvas',\n feedbackModalIntegration: 'feedback-modal',\n feedbackScreenshotIntegration: 'feedback-screenshot',\n};\n\nfunction getBundleName(name: string): string {\n return HYPHENATED_BUNDLES[name as LazyLoadableIntegrationName] || name.replace('Integration', '').toLowerCase();\n}\n\nconst WindowWithMaybeIntegration = WINDOW as {\n Sentry?: Partial<Record<LazyLoadableIntegrationName, IntegrationFn>>;\n};\n\n/**\n * Lazy load an integration from the CDN.\n * Rejects if the integration cannot be loaded.\n */\nexport async function lazyLoadIntegration(\n name: LazyLoadableIntegrationName,\n scriptNonce?: string,\n): Promise<IntegrationFn> {\n const bundle = LAZY_LOADABLE_NAMES.includes(name) ? getBundleName(name) : undefined;\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 = 'strict-origin';\n\n if (scriptNonce) {\n script.setAttribute('nonce', scriptNonce);\n }\n\n const waitForLoad = new Promise<void>((resolve, reject) => {\n script.addEventListener('load', () => resolve());\n script.addEventListener('error', reject);\n });\n\n const currentScript = WINDOW.document.currentScript;\n const parent = WINDOW.document.body || WINDOW.document.head || currentScript?.parentElement;\n\n if (parent) {\n parent.appendChild(script);\n } else {\n throw new Error(`Could not find parent element to insert lazy-loaded ${name} script`);\n }\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<BrowserClient>();\n const baseURL = client?.getOptions()?.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":";;;;;AAQA,MAAM,mBAAA,GAAsB;AAAA,EAC1B,mBAAA;AAAA,EACA,yBAAA;AAAA,EACA,qBAAA;AAAA,EACA,0BAAA;AAAA,EACA,+BAAA;AAAA,EACA,2BAAA;AAAA,EACA,yBAAA;AAAA,EACA,yBAAA;AAAA,EACA,mBAAA;AAAA,EACA,2BAAA;AAAA,EACA,0BAAA;AAAA,EACA,uBAAA;AAAA,EACA,8BAAA;AAAA,EACA,0BAAA;AAAA,EACA,6BAAA;AAAA,EACA,uBAAA;AAAA,EACA;AACF,CAAA;AAKA,MAAM,kBAAA,GAA2E;AAAA,EAC/E,uBAAA,EAAyB,eAAA;AAAA,EACzB,wBAAA,EAA0B,gBAAA;AAAA,EAC1B,6BAAA,EAA+B;AACjC,CAAA;AAEA,SAAS,cAAc,IAAA,EAAsB;AAC3C,EAAA,OAAO,kBAAA,CAAmB,IAAmC,CAAA,IAAK,IAAA,CAAK,QAAQ,aAAA,EAAe,EAAE,EAAE,WAAA,EAAY;AAChH;AAEA,MAAM,0BAAA,GAA6BA,cAAA;AAQnC,eAAsB,mBAAA,CACpB,MACA,WAAA,EACwB;AACxB,EAAA,MAAM,SAAS,mBAAA,CAAoB,QAAA,CAAS,IAAI,CAAA,GAAI,aAAA,CAAc,IAAI,CAAA,GAAI,MAAA;AAG1E,EAAA,MAAM,cAAA,GAAkB,0BAAA,CAA2B,MAAA,GAAS,0BAAA,CAA2B,UAAU,EAAC;AAElG,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,8BAAA,EAAiC,IAAI,CAAA,CAAE,CAAA;AAAA,EACzD;AAGA,EAAA,MAAM,QAAA,GAAW,eAAe,IAAI,CAAA;AAIpC,EAAA,IAAI,OAAO,QA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CAAA;AAEzC,EAAA,IAAI,OAAO,kBAAkB,UAAA,EAAY;AACvC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,4BAAA,EAA+B,IAAI,CAAA,CAAE,CAAA;AAAA,EACvD;AAEA,EAAA,OAAO,aAAA;AACT;AAEA,SAAS,aAAa,MAAA,EAAwB;AAC5C,EAAA,MAAM,SAASC,iBAAA,EAAyB;AACxC,EAAA,MAAM,OAAA,GAAU,MAAA,EAAQ,UAAA,EAAW,EAAG,UAAA,IAAc,gCAAA;AAEpD,EAAA,OAAO,IAAI,IAAI,CAAA,CAAA,EAAIC,mBAAW,IAAI,MAAM,CAAA,OAAA,CAAA,EAAW,OAAO,CAAA,CAAE,QAAA,EAAS;AACvE;;;;"}
|
|
1
|
+
{"version":3,"file":"lazyLoadIntegration.js","sources":["../../../../../src/utils/lazyLoadIntegration.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core/browser';\nimport { getClient, SDK_VERSION } from '@sentry/core/browser';\nimport type { BrowserClient } from '../client';\nimport { WINDOW } from '../helpers';\n\n// Single source of truth: as const array provides both the runtime list and the type.\n// Bundle file names are derived: strip 'Integration' suffix, lowercase.\n// Exceptions (hyphenated bundle names) are listed in HYPHENATED_BUNDLES.\nconst LAZY_LOADABLE_NAMES = [\n 'replayIntegration',\n 'replayCanvasIntegration',\n 'feedbackIntegration',\n 'feedbackModalIntegration',\n 'feedbackScreenshotIntegration',\n 'captureConsoleIntegration',\n 'contextLinesIntegration',\n 'linkedErrorsIntegration',\n 'dedupeIntegration',\n 'extraErrorDataIntegration',\n 'graphqlClientIntegration',\n 'httpClientIntegration',\n 'reportingObserverIntegration',\n 'rewriteFramesIntegration',\n 'browserProfilingIntegration',\n 'userTimingIntegration',\n 'interactionsIntegration',\n 'moduleMetadataIntegration',\n] as const;\n\ntype ElementOf<T extends readonly unknown[]> = T[number];\ntype LazyLoadableIntegrationName = ElementOf<typeof LAZY_LOADABLE_NAMES>;\n\nconst HYPHENATED_BUNDLES: Partial<Record<LazyLoadableIntegrationName, string>> = {\n replayCanvasIntegration: 'replay-canvas',\n feedbackModalIntegration: 'feedback-modal',\n feedbackScreenshotIntegration: 'feedback-screenshot',\n};\n\nfunction getBundleName(name: string): string {\n return HYPHENATED_BUNDLES[name as LazyLoadableIntegrationName] || name.replace('Integration', '').toLowerCase();\n}\n\nconst WindowWithMaybeIntegration = WINDOW as {\n Sentry?: Partial<Record<LazyLoadableIntegrationName, IntegrationFn>>;\n};\n\n/**\n * Lazy load an integration from the CDN.\n * Rejects if the integration cannot be loaded.\n */\nexport async function lazyLoadIntegration(\n name: LazyLoadableIntegrationName,\n scriptNonce?: string,\n): Promise<IntegrationFn> {\n const bundle = LAZY_LOADABLE_NAMES.includes(name) ? getBundleName(name) : undefined;\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 = 'strict-origin';\n\n if (scriptNonce) {\n script.setAttribute('nonce', scriptNonce);\n }\n\n const waitForLoad = new Promise<void>((resolve, reject) => {\n script.addEventListener('load', () => resolve());\n script.addEventListener('error', reject);\n });\n\n const currentScript = WINDOW.document.currentScript;\n const parent = WINDOW.document.body || WINDOW.document.head || currentScript?.parentElement;\n\n if (parent) {\n parent.appendChild(script);\n } else {\n throw new Error(`Could not find parent element to insert lazy-loaded ${name} script`);\n }\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<BrowserClient>();\n const baseURL = client?.getOptions()?.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":";;;;;AAQA,MAAM,mBAAA,GAAsB;AAAA,EAC1B,mBAAA;AAAA,EACA,yBAAA;AAAA,EACA,qBAAA;AAAA,EACA,0BAAA;AAAA,EACA,+BAAA;AAAA,EACA,2BAAA;AAAA,EACA,yBAAA;AAAA,EACA,yBAAA;AAAA,EACA,mBAAA;AAAA,EACA,2BAAA;AAAA,EACA,0BAAA;AAAA,EACA,uBAAA;AAAA,EACA,8BAAA;AAAA,EACA,0BAAA;AAAA,EACA,6BAAA;AAAA,EACA,uBAAA;AAAA,EACA,yBAAA;AAAA,EACA;AACF,CAAA;AAKA,MAAM,kBAAA,GAA2E;AAAA,EAC/E,uBAAA,EAAyB,eAAA;AAAA,EACzB,wBAAA,EAA0B,gBAAA;AAAA,EAC1B,6BAAA,EAA+B;AACjC,CAAA;AAEA,SAAS,cAAc,IAAA,EAAsB;AAC3C,EAAA,OAAO,kBAAA,CAAmB,IAAmC,CAAA,IAAK,IAAA,CAAK,QAAQ,aAAA,EAAe,EAAE,EAAE,WAAA,EAAY;AAChH;AAEA,MAAM,0BAAA,GAA6BA,cAAA;AAQnC,eAAsB,mBAAA,CACpB,MACA,WAAA,EACwB;AACxB,EAAA,MAAM,SAAS,mBAAA,CAAoB,QAAA,CAAS,IAAI,CAAA,GAAI,aAAA,CAAc,IAAI,CAAA,GAAI,MAAA;AAG1E,EAAA,MAAM,cAAA,GAAkB,0BAAA,CAA2B,MAAA,GAAS,0BAAA,CAA2B,UAAU,EAAC;AAElG,EAAA,IAAI,CAAC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AA,MAAM,WAAA;AAAA,EACR,CAAA,CAAA,MAAQ;AACN,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,gCAAA,EAAmC,IAAI,CAAA,CAAE,CAAA;AAAA,EAC3D;AAEA,EAAA,MAAM,aAAA,GAAgB,eAAe,IAAI,CAAA;AAEzC,EAAA,IAAI,OAAO,kBAAkB,UAAA,EAAY;AACvC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,4BAAA,EAA+B,IAAI,CAAA,CAAE,CAAA;AAAA,EACvD;AAEA,EAAA,OAAO,aAAA;AACT;AAEA,SAAS,aAAa,MAAA,EAAwB;AAC5C,EAAA,MAAM,SAASC,iBAAA,EAAyB;AACxC,EAAA,MAAM,OAAA,GAAU,MAAA,EAAQ,UAAA,EAAW,EAAG,UAAA,IAAc,gCAAA;AAEpD,EAAA,OAAO,IAAI,IAAI,CAAA,CAAA,EAAIC,mBAAW,IAAI,MAAM,CAAA,OAAA,CAAA,EAAW,OAAO,CAAA,CAAE,QAAA,EAAS;AACvE;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../../src/client.ts"],"sourcesContent":["import type {\n
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../../src/client.ts"],"sourcesContent":["import type {\n BrowserClientReplayOptions,\n ClientOptions,\n Event,\n EventHint,\n Options as CoreOptions,\n ParameterizedString,\n Scope,\n SeverityLevel,\n} from '@sentry/core/browser';\nimport { addAutoIpAddressToSession, applySdkMetadata, Client, getSDKSource } from '@sentry/core/browser';\nimport { eventFromException, eventFromMessage } from './eventbuilder';\nimport { WINDOW } from './helpers';\nimport type { BrowserTransportOptions } from './transports/types';\n\n/**\n * A magic string that build tooling can leverage in order to inject a release value into the SDK.\n */\ndeclare const __SENTRY_RELEASE__: string | undefined;\n\nexport type BrowserClientProfilingOptions = {\n /**\n * Sets profiling session sample rate for the entire profiling session.\n *\n * A profiling session corresponds to a user session, meaning it is set once at integration initialization and\n * persisted until the next page reload. This rate determines what percentage of user sessions will have profiling enabled.\n * @default 0\n */\n profileSessionSampleRate?: number;\n\n /**\n * Set the lifecycle mode of the profiler.\n * - **manual**: The profiler will be manually started and stopped via `startProfiler`/`stopProfiler`.\n * If a session is sampled, is dependent on the `profileSessionSampleRate`.\n * - **trace**: The profiler will be automatically started when a root span exists and stopped when there are no\n * more sampled root spans. Whether a session is sampled, is dependent on the `profileSessionSampleRate` and the\n * existing sampling configuration for tracing (`tracesSampleRate`/`tracesSampler`).\n *\n * @default 'manual'\n */\n profileLifecycle?: 'manual' | 'trace';\n};\n\ntype BrowserSpecificOptions = BrowserClientReplayOptions &\n BrowserClientProfilingOptions & {\n /** If configured, this URL will be used as base URL for lazy loading integration. */\n cdnBaseUrl?: string;\n\n /**\n * Important: Only set this option if you know what you are doing!\n *\n * By default, the SDK will check if `Sentry.init` is called in a browser extension.\n * In case it is, it will stop initialization and log a warning\n * because browser extensions require a different Sentry initialization process:\n * https://docs.sentry.io/platforms/javascript/best-practices/shared-environments/\n *\n * Setting up the SDK in a browser extension with global error monitoring is not recommended\n * and will likely flood you with errors from other web sites or extensions. This can heavily\n * impact your quota and cause interference with your and other Sentry SDKs in shared environments.\n *\n * If this check wrongfully flags your setup as a browser extension, you can set this\n * option to `true` to skip the check.\n *\n * @default false\n */\n skipBrowserExtensionCheck?: boolean;\n\n /**\n * If you use Spotlight by Sentry during development, use\n * this option to forward captured Sentry events to Spotlight.\n *\n * Either set it to true, or provide a specific Spotlight Sidecar URL.\n *\n * More details: https://spotlightjs.com/\n *\n * IMPORTANT: Only set this option to `true` while developing, not in production!\n */\n spotlight?: boolean | string;\n };\n/**\n * Configuration options for the Sentry Browser SDK.\n * @see @sentry/core Options for more information.\n */\nexport type BrowserOptions = CoreOptions<BrowserTransportOptions> & BrowserSpecificOptions;\n\n/**\n * Configuration options for the Sentry Browser SDK Client class\n * @see BrowserClient for more information.\n */\nexport type BrowserClientOptions = ClientOptions<BrowserTransportOptions> & BrowserSpecificOptions;\n\n/**\n * The Sentry Browser SDK Client.\n *\n * @see BrowserOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nexport class BrowserClient extends Client<BrowserClientOptions> {\n /**\n * Creates a new Browser SDK instance.\n *\n * @param options Configuration options for this SDK.\n */\n public constructor(options: BrowserClientOptions) {\n const opts = applyDefaultOptions(options);\n const sdkSource = WINDOW.SENTRY_SDK_SOURCE || getSDKSource();\n applySdkMetadata(opts, 'browser', ['browser'], sdkSource);\n\n super(opts);\n\n // Unhandled errors don't actually crash the browser, so we report `unhandled` rather than `crashed`.\n this._unhandledSessionStatus = 'unhandled';\n\n const { userInfo } = this.getDataCollectionOptions();\n\n if (opts._metadata?.sdk) {\n opts._metadata.sdk.settings = {\n // Only allow IP inferral by Relay if the user opted in via dataCollection\n infer_ip: userInfo ? 'auto' : 'never',\n // purposefully allowing already passed settings to override the default\n ...opts._metadata.sdk.settings,\n };\n }\n\n const { sendClientReports } = this._options;\n\n // Flush buffered data when the page becomes hidden (e.g. tab switch, navigation, or the page\n // being discarded). `flush()` emits the `flush` hook, which drains the span (streaming), log and\n // metric buffers and hands the resulting envelopes to the transport (which uses `keepalive`).\n // Client report outcomes don't listen to the `flush` hook, so we flush them separately.\n if (WINDOW.document) {\n WINDOW.document.addEventListener('visibilitychange', () => {\n if (WINDOW.document.visibilityState === 'hidden') {\n if (sendClientReports) {\n this._flushOutcomes();\n }\n // Defer the flush to a microtask so that visibilitychange listeners registered after this\n // one have already run. In particular, browser tracing's background-tab detection ends the\n // active pageload/navigation (segment) span when the page is hidden. Deferring ensures that\n // segment span has been added to the streaming buffer before we flush, so it is sent\n // together with its child spans instead of being orphaned.\n queueMicrotask(() => {\n void this.flush();\n });\n }\n });\n }\n\n if (userInfo) {\n this.on('beforeSendSession', addAutoIpAddressToSession);\n }\n }\n\n /**\n * @inheritDoc\n */\n public eventFromException(exception: unknown, hint?: EventHint): PromiseLike<Event> {\n return eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace);\n }\n\n /**\n * @inheritDoc\n */\n public eventFromMessage(\n message: ParameterizedString,\n level: SeverityLevel = 'info',\n hint?: EventHint,\n ): PromiseLike<Event> {\n return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace);\n }\n\n /**\n * @inheritDoc\n */\n protected _prepareEvent(\n event: Event,\n hint: EventHint,\n currentScope: Scope,\n isolationScope: Scope,\n ): PromiseLike<Event | null> {\n event.platform = event.platform || 'javascript';\n\n return super._prepareEvent(event, hint, currentScope, isolationScope);\n }\n}\n\n/** Exported only for tests. */\nexport function applyDefaultOptions<T extends Partial<BrowserClientOptions>>(optionsArg: T): T {\n return {\n release:\n typeof __SENTRY_RELEASE__ === 'string' // This allows build tooling to find-and-replace __SENTRY_RELEASE__ to inject a release value\n ? __SENTRY_RELEASE__\n : WINDOW.SENTRY_RELEASE?.id, // This supports the variable that sentry-webpack-plugin injects\n sendClientReports: true,\n // We default this to true, as it is the safer scenario\n parentSpanIsAlwaysRootSpan: true,\n ...optionsArg,\n };\n}\n"],"names":["Client","WINDOW","getSDKSource","applySdkMetadata","addAutoIpAddressToSession","eventFromException","eventFromMessage"],"mappings":";;;;;;AAiGO,MAAM,sBAAsBA,cAAA,CAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvD,YAAY,OAAA,EAA+B;AAChD,IAAA,MAAM,IAAA,GAAO,oBAAoB,OAAO,CAAA;AACxC,IAAA,MAAM,SAAA,GAAYC,cAAA,CAAO,iBAAA,IAAqBC,oBAAA,EAAa;AAC3D,IAAAC,wBAAA,CAAiB,IAAA,EAAM,SAAA,EAAW,CAAC,SAAS,GAAG,SAAS,CAAA;AAExD,IAAA,KAAA,CAAM,IAAI,CAAA;AAGV,IAAA,IAAA,CAAK,uBAAA,GAA0B,WAAA;AAE/B,IAAA,MAAM,EAAE,QAAA,EAAS,GAAI,IAAA,CAAK,wBAAA,EAAyB;AAEnD,IAAA,IAAI,IAAA,CAAK,WAAW,GAAA,EAAK;AACvB,MAA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IAAA,EACA,YAAA,EACA,cAAA,EAC2B;AAC3B,IAAA,KAAA,CAAM,QAAA,GAAW,MAAM,QAAA,IAAY,YAAA;AAEnC,IAAA,OAAO,KAAA,CAAM,aAAA,CAAc,KAAA,EAAO,IAAA,EAAM,cAAc,cAAc,CAAA;AAAA,EACtE;AACF;AAGO,SAAS,oBAA6D,UAAA,EAAkB;AAC7F,EAAA,OAAO;AAAA,IACL,SACE,OAAO,kBAAA,KAAuB,QAAA,GAC1B,kBAAA,GACAL,eAAO,cAAA,EAAgB,EAAA;AAAA;AAAA,IAC7B,iBAAA,EAAmB,IAAA;AAAA;AAAA,IAEnB,0BAAA,EAA4B,IAAA;AAAA,IAC5B,GAAG;AAAA,GACL;AACF;;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const browser = require('@sentry/core/browser');
|
|
4
|
+
const browserUtils = require('@sentry/browser-utils');
|
|
4
5
|
|
|
5
6
|
const WINDOW = browser.GLOBAL_OBJ;
|
|
6
7
|
let ignoreOnError = 0;
|
|
@@ -86,7 +87,7 @@ function wrap(fn, options = {}) {
|
|
|
86
87
|
return sentryWrapped;
|
|
87
88
|
}
|
|
88
89
|
function getHttpRequestData() {
|
|
89
|
-
const url =
|
|
90
|
+
const url = browserUtils.getLocationHref();
|
|
90
91
|
const { referrer } = WINDOW.document || {};
|
|
91
92
|
const { userAgent } = WINDOW.navigator || {};
|
|
92
93
|
const headers = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../../src/helpers.ts"],"sourcesContent":["import type { Mechanism, WrappedFunction } from '@sentry/core/browser';\nimport {\n addExceptionMechanism,\n addExceptionTypeValue,\n addNonEnumerableProperty,\n captureException,\n
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../../src/helpers.ts"],"sourcesContent":["import type { Mechanism, WrappedFunction } from '@sentry/core/browser';\nimport {\n addExceptionMechanism,\n addExceptionTypeValue,\n addNonEnumerableProperty,\n captureException,\n getOriginalFunction,\n GLOBAL_OBJ,\n markFunctionWrapped,\n withScope,\n} from '@sentry/core/browser';\nimport { getLocationHref } from '@sentry/browser-utils';\n\nexport const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nlet ignoreOnError: number = 0;\n\n/**\n * @hidden\n */\nexport function shouldIgnoreOnError(): boolean {\n return ignoreOnError > 0;\n}\n\n/**\n * @hidden\n */\nexport function ignoreNextOnError(): void {\n // onerror should trigger before setTimeout\n ignoreOnError++;\n setTimeout(() => {\n ignoreOnError--;\n });\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\ntype WrappableFunction = Function;\n\nexport function wrap<T extends WrappableFunction>(\n fn: T,\n options?: {\n mechanism?: Mechanism;\n },\n): WrappedFunction<T>;\nexport function wrap<NonFunction>(\n fn: NonFunction,\n options?: {\n mechanism?: Mechanism;\n },\n): NonFunction;\n/**\n * Instruments the given function and sends an event to Sentry every time the\n * function throws an exception.\n *\n * @param fn A function to wrap. It is generally safe to pass an unbound function, because the returned wrapper always\n * has a correct `this` context.\n * @returns The wrapped function.\n * @hidden\n */\nexport function wrap<T extends WrappableFunction, NonFunction>(\n fn: T | NonFunction,\n options: {\n mechanism?: Mechanism;\n } = {},\n): NonFunction | WrappedFunction<T> {\n // for future readers what this does is wrap a function and then create\n // a bi-directional wrapping between them.\n //\n // example: wrapped = wrap(original);\n // original.__sentry_wrapped__ -> wrapped\n // wrapped.__sentry_original__ -> original\n\n function isFunction(fn: T | NonFunction): fn is T {\n return typeof fn === 'function';\n }\n\n if (!isFunction(fn)) {\n return fn;\n }\n\n try {\n // If we're dealing with a function that was previously wrapped, return the original wrapper.\n // Check via hasOwnProperty so a `__sentry_wrapped__` inherited from a wrapped `Function.prototype`\n // is not mistaken for a real wrapper.\n const hasOwnWrapper = Object.prototype.hasOwnProperty.call(fn, '__sentry_wrapped__');\n if (hasOwnWrapper) {\n const wrapper = (fn as WrappedFunction<T>).__sentry_wrapped__;\n if (typeof wrapper === 'function') {\n return wrapper;\n } else {\n // If we find that the `__sentry_wrapped__` function is not a function at the time of accessing it, it means\n // that something messed with it. In that case we want to return the originally passed function.\n return fn;\n }\n }\n\n // We don't wanna wrap it twice\n if (getOriginalFunction(fn)) {\n return fn;\n }\n } catch {\n // Just accessing custom props in some Selenium environments\n // can cause a \"Permission denied\" exception (see raven-js#495).\n // Bail on wrapping and return the function as-is (defers to window.onerror).\n return fn;\n }\n\n // Wrap the function itself\n // It is important that `sentryWrapped` is not an arrow function to preserve the context of `this`\n const sentryWrapped = function (this: unknown, ...args: unknown[]): unknown {\n // Track depth on GLOBAL_OBJ so the thirdPartyErrorFilterIntegration (in @sentry/core) can detect\n // that processEvent is running inside a sentryWrapped call, even with minified/bundled code.\n GLOBAL_OBJ._sentryWrappedDepth = (GLOBAL_OBJ._sentryWrappedDepth || 0) + 1;\n try {\n // Also wrap arguments that are themselves functions\n const wrappedArguments = args.map(arg => wrap(arg, options));\n\n // Attempt to invoke user-land function\n // NOTE: If you are a Sentry user, and you are seeing this stack frame, it\n // means the sentry.javascript SDK caught an error invoking your application code. This\n // is expected behavior and NOT indicative of a bug with sentry.javascript.\n return fn.apply(this, wrappedArguments);\n } catch (ex) {\n ignoreNextOnError();\n\n withScope(scope => {\n scope.addEventProcessor(event => {\n if (options.mechanism) {\n addExceptionTypeValue(event, undefined, undefined);\n addExceptionMechanism(event, options.mechanism);\n }\n\n event.extra = {\n ...event.extra,\n arguments: args,\n };\n\n return event;\n });\n\n // no need to add a mechanism here, we already add it via an event processor above\n captureException(ex);\n });\n\n throw ex;\n } finally {\n GLOBAL_OBJ._sentryWrappedDepth = (GLOBAL_OBJ._sentryWrappedDepth || 0) - 1;\n }\n } as unknown as WrappedFunction<T>;\n\n // Wrap the wrapped function in a proxy, to ensure any other properties of the original function remain available\n try {\n for (const property in fn) {\n if (Object.prototype.hasOwnProperty.call(fn, property)) {\n sentryWrapped[property as keyof T] = fn[property as keyof T];\n }\n }\n } catch {\n // Accessing some objects may throw\n // ref: https://github.com/getsentry/sentry-javascript/issues/1168\n }\n\n // Signal that this function has been wrapped/filled already\n // for both debugging and to prevent it to being wrapped/filled twice\n markFunctionWrapped(sentryWrapped, fn);\n\n addNonEnumerableProperty(fn, '__sentry_wrapped__', sentryWrapped);\n\n // Restore original function name (not all browsers allow that)\n try {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const descriptor = Object.getOwnPropertyDescriptor(sentryWrapped, 'name')!;\n if (descriptor.configurable) {\n Object.defineProperty(sentryWrapped, 'name', {\n get(): string {\n return fn.name;\n },\n });\n }\n } catch {\n // This may throw if e.g. the descriptor does not exist, or a browser does not allow redefining `name`.\n // to save some bytes we simply try-catch this\n }\n\n return sentryWrapped;\n}\n\n/**\n * Get HTTP request data from the current page.\n */\nexport function getHttpRequestData(): { url: string; headers: Record<string, string> } {\n // grab as much info as exists and add it to the event\n const url = getLocationHref();\n const { referrer } = WINDOW.document || {};\n const { userAgent } = WINDOW.navigator || {};\n\n const headers = {\n ...(referrer && { Referer: referrer }),\n ...(userAgent && { 'User-Agent': userAgent }),\n };\n const request = {\n url,\n headers,\n };\n\n return request;\n}\n"],"names":["GLOBAL_OBJ","fn","getOriginalFunction","withScope","addExceptionTypeValue","addExceptionMechanism","captureException","markFunctionWrapped","addNonEnumerableProperty","getLocationHref"],"mappings":";;;;;AAaO,MAAM,MAAA,GAASA;AAEtB,IAAI,aAAA,GAAwB,CAAA;AAKrB,SAAS,mBAAA,GAA+B;AAC7C,EAAA,OAAO,aAAA,GAAgB,CAAA;AACzB;AAKO,SAAS,iBAAA,GAA0B;AAExC,EAAA,aAAA,EAAA;AACA,EAAA,UAAA,CAAW,MAAM;AACf,IAAA,aAAA,EAAA;AAAA,EACF,CAAC,CAAA;AACH;AA0BO,SAAS,IAAA,CACd,EAAA,EACA,OAAA,GAEI,EAAC,EAC6B;AAQlC,EAAA,SAAS,WAAW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EAAA,MAAM,MAAMC,4BAAA,EAAgB;AAC5B,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,MAAA,CAAO,YAAY,EAAC;AACzC,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,MAAA,CAAO,aAAa,EAAC;AAE3C,EAAA,MAAM,OAAA,GAAU;AAAA,IACd,GAAI,QAAA,IAAY,EAAE,OAAA,EAAS,QAAA,EAAS;AAAA,IACpC,GAAI,SAAA,IAAa,EAAE,YAAA,EAAc,SAAA;AAAU,GAC7C;AACA,EAAA,MAAM,OAAA,GAAU;AAAA,IACd,GAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,OAAO,OAAA;AACT;;;;;;;;"}
|
|
@@ -33,9 +33,9 @@ const browserUtils = require('@sentry/browser-utils');
|
|
|
33
33
|
const normalizeStringifyValue = require('./normalizeStringifyValue.js');
|
|
34
34
|
const reportPageLoaded = require('./tracing/reportPageLoaded.js');
|
|
35
35
|
const setActiveSpan = require('./tracing/setActiveSpan.js');
|
|
36
|
-
const spanstreaming = require('./integrations/spanstreaming.js');
|
|
37
36
|
const fetchStreamPerformance = require('./integrations/fetchStreamPerformance.js');
|
|
38
37
|
const webVitals = require('./integrations/webVitals.js');
|
|
38
|
+
const bfcache = require('./integrations/bfcache.js');
|
|
39
39
|
const offline = require('./transports/offline.js');
|
|
40
40
|
const integration$1 = require('./profiling/integration.js');
|
|
41
41
|
const spotlight = require('./integrations/spotlight.js');
|
|
@@ -58,7 +58,7 @@ exports.SDK_VERSION = browser.SDK_VERSION;
|
|
|
58
58
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_OP = browser.SEMANTIC_ATTRIBUTE_SENTRY_OP;
|
|
59
59
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = browser.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN;
|
|
60
60
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = browser.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE;
|
|
61
|
-
exports.
|
|
61
|
+
exports.SENTRY_SEGMENT_NAME_SOURCE = browser.SENTRY_SEGMENT_NAME_SOURCE;
|
|
62
62
|
exports.Scope = browser.Scope;
|
|
63
63
|
exports.addBreadcrumb = browser.addBreadcrumb;
|
|
64
64
|
exports.addEventProcessor = browser.addEventProcessor;
|
|
@@ -114,8 +114,10 @@ exports.setMeasurement = browser.setMeasurement;
|
|
|
114
114
|
exports.setTag = browser.setTag;
|
|
115
115
|
exports.setTags = browser.setTags;
|
|
116
116
|
exports.setUser = browser.setUser;
|
|
117
|
+
exports.spanStreamingIntegration = browser.spanStreamingIntegration;
|
|
117
118
|
exports.spanToBaggageHeader = browser.spanToBaggageHeader;
|
|
118
119
|
exports.spanToJSON = browser.spanToJSON;
|
|
120
|
+
exports.spanToStaticSpanJSON = browser.spanToStaticSpanJSON;
|
|
119
121
|
exports.spanToTraceHeader = browser.spanToTraceHeader;
|
|
120
122
|
exports.startInactiveSpan = browser.startInactiveSpan;
|
|
121
123
|
exports.startNewTrace = browser.startNewTrace;
|
|
@@ -172,18 +174,19 @@ exports.sendFeedback = feedback.sendFeedback;
|
|
|
172
174
|
exports.defaultRequestInstrumentationOptions = request.defaultRequestInstrumentationOptions;
|
|
173
175
|
exports.instrumentOutgoingRequests = request.instrumentOutgoingRequests;
|
|
174
176
|
exports.browserTracingIntegration = browserTracingIntegration.browserTracingIntegration;
|
|
175
|
-
exports.isBotUserAgent = browserTracingIntegration.isBotUserAgent;
|
|
176
177
|
exports.startBrowserTracingNavigationSpan = browserTracingIntegration.startBrowserTracingNavigationSpan;
|
|
177
178
|
exports.startBrowserTracingPageLoadSpan = browserTracingIntegration.startBrowserTracingPageLoadSpan;
|
|
178
179
|
exports.elementTimingIntegration = browserUtils.elementTimingIntegration;
|
|
179
180
|
exports.getAbsoluteUrl = browserUtils.getAbsoluteUrl;
|
|
181
|
+
exports.interactionsIntegration = browserUtils.interactionsIntegration;
|
|
182
|
+
exports.isBotUserAgent = browserUtils.isBotUserAgent;
|
|
180
183
|
exports.userTimingIntegration = browserUtils.userTimingIntegration;
|
|
181
184
|
exports.normalizeStringifyValue = normalizeStringifyValue.normalizeStringifyValue;
|
|
182
185
|
exports.reportPageLoaded = reportPageLoaded.reportPageLoaded;
|
|
183
186
|
exports.setActiveSpanInBrowser = setActiveSpan.setActiveSpanInBrowser;
|
|
184
|
-
exports.spanStreamingIntegration = spanstreaming.spanStreamingIntegration;
|
|
185
187
|
exports.fetchStreamPerformanceIntegration = fetchStreamPerformance.fetchStreamPerformanceIntegration;
|
|
186
188
|
exports.webVitalsIntegration = webVitals.webVitalsIntegration;
|
|
189
|
+
exports.bfcacheIntegration = bfcache.bfcacheIntegration;
|
|
187
190
|
exports.makeBrowserOfflineTransport = offline.makeBrowserOfflineTransport;
|
|
188
191
|
exports.browserProfilingIntegration = integration$1.browserProfilingIntegration;
|
|
189
192
|
exports.spotlightBrowserIntegration = spotlight.spotlightBrowserIntegration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const attributes = require('@sentry/conventions/attributes');
|
|
4
|
+
const browser = require('@sentry/core/browser');
|
|
5
|
+
const debugBuild = require('../debug-build.js');
|
|
6
|
+
const helpers = require('../helpers.js');
|
|
7
|
+
|
|
8
|
+
const INTEGRATION_NAME = "Bfcache";
|
|
9
|
+
const bfcacheIntegration = browser.defineIntegration((options = {}) => {
|
|
10
|
+
const maxReasons = _resolveMaxReasons(options.maxReasons);
|
|
11
|
+
return {
|
|
12
|
+
name: INTEGRATION_NAME,
|
|
13
|
+
setupOnce() {
|
|
14
|
+
if (!helpers.WINDOW.addEventListener || !helpers.WINDOW.performance?.getEntriesByType) {
|
|
15
|
+
debugBuild.DEBUG_BUILD && browser.debug.log(`[${INTEGRATION_NAME}] Browser APIs unavailable, skipping instrumentation.`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
function onPageShow(event) {
|
|
19
|
+
const routeName = _getSegmentName();
|
|
20
|
+
if (event.persisted) {
|
|
21
|
+
_captureBFCacheNavigation("hit", 0, routeName);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const navigationEntry = helpers.WINDOW.performance.getEntriesByType("navigation")[0];
|
|
25
|
+
if (navigationEntry?.type !== "back_forward") {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const reasons = _collectNotRestoredReasons(navigationEntry.notRestoredReasons, maxReasons);
|
|
29
|
+
_captureBFCacheNavigation("miss", reasons.length, routeName);
|
|
30
|
+
if (typeof navigationEntry.duration === "number" && navigationEntry.duration > 0) {
|
|
31
|
+
browser.metrics.distribution("browser.bfcache.reload.duration", navigationEntry.duration, {
|
|
32
|
+
unit: "millisecond",
|
|
33
|
+
attributes: _withOriginAttr({
|
|
34
|
+
[attributes.SENTRY_SEGMENT_NAME]: routeName
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
reasons.forEach((r) => _captureBFCacheReason(r, routeName));
|
|
39
|
+
}
|
|
40
|
+
helpers.WINDOW.addEventListener("pageshow", onPageShow, true);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
function _captureBFCacheNavigation(outcome, reasonCount, routeName) {
|
|
45
|
+
browser.metrics.count("browser.bfcache.navigation", 1, {
|
|
46
|
+
attributes: _withOriginAttr({
|
|
47
|
+
[attributes.BROWSER_BFCACHE_OUTCOME]: outcome,
|
|
48
|
+
// Attribute should be present if reasons are >= 1
|
|
49
|
+
[attributes.BROWSER_BFCACHE_NOT_RESTORED_REASON_COUNT]: reasonCount || void 0,
|
|
50
|
+
[attributes.SENTRY_SEGMENT_NAME]: routeName
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function _captureBFCacheReason({ reason, frame }, routeName) {
|
|
55
|
+
browser.metrics.count("browser.bfcache.not_restored", 1, {
|
|
56
|
+
attributes: _withOriginAttr({
|
|
57
|
+
[attributes.BROWSER_BFCACHE_REASON]: reason,
|
|
58
|
+
[attributes.BROWSER_BFCACHE_FRAME]: frame,
|
|
59
|
+
[attributes.SENTRY_SEGMENT_NAME]: routeName
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function _getSegmentName() {
|
|
64
|
+
return browser.getCurrentScope().getScopeData().transactionName || helpers.WINDOW.location?.pathname;
|
|
65
|
+
}
|
|
66
|
+
function _resolveMaxReasons(maxReasons) {
|
|
67
|
+
if (maxReasons == null) {
|
|
68
|
+
return Infinity;
|
|
69
|
+
}
|
|
70
|
+
if (maxReasons < 1) {
|
|
71
|
+
debugBuild.DEBUG_BUILD && browser.debug.warn(`[${INTEGRATION_NAME}] \`maxReasons\` must be at least 1, got ${maxReasons}. Using 1 instead.`);
|
|
72
|
+
return 1;
|
|
73
|
+
}
|
|
74
|
+
return maxReasons;
|
|
75
|
+
}
|
|
76
|
+
function _collectNotRestoredReasons(notRestoredReasons, maxReasons) {
|
|
77
|
+
const reasons = [];
|
|
78
|
+
if (!notRestoredReasons || maxReasons <= 0) {
|
|
79
|
+
return reasons;
|
|
80
|
+
}
|
|
81
|
+
_collectReasonsFromFrame(notRestoredReasons, "top", reasons, maxReasons);
|
|
82
|
+
return reasons;
|
|
83
|
+
}
|
|
84
|
+
function _collectReasonsFromFrame(frame, frameType, collectedReasons, maxReasons) {
|
|
85
|
+
if (collectedReasons.length >= maxReasons) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
frame.reasons?.forEach((reason) => {
|
|
89
|
+
if (collectedReasons.length >= maxReasons) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const reasonValue = typeof reason === "string" ? reason : reason.reason;
|
|
93
|
+
if (!reasonValue) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
collectedReasons.push({
|
|
97
|
+
reason: reasonValue,
|
|
98
|
+
frame: frameType
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
frame.children?.forEach((child) => {
|
|
102
|
+
_collectReasonsFromFrame(child, "child", collectedReasons, maxReasons);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function _withOriginAttr(attributes$1) {
|
|
106
|
+
attributes$1[attributes.SENTRY_ORIGIN] = "auto.browser.bfcache";
|
|
107
|
+
return attributes$1;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
exports._collectNotRestoredReasons = _collectNotRestoredReasons;
|
|
111
|
+
exports._resolveMaxReasons = _resolveMaxReasons;
|
|
112
|
+
exports.bfcacheIntegration = bfcacheIntegration;
|
|
113
|
+
//# sourceMappingURL=bfcache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bfcache.js","sources":["../../../../../src/integrations/bfcache.ts"],"sourcesContent":["import {\n SENTRY_SEGMENT_NAME,\n BROWSER_BFCACHE_FRAME,\n BROWSER_BFCACHE_NOT_RESTORED_REASON_COUNT,\n BROWSER_BFCACHE_OUTCOME,\n BROWSER_BFCACHE_REASON,\n SENTRY_ORIGIN,\n} from '@sentry/conventions/attributes';\nimport type { IntegrationFn, SpanAttributes } from '@sentry/core/browser';\nimport { debug, defineIntegration, getCurrentScope, metrics } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\n\nconst INTEGRATION_NAME = 'Bfcache';\n\ntype BFCacheOutcome = 'hit' | 'miss';\n\ntype BFCacheFrame = 'top' | 'child';\n\ninterface BFCacheIntegrationOptions {\n /**\n * Maximum number of not-restored reasons to emit per miss.\n *\n * By default every reason is reported. Set this to cap the number emitted per miss.\n * Values below 1 are clamped to 1.\n */\n maxReasons: number;\n}\n\ninterface NotRestoredReason {\n reason?: string;\n}\n\ninterface NotRestoredReasons {\n children?: NotRestoredReasons[] | null;\n reasons?: (NotRestoredReason | string)[] | null;\n}\n\ninterface NavigationTimingWithNotRestoredReasons extends PerformanceNavigationTiming {\n notRestoredReasons?: NotRestoredReasons | null;\n}\n\ninterface CollectedReason {\n reason: string;\n frame: BFCacheFrame;\n}\n\n/**\n * Captures bfcache hit/miss counters and Chromium notRestoredReasons when available.\n */\nexport const bfcacheIntegration = defineIntegration((options: Partial<BFCacheIntegrationOptions> = {}) => {\n const maxReasons = _resolveMaxReasons(options.maxReasons);\n\n return {\n name: INTEGRATION_NAME,\n\n setupOnce() {\n if (!WINDOW.addEventListener || !WINDOW.performance?.getEntriesByType) {\n DEBUG_BUILD && debug.log(`[${INTEGRATION_NAME}] Browser APIs unavailable, skipping instrumentation.`);\n return;\n }\n\n function onPageShow(event: PageTransitionEvent) {\n const routeName = _getSegmentName();\n if (event.persisted) {\n _captureBFCacheNavigation('hit', 0, routeName);\n return;\n }\n\n const navigationEntry = WINDOW.performance.getEntriesByType('navigation')[0] as\n | NavigationTimingWithNotRestoredReasons\n | undefined;\n\n if (navigationEntry?.type !== 'back_forward') {\n return;\n }\n\n const reasons = _collectNotRestoredReasons(navigationEntry.notRestoredReasons, maxReasons);\n _captureBFCacheNavigation('miss', reasons.length, routeName);\n\n // Measures how expensive the fallback reload was when a back/forward navigation missed bfcache.\n if (typeof navigationEntry.duration === 'number' && navigationEntry.duration > 0) {\n metrics.distribution('browser.bfcache.reload.duration', navigationEntry.duration, {\n unit: 'millisecond',\n attributes: _withOriginAttr({\n [SENTRY_SEGMENT_NAME]: routeName,\n }),\n });\n }\n\n reasons.forEach(r => _captureBFCacheReason(r, routeName));\n }\n\n // Listener should stay active because the event can trigger for an initial show before the bfcache entry coming into the second one.\n // This can be platform-dependent so we need to skip as many events till we get to the one containing the entry.\n // So we can't have { once } or a cleanup logic here, which is fine because `setupOnce` registers it a single time regardless of how many clients are created.\n WINDOW.addEventListener('pageshow', onPageShow, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Captures a bf navigation as a metric and records the outcome and reason count.\n */\nfunction _captureBFCacheNavigation(outcome: BFCacheOutcome, reasonCount: number, routeName?: string): void {\n metrics.count('browser.bfcache.navigation', 1, {\n attributes: _withOriginAttr({\n [BROWSER_BFCACHE_OUTCOME]: outcome,\n // Attribute should be present if reasons are >= 1\n [BROWSER_BFCACHE_NOT_RESTORED_REASON_COUNT]: reasonCount || undefined,\n [SENTRY_SEGMENT_NAME]: routeName,\n }),\n });\n}\n\n/**\n * Maps a collected reason to a metric and captures/sends it.\n */\nfunction _captureBFCacheReason({ reason, frame }: CollectedReason, routeName?: string) {\n metrics.count('browser.bfcache.not_restored', 1, {\n attributes: _withOriginAttr({\n [BROWSER_BFCACHE_REASON]: reason,\n [BROWSER_BFCACHE_FRAME]: frame,\n [SENTRY_SEGMENT_NAME]: routeName,\n }),\n });\n}\n\n/**\n * The segment name for a bfcache navigation, read from the scope rather than any span.\n *\n * A hit restore is silent to tracing (no pageload span), but the frozen scope still holds the last\n * transaction name a downstream SDK (Vue/React/etc.) set before the freeze, so we reuse that. On a miss the\n * page reloads with a fresh scope, so this is the new pageload name. Falls back to the raw pathname when unset.\n */\nfunction _getSegmentName(): string | undefined {\n return getCurrentScope().getScopeData().transactionName || WINDOW.location?.pathname;\n}\n\n/**\n * Resolves the configured `maxReasons` cap. Reports every reason by default and clamps values below 1 to 1,\n * since a cap under 1 would silently drop all reasons.\n *\n * Exported for tests only.\n */\nexport function _resolveMaxReasons(maxReasons: number | undefined): number {\n if (maxReasons == null) {\n return Infinity;\n }\n\n if (maxReasons < 1) {\n DEBUG_BUILD &&\n debug.warn(`[${INTEGRATION_NAME}] \\`maxReasons\\` must be at least 1, got ${maxReasons}. Using 1 instead.`);\n return 1;\n }\n\n return maxReasons;\n}\n\n/**\n * Flattens the (possibly nested) bfcache `notRestoredReasons` tree into a capped list of reasons.\n *\n * Exported for tests only.\n */\nexport function _collectNotRestoredReasons(\n notRestoredReasons: NotRestoredReasons | null | undefined,\n maxReasons: number,\n): CollectedReason[] {\n const reasons: CollectedReason[] = [];\n\n if (!notRestoredReasons || maxReasons <= 0) {\n return reasons;\n }\n\n _collectReasonsFromFrame(notRestoredReasons, 'top', reasons, maxReasons);\n\n return reasons;\n}\n\nfunction _collectReasonsFromFrame(\n frame: NotRestoredReasons,\n frameType: BFCacheFrame,\n collectedReasons: CollectedReason[],\n maxReasons: number,\n): void {\n if (collectedReasons.length >= maxReasons) {\n return;\n }\n\n frame.reasons?.forEach(reason => {\n if (collectedReasons.length >= maxReasons) {\n return;\n }\n\n const reasonValue = typeof reason === 'string' ? reason : reason.reason;\n if (!reasonValue) {\n return;\n }\n\n collectedReasons.push({\n reason: reasonValue,\n frame: frameType,\n });\n });\n\n frame.children?.forEach(child => {\n _collectReasonsFromFrame(child, 'child', collectedReasons, maxReasons);\n });\n}\n\n/**\n * Adds the origin attributes to a set of attributes, it mutates the original attributes.\n */\nfunction _withOriginAttr(attributes: SpanAttributes): SpanAttributes {\n attributes[SENTRY_ORIGIN] = 'auto.browser.bfcache';\n\n return attributes;\n}\n"],"names":["defineIntegration","WINDOW","DEBUG_BUILD","debug","metrics","SENTRY_SEGMENT_NAME","BROWSER_BFCACHE_OUTCOME","BROWSER_BFCACHE_NOT_RESTORED_REASON_COUNT","BROWSER_BFCACHE_REASON","BROWSER_BFCACHE_FRAME","getCurrentScope","attributes","SENTRY_ORIGIN"],"mappings":";;;;;;;AAaA,MAAM,gBAAA,GAAmB,SAAA;AAqClB,MAAM,kBAAA,GAAqBA,yBAA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readcrumbHandler(client, dom) {
|
|
|
82
82
|
const event = handlerData.event;
|
|
83
83
|
const element = _isEvent(event) ? event.target : event;
|
|
84
84
|
target = browserUtils.htmlTreeAsString(element, { keyAttrs, maxStringLength });
|
|
85
|
-
componentName =
|
|
85
|
+
componentName = browserUtils.getComponentName(element);
|
|
86
86
|
} catch {
|
|
87
87
|
target = "<unknown>";
|
|
88
88
|
}
|