@sentry/browser 10.38.0 → 10.39.0-alpha.0
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 +7 -0
- package/build/npm/cjs/dev/client.js.map +1 -1
- package/build/npm/cjs/dev/index.js +7 -2
- package/build/npm/cjs/dev/index.js.map +1 -1
- package/build/npm/cjs/dev/integrations/browsersession.js +13 -9
- package/build/npm/cjs/dev/integrations/browsersession.js.map +1 -1
- package/build/npm/cjs/dev/integrations/culturecontext.js +64 -0
- package/build/npm/cjs/dev/integrations/culturecontext.js.map +1 -0
- package/build/npm/cjs/dev/integrations/httpcontext.js +25 -1
- package/build/npm/cjs/dev/integrations/httpcontext.js.map +1 -1
- package/build/npm/cjs/dev/integrations/spanstreaming.js +87 -0
- package/build/npm/cjs/dev/integrations/spanstreaming.js.map +1 -0
- package/build/npm/cjs/dev/integrations/spotlight.js +5 -4
- package/build/npm/cjs/dev/integrations/spotlight.js.map +1 -1
- package/build/npm/cjs/dev/profiling/UIProfiler.js +10 -0
- package/build/npm/cjs/dev/profiling/UIProfiler.js.map +1 -1
- package/build/npm/cjs/dev/profiling/integration.js +10 -0
- package/build/npm/cjs/dev/profiling/integration.js.map +1 -1
- package/build/npm/cjs/dev/sdk.js +2 -0
- package/build/npm/cjs/dev/sdk.js.map +1 -1
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js +18 -11
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/dev/tracing/linkedTraces.js +1 -0
- package/build/npm/cjs/dev/tracing/linkedTraces.js.map +1 -1
- package/build/npm/cjs/dev/tracing/request.js +1 -0
- package/build/npm/cjs/dev/tracing/request.js.map +1 -1
- package/build/npm/cjs/prod/client.js +7 -0
- package/build/npm/cjs/prod/client.js.map +1 -1
- package/build/npm/cjs/prod/index.js +7 -2
- package/build/npm/cjs/prod/index.js.map +1 -1
- package/build/npm/cjs/prod/integrations/browsersession.js +13 -9
- package/build/npm/cjs/prod/integrations/browsersession.js.map +1 -1
- package/build/npm/cjs/prod/integrations/culturecontext.js +64 -0
- package/build/npm/cjs/prod/integrations/culturecontext.js.map +1 -0
- package/build/npm/cjs/prod/integrations/httpcontext.js +25 -1
- package/build/npm/cjs/prod/integrations/httpcontext.js.map +1 -1
- package/build/npm/cjs/prod/integrations/spanstreaming.js +87 -0
- package/build/npm/cjs/prod/integrations/spanstreaming.js.map +1 -0
- package/build/npm/cjs/prod/integrations/spotlight.js +5 -4
- package/build/npm/cjs/prod/integrations/spotlight.js.map +1 -1
- package/build/npm/cjs/prod/profiling/UIProfiler.js +10 -0
- package/build/npm/cjs/prod/profiling/UIProfiler.js.map +1 -1
- package/build/npm/cjs/prod/profiling/integration.js +10 -0
- package/build/npm/cjs/prod/profiling/integration.js.map +1 -1
- package/build/npm/cjs/prod/sdk.js +2 -0
- package/build/npm/cjs/prod/sdk.js.map +1 -1
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +18 -11
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/prod/tracing/linkedTraces.js +1 -0
- package/build/npm/cjs/prod/tracing/linkedTraces.js.map +1 -1
- package/build/npm/cjs/prod/tracing/request.js +1 -0
- package/build/npm/cjs/prod/tracing/request.js.map +1 -1
- package/build/npm/esm/dev/client.js +7 -0
- package/build/npm/esm/dev/client.js.map +1 -1
- package/build/npm/esm/dev/index.js +4 -2
- package/build/npm/esm/dev/index.js.map +1 -1
- package/build/npm/esm/dev/integrations/browsersession.js +13 -9
- package/build/npm/esm/dev/integrations/browsersession.js.map +1 -1
- package/build/npm/esm/dev/integrations/culturecontext.js +62 -0
- package/build/npm/esm/dev/integrations/culturecontext.js.map +1 -0
- package/build/npm/esm/dev/integrations/httpcontext.js +26 -2
- package/build/npm/esm/dev/integrations/httpcontext.js.map +1 -1
- package/build/npm/esm/dev/integrations/spanstreaming.js +85 -0
- package/build/npm/esm/dev/integrations/spanstreaming.js.map +1 -0
- package/build/npm/esm/dev/integrations/spotlight.js +5 -4
- package/build/npm/esm/dev/integrations/spotlight.js.map +1 -1
- package/build/npm/esm/dev/package.json +1 -1
- package/build/npm/esm/dev/profiling/UIProfiler.js +10 -0
- package/build/npm/esm/dev/profiling/UIProfiler.js.map +1 -1
- package/build/npm/esm/dev/profiling/integration.js +10 -0
- package/build/npm/esm/dev/profiling/integration.js.map +1 -1
- package/build/npm/esm/dev/sdk.js +2 -0
- package/build/npm/esm/dev/sdk.js.map +1 -1
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js +19 -13
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/dev/tracing/linkedTraces.js +1 -0
- package/build/npm/esm/dev/tracing/linkedTraces.js.map +1 -1
- package/build/npm/esm/dev/tracing/request.js +1 -0
- package/build/npm/esm/dev/tracing/request.js.map +1 -1
- package/build/npm/esm/prod/client.js +7 -0
- package/build/npm/esm/prod/client.js.map +1 -1
- package/build/npm/esm/prod/index.js +4 -2
- package/build/npm/esm/prod/index.js.map +1 -1
- package/build/npm/esm/prod/integrations/browsersession.js +13 -9
- package/build/npm/esm/prod/integrations/browsersession.js.map +1 -1
- package/build/npm/esm/prod/integrations/culturecontext.js +62 -0
- package/build/npm/esm/prod/integrations/culturecontext.js.map +1 -0
- package/build/npm/esm/prod/integrations/httpcontext.js +26 -2
- package/build/npm/esm/prod/integrations/httpcontext.js.map +1 -1
- package/build/npm/esm/prod/integrations/spanstreaming.js +85 -0
- package/build/npm/esm/prod/integrations/spanstreaming.js.map +1 -0
- package/build/npm/esm/prod/integrations/spotlight.js +5 -4
- package/build/npm/esm/prod/integrations/spotlight.js.map +1 -1
- package/build/npm/esm/prod/package.json +1 -1
- package/build/npm/esm/prod/profiling/UIProfiler.js +10 -0
- package/build/npm/esm/prod/profiling/UIProfiler.js.map +1 -1
- package/build/npm/esm/prod/profiling/integration.js +10 -0
- package/build/npm/esm/prod/profiling/integration.js.map +1 -1
- package/build/npm/esm/prod/sdk.js +2 -0
- package/build/npm/esm/prod/sdk.js.map +1 -1
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js +19 -13
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/prod/tracing/linkedTraces.js +1 -0
- package/build/npm/esm/prod/tracing/linkedTraces.js.map +1 -1
- package/build/npm/esm/prod/tracing/request.js +1 -0
- package/build/npm/esm/prod/tracing/request.js.map +1 -1
- package/build/npm/types/client.d.ts.map +1 -1
- package/build/npm/types/exports.d.ts +1 -0
- package/build/npm/types/exports.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.d.ts +2 -1
- package/build/npm/types/index.bundle.tracing.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts +2 -1
- package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.d.ts +2 -1
- package/build/npm/types/index.bundle.tracing.replay.d.ts.map +1 -1
- package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts +2 -1
- 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 +2 -1
- 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 +2 -1
- package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts.map +1 -1
- package/build/npm/types/index.d.ts +3 -2
- package/build/npm/types/index.d.ts.map +1 -1
- package/build/npm/types/integrations/browsersession.d.ts +16 -1
- package/build/npm/types/integrations/browsersession.d.ts.map +1 -1
- package/build/npm/types/integrations/culturecontext.d.ts +16 -0
- package/build/npm/types/integrations/culturecontext.d.ts.map +1 -0
- package/build/npm/types/integrations/httpcontext.d.ts.map +1 -1
- package/build/npm/types/integrations/spanstreaming.d.ts +5 -0
- package/build/npm/types/integrations/spanstreaming.d.ts.map +1 -0
- package/build/npm/types/integrations/spotlight.d.ts.map +1 -1
- package/build/npm/types/profiling/UIProfiler.d.ts +4 -0
- package/build/npm/types/profiling/UIProfiler.d.ts.map +1 -1
- package/build/npm/types/profiling/integration.d.ts.map +1 -1
- package/build/npm/types/sdk.d.ts.map +1 -1
- package/build/npm/types/tracing/browserTracingIntegration.d.ts +10 -0
- package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
- package/build/npm/types/tracing/request.d.ts.map +1 -1
- package/build/npm/types-ts3.8/exports.d.ts +1 -0
- package/build/npm/types-ts3.8/index.bundle.tracing.d.ts +2 -1
- package/build/npm/types-ts3.8/index.bundle.tracing.logs.metrics.d.ts +2 -1
- package/build/npm/types-ts3.8/index.bundle.tracing.replay.d.ts +2 -1
- package/build/npm/types-ts3.8/index.bundle.tracing.replay.feedback.d.ts +2 -1
- package/build/npm/types-ts3.8/index.bundle.tracing.replay.feedback.logs.metrics.d.ts +2 -1
- package/build/npm/types-ts3.8/index.bundle.tracing.replay.logs.metrics.d.ts +2 -1
- package/build/npm/types-ts3.8/index.d.ts +3 -2
- package/build/npm/types-ts3.8/integrations/browsersession.d.ts +16 -1
- package/build/npm/types-ts3.8/integrations/culturecontext.d.ts +16 -0
- package/build/npm/types-ts3.8/integrations/spanstreaming.d.ts +5 -0
- package/build/npm/types-ts3.8/profiling/UIProfiler.d.ts +4 -0
- package/build/npm/types-ts3.8/tracing/browserTracingIntegration.d.ts +10 -0
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sources":["../../../../../src/tracing/request.ts"],"sourcesContent":["import type {\n Client,\n HandlerDataXhr,\n RequestHookInfo,\n ResponseHookInfo,\n SentryWrappedXMLHttpRequest,\n Span,\n} from '@sentry/core';\nimport {\n addFetchEndInstrumentationHandler,\n addFetchInstrumentationHandler,\n getActiveSpan,\n getClient,\n getLocationHref,\n getTraceData,\n hasSpansEnabled,\n instrumentFetchRequest,\n parseUrl,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SentryNonRecordingSpan,\n setHttpStatus,\n spanToJSON,\n startInactiveSpan,\n stringMatchesSomePattern,\n stripDataUrlContent,\n stripUrlQueryAndFragment,\n} from '@sentry/core';\nimport type { XhrHint } from '@sentry-internal/browser-utils';\nimport {\n addPerformanceInstrumentationHandler,\n addXhrInstrumentationHandler,\n parseXhrResponseHeaders,\n resourceTimingToSpanAttributes,\n SENTRY_XHR_DATA_KEY,\n} from '@sentry-internal/browser-utils';\nimport type { BrowserClient } from '../client';\nimport { baggageHeaderHasSentryValues, createHeadersSafely, getFullURL, isPerformanceResourceTiming } from './utils';\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 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\nconst responseToSpanId = new WeakMap<object, string>();\nconst spanIdToEndTimestamp = new Map<string, number>();\n\nexport const defaultRequestInstrumentationOptions: RequestInstrumentationOptions = {\n traceFetch: true,\n traceXHR: true,\n enableHTTPTimings: true,\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 trackFetchStreamPerformance,\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 // Keeping track of http requests, whose body payloads resolved later than the initial resolved request\n // e.g. streaming using server sent events (SSE)\n client.addEventProcessor(event => {\n if (event.type === 'transaction' && event.spans) {\n event.spans.forEach(span => {\n if (span.op === 'http.client') {\n const updatedTimestamp = spanIdToEndTimestamp.get(span.span_id);\n if (updatedTimestamp) {\n span.timestamp = updatedTimestamp / 1000;\n spanIdToEndTimestamp.delete(span.span_id);\n }\n }\n });\n }\n return event;\n });\n\n if (trackFetchStreamPerformance) {\n addFetchEndInstrumentationHandler(handlerData => {\n if (handlerData.response) {\n const span = responseToSpanId.get(handlerData.response);\n if (span && handlerData.endTimestamp) {\n spanIdToEndTimestamp.set(span, handlerData.endTimestamp);\n }\n }\n });\n }\n\n addFetchInstrumentationHandler(handlerData => {\n const createdSpan = instrumentFetchRequest(handlerData, shouldCreateSpan, shouldAttachHeadersWithTargets, spans, {\n propagateTraceparent,\n onRequestSpanEnd,\n });\n\n if (handlerData.response && handlerData.fetchData.__span) {\n responseToSpanId.set(handlerData.response, handlerData.fetchData.__span);\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 createdSpan.setAttributes({\n 'http.url': fullUrl ? stripDataUrlContent(fullUrl) : undefined,\n 'server.address': host,\n });\n\n if (enableHTTPTimings) {\n addHTTPTimings(createdSpan);\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);\n }\n\n onRequestSpanStart?.(createdSpan, {\n headers: createHeadersSafely(handlerData.xhr.__sentry_xhr_v3__?.request_headers),\n });\n }\n });\n }\n}\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` on data.\n */\nfunction addHTTPTimings(span: Span): void {\n const { url } = spanToJSON(span).data;\n\n if (!url || typeof url !== 'string') {\n return;\n }\n\n const cleanup = addPerformanceInstrumentationHandler('resource', ({ entries }) => {\n entries.forEach(entry => {\n if (isPerformanceResourceTiming(entry) && entry.name.endsWith(url)) {\n span.setAttributes(resourceTimingToSpanAttributes(entry));\n // In the next tick, clean this handler up\n // We have to wait here because otherwise this cleans itself up before it is fully done\n setTimeout(cleanup);\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 */\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 // check first if the request has finished and is tracked by an existing span which should now end\n if (handlerData.endTimestamp && shouldCreateSpanResult) {\n const spanId = xhr.__sentry_xhr_span_id__;\n if (!spanId) return;\n\n const span = spans[spanId];\n if (span && 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 // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete spans[spanId];\n }\n return undefined;\n }\n\n const fullUrl = getFullURL(url);\n const parsedUrl = fullUrl ? parseUrl(fullUrl) : parseUrl(url);\n\n const urlForSpanName = stripDataUrlContent(stripUrlQueryAndFragment(url));\n\n const hasParent = !!getActiveSpan();\n\n const span =\n shouldCreateSpanResult && hasParent\n ? startInactiveSpan({\n name: `${method} ${urlForSpanName}`,\n attributes: {\n url: stripDataUrlContent(url),\n type: 'xhr',\n 'http.method': method,\n 'http.url': fullUrl ? stripDataUrlContent(fullUrl) : undefined,\n 'server.address': parsedUrl?.host,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.browser',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',\n ...(parsedUrl?.search && { 'http.query': parsedUrl?.search }),\n ...(parsedUrl?.hash && { 'http.fragment': parsedUrl?.hash }),\n },\n })\n : new SentryNonRecordingSpan();\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() && hasParent ? span : undefined,\n propagateTraceparent,\n );\n }\n\n const client = getClient();\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":["addFetchEndInstrumentationHandler","addFetchInstrumentationHandler","instrumentFetchRequest","getFullURL","parseUrl","stripDataUrlContent","addXhrInstrumentationHandler","createHeadersSafely","spanToJSON","addPerformanceInstrumentationHandler","isPerformanceResourceTiming","resourceTimingToSpanAttributes","getLocationHref","stringMatchesSomePattern","SENTRY_XHR_DATA_KEY","hasSpansEnabled","setHttpStatus","parseXhrResponseHeaders","stripUrlQueryAndFragment","getActiveSpan","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","SentryNonRecordingSpan","getClient","getTraceData","baggageHeaderHasSentryValues"],"mappings":";;;;;;AAuCA;;AAkFA,MAAM,gBAAA,GAAmB,IAAI,OAAO,EAAkB;AACtD,MAAM,oBAAA,GAAuB,IAAI,GAAG,EAAkB;;AAE/C,MAAM,oCAAoC,GAAkC;AACnF,EAAE,UAAU,EAAE,IAAI;AA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AA,GAAA,eAAA,GAAA,SAAA,CAAA;AACA,MAAA,IAAA,CAAA,qBAAA,IAAA,CAAAC,kCAAA,CAAA,qBAAA,CAAA,EAAA;AACA;AACA;AACA;AACA,QAAA,GAAA,CAAA,gBAAA,CAAA,SAAA,EAAA,mBAAA,CAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA,CAAA,CAAA,MAAA;AACA;AACA,EAAA;AACA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"request.js","sources":["../../../../../src/tracing/request.ts"],"sourcesContent":["import type {\n Client,\n HandlerDataXhr,\n RequestHookInfo,\n ResponseHookInfo,\n SentryWrappedXMLHttpRequest,\n Span,\n} from '@sentry/core';\nimport {\n addFetchEndInstrumentationHandler,\n addFetchInstrumentationHandler,\n getActiveSpan,\n getClient,\n getLocationHref,\n getTraceData,\n hasSpansEnabled,\n instrumentFetchRequest,\n parseUrl,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SentryNonRecordingSpan,\n setHttpStatus,\n spanToJSON,\n startInactiveSpan,\n stringMatchesSomePattern,\n stripDataUrlContent,\n stripUrlQueryAndFragment,\n} from '@sentry/core';\nimport type { XhrHint } from '@sentry-internal/browser-utils';\nimport {\n addPerformanceInstrumentationHandler,\n addXhrInstrumentationHandler,\n parseXhrResponseHeaders,\n resourceTimingToSpanAttributes,\n SENTRY_XHR_DATA_KEY,\n} from '@sentry-internal/browser-utils';\nimport type { BrowserClient } from '../client';\nimport { baggageHeaderHasSentryValues, createHeadersSafely, getFullURL, isPerformanceResourceTiming } from './utils';\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 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\nconst responseToSpanId = new WeakMap<object, string>();\nconst spanIdToEndTimestamp = new Map<string, number>();\n\nexport const defaultRequestInstrumentationOptions: RequestInstrumentationOptions = {\n traceFetch: true,\n traceXHR: true,\n enableHTTPTimings: true,\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 trackFetchStreamPerformance,\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 // Keeping track of http requests, whose body payloads resolved later than the initial resolved request\n // e.g. streaming using server sent events (SSE)\n // TODO (span-streaming): replace with client hook - do we need client.on('processSpan')?\n client.addEventProcessor(event => {\n if (event.type === 'transaction' && event.spans) {\n event.spans.forEach(span => {\n if (span.op === 'http.client') {\n const updatedTimestamp = spanIdToEndTimestamp.get(span.span_id);\n if (updatedTimestamp) {\n span.timestamp = updatedTimestamp / 1000;\n spanIdToEndTimestamp.delete(span.span_id);\n }\n }\n });\n }\n return event;\n });\n\n if (trackFetchStreamPerformance) {\n addFetchEndInstrumentationHandler(handlerData => {\n if (handlerData.response) {\n const span = responseToSpanId.get(handlerData.response);\n if (span && handlerData.endTimestamp) {\n spanIdToEndTimestamp.set(span, handlerData.endTimestamp);\n }\n }\n });\n }\n\n addFetchInstrumentationHandler(handlerData => {\n const createdSpan = instrumentFetchRequest(handlerData, shouldCreateSpan, shouldAttachHeadersWithTargets, spans, {\n propagateTraceparent,\n onRequestSpanEnd,\n });\n\n if (handlerData.response && handlerData.fetchData.__span) {\n responseToSpanId.set(handlerData.response, handlerData.fetchData.__span);\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 createdSpan.setAttributes({\n 'http.url': fullUrl ? stripDataUrlContent(fullUrl) : undefined,\n 'server.address': host,\n });\n\n if (enableHTTPTimings) {\n addHTTPTimings(createdSpan);\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);\n }\n\n onRequestSpanStart?.(createdSpan, {\n headers: createHeadersSafely(handlerData.xhr.__sentry_xhr_v3__?.request_headers),\n });\n }\n });\n }\n}\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` on data.\n */\nfunction addHTTPTimings(span: Span): void {\n const { url } = spanToJSON(span).data;\n\n if (!url || typeof url !== 'string') {\n return;\n }\n\n const cleanup = addPerformanceInstrumentationHandler('resource', ({ entries }) => {\n entries.forEach(entry => {\n if (isPerformanceResourceTiming(entry) && entry.name.endsWith(url)) {\n span.setAttributes(resourceTimingToSpanAttributes(entry));\n // In the next tick, clean this handler up\n // We have to wait here because otherwise this cleans itself up before it is fully done\n setTimeout(cleanup);\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 */\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 // check first if the request has finished and is tracked by an existing span which should now end\n if (handlerData.endTimestamp && shouldCreateSpanResult) {\n const spanId = xhr.__sentry_xhr_span_id__;\n if (!spanId) return;\n\n const span = spans[spanId];\n if (span && 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 // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete spans[spanId];\n }\n return undefined;\n }\n\n const fullUrl = getFullURL(url);\n const parsedUrl = fullUrl ? parseUrl(fullUrl) : parseUrl(url);\n\n const urlForSpanName = stripDataUrlContent(stripUrlQueryAndFragment(url));\n\n const hasParent = !!getActiveSpan();\n\n const span =\n shouldCreateSpanResult && hasParent\n ? startInactiveSpan({\n name: `${method} ${urlForSpanName}`,\n attributes: {\n url: stripDataUrlContent(url),\n type: 'xhr',\n 'http.method': method,\n 'http.url': fullUrl ? stripDataUrlContent(fullUrl) : undefined,\n 'server.address': parsedUrl?.host,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.browser',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',\n ...(parsedUrl?.search && { 'http.query': parsedUrl?.search }),\n ...(parsedUrl?.hash && { 'http.fragment': parsedUrl?.hash }),\n },\n })\n : new SentryNonRecordingSpan();\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() && hasParent ? span : undefined,\n propagateTraceparent,\n );\n }\n\n const client = getClient();\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":["addFetchEndInstrumentationHandler","addFetchInstrumentationHandler","instrumentFetchRequest","getFullURL","parseUrl","stripDataUrlContent","addXhrInstrumentationHandler","createHeadersSafely","spanToJSON","addPerformanceInstrumentationHandler","isPerformanceResourceTiming","resourceTimingToSpanAttributes","getLocationHref","stringMatchesSomePattern","SENTRY_XHR_DATA_KEY","hasSpansEnabled","setHttpStatus","parseXhrResponseHeaders","stripUrlQueryAndFragment","getActiveSpan","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","SentryNonRecordingSpan","getClient","getTraceData","baggageHeaderHasSentryValues"],"mappings":";;;;;;AAuCA;;AAkFA,MAAM,gBAAA,GAAmB,IAAI,OAAO,EAAkB;AACtD,MAAM,oBAAA,GAAuB,IAAI,GAAG,EAAkB;;AAE/C,MAAM,oCAAoC,GAAkC;AACnF,EAAE,UAAU,EAAE,IAAI;AAClB,EAAE,QAAQ,EAAE,IAAI;AAChB,EAAE,iBAAiB,EAAE,IAAI;AACzB,EAAE,2BAA2B,EAAE,KAAK;AACpC;;AAEA;AACO,SAAS,0BAA0B,CAAC,MAAM,EAAU,QAAQ,EAAiD;AACpH,EAAE,MAAM;AACR,IAAI,UAAU;AACd,IAAI,QAAQ;AACZ,IAAI,2BAA2B;AAC/B,IAAI,0BAA0B;AAC9B,IAAI,iBAAiB;AACrB,IAAI,uBAAuB;AAC3B,IAAI,kBAAkB;AACtB,IAAI,gBAAgB;AACpB,MAAM;AACN,IAAI,GAAG,oCAAoC;AAC3C,IAAI,GAAG,QAAQ;AACf,GAAG;;AAEH,EAAE,MAAM,gBAAA;AACR,IAAI,OAAO,0BAAA,KAA+B,UAAA,GAAa,0BAAA,GAA6B,CAAC,CAAC,KAAa,IAAI;;AAEvG,EAAE,MAAM,8BAAA,GAAiC,CAAC,GAAG,KAAsB,mBAAmB,CAAC,GAAG,EAAE,uBAAuB,CAAC;;AAEpH,EAAE,MAAM,KAAK,GAAyB,EAAE;;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,CAAA;AACA,EAAA;AACA;;AAEA,SAAA,cAAA;AACA,EAAA,GAAA;AACA,EAAA,iBAAA;AACA,EAAA,mBAAA;AACA,EAAA,iBAAA;AACA,EAAA;AACA,EAAA,MAAA,eAAA,GAAA,GAAA,CAAA,iBAAA,EAAA,eAAA;;AAEA,EAAA,IAAA,eAAA,GAAA,cAAA,CAAA,IAAA,CAAA,GAAA,CAAA,gBAAA,EAAA;AACA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,IAAA;AACA,IAAA,GAAA,CAAA,gBAAA,CAAA,cAAA,EAAA,iBAAA,CAAA;;AAEA,IAAA,IAAA,iBAAA,IAAA,CAAA,eAAA,GAAA,aAAA,CAAA,EAAA;AACA,MAAA,GAAA,CAAA,gBAAA,CAAA,aAAA,EAAA,iBAAA,CAAA;AACA,IAAA;;AAEA,IAAA,IAAA,mBAAA,EAAA;AACA;AACA;AACA;AACA,MAAA,MAAA,qBAAA,GAAA,eAAA,GAAA,SAAA,CAAA;AACA,MAAA,IAAA,CAAA,qBAAA,IAAA,CAAAC,kCAAA,CAAA,qBAAA,CAAA,EAAA;AACA;AACA;AACA;AACA,QAAA,GAAA,CAAA,gBAAA,CAAA,SAAA,EAAA,mBAAA,CAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA,CAAA,CAAA,MAAA;AACA;AACA,EAAA;AACA;;;;;;"}
|
|
@@ -63,6 +63,13 @@ class BrowserClient extends core.Client {
|
|
|
63
63
|
if (enableMetrics) {
|
|
64
64
|
core._INTERNAL_flushMetricsBuffer(this);
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
// TODO: does anything speak against flushing here in general?
|
|
68
|
+
// this would also allow us to let the logs and metric buffers listen
|
|
69
|
+
// for client.on('flush'), meaning we don't have to explicitly call
|
|
70
|
+
// them like above (?)
|
|
71
|
+
// For now, this will flush the span buffer (besides errors, txns, etc).
|
|
72
|
+
this.flush(2000).then(null, () => {});
|
|
66
73
|
}
|
|
67
74
|
});
|
|
68
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../../src/client.ts"],"sourcesContent":["import type {\n BrowserClientProfilingOptions,\n BrowserClientReplayOptions,\n ClientOptions,\n Event,\n EventHint,\n Options as CoreOptions,\n ParameterizedString,\n Scope,\n SeverityLevel,\n} from '@sentry/core';\nimport {\n _INTERNAL_flushLogsBuffer,\n _INTERNAL_flushMetricsBuffer,\n addAutoIpAddressToSession,\n applySdkMetadata,\n Client,\n getSDKSource,\n} from '@sentry/core';\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\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 // Only allow IP inferral by Relay if sendDefaultPii is true\n if (opts._metadata?.sdk) {\n opts._metadata.sdk.settings = {\n infer_ip: opts.sendDefaultPii ? 'auto' : 'never',\n // purposefully allowing already passed settings to override the default\n ...opts._metadata.sdk.settings,\n };\n }\n\n super(opts);\n\n const {\n sendDefaultPii,\n sendClientReports,\n enableLogs,\n _experiments,\n enableMetrics: enableMetricsOption,\n } = this._options;\n\n // todo(v11): Remove the experimental flag\n // eslint-disable-next-line deprecation/deprecation\n const enableMetrics = enableMetricsOption ?? _experiments?.enableMetrics ?? true;\n\n // Flush logs and metrics when page becomes hidden (e.g., tab switch, navigation)\n // todo(v11): Remove the experimental flag\n if (WINDOW.document && (sendClientReports || enableLogs || enableMetrics)) {\n WINDOW.document.addEventListener('visibilitychange', () => {\n if (WINDOW.document.visibilityState === 'hidden') {\n if (sendClientReports) {\n this._flushOutcomes();\n }\n if (enableLogs) {\n _INTERNAL_flushLogsBuffer(this);\n }\n\n if (enableMetrics) {\n _INTERNAL_flushMetricsBuffer(this);\n }\n }\n });\n }\n\n if (sendDefaultPii) {\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","_INTERNAL_flushLogsBuffer","_INTERNAL_flushMetricsBuffer","addAutoIpAddressToSession","eventFromException","eventFromMessage"],"mappings":";;;;;;AAuBA;AACA;AACA;;AAmDA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,aAAA,SAAsBA,WAAM,CAAuB;AAChE;AACA;AACA;AACA;AACA;AACA,GAAS,WAAW,CAAC,OAAO,EAAwB;AACpD,IAAI,MAAM,IAAA,GAAO,mBAAmB,CAAC,OAAO,CAAC;AAC7C,IAAI,MAAM,YAAYC,cAAM,CAAC,iBAAA,IAAqBC,iBAAY,EAAE;AAChE,IAAIC,qBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;;AAE7D;AACA,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;AAC7B,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW;AACpC,QAAQ,QAAQ,EAAE,IAAI,CAAC,iBAAiB,MAAA,GAAS,OAAO;AACxD;AACA,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ;AACtC,OAAO;AACP,IAAI;;AAEJ,IAAI,KAAK,CAAC,IAAI,CAAC;;AAEf,IAAI,MAAM;AACV,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,UAAU;AAChB,MAAM,YAAY;AAClB,MAAM,aAAa,EAAE,mBAAmB;AACxC,KAAI,GAAI,IAAI,CAAC,QAAQ;;AAErB;AACA;AACA,IAAI,MAAM,gBAAgB,mBAAA,IAAuB,YAAY,EAAE,aAAA,IAAiB,IAAI;;AAEpF;AACA;AACA,IAAI,IAAIF,cAAM,CAAC,QAAA,KAAa,iBAAA,IAAqB,UAAA,IAAc,aAAa,CAAC,EAAE;AAC/E,MAAMA,cAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,MAAM;AACjE,QAAQ,IAAIA,cAAM,CAAC,QAAQ,CAAC,eAAA,KAAoB,QAAQ,EAAE;AAC1D,UAAU,IAAI,iBAAiB,EAAE;AACjC,YAAY,IAAI,CAAC,cAAc,EAAE;AACjC,UAAU;AACV,UAAU,IAAI,UAAU,EAAE;AAC1B,YAAYG,8BAAyB,CAAC,IAAI,CAAC;AAC3C,UAAU;;AAEV,UAAU,IAAI,aAAa,EAAE;AAC7B,YAAYC,iCAA4B,CAAC,IAAI,CAAC;AAC9C,UAAU;
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../../src/client.ts"],"sourcesContent":["import type {\n BrowserClientProfilingOptions,\n BrowserClientReplayOptions,\n ClientOptions,\n Event,\n EventHint,\n Options as CoreOptions,\n ParameterizedString,\n Scope,\n SeverityLevel,\n} from '@sentry/core';\nimport {\n _INTERNAL_flushLogsBuffer,\n _INTERNAL_flushMetricsBuffer,\n addAutoIpAddressToSession,\n applySdkMetadata,\n Client,\n getSDKSource,\n} from '@sentry/core';\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\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 // Only allow IP inferral by Relay if sendDefaultPii is true\n if (opts._metadata?.sdk) {\n opts._metadata.sdk.settings = {\n infer_ip: opts.sendDefaultPii ? 'auto' : 'never',\n // purposefully allowing already passed settings to override the default\n ...opts._metadata.sdk.settings,\n };\n }\n\n super(opts);\n\n const {\n sendDefaultPii,\n sendClientReports,\n enableLogs,\n _experiments,\n enableMetrics: enableMetricsOption,\n } = this._options;\n\n // todo(v11): Remove the experimental flag\n // eslint-disable-next-line deprecation/deprecation\n const enableMetrics = enableMetricsOption ?? _experiments?.enableMetrics ?? true;\n\n // Flush logs and metrics when page becomes hidden (e.g., tab switch, navigation)\n // todo(v11): Remove the experimental flag\n if (WINDOW.document && (sendClientReports || enableLogs || enableMetrics)) {\n WINDOW.document.addEventListener('visibilitychange', () => {\n if (WINDOW.document.visibilityState === 'hidden') {\n if (sendClientReports) {\n this._flushOutcomes();\n }\n if (enableLogs) {\n _INTERNAL_flushLogsBuffer(this);\n }\n\n if (enableMetrics) {\n _INTERNAL_flushMetricsBuffer(this);\n }\n\n // TODO: does anything speak against flushing here in general?\n // this would also allow us to let the logs and metric buffers listen\n // for client.on('flush'), meaning we don't have to explicitly call\n // them like above (?)\n // For now, this will flush the span buffer (besides errors, txns, etc).\n this.flush(2000).then(null, () => {});\n }\n });\n }\n\n if (sendDefaultPii) {\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","_INTERNAL_flushLogsBuffer","_INTERNAL_flushMetricsBuffer","addAutoIpAddressToSession","eventFromException","eventFromMessage"],"mappings":";;;;;;AAuBA;AACA;AACA;;AAmDA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,aAAA,SAAsBA,WAAM,CAAuB;AAChE;AACA;AACA;AACA;AACA;AACA,GAAS,WAAW,CAAC,OAAO,EAAwB;AACpD,IAAI,MAAM,IAAA,GAAO,mBAAmB,CAAC,OAAO,CAAC;AAC7C,IAAI,MAAM,YAAYC,cAAM,CAAC,iBAAA,IAAqBC,iBAAY,EAAE;AAChE,IAAIC,qBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;;AAE7D;AACA,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;AAC7B,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW;AACpC,QAAQ,QAAQ,EAAE,IAAI,CAAC,iBAAiB,MAAA,GAAS,OAAO;AACxD;AACA,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,G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C,QAAQ,CAAC,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;AACzG,EAAE;;AAEF;AACA;AACA;AACA,GAAS,gBAAgB;AACzB,IAAI,OAAO;AACX,IAAI,KAAK,GAAkB,MAAM;AACjC,IAAI,IAAI;AACR,IAAwB;AACxB,IAAI,OAAOC,6BAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;AAC5G,EAAE;;AAEF;AACA;AACA;AACA,GAAY,aAAa;AACzB,IAAI,KAAK;AACT,IAAI,IAAI;AACR,IAAI,YAAY;AAChB,IAAI,cAAc;AAClB,IAA+B;AAC/B,IAAI,KAAK,CAAC,QAAA,GAAW,KAAK,CAAC,QAAA,IAAY,YAAY;;AAEnD,IAAI,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,cAAc,CAAC;AACzE,EAAE;AACF;;AAEA;AACO,SAAS,mBAAmB,CAA0C,UAAU,EAAQ;AAC/F,EAAE,OAAO;AACT,IAAI,OAAO;AACX,MAAM,OAAO,uBAAuB,QAAA;AACpC,UAAU;AACV,UAAUP,cAAM,CAAC,cAAc,EAAE,EAAE;AACnC,IAAI,iBAAiB,EAAE,IAAI;AAC3B;AACA,IAAI,0BAA0B,EAAE,IAAI;AACpC,IAAI,GAAG,UAAU;AACjB,GAAG;AACH;;;;;"}
|
|
@@ -17,6 +17,7 @@ const globalhandlers = require('./integrations/globalhandlers.js');
|
|
|
17
17
|
const httpcontext = require('./integrations/httpcontext.js');
|
|
18
18
|
const linkederrors = require('./integrations/linkederrors.js');
|
|
19
19
|
const browserapierrors = require('./integrations/browserapierrors.js');
|
|
20
|
+
const browsersession = require('./integrations/browsersession.js');
|
|
20
21
|
const lazyLoadIntegration = require('./utils/lazyLoadIntegration.js');
|
|
21
22
|
const reportingobserver = require('./integrations/reportingobserver.js');
|
|
22
23
|
const httpclient = require('./integrations/httpclient.js');
|
|
@@ -32,7 +33,7 @@ const setActiveSpan = require('./tracing/setActiveSpan.js');
|
|
|
32
33
|
const offline = require('./transports/offline.js');
|
|
33
34
|
const integration$1 = require('./profiling/integration.js');
|
|
34
35
|
const spotlight = require('./integrations/spotlight.js');
|
|
35
|
-
const
|
|
36
|
+
const culturecontext = require('./integrations/culturecontext.js');
|
|
36
37
|
const integration$2 = require('./integrations/featureFlags/launchdarkly/integration.js');
|
|
37
38
|
const integration = require('./integrations/featureFlags/openfeature/integration.js');
|
|
38
39
|
const integration$5 = require('./integrations/featureFlags/unleash/integration.js');
|
|
@@ -40,6 +41,7 @@ const integration$3 = require('./integrations/featureFlags/growthbook/integratio
|
|
|
40
41
|
const integration$4 = require('./integrations/featureFlags/statsig/integration.js');
|
|
41
42
|
const diagnoseSdk = require('./diagnose-sdk.js');
|
|
42
43
|
const webWorker = require('./integrations/webWorker.js');
|
|
44
|
+
const spanstreaming = require('./integrations/spanstreaming.js');
|
|
43
45
|
|
|
44
46
|
|
|
45
47
|
|
|
@@ -124,6 +126,7 @@ exports.updateSpanName = core.updateSpanName;
|
|
|
124
126
|
exports.withActiveSpan = core.withActiveSpan;
|
|
125
127
|
exports.withIsolationScope = core.withIsolationScope;
|
|
126
128
|
exports.withScope = core.withScope;
|
|
129
|
+
exports.withStreamSpan = core.withStreamSpan;
|
|
127
130
|
exports.zodErrorsIntegration = core.zodErrorsIntegration;
|
|
128
131
|
exports.WINDOW = helpers.WINDOW;
|
|
129
132
|
exports.BrowserClient = client.BrowserClient;
|
|
@@ -150,6 +153,7 @@ exports.globalHandlersIntegration = globalhandlers.globalHandlersIntegration;
|
|
|
150
153
|
exports.httpContextIntegration = httpcontext.httpContextIntegration;
|
|
151
154
|
exports.linkedErrorsIntegration = linkederrors.linkedErrorsIntegration;
|
|
152
155
|
exports.browserApiErrorsIntegration = browserapierrors.browserApiErrorsIntegration;
|
|
156
|
+
exports.browserSessionIntegration = browsersession.browserSessionIntegration;
|
|
153
157
|
exports.lazyLoadIntegration = lazyLoadIntegration.lazyLoadIntegration;
|
|
154
158
|
exports.reportingObserverIntegration = reportingobserver.reportingObserverIntegration;
|
|
155
159
|
exports.httpClientIntegration = httpclient.httpClientIntegration;
|
|
@@ -170,7 +174,7 @@ exports.setActiveSpanInBrowser = setActiveSpan.setActiveSpanInBrowser;
|
|
|
170
174
|
exports.makeBrowserOfflineTransport = offline.makeBrowserOfflineTransport;
|
|
171
175
|
exports.browserProfilingIntegration = integration$1.browserProfilingIntegration;
|
|
172
176
|
exports.spotlightBrowserIntegration = spotlight.spotlightBrowserIntegration;
|
|
173
|
-
exports.
|
|
177
|
+
exports.cultureContextIntegration = culturecontext.cultureContextIntegration;
|
|
174
178
|
exports.buildLaunchDarklyFlagUsedHandler = integration$2.buildLaunchDarklyFlagUsedHandler;
|
|
175
179
|
exports.launchDarklyIntegration = integration$2.launchDarklyIntegration;
|
|
176
180
|
exports.OpenFeatureIntegrationHook = integration.OpenFeatureIntegrationHook;
|
|
@@ -181,4 +185,5 @@ exports.statsigIntegration = integration$4.statsigIntegration;
|
|
|
181
185
|
exports.diagnoseSdkConnectivity = diagnoseSdk.diagnoseSdkConnectivity;
|
|
182
186
|
exports.registerWebWorker = webWorker.registerWebWorker;
|
|
183
187
|
exports.webWorkerIntegration = webWorker.webWorkerIntegration;
|
|
188
|
+
exports.spanStreamingIntegration = spanstreaming.spanStreamingIntegration;
|
|
184
189
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -11,7 +11,9 @@ const helpers = require('../helpers.js');
|
|
|
11
11
|
*
|
|
12
12
|
* Note: In order for session tracking to work, you need to set up Releases: https://docs.sentry.io/product/releases/
|
|
13
13
|
*/
|
|
14
|
-
const browserSessionIntegration = core.defineIntegration(() => {
|
|
14
|
+
const browserSessionIntegration = core.defineIntegration((options = {}) => {
|
|
15
|
+
const lifecycle = options.lifecycle ?? 'route';
|
|
16
|
+
|
|
15
17
|
return {
|
|
16
18
|
name: 'BrowserSession',
|
|
17
19
|
setupOnce() {
|
|
@@ -28,14 +30,16 @@ const browserSessionIntegration = core.defineIntegration(() => {
|
|
|
28
30
|
core.startSession({ ignoreDuration: true });
|
|
29
31
|
core.captureSession();
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
if (lifecycle === 'route') {
|
|
34
|
+
// We want to create a session for every navigation as well
|
|
35
|
+
browserUtils.addHistoryInstrumentationHandler(({ from, to }) => {
|
|
36
|
+
// Don't create an additional session for the initial route or if the location did not change
|
|
37
|
+
if (from !== undefined && from !== to) {
|
|
38
|
+
core.startSession({ ignoreDuration: true });
|
|
39
|
+
core.captureSession();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
39
43
|
},
|
|
40
44
|
};
|
|
41
45
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browsersession.js","sources":["../../../../../src/integrations/browsersession.ts"],"sourcesContent":["import { captureSession, debug, defineIntegration, startSession } from '@sentry/core';\nimport { addHistoryInstrumentationHandler } from '@sentry-internal/browser-utils';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\n\n/**\n * When added, automatically creates sessions which allow you to track adoption and crashes (crash free rate) in your Releases in Sentry.\n * More information: https://docs.sentry.io/product/releases/health/\n *\n * Note: In order for session tracking to work, you need to set up Releases: https://docs.sentry.io/product/releases/\n */\nexport const browserSessionIntegration = defineIntegration(() => {\n return {\n name: 'BrowserSession',\n setupOnce() {\n if (typeof WINDOW.document === 'undefined') {\n DEBUG_BUILD &&\n debug.warn('Using the `browserSessionIntegration` in non-browser environments is not supported.');\n return;\n }\n\n // The session duration for browser sessions does not track a meaningful\n // concept that can be used as a metric.\n // Automatically captured sessions are akin to page views, and thus we\n // discard their duration.\n startSession({ ignoreDuration: true });\n captureSession();\n\n // We want to create a session for every navigation as well\n
|
|
1
|
+
{"version":3,"file":"browsersession.js","sources":["../../../../../src/integrations/browsersession.ts"],"sourcesContent":["import { captureSession, debug, defineIntegration, startSession } from '@sentry/core';\nimport { addHistoryInstrumentationHandler } from '@sentry-internal/browser-utils';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\n\ninterface BrowserSessionOptions {\n /**\n * Controls the session lifecycle - when new sessions are created.\n *\n * - `'route'`: A session is created on page load and on every navigation.\n * This is the default behavior.\n * - `'page'`: A session is created once when the page is loaded. Session is not\n * updated on navigation. This is useful for webviews or single-page apps where\n * URL changes should not trigger new sessions.\n *\n * @default 'route'\n */\n lifecycle?: 'route' | 'page';\n}\n\n/**\n * When added, automatically creates sessions which allow you to track adoption and crashes (crash free rate) in your Releases in Sentry.\n * More information: https://docs.sentry.io/product/releases/health/\n *\n * Note: In order for session tracking to work, you need to set up Releases: https://docs.sentry.io/product/releases/\n */\nexport const browserSessionIntegration = defineIntegration((options: BrowserSessionOptions = {}) => {\n const lifecycle = options.lifecycle ?? 'route';\n\n return {\n name: 'BrowserSession',\n setupOnce() {\n if (typeof WINDOW.document === 'undefined') {\n DEBUG_BUILD &&\n debug.warn('Using the `browserSessionIntegration` in non-browser environments is not supported.');\n return;\n }\n\n // The session duration for browser sessions does not track a meaningful\n // concept that can be used as a metric.\n // Automatically captured sessions are akin to page views, and thus we\n // discard their duration.\n startSession({ ignoreDuration: true });\n captureSession();\n\n if (lifecycle === 'route') {\n // We want to create a session for every navigation as well\n addHistoryInstrumentationHandler(({ from, to }) => {\n // Don't create an additional session for the initial route or if the location did not change\n if (from !== undefined && from !== to) {\n startSession({ ignoreDuration: true });\n captureSession();\n }\n });\n }\n },\n };\n});\n"],"names":["defineIntegration","WINDOW","DEBUG_BUILD","debug","startSession","captureSession","addHistoryInstrumentationHandler"],"mappings":";;;;;;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,yBAAA,GAA4BA,sBAAiB,CAAC,CAAC,OAAO,GAA0B,EAAE,KAAK;AACpG,EAAE,MAAM,SAAA,GAAY,OAAO,CAAC,SAAA,IAAa,OAAO;;AAEhD,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,IAAI,OAAOC,cAAM,CAAC,QAAA,KAAa,WAAW,EAAE;AAClD,QAAQC,sBAAA;AACR,UAAUC,UAAK,CAAC,IAAI,CAAC,qFAAqF,CAAC;AAC3G,QAAQ;AACR,MAAM;;AAEN;AACA;AACA;AACA;AACA,MAAMC,iBAAY,CAAC,EAAE,cAAc,EAAE,IAAA,EAAM,CAAC;AAC5C,MAAMC,mBAAc,EAAE;;AAEtB,MAAM,IAAI,SAAA,KAAc,OAAO,EAAE;AACjC;AACA,QAAQC,6CAAgC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAA,EAAI,KAAK;AAC3D;AACA,UAAU,IAAI,IAAA,KAAS,aAAa,IAAA,KAAS,EAAE,EAAE;AACjD,YAAYF,iBAAY,CAAC,EAAE,cAAc,EAAE,IAAA,EAAM,CAAC;AAClD,YAAYC,mBAAc,EAAE;AAC5B,UAAU;AACV,QAAQ,CAAC,CAAC;AACV,MAAM;AACN,IAAI,CAAC;AACL,GAAG;AACH,CAAC;;;;"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
const helpers = require('../helpers.js');
|
|
5
|
+
|
|
6
|
+
const INTEGRATION_NAME = 'CultureContext';
|
|
7
|
+
|
|
8
|
+
const _cultureContextIntegration = (() => {
|
|
9
|
+
return {
|
|
10
|
+
name: INTEGRATION_NAME,
|
|
11
|
+
preprocessEvent(event) {
|
|
12
|
+
const culture = getCultureContext();
|
|
13
|
+
|
|
14
|
+
if (culture) {
|
|
15
|
+
event.contexts = {
|
|
16
|
+
...event.contexts,
|
|
17
|
+
culture: { ...culture, ...event.contexts?.culture },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}) ;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Captures culture context from the browser.
|
|
26
|
+
*
|
|
27
|
+
* Enabled by default.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```js
|
|
31
|
+
* import * as Sentry from '@sentry/browser';
|
|
32
|
+
*
|
|
33
|
+
* Sentry.init({
|
|
34
|
+
* integrations: [Sentry.cultureContextIntegration()],
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
const cultureContextIntegration = core.defineIntegration(_cultureContextIntegration);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the culture context from the browser's Intl API.
|
|
42
|
+
*/
|
|
43
|
+
function getCultureContext() {
|
|
44
|
+
try {
|
|
45
|
+
const intl = (helpers.WINDOW ).Intl;
|
|
46
|
+
if (!intl) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const options = intl.DateTimeFormat().resolvedOptions();
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
locale: options.locale,
|
|
54
|
+
timezone: options.timeZone,
|
|
55
|
+
calendar: options.calendar,
|
|
56
|
+
};
|
|
57
|
+
} catch {
|
|
58
|
+
// Ignore errors
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
exports.cultureContextIntegration = cultureContextIntegration;
|
|
64
|
+
//# sourceMappingURL=culturecontext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"culturecontext.js","sources":["../../../../../src/integrations/culturecontext.ts"],"sourcesContent":["import type { CultureContext, IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { WINDOW } from '../helpers';\n\nconst INTEGRATION_NAME = 'CultureContext';\n\nconst _cultureContextIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n preprocessEvent(event) {\n const culture = getCultureContext();\n\n if (culture) {\n event.contexts = {\n ...event.contexts,\n culture: { ...culture, ...event.contexts?.culture },\n };\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Captures culture context from the browser.\n *\n * Enabled by default.\n *\n * @example\n * ```js\n * import * as Sentry from '@sentry/browser';\n *\n * Sentry.init({\n * integrations: [Sentry.cultureContextIntegration()],\n * });\n * ```\n */\nexport const cultureContextIntegration = defineIntegration(_cultureContextIntegration);\n\n/**\n * Returns the culture context from the browser's Intl API.\n */\nfunction getCultureContext(): CultureContext | undefined {\n try {\n const intl = (WINDOW as { Intl?: typeof Intl }).Intl;\n if (!intl) {\n return undefined;\n }\n\n const options = intl.DateTimeFormat().resolvedOptions();\n\n return {\n locale: options.locale,\n timezone: options.timeZone,\n calendar: options.calendar,\n };\n } catch {\n // Ignore errors\n return undefined;\n }\n}\n"],"names":["defineIntegration","WINDOW"],"mappings":";;;;;AAIA,MAAM,gBAAA,GAAmB,gBAAgB;;AAEzC,MAAM,0BAAA,IAA8B,MAAM;AAC1C,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,eAAe,CAAC,KAAK,EAAE;AAC3B,MAAM,MAAM,OAAA,GAAU,iBAAiB,EAAE;;AAEzC,MAAM,IAAI,OAAO,EAAE;AACnB,QAAQ,KAAK,CAAC,QAAA,GAAW;AACzB,UAAU,GAAG,KAAK,CAAC,QAAQ;AAC3B,UAAU,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,OAAA,EAAS;AAC7D,SAAS;AACT,MAAM;AACN,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,yBAAA,GAA4BA,sBAAiB,CAAC,0BAA0B;;AAErF;AACA;AACA;AACA,SAAS,iBAAiB,GAA+B;AACzD,EAAE,IAAI;AACN,IAAI,MAAM,IAAA,GAAO,CAACC,cAAA,GAAkC,IAAI;AACxD,IAAI,IAAI,CAAC,IAAI,EAAE;AACf,MAAM,OAAO,SAAS;AACtB,IAAI;;AAEJ,IAAI,MAAM,OAAA,GAAU,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE;;AAE3D,IAAI,OAAO;AACX,MAAM,MAAM,EAAE,OAAO,CAAC,MAAM;AAC5B,MAAM,QAAQ,EAAE,OAAO,CAAC,QAAQ;AAChC,MAAM,QAAQ,EAAE,OAAO,CAAC,QAAQ;AAChC,KAAK;AACL,EAAE,EAAE,MAAM;AACV;AACA,IAAI,OAAO,SAAS;AACpB,EAAE;AACF;;;;"}
|
|
@@ -3,16 +3,40 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
4
|
const helpers = require('../helpers.js');
|
|
5
5
|
|
|
6
|
+
// Treeshakable guard to remove all code related to tracing
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* Collects information about HTTP request headers and
|
|
8
10
|
* attaches them to the event.
|
|
9
11
|
*/
|
|
10
12
|
const httpContextIntegration = core.defineIntegration(() => {
|
|
13
|
+
const inBrowserEnvironment = helpers.WINDOW.navigator || helpers.WINDOW.location || helpers.WINDOW.document;
|
|
14
|
+
|
|
11
15
|
return {
|
|
12
16
|
name: 'HttpContext',
|
|
17
|
+
setup(client) {
|
|
18
|
+
if (!inBrowserEnvironment) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
|
|
23
|
+
if (core.hasSpanStreamingEnabled(client)) {
|
|
24
|
+
client.on('processSegmentSpan', spanJSON => {
|
|
25
|
+
const { url, headers } = helpers.getHttpRequestData();
|
|
26
|
+
|
|
27
|
+
const attributeHeaders = core.httpHeadersToSpanAttributes(headers);
|
|
28
|
+
|
|
29
|
+
core.safeSetSpanJSONAttributes(spanJSON, {
|
|
30
|
+
[core.SEMANTIC_ATTRIBUTE_URL_FULL]: url,
|
|
31
|
+
...attributeHeaders,
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
13
37
|
preprocessEvent(event) {
|
|
14
38
|
// if none of the information we want exists, don't bother
|
|
15
|
-
if (!
|
|
39
|
+
if (!inBrowserEnvironment) {
|
|
16
40
|
return;
|
|
17
41
|
}
|
|
18
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpcontext.js","sources":["../../../../../src/integrations/httpcontext.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"httpcontext.js","sources":["../../../../../src/integrations/httpcontext.ts"],"sourcesContent":["import {\n defineIntegration,\n hasSpanStreamingEnabled,\n httpHeadersToSpanAttributes,\n safeSetSpanJSONAttributes,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n} from '@sentry/core';\nimport { getHttpRequestData, WINDOW } from '../helpers';\n\n// Treeshakable guard to remove all code related to tracing\ndeclare const __SENTRY_TRACING__: boolean | undefined;\n\n/**\n * Collects information about HTTP request headers and\n * attaches them to the event.\n */\nexport const httpContextIntegration = defineIntegration(() => {\n const inBrowserEnvironment = WINDOW.navigator || WINDOW.location || WINDOW.document;\n\n return {\n name: 'HttpContext',\n setup(client) {\n if (!inBrowserEnvironment) {\n return;\n }\n\n if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {\n if (hasSpanStreamingEnabled(client)) {\n client.on('processSegmentSpan', spanJSON => {\n const { url, headers } = getHttpRequestData();\n\n const attributeHeaders = httpHeadersToSpanAttributes(headers);\n\n safeSetSpanJSONAttributes(spanJSON, {\n [SEMANTIC_ATTRIBUTE_URL_FULL]: url,\n ...attributeHeaders,\n });\n });\n }\n }\n },\n preprocessEvent(event) {\n // if none of the information we want exists, don't bother\n if (!inBrowserEnvironment) {\n return;\n }\n\n const reqData = getHttpRequestData();\n const headers = {\n ...reqData.headers,\n ...event.request?.headers,\n };\n\n event.request = {\n ...reqData,\n ...event.request,\n headers,\n };\n },\n };\n});\n"],"names":["defineIntegration","WINDOW","hasSpanStreamingEnabled","getHttpRequestData","httpHeadersToSpanAttributes","safeSetSpanJSONAttributes","SEMANTIC_ATTRIBUTE_URL_FULL"],"mappings":";;;;;AASA;;AAGA;AACA;AACA;AACA;MACa,sBAAA,GAAyBA,sBAAiB,CAAC,MAAM;AAC9D,EAAE,MAAM,oBAAA,GAAuBC,cAAM,CAAC,SAAA,IAAaA,cAAM,CAAC,QAAA,IAAYA,cAAM,CAAC,QAAQ;;AAErF,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,aAAa;AACvB,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,IAAI,CAAC,oBAAoB,EAAE;AACjC,QAAQ;AACR,MAAM;;AAEN,MAAM,IAAI,OAAO,kBAAA,KAAuB,WAAA,IAAe,kBAAkB,EAAE;AAC3E,QAAQ,IAAIC,4BAAuB,CAAC,MAAM,CAAC,EAAE;AAC7C,UAAU,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,YAAY;AACtD,YAAY,MAAM,EAAE,GAAG,EAAE,SAAQ,GAAIC,0BAAkB,EAAE;;AAEzD,YAAY,MAAM,gBAAA,GAAmBC,gCAA2B,CAAC,OAAO,CAAC;;AAEzE,YAAYC,8BAAyB,CAAC,QAAQ,EAAE;AAChD,cAAc,CAACC,gCAA2B,GAAG,GAAG;AAChD,cAAc,GAAG,gBAAgB;AACjC,aAAa,CAAC;AACd,UAAU,CAAC,CAAC;AACZ,QAAQ;AACR,MAAM;AACN,IAAI,CAAC;AACL,IAAI,eAAe,CAAC,KAAK,EAAE;AAC3B;AACA,MAAM,IAAI,CAAC,oBAAoB,EAAE;AACjC,QAAQ;AACR,MAAM;;AAEN,MAAM,MAAM,OAAA,GAAUH,0BAAkB,EAAE;AAC1C,MAAM,MAAM,UAAU;AACtB,QAAQ,GAAG,OAAO,CAAC,OAAO;AAC1B,QAAQ,GAAG,KAAK,CAAC,OAAO,EAAE,OAAO;AACjC,OAAO;;AAEP,MAAM,KAAK,CAAC,OAAA,GAAU;AACtB,QAAQ,GAAG,OAAO;AAClB,QAAQ,GAAG,KAAK,CAAC,OAAO;AACxB,QAAQ,OAAO;AACf,OAAO;AACP,IAAI,CAAC;AACL,GAAG;AACH,CAAC;;;;"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
const debugBuild = require('../debug-build.js');
|
|
5
|
+
|
|
6
|
+
const spanStreamingIntegration = core.defineIntegration(((userOptions) => {
|
|
7
|
+
const validatedUserProvidedBatchLimit =
|
|
8
|
+
userOptions?.batchLimit && userOptions.batchLimit <= 1000 && userOptions.batchLimit >= 1
|
|
9
|
+
? userOptions.batchLimit
|
|
10
|
+
: undefined;
|
|
11
|
+
|
|
12
|
+
if (debugBuild.DEBUG_BUILD && userOptions?.batchLimit && !validatedUserProvidedBatchLimit) {
|
|
13
|
+
core.debug.warn('SpanStreaming batchLimit must be between 1 and 1000, defaulting to 1000');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let sdkConfigured = false;
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
name: 'SpanStreaming',
|
|
20
|
+
beforeSetup(client) {
|
|
21
|
+
const clientOptions = client.getOptions();
|
|
22
|
+
if (!clientOptions.traceLifecycle) {
|
|
23
|
+
client.getOptions().traceLifecycle = 'stream';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const initialMessage = 'spanStreamingIntegration requires';
|
|
27
|
+
const fallbackMsg = 'Falling back to static trace lifecycle.';
|
|
28
|
+
|
|
29
|
+
if (!clientOptions.traceLifecycle) {
|
|
30
|
+
// For browser, we auto-enable span streaming already if this integration is enabled
|
|
31
|
+
// This avoids requiring users to manually opt into span streaming via 2 mechanisms
|
|
32
|
+
// so we set `traceLifecycle` to `stream` if it's not set.
|
|
33
|
+
client.getOptions().traceLifecycle = 'stream';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (clientOptions.traceLifecycle !== 'stream') {
|
|
37
|
+
// If there's a conflict between this integration being added and `traceLifecycle` being set to `static`
|
|
38
|
+
// we prefer static (non-span-streaming) mode.
|
|
39
|
+
debugBuild.DEBUG_BUILD &&
|
|
40
|
+
core.debug.warn(
|
|
41
|
+
`${initialMessage} \`traceLifecycle\` is set to ${clientOptions.traceLifecycle}. ${fallbackMsg}. Either remove \`spanStreamingIntegration\` or set \`traceLifecycle\` to "stream".`,
|
|
42
|
+
);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const beforeSendSpan = clientOptions.beforeSendSpan;
|
|
47
|
+
if (beforeSendSpan && !core.isV2BeforeSendSpanCallback(beforeSendSpan)) {
|
|
48
|
+
client.getOptions().traceLifecycle = 'static';
|
|
49
|
+
core.debug.warn(`${initialMessage} a beforeSendSpan callback using \`withStreamSpan\`! ${fallbackMsg}`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
sdkConfigured = true;
|
|
54
|
+
},
|
|
55
|
+
setup(client) {
|
|
56
|
+
if (!sdkConfigured) {
|
|
57
|
+
// options validation failed in beforeSetup, so we don't do anything here
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const buffer = new core.SpanBuffer(client);
|
|
62
|
+
|
|
63
|
+
client.on('enqueueSpan', spanJSON => {
|
|
64
|
+
buffer.addSpan(spanJSON);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
client.on('afterSpanEnd', span => {
|
|
68
|
+
core.captureSpan(span, client);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
client.on('processSpan', spanJSON => {
|
|
72
|
+
core.safeSetSpanJSONAttributes(spanJSON, {
|
|
73
|
+
// browser-only: tell Sentry to infer the IP address from the request
|
|
74
|
+
'client.address': client.getOptions().sendDefaultPii ? '{{auto}}' : undefined,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// in addition to capturing the span, we also flush the trace when the segment
|
|
79
|
+
// span ends to ensure things are sent timely. We never know when the browser
|
|
80
|
+
// is closed, users navigate away, etc.
|
|
81
|
+
client.on('afterSegmentSpanEnd', segmentSpan => buffer.flushTrace(segmentSpan.spanContext().traceId));
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}) );
|
|
85
|
+
|
|
86
|
+
exports.spanStreamingIntegration = spanStreamingIntegration;
|
|
87
|
+
//# sourceMappingURL=spanstreaming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spanstreaming.js","sources":["../../../../../src/integrations/spanstreaming.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport {\n captureSpan,\n debug,\n defineIntegration,\n isV2BeforeSendSpanCallback,\n safeSetSpanJSONAttributes,\n SpanBuffer,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\nexport interface SpanStreamingOptions {\n batchLimit: number;\n}\n\nexport const spanStreamingIntegration = defineIntegration(((userOptions?: Partial<SpanStreamingOptions>) => {\n const validatedUserProvidedBatchLimit =\n userOptions?.batchLimit && userOptions.batchLimit <= 1000 && userOptions.batchLimit >= 1\n ? userOptions.batchLimit\n : undefined;\n\n if (DEBUG_BUILD && userOptions?.batchLimit && !validatedUserProvidedBatchLimit) {\n debug.warn('SpanStreaming batchLimit must be between 1 and 1000, defaulting to 1000');\n }\n\n let sdkConfigured = false;\n\n return {\n name: 'SpanStreaming',\n beforeSetup(client) {\n const clientOptions = client.getOptions();\n if (!clientOptions.traceLifecycle) {\n client.getOptions().traceLifecycle = 'stream';\n }\n\n const initialMessage = 'spanStreamingIntegration requires';\n const fallbackMsg = 'Falling back to static trace lifecycle.';\n\n if (!clientOptions.traceLifecycle) {\n // For browser, we auto-enable span streaming already if this integration is enabled\n // This avoids requiring users to manually opt into span streaming via 2 mechanisms\n // so we set `traceLifecycle` to `stream` if it's not set.\n client.getOptions().traceLifecycle = 'stream';\n }\n\n if (clientOptions.traceLifecycle !== 'stream') {\n // If there's a conflict between this integration being added and `traceLifecycle` being set to `static`\n // we prefer static (non-span-streaming) mode.\n DEBUG_BUILD &&\n debug.warn(\n `${initialMessage} \\`traceLifecycle\\` is set to ${clientOptions.traceLifecycle}. ${fallbackMsg}. Either remove \\`spanStreamingIntegration\\` or set \\`traceLifecycle\\` to \"stream\".`,\n );\n return;\n }\n\n const beforeSendSpan = clientOptions.beforeSendSpan;\n if (beforeSendSpan && !isV2BeforeSendSpanCallback(beforeSendSpan)) {\n client.getOptions().traceLifecycle = 'static';\n debug.warn(`${initialMessage} a beforeSendSpan callback using \\`withStreamSpan\\`! ${fallbackMsg}`);\n return;\n }\n\n sdkConfigured = true;\n },\n setup(client) {\n if (!sdkConfigured) {\n // options validation failed in beforeSetup, so we don't do anything here\n return;\n }\n\n const buffer = new SpanBuffer(client);\n\n client.on('enqueueSpan', spanJSON => {\n buffer.addSpan(spanJSON);\n });\n\n client.on('afterSpanEnd', span => {\n captureSpan(span, client);\n });\n\n client.on('processSpan', spanJSON => {\n safeSetSpanJSONAttributes(spanJSON, {\n // browser-only: tell Sentry to infer the IP address from the request\n 'client.address': client.getOptions().sendDefaultPii ? '{{auto}}' : undefined,\n });\n });\n\n // in addition to capturing the span, we also flush the trace when the segment\n // span ends to ensure things are sent timely. We never know when the browser\n // is closed, users navigate away, etc.\n client.on('afterSegmentSpanEnd', segmentSpan => buffer.flushTrace(segmentSpan.spanContext().traceId));\n },\n };\n}) satisfies IntegrationFn);\n"],"names":["defineIntegration","DEBUG_BUILD","debug","isV2BeforeSendSpanCallback","SpanBuffer","captureSpan","safeSetSpanJSONAttributes"],"mappings":";;;;;AAeO,MAAM,2BAA2BA,sBAAiB,EAAE,CAAC,WAAW,KAAqC;AAC5G,EAAE,MAAM,+BAAA;AACR,IAAI,WAAW,EAAE,UAAA,IAAc,WAAW,CAAC,UAAA,IAAc,IAAA,IAAQ,WAAW,CAAC,cAAc;AAC3F,QAAQ,WAAW,CAAC;AACpB,QAAQ,SAAS;;AAEjB,EAAE,IAAIC,sBAAA,IAAe,WAAW,EAAE,UAAA,IAAc,CAAC,+BAA+B,EAAE;AAClF,IAAIC,UAAK,CAAC,IAAI,CAAC,yEAAyE,CAAC;AACzF,EAAE;;AAEF,EAAE,IAAI,aAAA,GAAgB,KAAK;;AAE3B,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,eAAe;AACzB,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,MAAM,MAAM,aAAA,GAAgB,MAAM,CAAC,UAAU,EAAE;AAC/C,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE;AACzC,QAAQ,MAAM,CAAC,UAAU,EAAE,CAAC,cAAA,GAAiB,QAAQ;AACrD,MAAM;;AAEN,MAAM,MAAM,cAAA,GAAiB,mCAAmC;AAChE,MAAM,MAAM,WAAA,GAAc,yCAAyC;;AAEnE,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE;AACzC;AACA;AACA;AACA,QAAQ,MAAM,CAAC,UAAU,EAAE,CAAC,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AA,GAAA,SAAA;AACA,SAAA,CAAA;AACA,MAAA,CAAA,CAAA;;AAEA;AACA;AACA;AACA,MAAA,MAAA,CAAA,EAAA,CAAA,qBAAA,EAAA,WAAA,IAAA,MAAA,CAAA,UAAA,CAAA,WAAA,CAAA,WAAA,EAAA,CAAA,OAAA,CAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA;;;;"}
|
|
@@ -17,6 +17,7 @@ const _spotlightIntegration = ((options = {}) => {
|
|
|
17
17
|
// We don't want to send interaction transactions/root spans created from
|
|
18
18
|
// clicks within Spotlight to Sentry. Neither do we want them to be sent to
|
|
19
19
|
// spotlight.
|
|
20
|
+
// TODO (span-streaming): port this to what exactly?
|
|
20
21
|
processEvent: event => (isSpotlightInteraction(event) ? null : event),
|
|
21
22
|
afterAllSetup: (client) => {
|
|
22
23
|
setupSidecarForwarding(client, sidecarUrl);
|
|
@@ -72,10 +73,10 @@ const spotlightBrowserIntegration = core.defineIntegration(_spotlightIntegration
|
|
|
72
73
|
function isSpotlightInteraction(event) {
|
|
73
74
|
return Boolean(
|
|
74
75
|
event.type === 'transaction' &&
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
event.spans &&
|
|
77
|
+
event.contexts?.trace &&
|
|
78
|
+
event.contexts.trace.op === 'ui.action.click' &&
|
|
79
|
+
event.spans.some(({ description }) => description?.includes('#sentry-spotlight')),
|
|
79
80
|
);
|
|
80
81
|
}
|
|
81
82
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotlight.js","sources":["../../../../../src/integrations/spotlight.ts"],"sourcesContent":["import type { Client, Envelope, Event, IntegrationFn } from '@sentry/core';\nimport { debug, defineIntegration, serializeEnvelope } from '@sentry/core';\nimport { getNativeImplementation } from '@sentry-internal/browser-utils';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { WINDOW } from '../helpers';\n\nexport type SpotlightConnectionOptions = {\n /**\n * Set this if the Spotlight Sidecar is not running on localhost:8969\n * By default, the Url is set to http://localhost:8969/stream\n */\n sidecarUrl?: string;\n};\n\nexport const INTEGRATION_NAME = 'SpotlightBrowser';\n\nconst _spotlightIntegration = ((options: Partial<SpotlightConnectionOptions> = {}) => {\n const sidecarUrl = options.sidecarUrl || 'http://localhost:8969/stream';\n\n return {\n name: INTEGRATION_NAME,\n setup: () => {\n DEBUG_BUILD && debug.log('Using Sidecar URL', sidecarUrl);\n },\n // We don't want to send interaction transactions/root spans created from\n // clicks within Spotlight to Sentry. Neither do we want them to be sent to\n // spotlight.\n processEvent: event => (isSpotlightInteraction(event) ? null : event),\n afterAllSetup: (client: Client) => {\n setupSidecarForwarding(client, sidecarUrl);\n },\n };\n}) satisfies IntegrationFn;\n\nfunction setupSidecarForwarding(client: Client, sidecarUrl: string): void {\n const makeFetch: typeof WINDOW.fetch | undefined = getNativeImplementation('fetch');\n let failCount = 0;\n\n client.on('beforeEnvelope', (envelope: Envelope) => {\n if (failCount > 3) {\n debug.warn('[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests:', failCount);\n return;\n }\n\n makeFetch(sidecarUrl, {\n method: 'POST',\n body: serializeEnvelope(envelope),\n headers: {\n 'Content-Type': 'application/x-sentry-envelope',\n },\n mode: 'cors',\n }).then(\n res => {\n if (res.status >= 200 && res.status < 400) {\n // Reset failed requests counter on success\n failCount = 0;\n }\n },\n err => {\n failCount++;\n debug.error(\n \"Sentry SDK can't connect to Sidecar is it running? See: https://spotlightjs.com/sidecar/npx/\",\n err,\n );\n },\n );\n });\n}\n\n/**\n * Use this integration to send errors and transactions to Spotlight.\n *\n * Learn more about spotlight at https://spotlightjs.com\n */\nexport const spotlightBrowserIntegration = defineIntegration(_spotlightIntegration);\n\n/**\n * Flags if the event is a transaction created from an interaction with the spotlight UI.\n */\nexport function isSpotlightInteraction(event: Event): boolean {\n return Boolean(\n event.type === 'transaction' &&\n
|
|
1
|
+
{"version":3,"file":"spotlight.js","sources":["../../../../../src/integrations/spotlight.ts"],"sourcesContent":["import type { Client, Envelope, Event, IntegrationFn } from '@sentry/core';\nimport { debug, defineIntegration, serializeEnvelope } from '@sentry/core';\nimport { getNativeImplementation } from '@sentry-internal/browser-utils';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { WINDOW } from '../helpers';\n\nexport type SpotlightConnectionOptions = {\n /**\n * Set this if the Spotlight Sidecar is not running on localhost:8969\n * By default, the Url is set to http://localhost:8969/stream\n */\n sidecarUrl?: string;\n};\n\nexport const INTEGRATION_NAME = 'SpotlightBrowser';\n\nconst _spotlightIntegration = ((options: Partial<SpotlightConnectionOptions> = {}) => {\n const sidecarUrl = options.sidecarUrl || 'http://localhost:8969/stream';\n\n return {\n name: INTEGRATION_NAME,\n setup: () => {\n DEBUG_BUILD && debug.log('Using Sidecar URL', sidecarUrl);\n },\n // We don't want to send interaction transactions/root spans created from\n // clicks within Spotlight to Sentry. Neither do we want them to be sent to\n // spotlight.\n // TODO (span-streaming): port this to what exactly?\n processEvent: event => (isSpotlightInteraction(event) ? null : event),\n afterAllSetup: (client: Client) => {\n setupSidecarForwarding(client, sidecarUrl);\n },\n };\n}) satisfies IntegrationFn;\n\nfunction setupSidecarForwarding(client: Client, sidecarUrl: string): void {\n const makeFetch: typeof WINDOW.fetch | undefined = getNativeImplementation('fetch');\n let failCount = 0;\n\n client.on('beforeEnvelope', (envelope: Envelope) => {\n if (failCount > 3) {\n debug.warn('[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests:', failCount);\n return;\n }\n\n makeFetch(sidecarUrl, {\n method: 'POST',\n body: serializeEnvelope(envelope),\n headers: {\n 'Content-Type': 'application/x-sentry-envelope',\n },\n mode: 'cors',\n }).then(\n res => {\n if (res.status >= 200 && res.status < 400) {\n // Reset failed requests counter on success\n failCount = 0;\n }\n },\n err => {\n failCount++;\n debug.error(\n \"Sentry SDK can't connect to Sidecar is it running? See: https://spotlightjs.com/sidecar/npx/\",\n err,\n );\n },\n );\n });\n}\n\n/**\n * Use this integration to send errors and transactions to Spotlight.\n *\n * Learn more about spotlight at https://spotlightjs.com\n */\nexport const spotlightBrowserIntegration = defineIntegration(_spotlightIntegration);\n\n/**\n * Flags if the event is a transaction created from an interaction with the spotlight UI.\n */\nexport function isSpotlightInteraction(event: Event): boolean {\n return Boolean(\n event.type === 'transaction' &&\n event.spans &&\n event.contexts?.trace &&\n event.contexts.trace.op === 'ui.action.click' &&\n event.spans.some(({ description }) => description?.includes('#sentry-spotlight')),\n );\n}\n"],"names":["DEBUG_BUILD","debug","getNativeImplementation","serializeEnvelope","defineIntegration"],"mappings":";;;;;;AAcO,MAAM,gBAAA,GAAmB;;AAEhC,MAAM,qBAAA,IAAyB,CAAC,OAAO,GAAwC,EAAE,KAAK;AACtF,EAAE,MAAM,UAAA,GAAa,OAAO,CAAC,UAAA,IAAc,8BAA8B;;AAEzE,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,EAAE,MAAM;AACjB,MAAMA,sBAAA,IAAeC,UAAK,CAAC,GAAG,CAAC,mBAAmB,EAAE,UAAU,CAAC;AAC/D,IAAI,CAAC;AACL;AACA;AACA;AACA;AACA,IAAI,YAAY,EAAE,KAAA,KAAU,sBAAsB,CAAC,KAAK,CAAA,GAAI,IAAA,GAAO,KAAK,CAAC;AACzE,IAAI,aAAa,EAAE,CAAC,MAAM,KAAa;AACvC,MAAM,sBAAsB,CAAC,MAAM,EAAE,UAAU,CAAC;AAChD,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED,SAAS,sBAAsB,CAAC,MAAM,EAAU,UAAU,EAAgB;AAC1E,EAAE,MAAM,SAAS,GAAoCC,oCAAuB,CAAC,OAAO,CAAC;AACrF,EAAE,IAAI,SAAA,GAAY,CAAC;;AAEnB,EAAE,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,QAAQ,KAAe;AACtD,IAAI,IAAI,SAAA,GAAY,CAAC,EAAE;AACvB,MAAMD,UAAK,CAAC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
|
|
109
|
+
/** Returns the current profiler session ID, or undefined if not initialized. */
|
|
110
|
+
getProfilerId() {
|
|
111
|
+
return this._profilerId;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Returns whether the profiler is currently running (recording). */
|
|
115
|
+
isRunning() {
|
|
116
|
+
return this._isRunning;
|
|
117
|
+
}
|
|
118
|
+
|
|
109
119
|
/** Handle an already-active root span at integration setup time (used only in trace mode). */
|
|
110
120
|
notifyRootSpanActive(rootSpan) {
|
|
111
121
|
if (this._lifecycleMode !== 'trace' || !this._sessionSampled) {
|