@sentry/browser 10.48.0 → 10.50.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.
Files changed (88) hide show
  1. package/build/npm/cjs/dev/index.js +3 -0
  2. package/build/npm/cjs/dev/index.js.map +1 -1
  3. package/build/npm/cjs/dev/integrations/culturecontext.js +12 -0
  4. package/build/npm/cjs/dev/integrations/culturecontext.js.map +1 -1
  5. package/build/npm/cjs/dev/integrations/graphqlClient.js +3 -1
  6. package/build/npm/cjs/dev/integrations/graphqlClient.js.map +1 -1
  7. package/build/npm/cjs/dev/integrations/spanstreaming.js +1 -1
  8. package/build/npm/cjs/dev/integrations/spanstreaming.js.map +1 -1
  9. package/build/npm/cjs/dev/integrations/view-hierarchy.js +101 -0
  10. package/build/npm/cjs/dev/integrations/view-hierarchy.js.map +1 -0
  11. package/build/npm/cjs/dev/tracing/browserTracingIntegration.js +18 -7
  12. package/build/npm/cjs/dev/tracing/browserTracingIntegration.js.map +1 -1
  13. package/build/npm/cjs/dev/tracing/request.js +5 -1
  14. package/build/npm/cjs/dev/tracing/request.js.map +1 -1
  15. package/build/npm/cjs/prod/index.js +3 -0
  16. package/build/npm/cjs/prod/index.js.map +1 -1
  17. package/build/npm/cjs/prod/integrations/culturecontext.js +12 -0
  18. package/build/npm/cjs/prod/integrations/culturecontext.js.map +1 -1
  19. package/build/npm/cjs/prod/integrations/graphqlClient.js +3 -1
  20. package/build/npm/cjs/prod/integrations/graphqlClient.js.map +1 -1
  21. package/build/npm/cjs/prod/integrations/spanstreaming.js +1 -1
  22. package/build/npm/cjs/prod/integrations/spanstreaming.js.map +1 -1
  23. package/build/npm/cjs/prod/integrations/view-hierarchy.js +101 -0
  24. package/build/npm/cjs/prod/integrations/view-hierarchy.js.map +1 -0
  25. package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +18 -7
  26. package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -1
  27. package/build/npm/cjs/prod/tracing/request.js +5 -1
  28. package/build/npm/cjs/prod/tracing/request.js.map +1 -1
  29. package/build/npm/esm/dev/index.js +2 -1
  30. package/build/npm/esm/dev/index.js.map +1 -1
  31. package/build/npm/esm/dev/integrations/culturecontext.js +12 -0
  32. package/build/npm/esm/dev/integrations/culturecontext.js.map +1 -1
  33. package/build/npm/esm/dev/integrations/graphqlClient.js +3 -1
  34. package/build/npm/esm/dev/integrations/graphqlClient.js.map +1 -1
  35. package/build/npm/esm/dev/integrations/spanstreaming.js +1 -1
  36. package/build/npm/esm/dev/integrations/spanstreaming.js.map +1 -1
  37. package/build/npm/esm/dev/integrations/view-hierarchy.js +99 -0
  38. package/build/npm/esm/dev/integrations/view-hierarchy.js.map +1 -0
  39. package/build/npm/esm/dev/package.json +1 -1
  40. package/build/npm/esm/dev/tracing/browserTracingIntegration.js +20 -10
  41. package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -1
  42. package/build/npm/esm/dev/tracing/request.js +6 -2
  43. package/build/npm/esm/dev/tracing/request.js.map +1 -1
  44. package/build/npm/esm/prod/index.js +2 -1
  45. package/build/npm/esm/prod/index.js.map +1 -1
  46. package/build/npm/esm/prod/integrations/culturecontext.js +12 -0
  47. package/build/npm/esm/prod/integrations/culturecontext.js.map +1 -1
  48. package/build/npm/esm/prod/integrations/graphqlClient.js +3 -1
  49. package/build/npm/esm/prod/integrations/graphqlClient.js.map +1 -1
  50. package/build/npm/esm/prod/integrations/spanstreaming.js +1 -1
  51. package/build/npm/esm/prod/integrations/spanstreaming.js.map +1 -1
  52. package/build/npm/esm/prod/integrations/view-hierarchy.js +99 -0
  53. package/build/npm/esm/prod/integrations/view-hierarchy.js.map +1 -0
  54. package/build/npm/esm/prod/package.json +1 -1
  55. package/build/npm/esm/prod/tracing/browserTracingIntegration.js +20 -10
  56. package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -1
  57. package/build/npm/esm/prod/tracing/request.js +6 -2
  58. package/build/npm/esm/prod/tracing/request.js.map +1 -1
  59. package/build/npm/types/index.bundle.tracing.d.ts +1 -1
  60. package/build/npm/types/index.bundle.tracing.d.ts.map +1 -1
  61. package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts +1 -1
  62. package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts.map +1 -1
  63. package/build/npm/types/index.bundle.tracing.replay.d.ts +1 -1
  64. package/build/npm/types/index.bundle.tracing.replay.d.ts.map +1 -1
  65. package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts +1 -1
  66. package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts.map +1 -1
  67. package/build/npm/types/index.bundle.tracing.replay.feedback.logs.metrics.d.ts +1 -1
  68. package/build/npm/types/index.bundle.tracing.replay.feedback.logs.metrics.d.ts.map +1 -1
  69. package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts +1 -1
  70. package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts.map +1 -1
  71. package/build/npm/types/index.d.ts +2 -1
  72. package/build/npm/types/index.d.ts.map +1 -1
  73. package/build/npm/types/integrations/culturecontext.d.ts.map +1 -1
  74. package/build/npm/types/integrations/graphqlClient.d.ts.map +1 -1
  75. package/build/npm/types/integrations/view-hierarchy.d.ts +49 -0
  76. package/build/npm/types/integrations/view-hierarchy.d.ts.map +1 -0
  77. package/build/npm/types/tracing/browserTracingIntegration.d.ts +1 -0
  78. package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
  79. package/build/npm/types-ts3.8/index.bundle.tracing.d.ts +1 -1
  80. package/build/npm/types-ts3.8/index.bundle.tracing.logs.metrics.d.ts +1 -1
  81. package/build/npm/types-ts3.8/index.bundle.tracing.replay.d.ts +1 -1
  82. package/build/npm/types-ts3.8/index.bundle.tracing.replay.feedback.d.ts +1 -1
  83. package/build/npm/types-ts3.8/index.bundle.tracing.replay.feedback.logs.metrics.d.ts +1 -1
  84. package/build/npm/types-ts3.8/index.bundle.tracing.replay.logs.metrics.d.ts +1 -1
  85. package/build/npm/types-ts3.8/index.d.ts +2 -1
  86. package/build/npm/types-ts3.8/integrations/view-hierarchy.d.ts +49 -0
  87. package/build/npm/types-ts3.8/tracing/browserTracingIntegration.d.ts +1 -0
  88. package/package.json +7 -7
@@ -287,6 +287,7 @@ function xhrCallback(
287
287
 
288
288
  const urlForSpanName = core.stripDataUrlContent(core.stripUrlQueryAndFragment(url));
289
289
 
290
+ const client = core.getClient();
290
291
  const hasParent = !!core.getActiveSpan();
291
292
 
292
293
  const span =
@@ -307,6 +308,10 @@ function xhrCallback(
307
308
  })
308
309
  : new core.SentryNonRecordingSpan();
309
310
 
311
+ if (shouldCreateSpanResult && !hasParent) {
312
+ client?.recordDroppedEvent('no_parent_span', 'span');
313
+ }
314
+
310
315
  xhr.__sentry_xhr_span_id__ = span.spanContext().spanId;
311
316
  spans[xhr.__sentry_xhr_span_id__] = span;
312
317
 
@@ -321,7 +326,6 @@ function xhrCallback(
321
326
  );
322
327
  }
323
328
 
324
- const client = core.getClient();
325
329
  if (client) {
326
330
  client.emit('beforeOutgoingRequestSpan', span, handlerData );
327
331
  }
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sources":["../../../../../src/tracing/request.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type {\n Client,\n HandlerDataXhr,\n RequestHookInfo,\n ResponseHookInfo,\n SentryWrappedXMLHttpRequest,\n Span,\n SpanTimeInput,\n} from '@sentry/core';\nimport {\n addFetchEndInstrumentationHandler,\n addFetchInstrumentationHandler,\n getActiveSpan,\n getClient,\n getLocationHref,\n getTraceData,\n hasSpansEnabled,\n hasSpanStreamingEnabled,\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 timestampInSeconds,\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, client);\n }\n\n onRequestSpanStart?.(createdSpan, { headers: handlerData.headers });\n }\n });\n }\n\n if (traceXHR) {\n addXhrInstrumentationHandler(handlerData => {\n const createdSpan = xhrCallback(\n handlerData,\n shouldCreateSpan,\n shouldAttachHeadersWithTargets,\n spans,\n propagateTraceparent,\n onRequestSpanEnd,\n );\n\n if (createdSpan) {\n if (enableHTTPTimings) {\n addHTTPTimings(createdSpan, client);\n }\n\n onRequestSpanStart?.(createdSpan, {\n headers: createHeadersSafely(handlerData.xhr.__sentry_xhr_v3__?.request_headers),\n });\n }\n });\n }\n}\n\n/**\n * The maximum time (ms) to wait for PerformanceResourceTiming data before ending the span.\n * Same approach is used by OTel's browser fetch instrumentation:\n * See {@link https://github.com/open-telemetry/opentelemetry-js/blob/30f94fe99339287b1e4d3c8bb90172c2523f06f4/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L352-L372}\n */\nconst HTTP_TIMING_WAIT_MS = 300;\n\n/**\n * Creates a temporary observer to listen to the next fetch/xhr resourcing timings,\n * so that when timings hit their per-browser limit they don't need to be removed.\n *\n * @param span A span that has yet to be finished, must contain `url` on data.\n */\nfunction addHTTPTimings(span: Span, client: Client): void {\n const { url } = spanToJSON(span).data;\n\n if (!url || typeof url !== 'string') {\n return;\n }\n\n // Clean up the performance observer and other resources\n // We have to wait here because otherwise this cleans itself up before it is fully done.\n // Default (non-streaming): just deregister the observer.\n let onEntryFound = (): void => void setTimeout(unsubscribePerformanceObsever);\n\n // For streamed spans, we have to artificially delay the ending of the span until we\n // either receive the timing data, or HTTP_TIMING_WAIT_MS elapses.\n if (hasSpanStreamingEnabled(client)) {\n const originalEnd = span.end.bind(span);\n\n span.end = (endTimestamp?: SpanTimeInput) => {\n const capturedEndTimestamp = endTimestamp ?? timestampInSeconds();\n let isEnded = false;\n\n const endSpanAndCleanup = (): void => {\n if (isEnded) {\n return;\n }\n isEnded = true;\n setTimeout(unsubscribePerformanceObsever);\n originalEnd(capturedEndTimestamp);\n clearTimeout(fallbackTimeout);\n };\n\n onEntryFound = endSpanAndCleanup;\n\n // Fallback: always end the span after HTTP_TIMING_WAIT_MS even if no\n // PerformanceResourceTiming entry arrives (e.g. cross-origin without\n // Timing-Allow-Origin, or the browser didn't fire the observer in time).\n const fallbackTimeout = setTimeout(endSpanAndCleanup, HTTP_TIMING_WAIT_MS);\n };\n }\n\n const unsubscribePerformanceObsever = addPerformanceInstrumentationHandler('resource', ({ entries }) => {\n entries.forEach(entry => {\n if (isPerformanceResourceTiming(entry) && entry.name.endsWith(url)) {\n span.setAttributes(resourceTimingToSpanAttributes(entry));\n onEntryFound();\n }\n });\n });\n}\n\n/**\n * A function that determines whether to attach tracing headers to a request.\n * We only export this function for testing purposes.\n */\nexport function shouldAttachHeaders(\n targetUrl: string,\n tracePropagationTargets: (string | RegExp)[] | undefined,\n): boolean {\n // window.location.href not being defined is an edge case in the browser but we need to handle it.\n // Potentially dangerous situations where it may not be defined: Browser Extensions, Web Workers, patching of the location obj\n const href = getLocationHref();\n\n if (!href) {\n // If there is no window.location.origin, we default to only attaching tracing headers to relative requests, i.e. ones that start with `/`\n // BIG DISCLAIMER: Users can call URLs with a double slash (fetch(\"//example.com/api\")), this is a shorthand for \"send to the same protocol\",\n // so we need a to exclude those requests, because they might be cross origin.\n const isRelativeSameOriginRequest = !!targetUrl.match(/^\\/(?!\\/)/);\n if (!tracePropagationTargets) {\n return isRelativeSameOriginRequest;\n } else {\n return stringMatchesSomePattern(targetUrl, tracePropagationTargets);\n }\n } else {\n let resolvedUrl;\n let currentOrigin;\n\n // URL parsing may fail, we default to not attaching trace headers in that case.\n try {\n resolvedUrl = new URL(targetUrl, href);\n currentOrigin = new URL(href).origin;\n } catch {\n return false;\n }\n\n const isSameOriginRequest = resolvedUrl.origin === currentOrigin;\n if (!tracePropagationTargets) {\n return isSameOriginRequest;\n } else {\n return (\n stringMatchesSomePattern(resolvedUrl.toString(), tracePropagationTargets) ||\n (isSameOriginRequest && stringMatchesSomePattern(resolvedUrl.pathname, tracePropagationTargets))\n );\n }\n }\n}\n\n/**\n * Create and track xhr request spans\n *\n * @returns Span if a span was created, otherwise void.\n */\nfunction xhrCallback(\n handlerData: HandlerDataXhr,\n shouldCreateSpan: (url: string) => boolean,\n shouldAttachHeaders: (url: string) => boolean,\n spans: Record<string, Span>,\n propagateTraceparent?: boolean,\n onRequestSpanEnd?: RequestInstrumentationOptions['onRequestSpanEnd'],\n): Span | undefined {\n const xhr = handlerData.xhr;\n const sentryXhrData = xhr?.[SENTRY_XHR_DATA_KEY];\n\n if (!xhr || xhr.__sentry_own_request__ || !sentryXhrData) {\n return undefined;\n }\n\n const { url, method } = sentryXhrData;\n\n const shouldCreateSpanResult = hasSpansEnabled() && shouldCreateSpan(url);\n\n // Handle XHR completion - clean up spans from the record\n if (handlerData.endTimestamp) {\n const spanId = xhr.__sentry_xhr_span_id__;\n if (!spanId) return;\n\n const span = spans[spanId];\n\n if (span) {\n if (shouldCreateSpanResult && sentryXhrData.status_code !== undefined) {\n setHttpStatus(span, sentryXhrData.status_code);\n span.end();\n\n onRequestSpanEnd?.(span, {\n headers: createHeadersSafely(parseXhrResponseHeaders(xhr as XMLHttpRequest & SentryWrappedXMLHttpRequest)),\n error: handlerData.error,\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete spans[spanId];\n }\n\n return undefined;\n }\n\n const fullUrl = getFullURL(url);\n const parsedUrl = fullUrl ? parseUrl(fullUrl) : parseUrl(url);\n\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","hasSpanStreamingEnabled","timestampInSeconds","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":";;;;;;AA2CA;;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,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A,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;;;;;;"}
1
+ {"version":3,"file":"request.js","sources":["../../../../../src/tracing/request.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type {\n Client,\n HandlerDataXhr,\n RequestHookInfo,\n ResponseHookInfo,\n SentryWrappedXMLHttpRequest,\n Span,\n SpanTimeInput,\n} from '@sentry/core';\nimport {\n addFetchEndInstrumentationHandler,\n addFetchInstrumentationHandler,\n getActiveSpan,\n getClient,\n getLocationHref,\n getTraceData,\n hasSpansEnabled,\n hasSpanStreamingEnabled,\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 timestampInSeconds,\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, client);\n }\n\n onRequestSpanStart?.(createdSpan, { headers: handlerData.headers });\n }\n });\n }\n\n if (traceXHR) {\n addXhrInstrumentationHandler(handlerData => {\n const createdSpan = xhrCallback(\n handlerData,\n shouldCreateSpan,\n shouldAttachHeadersWithTargets,\n spans,\n propagateTraceparent,\n onRequestSpanEnd,\n );\n\n if (createdSpan) {\n if (enableHTTPTimings) {\n addHTTPTimings(createdSpan, client);\n }\n\n onRequestSpanStart?.(createdSpan, {\n headers: createHeadersSafely(handlerData.xhr.__sentry_xhr_v3__?.request_headers),\n });\n }\n });\n }\n}\n\n/**\n * The maximum time (ms) to wait for PerformanceResourceTiming data before ending the span.\n * Same approach is used by OTel's browser fetch instrumentation:\n * See {@link https://github.com/open-telemetry/opentelemetry-js/blob/30f94fe99339287b1e4d3c8bb90172c2523f06f4/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L352-L372}\n */\nconst HTTP_TIMING_WAIT_MS = 300;\n\n/**\n * Creates a temporary observer to listen to the next fetch/xhr resourcing timings,\n * so that when timings hit their per-browser limit they don't need to be removed.\n *\n * @param span A span that has yet to be finished, must contain `url` on data.\n */\nfunction addHTTPTimings(span: Span, client: Client): void {\n const { url } = spanToJSON(span).data;\n\n if (!url || typeof url !== 'string') {\n return;\n }\n\n // Clean up the performance observer and other resources\n // We have to wait here because otherwise this cleans itself up before it is fully done.\n // Default (non-streaming): just deregister the observer.\n let onEntryFound = (): void => void setTimeout(unsubscribePerformanceObsever);\n\n // For streamed spans, we have to artificially delay the ending of the span until we\n // either receive the timing data, or HTTP_TIMING_WAIT_MS elapses.\n if (hasSpanStreamingEnabled(client)) {\n const originalEnd = span.end.bind(span);\n\n span.end = (endTimestamp?: SpanTimeInput) => {\n const capturedEndTimestamp = endTimestamp ?? timestampInSeconds();\n let isEnded = false;\n\n const endSpanAndCleanup = (): void => {\n if (isEnded) {\n return;\n }\n isEnded = true;\n setTimeout(unsubscribePerformanceObsever);\n originalEnd(capturedEndTimestamp);\n clearTimeout(fallbackTimeout);\n };\n\n onEntryFound = endSpanAndCleanup;\n\n // Fallback: always end the span after HTTP_TIMING_WAIT_MS even if no\n // PerformanceResourceTiming entry arrives (e.g. cross-origin without\n // Timing-Allow-Origin, or the browser didn't fire the observer in time).\n const fallbackTimeout = setTimeout(endSpanAndCleanup, HTTP_TIMING_WAIT_MS);\n };\n }\n\n const unsubscribePerformanceObsever = addPerformanceInstrumentationHandler('resource', ({ entries }) => {\n entries.forEach(entry => {\n if (isPerformanceResourceTiming(entry) && entry.name.endsWith(url)) {\n span.setAttributes(resourceTimingToSpanAttributes(entry));\n onEntryFound();\n }\n });\n });\n}\n\n/**\n * A function that determines whether to attach tracing headers to a request.\n * We only export this function for testing purposes.\n */\nexport function shouldAttachHeaders(\n targetUrl: string,\n tracePropagationTargets: (string | RegExp)[] | undefined,\n): boolean {\n // window.location.href not being defined is an edge case in the browser but we need to handle it.\n // Potentially dangerous situations where it may not be defined: Browser Extensions, Web Workers, patching of the location obj\n const href = getLocationHref();\n\n if (!href) {\n // If there is no window.location.origin, we default to only attaching tracing headers to relative requests, i.e. ones that start with `/`\n // BIG DISCLAIMER: Users can call URLs with a double slash (fetch(\"//example.com/api\")), this is a shorthand for \"send to the same protocol\",\n // so we need a to exclude those requests, because they might be cross origin.\n const isRelativeSameOriginRequest = !!targetUrl.match(/^\\/(?!\\/)/);\n if (!tracePropagationTargets) {\n return isRelativeSameOriginRequest;\n } else {\n return stringMatchesSomePattern(targetUrl, tracePropagationTargets);\n }\n } else {\n let resolvedUrl;\n let currentOrigin;\n\n // URL parsing may fail, we default to not attaching trace headers in that case.\n try {\n resolvedUrl = new URL(targetUrl, href);\n currentOrigin = new URL(href).origin;\n } catch {\n return false;\n }\n\n const isSameOriginRequest = resolvedUrl.origin === currentOrigin;\n if (!tracePropagationTargets) {\n return isSameOriginRequest;\n } else {\n return (\n stringMatchesSomePattern(resolvedUrl.toString(), tracePropagationTargets) ||\n (isSameOriginRequest && stringMatchesSomePattern(resolvedUrl.pathname, tracePropagationTargets))\n );\n }\n }\n}\n\n/**\n * Create and track xhr request spans\n *\n * @returns Span if a span was created, otherwise void.\n */\nfunction xhrCallback(\n handlerData: HandlerDataXhr,\n shouldCreateSpan: (url: string) => boolean,\n shouldAttachHeaders: (url: string) => boolean,\n spans: Record<string, Span>,\n propagateTraceparent?: boolean,\n onRequestSpanEnd?: RequestInstrumentationOptions['onRequestSpanEnd'],\n): Span | undefined {\n const xhr = handlerData.xhr;\n const sentryXhrData = xhr?.[SENTRY_XHR_DATA_KEY];\n\n if (!xhr || xhr.__sentry_own_request__ || !sentryXhrData) {\n return undefined;\n }\n\n const { url, method } = sentryXhrData;\n\n const shouldCreateSpanResult = hasSpansEnabled() && shouldCreateSpan(url);\n\n // Handle XHR completion - clean up spans from the record\n if (handlerData.endTimestamp) {\n const spanId = xhr.__sentry_xhr_span_id__;\n if (!spanId) return;\n\n const span = spans[spanId];\n\n if (span) {\n if (shouldCreateSpanResult && sentryXhrData.status_code !== undefined) {\n setHttpStatus(span, sentryXhrData.status_code);\n span.end();\n\n onRequestSpanEnd?.(span, {\n headers: createHeadersSafely(parseXhrResponseHeaders(xhr as XMLHttpRequest & SentryWrappedXMLHttpRequest)),\n error: handlerData.error,\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete spans[spanId];\n }\n\n return undefined;\n }\n\n const fullUrl = getFullURL(url);\n const parsedUrl = fullUrl ? parseUrl(fullUrl) : parseUrl(url);\n\n const urlForSpanName = stripDataUrlContent(stripUrlQueryAndFragment(url));\n\n const client = getClient();\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 if (shouldCreateSpanResult && !hasParent) {\n client?.recordDroppedEvent('no_parent_span', 'span');\n }\n\n xhr.__sentry_xhr_span_id__ = span.spanContext().spanId;\n spans[xhr.__sentry_xhr_span_id__] = span;\n\n if (shouldAttachHeaders(url)) {\n addTracingHeadersToXhrRequest(\n xhr,\n // If performance is disabled (TWP) or there's no active root span (pageload/navigation/interaction),\n // we do not want to use the span as base for the trace headers,\n // which means that the headers will be generated from the scope and the sampling decision is deferred\n hasSpansEnabled() && hasParent ? span : undefined,\n propagateTraceparent,\n );\n }\n\n if (client) {\n client.emit('beforeOutgoingRequestSpan', span, handlerData as XhrHint);\n }\n\n return span;\n}\n\nfunction addTracingHeadersToXhrRequest(\n xhr: SentryWrappedXMLHttpRequest,\n span?: Span,\n propagateTraceparent?: boolean,\n): void {\n const { 'sentry-trace': sentryTrace, baggage, traceparent } = getTraceData({ span, propagateTraceparent });\n\n if (sentryTrace) {\n setHeaderOnXhr(xhr, sentryTrace, baggage, traceparent);\n }\n}\n\nfunction setHeaderOnXhr(\n xhr: SentryWrappedXMLHttpRequest,\n sentryTraceHeader: string,\n sentryBaggageHeader: string | undefined,\n traceparentHeader: string | undefined,\n): void {\n const originalHeaders = xhr.__sentry_xhr_v3__?.request_headers;\n\n if (originalHeaders?.['sentry-trace'] || !xhr.setRequestHeader) {\n // bail if a sentry-trace header is already set\n return;\n }\n\n try {\n xhr.setRequestHeader('sentry-trace', sentryTraceHeader);\n\n if (traceparentHeader && !originalHeaders?.['traceparent']) {\n xhr.setRequestHeader('traceparent', traceparentHeader);\n }\n\n if (sentryBaggageHeader) {\n // only add our headers if\n // - no pre-existing baggage header exists\n // - or it is set and doesn't yet contain sentry values\n const originalBaggageHeader = originalHeaders?.['baggage'];\n if (!originalBaggageHeader || !baggageHeaderHasSentryValues(originalBaggageHeader)) {\n // From MDN: \"If this method is called several times with the same header, the values are merged into one single request header.\"\n // We can therefore simply set a baggage header without checking what was there before\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader\n xhr.setRequestHeader('baggage', sentryBaggageHeader);\n }\n }\n } catch {\n // Error: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.\n }\n}\n"],"names":["addFetchEndInstrumentationHandler","addFetchInstrumentationHandler","instrumentFetchRequest","getFullURL","parseUrl","stripDataUrlContent","addXhrInstrumentationHandler","createHeadersSafely","spanToJSON","hasSpanStreamingEnabled","timestampInSeconds","addPerformanceInstrumentationHandler","isPerformanceResourceTiming","resourceTimingToSpanAttributes","getLocationHref","stringMatchesSomePattern","SENTRY_XHR_DATA_KEY","hasSpansEnabled","setHttpStatus","parseXhrResponseHeaders","stripUrlQueryAndFragment","getClient","getActiveSpan","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","SentryNonRecordingSpan","getTraceData","baggageHeaderHasSentryValues"],"mappings":";;;;;;AA2CA;;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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AA,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;;;;;;"}
@@ -23,6 +23,7 @@ const reportingobserver = require('./integrations/reportingobserver.js');
23
23
  const httpclient = require('./integrations/httpclient.js');
24
24
  const contextlines = require('./integrations/contextlines.js');
25
25
  const graphqlClient = require('./integrations/graphqlClient.js');
26
+ const viewHierarchy = require('./integrations/view-hierarchy.js');
26
27
  const replay = require('@sentry-internal/replay');
27
28
  const replayCanvas = require('@sentry-internal/replay-canvas');
28
29
  const feedback = require('@sentry-internal/feedback');
@@ -162,6 +163,7 @@ exports.reportingObserverIntegration = reportingobserver.reportingObserverIntegr
162
163
  exports.httpClientIntegration = httpclient.httpClientIntegration;
163
164
  exports.contextLinesIntegration = contextlines.contextLinesIntegration;
164
165
  exports.graphqlClientIntegration = graphqlClient.graphqlClientIntegration;
166
+ exports.viewHierarchyIntegration = viewHierarchy.viewHierarchyIntegration;
165
167
  exports.getReplay = replay.getReplay;
166
168
  exports.replayIntegration = replay.replayIntegration;
167
169
  exports.replayCanvasIntegration = replayCanvas.replayCanvasIntegration;
@@ -170,6 +172,7 @@ exports.sendFeedback = feedback.sendFeedback;
170
172
  exports.defaultRequestInstrumentationOptions = request.defaultRequestInstrumentationOptions;
171
173
  exports.instrumentOutgoingRequests = request.instrumentOutgoingRequests;
172
174
  exports.browserTracingIntegration = browserTracingIntegration.browserTracingIntegration;
175
+ exports.isBotUserAgent = browserTracingIntegration.isBotUserAgent;
173
176
  exports.startBrowserTracingNavigationSpan = browserTracingIntegration.startBrowserTracingNavigationSpan;
174
177
  exports.startBrowserTracingPageLoadSpan = browserTracingIntegration.startBrowserTracingPageLoadSpan;
175
178
  exports.elementTimingIntegration = browserUtils.elementTimingIntegration;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -18,6 +18,18 @@ const _cultureContextIntegration = (() => {
18
18
  };
19
19
  }
20
20
  },
21
+ processSegmentSpan(span) {
22
+ const culture = getCultureContext();
23
+
24
+ if (culture) {
25
+ span.attributes = {
26
+ 'culture.locale': culture.locale,
27
+ 'culture.timezone': culture.timezone,
28
+ 'culture.calendar': culture.calendar,
29
+ ...span.attributes,
30
+ };
31
+ }
32
+ },
21
33
  };
22
34
  }) ;
23
35
 
@@ -1 +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;;;;"}
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 processSegmentSpan(span) {\n const culture = getCultureContext();\n\n if (culture) {\n span.attributes = {\n 'culture.locale': culture.locale,\n 'culture.timezone': culture.timezone,\n 'culture.calendar': culture.calendar,\n ...span.attributes,\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,IAAI,kBAAkB,CAAC,IAAI,EAAE;AAC7B,MAAM,MAAM,OAAA,GAAU,iBAAiB,EAAE;;AAEzC,MAAM,IAAI,OAAO,EAAE;AACnB,QAAQ,IAAI,CAAC,UAAA,GAAa;AAC1B,UAAU,gBAAgB,EAAE,OAAO,CAAC,MAAM;AAC1C,UAAU,kBAAkB,EAAE,OAAO,CAAC,QAAQ;AAC9C,UAAU,kBAAkB,EAAE,OAAO,CAAC,QAAQ;AAC9C,UAAU,GAAG,IAAI,CAAC,UAAU;AAC5B,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;;;;"}
@@ -28,7 +28,9 @@ function _updateSpanWithGraphQLData(client, options) {
28
28
  return;
29
29
  }
30
30
 
31
- const httpUrl = spanAttributes[core.SEMANTIC_ATTRIBUTE_URL_FULL] || spanAttributes['http.url'];
31
+ // Fall back to `url` because fetch instrumentation only sets `http.url` for absolute URLs;
32
+ // relative URLs end up only in `url` (see `getFetchSpanAttributes` in packages/core/src/fetch.ts).
33
+ const httpUrl = spanAttributes[core.SEMANTIC_ATTRIBUTE_URL_FULL] || spanAttributes['http.url'] || spanAttributes['url'];
32
34
  const httpMethod = spanAttributes[core.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD] || spanAttributes['http.method'];
33
35
 
34
36
  if (!core.isString(httpUrl) || !core.isString(httpMethod)) {
@@ -1 +1 @@
1
- {"version":3,"file":"graphqlClient.js","sources":["../../../../../src/integrations/graphqlClient.ts"],"sourcesContent":["import type { Client, IntegrationFn } from '@sentry/core';\nimport {\n defineIntegration,\n isString,\n SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n spanToJSON,\n stringMatchesSomePattern,\n} from '@sentry/core';\nimport type { FetchHint, XhrHint } from '@sentry-internal/browser-utils';\nimport { getBodyString, getFetchRequestArgBody, SENTRY_XHR_DATA_KEY } from '@sentry-internal/browser-utils';\n\ninterface GraphQLClientOptions {\n endpoints: Array<string | RegExp>;\n}\n\n/** Standard graphql request shape: https://graphql.org/learn/serving-over-http/#post-request-and-body */\ninterface GraphQLStandardRequest {\n query: string;\n operationName?: string;\n variables?: Record<string, unknown>;\n extensions?: Record<string, unknown>;\n}\n\n/** Persisted operation request */\ninterface GraphQLPersistedRequest {\n operationName: string;\n variables?: Record<string, unknown>;\n extensions: {\n persistedQuery: {\n version: number;\n sha256Hash: string;\n };\n } & Record<string, unknown>;\n}\n\ntype GraphQLRequestPayload = GraphQLStandardRequest | GraphQLPersistedRequest;\n\ninterface GraphQLOperation {\n operationType?: string;\n operationName?: string;\n}\n\nconst INTEGRATION_NAME = 'GraphQLClient';\n\nconst _graphqlClientIntegration = ((options: GraphQLClientOptions) => {\n return {\n name: INTEGRATION_NAME,\n setup(client: Client) {\n _updateSpanWithGraphQLData(client, options);\n _updateBreadcrumbWithGraphQLData(client, options);\n },\n };\n}) satisfies IntegrationFn;\n\nfunction _updateSpanWithGraphQLData(client: Client, options: GraphQLClientOptions): void {\n client.on('beforeOutgoingRequestSpan', (span, hint) => {\n const spanJSON = spanToJSON(span);\n\n const spanAttributes = spanJSON.data || {};\n const spanOp = spanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_OP];\n\n const isHttpClientSpan = spanOp === 'http.client';\n\n if (!isHttpClientSpan) {\n return;\n }\n\n const httpUrl = spanAttributes[SEMANTIC_ATTRIBUTE_URL_FULL] || spanAttributes['http.url'];\n const httpMethod = spanAttributes[SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD] || spanAttributes['http.method'];\n\n if (!isString(httpUrl) || !isString(httpMethod)) {\n return;\n }\n\n const { endpoints } = options;\n const isTracedGraphqlEndpoint = stringMatchesSomePattern(httpUrl, endpoints);\n const payload = getRequestPayloadXhrOrFetch(hint as XhrHint | FetchHint);\n\n if (isTracedGraphqlEndpoint && payload) {\n const graphqlBody = getGraphQLRequestPayload(payload);\n\n if (graphqlBody) {\n const operationInfo = _getGraphQLOperation(graphqlBody);\n span.updateName(`${httpMethod} ${httpUrl} (${operationInfo})`);\n\n // Handle standard requests - always capture the query document\n if (isStandardRequest(graphqlBody)) {\n span.setAttribute('graphql.document', graphqlBody.query);\n }\n\n // Handle persisted operations - capture hash for debugging\n if (isPersistedRequest(graphqlBody)) {\n span.setAttribute('graphql.persisted_query.hash.sha256', graphqlBody.extensions.persistedQuery.sha256Hash);\n span.setAttribute('graphql.persisted_query.version', graphqlBody.extensions.persistedQuery.version);\n }\n }\n }\n });\n}\n\nfunction _updateBreadcrumbWithGraphQLData(client: Client, options: GraphQLClientOptions): void {\n client.on('beforeOutgoingRequestBreadcrumb', (breadcrumb, handlerData) => {\n const { category, type, data } = breadcrumb;\n\n const isFetch = category === 'fetch';\n const isXhr = category === 'xhr';\n const isHttpBreadcrumb = type === 'http';\n\n if (isHttpBreadcrumb && (isFetch || isXhr)) {\n const httpUrl = data?.url;\n const { endpoints } = options;\n\n const isTracedGraphqlEndpoint = stringMatchesSomePattern(httpUrl, endpoints);\n const payload = getRequestPayloadXhrOrFetch(handlerData as XhrHint | FetchHint);\n\n if (isTracedGraphqlEndpoint && data && payload) {\n const graphqlBody = getGraphQLRequestPayload(payload);\n\n if (!data.graphql && graphqlBody) {\n const operationInfo = _getGraphQLOperation(graphqlBody);\n\n data['graphql.operation'] = operationInfo;\n\n if (isStandardRequest(graphqlBody)) {\n data['graphql.document'] = graphqlBody.query;\n }\n\n if (isPersistedRequest(graphqlBody)) {\n data['graphql.persisted_query.hash.sha256'] = graphqlBody.extensions.persistedQuery.sha256Hash;\n data['graphql.persisted_query.version'] = graphqlBody.extensions.persistedQuery.version;\n }\n }\n }\n }\n });\n}\n\n/**\n * @param requestBody - GraphQL request\n * @returns A formatted version of the request: 'TYPE NAME' or 'TYPE' or 'persisted NAME'\n */\nexport function _getGraphQLOperation(requestBody: GraphQLRequestPayload): string {\n // Handle persisted operations\n if (isPersistedRequest(requestBody)) {\n return `persisted ${requestBody.operationName}`;\n }\n\n // Handle standard GraphQL requests\n if (isStandardRequest(requestBody)) {\n const { query: graphqlQuery, operationName: graphqlOperationName } = requestBody;\n const { operationName = graphqlOperationName, operationType } = parseGraphQLQuery(graphqlQuery);\n const operationInfo = operationName ? `${operationType} ${operationName}` : `${operationType}`;\n return operationInfo;\n }\n\n // Fallback for unknown request types\n return 'unknown';\n}\n\n/**\n * Get the request body/payload based on the shape of the hint.\n *\n * Exported for tests only.\n */\nexport function getRequestPayloadXhrOrFetch(hint: XhrHint | FetchHint): string | undefined {\n const isXhr = 'xhr' in hint;\n\n let body: string | undefined;\n\n if (isXhr) {\n const sentryXhrData = hint.xhr[SENTRY_XHR_DATA_KEY];\n body = sentryXhrData && getBodyString(sentryXhrData.body)[0];\n } else {\n const sentryFetchData = getFetchRequestArgBody(hint.input);\n body = getBodyString(sentryFetchData)[0];\n }\n\n return body;\n}\n\n/**\n * Extract the name and type of the operation from the GraphQL query.\n *\n * Exported for tests only.\n */\nexport function parseGraphQLQuery(query: string): GraphQLOperation {\n const namedQueryRe = /^(?:\\s*)(query|mutation|subscription)(?:\\s*)(\\w+)(?:\\s*)[{(]/;\n const unnamedQueryRe = /^(?:\\s*)(query|mutation|subscription)(?:\\s*)[{(]/;\n\n const namedMatch = query.match(namedQueryRe);\n if (namedMatch) {\n return {\n operationType: namedMatch[1],\n operationName: namedMatch[2],\n };\n }\n\n const unnamedMatch = query.match(unnamedQueryRe);\n if (unnamedMatch) {\n return {\n operationType: unnamedMatch[1],\n operationName: undefined,\n };\n }\n return {\n operationType: undefined,\n operationName: undefined,\n };\n}\n\n/**\n * Helper to safely check if a value is a non-null object\n */\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Type guard to check if a request is a standard GraphQL request\n */\nfunction isStandardRequest(payload: unknown): payload is GraphQLStandardRequest {\n return isObject(payload) && typeof payload.query === 'string';\n}\n\n/**\n * Type guard to check if a request is a persisted operation request\n */\nfunction isPersistedRequest(payload: unknown): payload is GraphQLPersistedRequest {\n return (\n isObject(payload) &&\n typeof payload.operationName === 'string' &&\n isObject(payload.extensions) &&\n isObject(payload.extensions.persistedQuery) &&\n typeof payload.extensions.persistedQuery.sha256Hash === 'string' &&\n typeof payload.extensions.persistedQuery.version === 'number'\n );\n}\n\n/**\n * Extract the payload of a request if it's GraphQL.\n * Exported for tests only.\n * @param payload - A valid JSON string\n * @returns A POJO or undefined\n */\nexport function getGraphQLRequestPayload(payload: string): GraphQLRequestPayload | undefined {\n try {\n const requestBody = JSON.parse(payload);\n\n // Return any valid GraphQL request (standard, persisted, or APQ retry with both)\n if (isStandardRequest(requestBody) || isPersistedRequest(requestBody)) {\n return requestBody;\n }\n\n // Not a GraphQL request\n return undefined;\n } catch {\n // Invalid JSON\n return undefined;\n }\n}\n\n/**\n * This integration ensures that GraphQL requests made in the browser\n * have their GraphQL-specific data captured and attached to spans and breadcrumbs.\n */\nexport const graphqlClientIntegration = defineIntegration(_graphqlClientIntegration);\n"],"names":["spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_URL_FULL","SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD","isString","stringMatchesSomePattern","SENTRY_XHR_DATA_KEY","getBodyString","getFetchRequestArgBody","defineIntegration"],"mappings":";;;;;AA4CA,MAAM,gBAAA,GAA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;;;;;;"}
1
+ {"version":3,"file":"graphqlClient.js","sources":["../../../../../src/integrations/graphqlClient.ts"],"sourcesContent":["import type { Client, IntegrationFn } from '@sentry/core';\nimport {\n defineIntegration,\n isString,\n SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n spanToJSON,\n stringMatchesSomePattern,\n} from '@sentry/core';\nimport type { FetchHint, XhrHint } from '@sentry-internal/browser-utils';\nimport { getBodyString, getFetchRequestArgBody, SENTRY_XHR_DATA_KEY } from '@sentry-internal/browser-utils';\n\ninterface GraphQLClientOptions {\n endpoints: Array<string | RegExp>;\n}\n\n/** Standard graphql request shape: https://graphql.org/learn/serving-over-http/#post-request-and-body */\ninterface GraphQLStandardRequest {\n query: string;\n operationName?: string;\n variables?: Record<string, unknown>;\n extensions?: Record<string, unknown>;\n}\n\n/** Persisted operation request */\ninterface GraphQLPersistedRequest {\n operationName: string;\n variables?: Record<string, unknown>;\n extensions: {\n persistedQuery: {\n version: number;\n sha256Hash: string;\n };\n } & Record<string, unknown>;\n}\n\ntype GraphQLRequestPayload = GraphQLStandardRequest | GraphQLPersistedRequest;\n\ninterface GraphQLOperation {\n operationType?: string;\n operationName?: string;\n}\n\nconst INTEGRATION_NAME = 'GraphQLClient';\n\nconst _graphqlClientIntegration = ((options: GraphQLClientOptions) => {\n return {\n name: INTEGRATION_NAME,\n setup(client: Client) {\n _updateSpanWithGraphQLData(client, options);\n _updateBreadcrumbWithGraphQLData(client, options);\n },\n };\n}) satisfies IntegrationFn;\n\nfunction _updateSpanWithGraphQLData(client: Client, options: GraphQLClientOptions): void {\n client.on('beforeOutgoingRequestSpan', (span, hint) => {\n const spanJSON = spanToJSON(span);\n\n const spanAttributes = spanJSON.data || {};\n const spanOp = spanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_OP];\n\n const isHttpClientSpan = spanOp === 'http.client';\n\n if (!isHttpClientSpan) {\n return;\n }\n\n // Fall back to `url` because fetch instrumentation only sets `http.url` for absolute URLs;\n // relative URLs end up only in `url` (see `getFetchSpanAttributes` in packages/core/src/fetch.ts).\n const httpUrl = spanAttributes[SEMANTIC_ATTRIBUTE_URL_FULL] || spanAttributes['http.url'] || spanAttributes['url'];\n const httpMethod = spanAttributes[SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD] || spanAttributes['http.method'];\n\n if (!isString(httpUrl) || !isString(httpMethod)) {\n return;\n }\n\n const { endpoints } = options;\n const isTracedGraphqlEndpoint = stringMatchesSomePattern(httpUrl, endpoints);\n const payload = getRequestPayloadXhrOrFetch(hint as XhrHint | FetchHint);\n\n if (isTracedGraphqlEndpoint && payload) {\n const graphqlBody = getGraphQLRequestPayload(payload);\n\n if (graphqlBody) {\n const operationInfo = _getGraphQLOperation(graphqlBody);\n span.updateName(`${httpMethod} ${httpUrl} (${operationInfo})`);\n\n // Handle standard requests - always capture the query document\n if (isStandardRequest(graphqlBody)) {\n span.setAttribute('graphql.document', graphqlBody.query);\n }\n\n // Handle persisted operations - capture hash for debugging\n if (isPersistedRequest(graphqlBody)) {\n span.setAttribute('graphql.persisted_query.hash.sha256', graphqlBody.extensions.persistedQuery.sha256Hash);\n span.setAttribute('graphql.persisted_query.version', graphqlBody.extensions.persistedQuery.version);\n }\n }\n }\n });\n}\n\nfunction _updateBreadcrumbWithGraphQLData(client: Client, options: GraphQLClientOptions): void {\n client.on('beforeOutgoingRequestBreadcrumb', (breadcrumb, handlerData) => {\n const { category, type, data } = breadcrumb;\n\n const isFetch = category === 'fetch';\n const isXhr = category === 'xhr';\n const isHttpBreadcrumb = type === 'http';\n\n if (isHttpBreadcrumb && (isFetch || isXhr)) {\n const httpUrl = data?.url;\n const { endpoints } = options;\n\n const isTracedGraphqlEndpoint = stringMatchesSomePattern(httpUrl, endpoints);\n const payload = getRequestPayloadXhrOrFetch(handlerData as XhrHint | FetchHint);\n\n if (isTracedGraphqlEndpoint && data && payload) {\n const graphqlBody = getGraphQLRequestPayload(payload);\n\n if (!data.graphql && graphqlBody) {\n const operationInfo = _getGraphQLOperation(graphqlBody);\n\n data['graphql.operation'] = operationInfo;\n\n if (isStandardRequest(graphqlBody)) {\n data['graphql.document'] = graphqlBody.query;\n }\n\n if (isPersistedRequest(graphqlBody)) {\n data['graphql.persisted_query.hash.sha256'] = graphqlBody.extensions.persistedQuery.sha256Hash;\n data['graphql.persisted_query.version'] = graphqlBody.extensions.persistedQuery.version;\n }\n }\n }\n }\n });\n}\n\n/**\n * @param requestBody - GraphQL request\n * @returns A formatted version of the request: 'TYPE NAME' or 'TYPE' or 'persisted NAME'\n */\nexport function _getGraphQLOperation(requestBody: GraphQLRequestPayload): string {\n // Handle persisted operations\n if (isPersistedRequest(requestBody)) {\n return `persisted ${requestBody.operationName}`;\n }\n\n // Handle standard GraphQL requests\n if (isStandardRequest(requestBody)) {\n const { query: graphqlQuery, operationName: graphqlOperationName } = requestBody;\n const { operationName = graphqlOperationName, operationType } = parseGraphQLQuery(graphqlQuery);\n const operationInfo = operationName ? `${operationType} ${operationName}` : `${operationType}`;\n return operationInfo;\n }\n\n // Fallback for unknown request types\n return 'unknown';\n}\n\n/**\n * Get the request body/payload based on the shape of the hint.\n *\n * Exported for tests only.\n */\nexport function getRequestPayloadXhrOrFetch(hint: XhrHint | FetchHint): string | undefined {\n const isXhr = 'xhr' in hint;\n\n let body: string | undefined;\n\n if (isXhr) {\n const sentryXhrData = hint.xhr[SENTRY_XHR_DATA_KEY];\n body = sentryXhrData && getBodyString(sentryXhrData.body)[0];\n } else {\n const sentryFetchData = getFetchRequestArgBody(hint.input);\n body = getBodyString(sentryFetchData)[0];\n }\n\n return body;\n}\n\n/**\n * Extract the name and type of the operation from the GraphQL query.\n *\n * Exported for tests only.\n */\nexport function parseGraphQLQuery(query: string): GraphQLOperation {\n const namedQueryRe = /^(?:\\s*)(query|mutation|subscription)(?:\\s*)(\\w+)(?:\\s*)[{(]/;\n const unnamedQueryRe = /^(?:\\s*)(query|mutation|subscription)(?:\\s*)[{(]/;\n\n const namedMatch = query.match(namedQueryRe);\n if (namedMatch) {\n return {\n operationType: namedMatch[1],\n operationName: namedMatch[2],\n };\n }\n\n const unnamedMatch = query.match(unnamedQueryRe);\n if (unnamedMatch) {\n return {\n operationType: unnamedMatch[1],\n operationName: undefined,\n };\n }\n return {\n operationType: undefined,\n operationName: undefined,\n };\n}\n\n/**\n * Helper to safely check if a value is a non-null object\n */\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Type guard to check if a request is a standard GraphQL request\n */\nfunction isStandardRequest(payload: unknown): payload is GraphQLStandardRequest {\n return isObject(payload) && typeof payload.query === 'string';\n}\n\n/**\n * Type guard to check if a request is a persisted operation request\n */\nfunction isPersistedRequest(payload: unknown): payload is GraphQLPersistedRequest {\n return (\n isObject(payload) &&\n typeof payload.operationName === 'string' &&\n isObject(payload.extensions) &&\n isObject(payload.extensions.persistedQuery) &&\n typeof payload.extensions.persistedQuery.sha256Hash === 'string' &&\n typeof payload.extensions.persistedQuery.version === 'number'\n );\n}\n\n/**\n * Extract the payload of a request if it's GraphQL.\n * Exported for tests only.\n * @param payload - A valid JSON string\n * @returns A POJO or undefined\n */\nexport function getGraphQLRequestPayload(payload: string): GraphQLRequestPayload | undefined {\n try {\n const requestBody = JSON.parse(payload);\n\n // Return any valid GraphQL request (standard, persisted, or APQ retry with both)\n if (isStandardRequest(requestBody) || isPersistedRequest(requestBody)) {\n return requestBody;\n }\n\n // Not a GraphQL request\n return undefined;\n } catch {\n // Invalid JSON\n return undefined;\n }\n}\n\n/**\n * This integration ensures that GraphQL requests made in the browser\n * have their GraphQL-specific data captured and attached to spans and breadcrumbs.\n */\nexport const graphqlClientIntegration = defineIntegration(_graphqlClientIntegration);\n"],"names":["spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_URL_FULL","SEMANTIC_ATTRIBUTE_HTTP_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IAAA,OAAA,SAAA;AACA,EAAA,CAAA,CAAA,MAAA;AACA;AACA,IAAA,OAAA,SAAA;AACA,EAAA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAA,wBAAA,GAAAE,sBAAA,CAAA,yBAAA;;;;;;;;"}
@@ -12,7 +12,7 @@ const spanStreamingIntegration = core.defineIntegration(() => {
12
12
  // This avoids the classic double-opt-in problem we'd otherwise have in the browser SDK.
13
13
  const clientOptions = client.getOptions();
14
14
  if (!clientOptions.traceLifecycle) {
15
- debugBuild.DEBUG_BUILD && core.debug.log('[SpanStreaming] set `traceLifecycle` to "stream"');
15
+ debugBuild.DEBUG_BUILD && core.debug.log('[SpanStreaming] setting `traceLifecycle` to "stream"');
16
16
  clientOptions.traceLifecycle = 'stream';
17
17
  }
18
18
  },
@@ -1 +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 hasSpanStreamingEnabled,\n isStreamedBeforeSendSpanCallback,\n SpanBuffer,\n spanIsSampled,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\nexport const spanStreamingIntegration = defineIntegration(() => {\n return {\n name: 'SpanStreaming',\n\n beforeSetup(client) {\n // If users only set spanStreamingIntegration, without traceLifecycle, we set it to \"stream\" for them.\n // This avoids the classic double-opt-in problem we'd otherwise have in the browser SDK.\n const clientOptions = client.getOptions();\n if (!clientOptions.traceLifecycle) {\n DEBUG_BUILD && debug.log('[SpanStreaming] set `traceLifecycle` to \"stream\"');\n clientOptions.traceLifecycle = 'stream';\n }\n },\n\n setup(client) {\n const initialMessage = 'SpanStreaming integration requires';\n const fallbackMsg = 'Falling back to static trace lifecycle.';\n const clientOptions = client.getOptions();\n\n if (!hasSpanStreamingEnabled(client)) {\n clientOptions.traceLifecycle = 'static';\n DEBUG_BUILD && debug.warn(`${initialMessage} \\`traceLifecycle\\` to be set to \"stream\"! ${fallbackMsg}`);\n return;\n }\n\n const beforeSendSpan = clientOptions.beforeSendSpan;\n // If users misconfigure their SDK by opting into span streaming but\n // using an incompatible beforeSendSpan callback, we fall back to the static trace lifecycle.\n if (beforeSendSpan && !isStreamedBeforeSendSpanCallback(beforeSendSpan)) {\n clientOptions.traceLifecycle = 'static';\n DEBUG_BUILD &&\n debug.warn(`${initialMessage} a beforeSendSpan callback using \\`withStreamedSpan\\`! ${fallbackMsg}`);\n return;\n }\n\n const buffer = new SpanBuffer(client);\n\n client.on('afterSpanEnd', span => {\n // Negatively sampled spans must not be captured.\n // This happens because OTel and we create non-recording spans for negatively sampled spans\n // that go through the same life cycle as recording spans.\n if (!spanIsSampled(span)) {\n return;\n }\n buffer.add(captureSpan(span, client));\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 => {\n const traceId = segmentSpan.spanContext().traceId;\n setTimeout(() => {\n buffer.flush(traceId);\n }, 500);\n });\n },\n };\n}) satisfies IntegrationFn;\n"],"names":["defineIntegration","DEBUG_BUILD","debug","hasSpanStreamingEnabled","isStreamedBeforeSendSpanCallback","SpanBuffer","spanIsSampled","captureSpan"],"mappings":";;;;;MAYa,wBAAA,GAA2BA,sBAAiB,CAAC,MAAM;AAChE,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,eAAe;;AAEzB,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB;AACA;AACA,MAAM,MAAM,aAAA,GAAgB,MAAM,CAAC,UAAU,EAAE;AAC/C,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE;AACzC,QAAQC,0BAAeC,UAAK,CAAC,GAAG,CAAC,kDAAkD,CAAC;AACpF,QAAQ,aAAa,CAAC,cAAA,GAAiB,QAAQ;AAC/C,MAAM;AACN,IAAI,CAAC;;AAEL,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM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A;AACA,MAAA,CAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;;;"}
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 hasSpanStreamingEnabled,\n isStreamedBeforeSendSpanCallback,\n SpanBuffer,\n spanIsSampled,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\nexport const spanStreamingIntegration = defineIntegration(() => {\n return {\n name: 'SpanStreaming',\n\n beforeSetup(client) {\n // If users only set spanStreamingIntegration, without traceLifecycle, we set it to \"stream\" for them.\n // This avoids the classic double-opt-in problem we'd otherwise have in the browser SDK.\n const clientOptions = client.getOptions();\n if (!clientOptions.traceLifecycle) {\n DEBUG_BUILD && debug.log('[SpanStreaming] setting `traceLifecycle` to \"stream\"');\n clientOptions.traceLifecycle = 'stream';\n }\n },\n\n setup(client) {\n const initialMessage = 'SpanStreaming integration requires';\n const fallbackMsg = 'Falling back to static trace lifecycle.';\n const clientOptions = client.getOptions();\n\n if (!hasSpanStreamingEnabled(client)) {\n clientOptions.traceLifecycle = 'static';\n DEBUG_BUILD && debug.warn(`${initialMessage} \\`traceLifecycle\\` to be set to \"stream\"! ${fallbackMsg}`);\n return;\n }\n\n const beforeSendSpan = clientOptions.beforeSendSpan;\n // If users misconfigure their SDK by opting into span streaming but\n // using an incompatible beforeSendSpan callback, we fall back to the static trace lifecycle.\n if (beforeSendSpan && !isStreamedBeforeSendSpanCallback(beforeSendSpan)) {\n clientOptions.traceLifecycle = 'static';\n DEBUG_BUILD &&\n debug.warn(`${initialMessage} a beforeSendSpan callback using \\`withStreamedSpan\\`! ${fallbackMsg}`);\n return;\n }\n\n const buffer = new SpanBuffer(client);\n\n client.on('afterSpanEnd', span => {\n // Negatively sampled spans must not be captured.\n // This happens because OTel and we create non-recording spans for negatively sampled spans\n // that go through the same life cycle as recording spans.\n if (!spanIsSampled(span)) {\n return;\n }\n buffer.add(captureSpan(span, client));\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 => {\n const traceId = segmentSpan.spanContext().traceId;\n setTimeout(() => {\n buffer.flush(traceId);\n }, 500);\n });\n },\n };\n}) satisfies IntegrationFn;\n"],"names":["defineIntegration","DEBUG_BUILD","debug","hasSpanStreamingEnabled","isStreamedBeforeSendSpanCallback","SpanBuffer","spanIsSampled","captureSpan"],"mappings":";;;;;MAYa,wBAAA,GAA2BA,sBAAiB,CAAC,MAAM;AAChE,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,eAAe;;AAEzB,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB;AACA;AACA,MAAM,MAAM,aAAA,GAAgB,MAAM,CAAC,UAAU,EAAE;AAC/C,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE;AACzC,QAAQC,0BAAeC,UAAK,CAAC,GAAG,CAAC,sDAAsD,CAAC;AACxF,QAAQ,aAAa,CAAC,cAAA,GAAiB,QAAQ;AAC/C,MAAM;AACN,IAAI,CAAC;;AAEL,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,cAAA,GAAiB,oCAAoC;AACjE,MAAM,MAAM,WAAA,GAAc,yCAAyC;AACnE,MAAM,MAAM,aAAA,GAAgB,MAAM,CAAC,UAAU,EAAE;;AAE/C,MAAM,IAAI,CAACC,4BAAuB,CAAC,MAAM,CAAC,EAAE;AAC5C,QAAQ,aAAa,CAAC,cAAA,GAAiB,QAAQ;AAC/C,QAAQF,0BAAeC,UAAK,CAAC,IAAI,CAAC,CAAC,EAAA,cAAA,CAAA,2CAAA,EAAA,WAAA,CAAA,CAAA,CAAA;AACA,QAAA;AACA,MAAA;;AAEA,MAAA,MAAA,cAAA,GAAA,aAAA,CAAA,cAAA;AACA;AACA;AACA,MAAA,IAAA,cAAA,IAAA,CAAAE,qCAAA,CAAA,cAAA,CAAA,EAAA;AACA,QAAA,aAAA,CAAA,cAAA,GAAA,QAAA;AACA,QAAAH,sBAAA;AACA,UAAAC,UAAA,CAAA,IAAA,CAAA,CAAA,EAAA,cAAA,CAAA,uDAAA,EAAA,WAAA,CAAA,CAAA,CAAA;AACA,QAAA;AACA,MAAA;;AAEA,MAAA,MAAA,MAAA,GAAA,IAAAG,eAAA,CAAA,MAAA,CAAA;;AAEA,MAAA,MAAA,CAAA,EAAA,CAAA,cAAA,EAAA,IAAA,IAAA;AACA;AACA;AACA;AACA,QAAA,IAAA,CAAAC,kBAAA,CAAA,IAAA,CAAA,EAAA;AACA,UAAA;AACA,QAAA;AACA,QAAA,MAAA,CAAA,GAAA,CAAAC,gBAAA,CAAA,IAAA,EAAA,MAAA,CAAA,CAAA;AACA,MAAA,CAAA,CAAA;;AAEA;AACA;AACA;AACA,MAAA,MAAA,CAAA,EAAA,CAAA,qBAAA,EAAA,WAAA,IAAA;AACA,QAAA,MAAA,OAAA,GAAA,WAAA,CAAA,WAAA,EAAA,CAAA,OAAA;AACA,QAAA,UAAA,CAAA,MAAA;AACA,UAAA,MAAA,CAAA,KAAA,CAAA,OAAA,CAAA;AACA,QAAA,CAAA,EAAA,GAAA,CAAA;AACA,MAAA,CAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;;;"}
@@ -0,0 +1,101 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const helpers = require('../helpers.js');
5
+
6
+ /**
7
+ * An integration to include a view hierarchy attachment which contains the DOM.
8
+ */
9
+ const viewHierarchyIntegration = core.defineIntegration((options = {}) => {
10
+ const skipHtmlTags = ['script'];
11
+
12
+ /** Walk an element */
13
+ function walk(element, windows, depth = 0) {
14
+ if (!element) {
15
+ return;
16
+ }
17
+
18
+ // With Web Components, we need to walk into shadow DOMs
19
+ const children = 'shadowRoot' in element && element.shadowRoot ? element.shadowRoot.children : element.children;
20
+
21
+ for (const child of children) {
22
+ if (!(child instanceof HTMLElement)) {
23
+ continue;
24
+ }
25
+
26
+ const componentName = core.getComponentName(child, 1) || undefined;
27
+ const tagName = child.tagName.toLowerCase();
28
+
29
+ if (skipHtmlTags.includes(tagName)) {
30
+ continue;
31
+ }
32
+
33
+ const result = options.onElement?.({ element: child, componentName, tagName, depth }) || {};
34
+
35
+ if (result === 'skip') {
36
+ continue;
37
+ }
38
+
39
+ // Skip this element but include its children
40
+ if (result === 'children') {
41
+ walk(child, windows, depth + 1);
42
+ continue;
43
+ }
44
+
45
+ const { x, y, width, height } = child.getBoundingClientRect();
46
+
47
+ const window = {
48
+ identifier: (child.id || undefined) ,
49
+ type: componentName || tagName,
50
+ visible: true,
51
+ alpha: 1,
52
+ height,
53
+ width,
54
+ x,
55
+ y,
56
+ ...result,
57
+ };
58
+
59
+ const children = [];
60
+ window.children = children;
61
+
62
+ // Recursively walk the children
63
+ walk(child, window.children, depth + 1);
64
+
65
+ windows.push(window);
66
+ }
67
+ }
68
+
69
+ return {
70
+ name: 'ViewHierarchy',
71
+ processEvent: (event, hint) => {
72
+ // only capture for error events
73
+ if (event.type !== undefined || options.shouldAttach?.(event, hint) === false) {
74
+ return event;
75
+ }
76
+
77
+ const root = {
78
+ rendering_system: 'DOM',
79
+ positioning: 'absolute',
80
+ windows: [],
81
+ };
82
+
83
+ walk(options.rootElement?.() || helpers.WINDOW.document.body, root.windows);
84
+
85
+ const attachment = {
86
+ filename: 'view-hierarchy.json',
87
+ attachmentType: 'event.view_hierarchy',
88
+ contentType: 'application/json',
89
+ data: JSON.stringify(root),
90
+ };
91
+
92
+ hint.attachments = hint.attachments || [];
93
+ hint.attachments.push(attachment);
94
+
95
+ return event;
96
+ },
97
+ };
98
+ });
99
+
100
+ exports.viewHierarchyIntegration = viewHierarchyIntegration;
101
+ //# sourceMappingURL=view-hierarchy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-hierarchy.js","sources":["../../../../../src/integrations/view-hierarchy.ts"],"sourcesContent":["import type { Attachment, Event, EventHint, ViewHierarchyData, ViewHierarchyWindow } from '@sentry/core';\nimport { defineIntegration, getComponentName } from '@sentry/core';\nimport { WINDOW } from '../helpers';\n\ninterface OnElementArgs {\n /**\n * The element being processed.\n */\n element: HTMLElement;\n /**\n * Lowercase tag name of the element.\n */\n tagName: string;\n /**\n * The component name of the element.\n */\n componentName?: string;\n\n /**\n * The current depth of the element in the view hierarchy. The root element will have a depth of 0.\n *\n * This allows you to limit the traversal depth for large DOM trees.\n */\n depth?: number;\n}\n\ninterface Options {\n /**\n * Whether to attach the view hierarchy to the event.\n *\n * Default: Always attach.\n */\n shouldAttach?: (event: Event, hint: EventHint) => boolean;\n\n /**\n * A function that returns the root element to start walking the DOM from.\n *\n * Default: `window.document.body`\n */\n rootElement?: () => HTMLElement | undefined;\n\n /**\n * Called for each HTMLElement as we walk the DOM.\n *\n * Return an object to include the element with any additional properties.\n * Return `skip` to exclude the element and its children.\n * Return `children` to skip the element but include its children.\n */\n onElement?: (prop: OnElementArgs) => Record<string, string | number | boolean> | 'skip' | 'children';\n}\n\n/**\n * An integration to include a view hierarchy attachment which contains the DOM.\n */\nexport const viewHierarchyIntegration = defineIntegration((options: Options = {}) => {\n const skipHtmlTags = ['script'];\n\n /** Walk an element */\n function walk(element: HTMLElement, windows: ViewHierarchyWindow[], depth = 0): void {\n if (!element) {\n return;\n }\n\n // With Web Components, we need to walk into shadow DOMs\n const children = 'shadowRoot' in element && element.shadowRoot ? element.shadowRoot.children : element.children;\n\n for (const child of children) {\n if (!(child instanceof HTMLElement)) {\n continue;\n }\n\n const componentName = getComponentName(child, 1) || undefined;\n const tagName = child.tagName.toLowerCase();\n\n if (skipHtmlTags.includes(tagName)) {\n continue;\n }\n\n const result = options.onElement?.({ element: child, componentName, tagName, depth }) || {};\n\n if (result === 'skip') {\n continue;\n }\n\n // Skip this element but include its children\n if (result === 'children') {\n walk(child, windows, depth + 1);\n continue;\n }\n\n const { x, y, width, height } = child.getBoundingClientRect();\n\n const window: ViewHierarchyWindow = {\n identifier: (child.id || undefined) as string,\n type: componentName || tagName,\n visible: true,\n alpha: 1,\n height,\n width,\n x,\n y,\n ...result,\n };\n\n const children: ViewHierarchyWindow[] = [];\n window.children = children;\n\n // Recursively walk the children\n walk(child, window.children, depth + 1);\n\n windows.push(window);\n }\n }\n\n return {\n name: 'ViewHierarchy',\n processEvent: (event, hint) => {\n // only capture for error events\n if (event.type !== undefined || options.shouldAttach?.(event, hint) === false) {\n return event;\n }\n\n const root: ViewHierarchyData = {\n rendering_system: 'DOM',\n positioning: 'absolute',\n windows: [],\n };\n\n walk(options.rootElement?.() || WINDOW.document.body, root.windows);\n\n const attachment: Attachment = {\n filename: 'view-hierarchy.json',\n attachmentType: 'event.view_hierarchy',\n contentType: 'application/json',\n data: JSON.stringify(root),\n };\n\n hint.attachments = hint.attachments || [];\n hint.attachments.push(attachment);\n\n return event;\n },\n };\n});\n"],"names":["defineIntegration","getComponentName","WINDOW"],"mappings":";;;;;AAmDA;AACA;AACA;AACO,MAAM,wBAAA,GAA2BA,sBAAiB,CAAC,CAAC,OAAO,GAAY,EAAE,KAAK;AACrF,EAAE,MAAM,YAAA,GAAe,CAAC,QAAQ,CAAC;;AAEjC;AACA,EAAE,SAAS,IAAI,CAAC,OAAO,EAAe,OAAO,EAAyB,KAAA,GAAQ,CAAC,EAAQ;AACvF,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,MAAM;AACN,IAAI;;AAEJ;AACA,IAAI,MAAM,QAAA,GAAW,gBAAgB,OAAA,IAAW,OAAO,CAAC,aAAa,OAAO,CAAC,UAAU,CAAC,WAAW,OAAO,CAAC,QAAQ;;AAEnH,IAAI,KAAK,MAAM,KAAA,IAAS,QAAQ,EAAE;AAClC,MAAM,IAAI,EAAE,iBAAiB,WAAW,CAAC,EAAE;AAC3C,QAAQ;AACR,MAAM;;AAEN,MAAM,MAAM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,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,eAAe;AACzB,IAAI,YAAY,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK;AACnC;AACA,MAAM,IAAI,KAAK,CAAC,IAAA,KAAS,aAAa,OAAO,CAAC,YAAY,GAAG,KAAK,EAAE,IAAI,CAAA,KAAM,KAAK,EAAE;AACrF,QAAQ,OAAO,KAAK;AACpB,MAAM;;AAEN,MAAM,MAAM,IAAI,GAAsB;AACtC,QAAQ,gBAAgB,EAAE,KAAK;AAC/B,QAAQ,WAAW,EAAE,UAAU;AAC/B,QAAQ,OAAO,EAAE,EAAE;AACnB,OAAO;;AAEP,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,IAAG,IAAKC,cAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC;;AAEzE,MAAM,MAAM,UAAU,GAAe;AACrC,QAAQ,QAAQ,EAAE,qBAAqB;AACvC,QAAQ,cAAc,EAAE,sBAAsB;AAC9C,QAAQ,WAAW,EAAE,kBAAkB;AACvC,QAAQ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;AAClC,OAAO;;AAEP,MAAM,IAAI,CAAC,WAAA,GAAc,IAAI,CAAC,WAAA,IAAe,EAAE;AAC/C,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;;AAEvC,MAAM,OAAO,KAAK;AAClB,IAAI,CAAC;AACL,GAAG;AACH,CAAC;;;;"}
@@ -18,7 +18,7 @@ const BROWSER_TRACING_INTEGRATION_ID = 'BrowserTracing';
18
18
  const BOT_USER_AGENT_RE =
19
19
  /Googlebot|Google-InspectionTool|Storebot-Google|Bingbot|Slurp|DuckDuckBot|Baiduspider|YandexBot|Facebot|facebookexternalhit|LinkedInBot|Twitterbot|Applebot/i;
20
20
 
21
- function _isBotUserAgent() {
21
+ function isBotUserAgent() {
22
22
  const nav = helpers.WINDOW.navigator ;
23
23
  if (!nav?.userAgent) {
24
24
  return false;
@@ -104,7 +104,7 @@ const browserTracingIntegration = ((options = {}) => {
104
104
  ...options,
105
105
  };
106
106
 
107
- const _isBot = _isBotUserAgent();
107
+ const _isBot = isBotUserAgent();
108
108
 
109
109
  let _collectWebVitals;
110
110
  let lastInteractionTimestamp;
@@ -152,11 +152,13 @@ const browserTracingIntegration = ((options = {}) => {
152
152
  // This will generally always be defined here, because it is set in `setup()` of the integration
153
153
  // but technically, it is optional, so we guard here to be extra safe
154
154
  _collectWebVitals?.();
155
+ const spanStreamingEnabled = core.hasSpanStreamingEnabled(client);
155
156
  browserUtils.addPerformanceEntries(span, {
156
- recordClsOnPageloadSpan: !enableStandaloneClsSpans,
157
- recordLcpOnPageloadSpan: !enableStandaloneLcpSpans,
157
+ recordClsOnPageloadSpan: !spanStreamingEnabled && !enableStandaloneClsSpans,
158
+ recordLcpOnPageloadSpan: !spanStreamingEnabled && !enableStandaloneLcpSpans,
158
159
  ignoreResourceSpans,
159
160
  ignorePerformanceApiSpans,
161
+ spanStreamingEnabled,
160
162
  });
161
163
  setActiveIdleSpan(client, undefined);
162
164
 
@@ -213,13 +215,21 @@ const browserTracingIntegration = ((options = {}) => {
213
215
 
214
216
  core.registerSpanErrorInstrumentation();
215
217
 
218
+ const spanStreamingEnabled = core.hasSpanStreamingEnabled(client);
219
+
216
220
  _collectWebVitals = browserUtils.startTrackingWebVitals({
217
- recordClsStandaloneSpans: enableStandaloneClsSpans || false,
218
- recordLcpStandaloneSpans: enableStandaloneLcpSpans || false,
221
+ recordClsStandaloneSpans: spanStreamingEnabled ? undefined : enableStandaloneClsSpans || false,
222
+ recordLcpStandaloneSpans: spanStreamingEnabled ? undefined : enableStandaloneLcpSpans || false,
219
223
  client,
220
224
  });
221
225
 
222
- if (enableInp) {
226
+ if (spanStreamingEnabled) {
227
+ browserUtils.trackLcpAsSpan(client);
228
+ browserUtils.trackClsAsSpan(client);
229
+ if (enableInp) {
230
+ browserUtils.trackInpAsSpan();
231
+ }
232
+ } else if (enableInp) {
223
233
  browserUtils.startTrackingINP();
224
234
  }
225
235
 
@@ -610,6 +620,7 @@ exports.BROWSER_TRACING_INTEGRATION_ID = BROWSER_TRACING_INTEGRATION_ID;
610
620
  exports.browserTracingIntegration = browserTracingIntegration;
611
621
  exports.getMetaContent = getMetaContent;
612
622
  exports.getServerTiming = getServerTiming;
623
+ exports.isBotUserAgent = isBotUserAgent;
613
624
  exports.startBrowserTracingNavigationSpan = startBrowserTracingNavigationSpan;
614
625
  exports.startBrowserTracingPageLoadSpan = startBrowserTracingPageLoadSpan;
615
626
  //# sourceMappingURL=browserTracingIntegration.js.map