@sentry/browser 11.0.0-beta.1 → 11.0.0-rc.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/index.js +1 -0
- package/build/npm/cjs/dev/index.js.map +1 -1
- package/build/npm/cjs/dev/integrations/breadcrumbs.js +0 -32
- package/build/npm/cjs/dev/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/cjs/dev/integrations/contextlines.js +1 -1
- package/build/npm/cjs/dev/integrations/contextlines.js.map +1 -1
- package/build/npm/cjs/dev/integrations/httpcontext.js +12 -7
- package/build/npm/cjs/dev/integrations/httpcontext.js.map +1 -1
- package/build/npm/cjs/dev/integrations/webVitals.js +15 -4
- package/build/npm/cjs/dev/integrations/webVitals.js.map +1 -1
- package/build/npm/cjs/dev/sdk.js +1 -0
- package/build/npm/cjs/dev/sdk.js.map +1 -1
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js +51 -7
- package/build/npm/cjs/dev/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/dev/tracing/linkedTraces.js.map +1 -1
- package/build/npm/cjs/prod/index.js +1 -0
- package/build/npm/cjs/prod/index.js.map +1 -1
- package/build/npm/cjs/prod/integrations/breadcrumbs.js +0 -32
- package/build/npm/cjs/prod/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/cjs/prod/integrations/contextlines.js +1 -1
- package/build/npm/cjs/prod/integrations/contextlines.js.map +1 -1
- package/build/npm/cjs/prod/integrations/httpcontext.js +12 -7
- package/build/npm/cjs/prod/integrations/httpcontext.js.map +1 -1
- package/build/npm/cjs/prod/integrations/webVitals.js +15 -4
- package/build/npm/cjs/prod/integrations/webVitals.js.map +1 -1
- package/build/npm/cjs/prod/sdk.js +1 -0
- package/build/npm/cjs/prod/sdk.js.map +1 -1
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +51 -7
- package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/prod/tracing/linkedTraces.js.map +1 -1
- package/build/npm/esm/dev/index.js +1 -1
- package/build/npm/esm/dev/integrations/breadcrumbs.js +1 -33
- package/build/npm/esm/dev/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/esm/dev/integrations/contextlines.js +1 -1
- package/build/npm/esm/dev/integrations/contextlines.js.map +1 -1
- package/build/npm/esm/dev/integrations/httpcontext.js +14 -9
- package/build/npm/esm/dev/integrations/httpcontext.js.map +1 -1
- package/build/npm/esm/dev/integrations/webVitals.js +16 -5
- package/build/npm/esm/dev/integrations/webVitals.js.map +1 -1
- package/build/npm/esm/dev/package.json +1 -1
- package/build/npm/esm/dev/sdk.js +2 -1
- package/build/npm/esm/dev/sdk.js.map +1 -1
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js +53 -9
- package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/dev/tracing/linkedTraces.js.map +1 -1
- package/build/npm/esm/prod/index.js +1 -1
- package/build/npm/esm/prod/integrations/breadcrumbs.js +1 -33
- package/build/npm/esm/prod/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/esm/prod/integrations/contextlines.js +1 -1
- package/build/npm/esm/prod/integrations/contextlines.js.map +1 -1
- package/build/npm/esm/prod/integrations/httpcontext.js +14 -9
- package/build/npm/esm/prod/integrations/httpcontext.js.map +1 -1
- package/build/npm/esm/prod/integrations/webVitals.js +16 -5
- package/build/npm/esm/prod/integrations/webVitals.js.map +1 -1
- package/build/npm/esm/prod/package.json +1 -1
- package/build/npm/esm/prod/sdk.js +2 -1
- package/build/npm/esm/prod/sdk.js.map +1 -1
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js +53 -9
- package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/prod/tracing/linkedTraces.js.map +1 -1
- package/build/npm/types/exports.d.ts +1 -1
- package/build/npm/types/exports.d.ts.map +1 -1
- package/build/npm/types/integrations/breadcrumbs.d.ts +0 -1
- package/build/npm/types/integrations/breadcrumbs.d.ts.map +1 -1
- package/build/npm/types/integrations/contextlines.d.ts +1 -1
- package/build/npm/types/integrations/contextlines.d.ts.map +1 -1
- package/build/npm/types/integrations/httpcontext.d.ts.map +1 -1
- package/build/npm/types/integrations/webVitals.d.ts +35 -0
- package/build/npm/types/integrations/webVitals.d.ts.map +1 -1
- package/build/npm/types/sdk.d.ts.map +1 -1
- package/build/npm/types/tracing/browserTracingIntegration.d.ts +20 -0
- package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
- package/build/npm/types/tracing/linkedTraces.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumbs.js","sources":["../../../../../src/integrations/breadcrumbs.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport type {\n Breadcrumb,\n Client,\n Event as SentryEvent,\n FetchBreadcrumbData,\n FetchBreadcrumbHint,\n HandlerDataConsole,\n HandlerDataFetch,\n IntegrationFn,\n} from '@sentry/core';\nimport {\n addBreadcrumb,\n addConsoleInstrumentationHandler,\n addFetchInstrumentationHandler,\n debug,\n defineIntegration,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n getEventDescription,\n parseUrl,\n safeJoin,\n severityLevelFromString,\n} from '@sentry/core';\nimport type { FetchHint, HandlerDataDom, HandlerDataHistory, HandlerDataXhr } from '@sentry/browser-utils';\nimport {\n addClickKeypressInstrumentationHandler,\n addHistoryInstrumentationHandler,\n addXhrInstrumentationHandler,\n htmlTreeAsString,\n getComponentName,\n SENTRY_XHR_DATA_KEY,\n} from '@sentry/browser-utils';\nimport type { XhrBreadcrumbData, XhrBreadcrumbHint } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\n\ninterface BreadcrumbsOptions {\n console: boolean;\n dom:\n | boolean\n | {\n serializeAttribute?: string | string[];\n maxStringLength?: number;\n };\n fetch: boolean;\n history: boolean;\n sentry: boolean;\n xhr: boolean;\n}\n\n/** maxStringLength gets capped to prevent 100 breadcrumbs exceeding 1MB event payload size */\nconst MAX_ALLOWED_STRING_LENGTH = 1024;\n\nconst INTEGRATION_NAME = 'Breadcrumbs' as const;\n\nconst _breadcrumbsIntegration = ((options: Partial<BreadcrumbsOptions> = {}) => {\n const _options = {\n console: true,\n dom: true,\n fetch: true,\n history: true,\n sentry: true,\n xhr: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n // TODO(v11): Remove this functionality and use `consoleIntegration` from @sentry/core instead.\n if (_options.console) {\n addConsoleInstrumentationHandler(_getConsoleBreadcrumbHandler(client));\n }\n if (_options.dom) {\n addClickKeypressInstrumentationHandler(_getDomBreadcrumbHandler(client, _options.dom));\n }\n if (_options.xhr) {\n addXhrInstrumentationHandler(_getXhrBreadcrumbHandler(client));\n }\n if (_options.fetch) {\n addFetchInstrumentationHandler(_getFetchBreadcrumbHandler(client));\n }\n if (_options.history) {\n addHistoryInstrumentationHandler(_getHistoryBreadcrumbHandler(client));\n }\n if (_options.sentry) {\n client.on('beforeSendEvent', _getSentryBreadcrumbHandler(client));\n }\n },\n };\n}) satisfies IntegrationFn;\n\nexport const breadcrumbsIntegration = defineIntegration(_breadcrumbsIntegration);\n\n/**\n * Adds a breadcrumb for Sentry events or transactions if this option is enabled.\n */\nfunction _getSentryBreadcrumbHandler(client: Client): (event: SentryEvent) => void {\n return function addSentryBreadcrumb(event: SentryEvent): void {\n if (getClient() !== client) {\n return;\n }\n\n addBreadcrumb(\n {\n category: `sentry.${event.type === 'transaction' ? 'transaction' : 'event'}`,\n event_id: event.event_id,\n level: event.level,\n message: getEventDescription(event),\n },\n {\n event,\n },\n );\n };\n}\n\n/**\n * A HOC that creates a function that creates breadcrumbs from DOM API calls.\n * This is a HOC so that we get access to dom options in the closure.\n */\nfunction _getDomBreadcrumbHandler(\n client: Client,\n dom: BreadcrumbsOptions['dom'],\n): (handlerData: HandlerDataDom) => void {\n return function _innerDomBreadcrumb(handlerData: HandlerDataDom): void {\n if (getClient() !== client) {\n return;\n }\n\n let target;\n let componentName;\n let keyAttrs = typeof dom === 'object' ? dom.serializeAttribute : undefined;\n\n let maxStringLength =\n typeof dom === 'object' && typeof dom.maxStringLength === 'number' ? dom.maxStringLength : undefined;\n if (maxStringLength && maxStringLength > MAX_ALLOWED_STRING_LENGTH) {\n DEBUG_BUILD &&\n debug.warn(\n `\\`dom.maxStringLength\\` cannot exceed ${MAX_ALLOWED_STRING_LENGTH}, but a value of ${maxStringLength} was configured. Sentry will use ${MAX_ALLOWED_STRING_LENGTH} instead.`,\n );\n maxStringLength = MAX_ALLOWED_STRING_LENGTH;\n }\n\n if (typeof keyAttrs === 'string') {\n keyAttrs = [keyAttrs];\n }\n\n // Accessing event.target can throw (see getsentry/raven-js#838, #768)\n try {\n const event = handlerData.event as Event | Node;\n const element = _isEvent(event) ? event.target : event;\n\n target = htmlTreeAsString(element, { keyAttrs, maxStringLength });\n componentName = getComponentName(element);\n } catch {\n target = '<unknown>';\n }\n\n if (target.length === 0) {\n return;\n }\n\n const breadcrumb: Breadcrumb = {\n category: `ui.${handlerData.name}`,\n message: target,\n };\n\n if (componentName) {\n breadcrumb.data = { 'ui.component_name': componentName };\n }\n\n addBreadcrumb(breadcrumb, {\n event: handlerData.event,\n name: handlerData.name,\n global: handlerData.global,\n });\n };\n}\n\n/**\n * Creates breadcrumbs from console API calls\n */\nfunction _getConsoleBreadcrumbHandler(client: Client): (handlerData: HandlerDataConsole) => void {\n return function _consoleBreadcrumb(handlerData: HandlerDataConsole): void {\n if (getClient() !== client) {\n return;\n }\n\n const breadcrumb = {\n category: 'console',\n data: {\n arguments: handlerData.args,\n logger: 'console',\n },\n level: severityLevelFromString(handlerData.level),\n message: safeJoin(handlerData.args, ' '),\n };\n\n if (handlerData.level === 'assert') {\n if (handlerData.args[0] === false) {\n breadcrumb.message = `Assertion failed: ${safeJoin(handlerData.args.slice(1), ' ') || 'console.assert'}`;\n breadcrumb.data.arguments = handlerData.args.slice(1);\n } else {\n // Don't capture a breadcrumb for passed assertions\n return;\n }\n }\n\n addBreadcrumb(breadcrumb, {\n input: handlerData.args,\n level: handlerData.level,\n });\n };\n}\n\n/**\n * Creates breadcrumbs from XHR API calls\n */\nfunction _getXhrBreadcrumbHandler(client: Client): (handlerData: HandlerDataXhr) => void {\n return function _xhrBreadcrumb(handlerData: HandlerDataXhr): void {\n if (getClient() !== client) {\n return;\n }\n\n const { startTimestamp, endTimestamp } = handlerData;\n\n const sentryXhrData = handlerData.xhr[SENTRY_XHR_DATA_KEY];\n\n // We only capture complete, non-sentry requests\n if (!startTimestamp || !endTimestamp || !sentryXhrData) {\n return;\n }\n\n const { method, url, status_code, body } = sentryXhrData;\n\n const data: XhrBreadcrumbData = {\n method,\n url,\n status_code,\n };\n\n const hint: XhrBreadcrumbHint = {\n xhr: handlerData.xhr,\n input: body,\n startTimestamp,\n endTimestamp,\n };\n\n const breadcrumb = {\n category: 'xhr',\n data,\n type: 'http',\n level: getBreadcrumbLogLevelFromHttpStatusCode(status_code),\n };\n\n client.emit('beforeOutgoingRequestBreadcrumb', breadcrumb, hint);\n\n addBreadcrumb(breadcrumb, hint);\n };\n}\n\n/**\n * Creates breadcrumbs from fetch API calls\n */\nfunction _getFetchBreadcrumbHandler(client: Client): (handlerData: HandlerDataFetch) => void {\n return function _fetchBreadcrumb(handlerData: HandlerDataFetch): void {\n if (getClient() !== client) {\n return;\n }\n\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n if (handlerData.fetchData.url.match(/sentry_key/) && handlerData.fetchData.method === 'POST') {\n // We will not create breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)\n return;\n }\n\n if (handlerData.error) {\n const hint: FetchBreadcrumbHint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n const breadcrumb = {\n category: 'fetch',\n data: handlerData.fetchData,\n level: 'error',\n type: 'http',\n } satisfies Breadcrumb;\n\n client.emit('beforeOutgoingRequestBreadcrumb', breadcrumb, hint as FetchHint);\n\n addBreadcrumb(breadcrumb, hint);\n } else {\n const response = handlerData.response as Response | undefined;\n const data: FetchBreadcrumbData = {\n ...handlerData.fetchData,\n status_code: response?.status,\n };\n\n const hint: FetchBreadcrumbHint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n\n const breadcrumb = {\n category: 'fetch',\n data,\n type: 'http',\n level: getBreadcrumbLogLevelFromHttpStatusCode(data.status_code),\n };\n\n client.emit('beforeOutgoingRequestBreadcrumb', breadcrumb, hint as FetchHint);\n\n addBreadcrumb(breadcrumb, hint);\n }\n };\n}\n\n/**\n * Creates breadcrumbs from history API calls\n */\nfunction _getHistoryBreadcrumbHandler(client: Client): (handlerData: HandlerDataHistory) => void {\n return function _historyBreadcrumb(handlerData: HandlerDataHistory): void {\n if (getClient() !== client) {\n return;\n }\n\n let from: string | undefined = handlerData.from;\n let to: string | undefined = handlerData.to;\n const parsedLoc = parseUrl(WINDOW.location.href);\n let parsedFrom = from ? parseUrl(from) : undefined;\n const parsedTo = parseUrl(to);\n\n // Initial pushState doesn't provide `from` information\n if (!parsedFrom?.path) {\n parsedFrom = parsedLoc;\n }\n\n // Use only the path component of the URL if the URL matches the current\n // document (almost all the time when using pushState)\n if (parsedLoc.protocol === parsedTo.protocol && parsedLoc.host === parsedTo.host) {\n to = parsedTo.relative;\n }\n if (parsedLoc.protocol === parsedFrom.protocol && parsedLoc.host === parsedFrom.host) {\n from = parsedFrom.relative;\n }\n\n addBreadcrumb({\n category: 'navigation',\n data: {\n from,\n to,\n },\n });\n };\n}\n\nfunction _isEvent(event: unknown): event is Event {\n return !!event && !!(event as Record<string, unknown>).target;\n}\n"],"names":[],"mappings":";;;;;AAqDA,MAAM,yBAAA,GAA4B,IAAA;AAElC,MAAM,gBAAA,GAAmB,aAAA;AAEzB,MAAM,uBAAA,IAA2B,CAAC,O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UAAA,CAAW,YAAY,SAAA,CAAU,IAAA,KAAS,WAAW,IAAA,EAAM;AACpF,MAAA,IAAA,GAAO,UAAA,CAAW,QAAA;AAAA,IACpB;AAEA,IAAA,aAAA,CAAc;AAAA,MACZ,QAAA,EAAU,YAAA;AAAA,MACV,IAAA,EAAM;AAAA,QACJ,IAAA;AAAA,QACA;AAAA;AACF,KACD,CAAA;AAAA,EACH,CAAA;AACF;AAEA,SAAS,SAAS,KAAA,EAAgC;AAChD,EAAA,OAAO,CAAC,CAAC,KAAA,IAAS,CAAC,CAAE,KAAA,CAAkC,MAAA;AACzD;;;;"}
|
|
1
|
+
{"version":3,"file":"breadcrumbs.js","sources":["../../../../../src/integrations/breadcrumbs.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport type {\n Breadcrumb,\n Client,\n Event as SentryEvent,\n FetchBreadcrumbData,\n FetchBreadcrumbHint,\n HandlerDataFetch,\n IntegrationFn,\n} from '@sentry/core';\nimport {\n addBreadcrumb,\n addFetchInstrumentationHandler,\n debug,\n defineIntegration,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n getEventDescription,\n parseUrl,\n} from '@sentry/core';\nimport type { FetchHint, HandlerDataDom, HandlerDataHistory, HandlerDataXhr } from '@sentry/browser-utils';\nimport {\n addClickKeypressInstrumentationHandler,\n addHistoryInstrumentationHandler,\n addXhrInstrumentationHandler,\n htmlTreeAsString,\n getComponentName,\n SENTRY_XHR_DATA_KEY,\n} from '@sentry/browser-utils';\nimport type { XhrBreadcrumbData, XhrBreadcrumbHint } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\n\ninterface BreadcrumbsOptions {\n dom:\n | boolean\n | {\n serializeAttribute?: string | string[];\n maxStringLength?: number;\n };\n fetch: boolean;\n history: boolean;\n sentry: boolean;\n xhr: boolean;\n}\n\n/** maxStringLength gets capped to prevent 100 breadcrumbs exceeding 1MB event payload size */\nconst MAX_ALLOWED_STRING_LENGTH = 1024;\n\nconst INTEGRATION_NAME = 'Breadcrumbs' as const;\n\nconst _breadcrumbsIntegration = ((options: Partial<BreadcrumbsOptions> = {}) => {\n const _options = {\n dom: true,\n fetch: true,\n history: true,\n sentry: true,\n xhr: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n if (_options.dom) {\n addClickKeypressInstrumentationHandler(_getDomBreadcrumbHandler(client, _options.dom));\n }\n if (_options.xhr) {\n addXhrInstrumentationHandler(_getXhrBreadcrumbHandler(client));\n }\n if (_options.fetch) {\n addFetchInstrumentationHandler(_getFetchBreadcrumbHandler(client));\n }\n if (_options.history) {\n addHistoryInstrumentationHandler(_getHistoryBreadcrumbHandler(client));\n }\n if (_options.sentry) {\n client.on('beforeSendEvent', _getSentryBreadcrumbHandler(client));\n }\n },\n };\n}) satisfies IntegrationFn;\n\nexport const breadcrumbsIntegration = defineIntegration(_breadcrumbsIntegration);\n\n/**\n * Adds a breadcrumb for Sentry events or transactions if this option is enabled.\n */\nfunction _getSentryBreadcrumbHandler(client: Client): (event: SentryEvent) => void {\n return function addSentryBreadcrumb(event: SentryEvent): void {\n if (getClient() !== client) {\n return;\n }\n\n addBreadcrumb(\n {\n category: `sentry.${event.type === 'transaction' ? 'transaction' : 'event'}`,\n event_id: event.event_id,\n level: event.level,\n message: getEventDescription(event),\n },\n {\n event,\n },\n );\n };\n}\n\n/**\n * A HOC that creates a function that creates breadcrumbs from DOM API calls.\n * This is a HOC so that we get access to dom options in the closure.\n */\nfunction _getDomBreadcrumbHandler(\n client: Client,\n dom: BreadcrumbsOptions['dom'],\n): (handlerData: HandlerDataDom) => void {\n return function _innerDomBreadcrumb(handlerData: HandlerDataDom): void {\n if (getClient() !== client) {\n return;\n }\n\n let target;\n let componentName;\n let keyAttrs = typeof dom === 'object' ? dom.serializeAttribute : undefined;\n\n let maxStringLength =\n typeof dom === 'object' && typeof dom.maxStringLength === 'number' ? dom.maxStringLength : undefined;\n if (maxStringLength && maxStringLength > MAX_ALLOWED_STRING_LENGTH) {\n DEBUG_BUILD &&\n debug.warn(\n `\\`dom.maxStringLength\\` cannot exceed ${MAX_ALLOWED_STRING_LENGTH}, but a value of ${maxStringLength} was configured. Sentry will use ${MAX_ALLOWED_STRING_LENGTH} instead.`,\n );\n maxStringLength = MAX_ALLOWED_STRING_LENGTH;\n }\n\n if (typeof keyAttrs === 'string') {\n keyAttrs = [keyAttrs];\n }\n\n // Accessing event.target can throw (see getsentry/raven-js#838, #768)\n try {\n const event = handlerData.event as Event | Node;\n const element = _isEvent(event) ? event.target : event;\n\n target = htmlTreeAsString(element, { keyAttrs, maxStringLength });\n componentName = getComponentName(element);\n } catch {\n target = '<unknown>';\n }\n\n if (target.length === 0) {\n return;\n }\n\n const breadcrumb: Breadcrumb = {\n category: `ui.${handlerData.name}`,\n message: target,\n };\n\n if (componentName) {\n breadcrumb.data = { 'ui.component_name': componentName };\n }\n\n addBreadcrumb(breadcrumb, {\n event: handlerData.event,\n name: handlerData.name,\n global: handlerData.global,\n });\n };\n}\n\n/**\n * Creates breadcrumbs from XHR API calls\n */\nfunction _getXhrBreadcrumbHandler(client: Client): (handlerData: HandlerDataXhr) => void {\n return function _xhrBreadcrumb(handlerData: HandlerDataXhr): void {\n if (getClient() !== client) {\n return;\n }\n\n const { startTimestamp, endTimestamp } = handlerData;\n\n const sentryXhrData = handlerData.xhr[SENTRY_XHR_DATA_KEY];\n\n // We only capture complete, non-sentry requests\n if (!startTimestamp || !endTimestamp || !sentryXhrData) {\n return;\n }\n\n const { method, url, status_code, body } = sentryXhrData;\n\n const data: XhrBreadcrumbData = {\n method,\n url,\n status_code,\n };\n\n const hint: XhrBreadcrumbHint = {\n xhr: handlerData.xhr,\n input: body,\n startTimestamp,\n endTimestamp,\n };\n\n const breadcrumb = {\n category: 'xhr',\n data,\n type: 'http',\n level: getBreadcrumbLogLevelFromHttpStatusCode(status_code),\n };\n\n client.emit('beforeOutgoingRequestBreadcrumb', breadcrumb, hint);\n\n addBreadcrumb(breadcrumb, hint);\n };\n}\n\n/**\n * Creates breadcrumbs from fetch API calls\n */\nfunction _getFetchBreadcrumbHandler(client: Client): (handlerData: HandlerDataFetch) => void {\n return function _fetchBreadcrumb(handlerData: HandlerDataFetch): void {\n if (getClient() !== client) {\n return;\n }\n\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n if (handlerData.fetchData.url.match(/sentry_key/) && handlerData.fetchData.method === 'POST') {\n // We will not create breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)\n return;\n }\n\n if (handlerData.error) {\n const hint: FetchBreadcrumbHint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n const breadcrumb = {\n category: 'fetch',\n data: handlerData.fetchData,\n level: 'error',\n type: 'http',\n } satisfies Breadcrumb;\n\n client.emit('beforeOutgoingRequestBreadcrumb', breadcrumb, hint as FetchHint);\n\n addBreadcrumb(breadcrumb, hint);\n } else {\n const response = handlerData.response as Response | undefined;\n const data: FetchBreadcrumbData = {\n ...handlerData.fetchData,\n status_code: response?.status,\n };\n\n const hint: FetchBreadcrumbHint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n\n const breadcrumb = {\n category: 'fetch',\n data,\n type: 'http',\n level: getBreadcrumbLogLevelFromHttpStatusCode(data.status_code),\n };\n\n client.emit('beforeOutgoingRequestBreadcrumb', breadcrumb, hint as FetchHint);\n\n addBreadcrumb(breadcrumb, hint);\n }\n };\n}\n\n/**\n * Creates breadcrumbs from history API calls\n */\nfunction _getHistoryBreadcrumbHandler(client: Client): (handlerData: HandlerDataHistory) => void {\n return function _historyBreadcrumb(handlerData: HandlerDataHistory): void {\n if (getClient() !== client) {\n return;\n }\n\n let from: string | undefined = handlerData.from;\n let to: string | undefined = handlerData.to;\n const parsedLoc = parseUrl(WINDOW.location.href);\n let parsedFrom = from ? parseUrl(from) : undefined;\n const parsedTo = parseUrl(to);\n\n // Initial pushState doesn't provide `from` information\n if (!parsedFrom?.path) {\n parsedFrom = parsedLoc;\n }\n\n // Use only the path component of the URL if the URL matches the current\n // document (almost all the time when using pushState)\n if (parsedLoc.protocol === parsedTo.protocol && parsedLoc.host === parsedTo.host) {\n to = parsedTo.relative;\n }\n if (parsedLoc.protocol === parsedFrom.protocol && parsedLoc.host === parsedFrom.host) {\n from = parsedFrom.relative;\n }\n\n addBreadcrumb({\n category: 'navigation',\n data: {\n from,\n to,\n },\n });\n };\n}\n\nfunction _isEvent(event: unknown): event is Event {\n return !!event && !!(event as Record<string, unknown>).target;\n}\n"],"names":[],"mappings":";;;;;AAgDA,MAAM,yBAAA,GAA4B,IAAA;AAElC,MAAM,gBAAA,GAAmB,aAAA;AAEzB,MAAM,uBAAA,IAA2B,CAAC,OAAA,GAAuC,EAAC,KAAM;AAC9E,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,GAAA,EAAK,IAAA;AAAA,IACL,KAAA,EAAO,IAAA;AAAA,IACP,OAAA,EAAS,IAAA;AAAA,IACT,MAAA,EAAQ,IAAA;AAAA,IACR,GAAA,EAAK,IAAA;AAAA,IACL,GAAG;AAAA,GACL;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,MAAM,MAAA,EAAQ;AACZ,MAAA,IAAI,SAAS,GAAA,EAAK;AAChB,QAAA,sCAAA,CAAuC,wBAAA,CAAyB,MAAA,EAAQ,QAAA,CAAS,GAAG,CAAC,CAAA;AAAA,MACvF;AACA,MAAA,IAAI,SAAS,GAAA,EAAK;AAChB,QAAA,4BAAA,CAA6B,wBAAA,CAAyB,MAAM,CAAC,CAAA;AAAA,MAC/D;AACA,MAAA,IAAI,SAAS,KAAA,EAAO;AAClB,QAAA,8BAAA,CAA+B,0BAAA,CAA2B,MAAM,CAAC,CAAA;AAAA,MACnE;AACA,MAAA,IAAI,SAAS,OAAA,EAAS;AACpB,QAAA,gCAAA,CAAiC,4BAAA,CAA6B,MAA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AAC1B,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,OAA2B,WAAA,CAAY,IAAA;AAC3C,IAAA,IAAI,KAAyB,WAAA,CAAY,EAAA;AACzC,IAAA,MAAM,SAAA,GAAY,QAAA,CAAS,MAAA,CAAO,QAAA,CAAS,IAAI,CAAA;AAC/C,IAAA,IAAI,UAAA,GAAa,IAAA,GAAO,QAAA,CAAS,IAAI,CAAA,GAAI,MAAA;AACzC,IAAA,MAAM,QAAA,GAAW,SAAS,EAAE,CAAA;AAG5B,IAAA,IAAI,CAAC,YAAY,IAAA,EAAM;AACrB,MAAA,UAAA,GAAa,SAAA;AAAA,IACf;AAIA,IAAA,IAAI,UAAU,QAAA,KAAa,QAAA,CAAS,YAAY,SAAA,CAAU,IAAA,KAAS,SAAS,IAAA,EAAM;AAChF,MAAA,EAAA,GAAK,QAAA,CAAS,QAAA;AAAA,IAChB;AACA,IAAA,IAAI,UAAU,QAAA,KAAa,UAAA,CAAW,YAAY,SAAA,CAAU,IAAA,KAAS,WAAW,IAAA,EAAM;AACpF,MAAA,IAAA,GAAO,UAAA,CAAW,QAAA;AAAA,IACpB;AAEA,IAAA,aAAA,CAAc;AAAA,MACZ,QAAA,EAAU,YAAA;AAAA,MACV,IAAA,EAAM;AAAA,QACJ,IAAA;AAAA,QACA;AAAA;AACF,KACD,CAAA;AAAA,EACH,CAAA;AACF;AAEA,SAAS,SAAS,KAAA,EAAgC;AAChD,EAAA,OAAO,CAAC,CAAC,KAAA,IAAS,CAAC,CAAE,KAAA,CAAkC,MAAA;AACzD;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineIntegration, GLOBAL_OBJ, stripUrlQueryAndFragment, addContextToFrame } from '@sentry/core';
|
|
2
2
|
|
|
3
3
|
const WINDOW = GLOBAL_OBJ;
|
|
4
|
-
const DEFAULT_LINES_OF_CONTEXT =
|
|
4
|
+
const DEFAULT_LINES_OF_CONTEXT = 5;
|
|
5
5
|
const INTEGRATION_NAME = "ContextLines";
|
|
6
6
|
const _contextLinesIntegration = ((options = {}) => {
|
|
7
7
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextlines.js","sources":["../../../../../src/integrations/contextlines.ts"],"sourcesContent":["import type { Event, IntegrationFn, StackFrame } from '@sentry/core';\nimport { addContextToFrame, defineIntegration, GLOBAL_OBJ, stripUrlQueryAndFragment } from '@sentry/core';\n\nconst WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nconst DEFAULT_LINES_OF_CONTEXT =
|
|
1
|
+
{"version":3,"file":"contextlines.js","sources":["../../../../../src/integrations/contextlines.ts"],"sourcesContent":["import type { Event, IntegrationFn, StackFrame } from '@sentry/core';\nimport { addContextToFrame, defineIntegration, GLOBAL_OBJ, stripUrlQueryAndFragment } from '@sentry/core';\n\nconst WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nconst DEFAULT_LINES_OF_CONTEXT = 5;\n\nconst INTEGRATION_NAME = 'ContextLines' as const;\n\ninterface ContextLinesOptions {\n /**\n * Sets the number of context lines for each frame when loading a file.\n * Defaults to `dataCollection.frameContextLines` (5).\n *\n * Set to 0 to disable loading and inclusion of source files.\n *\n * When set, this option takes precedence over `dataCollection.frameContextLines`.\n **/\n frameContextLines?: number;\n}\n\nconst _contextLinesIntegration = ((options: ContextLinesOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n processEvent(event, _hint, client) {\n const contextLines =\n options.frameContextLines ?? client?.getDataCollectionOptions().frameContextLines ?? DEFAULT_LINES_OF_CONTEXT;\n return addSourceContext(event, contextLines);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Collects source context lines around the lines of stackframes pointing to JS embedded in\n * the current page's HTML.\n *\n * This integration DOES NOT work for stack frames pointing to JS files that are loaded by the browser.\n * For frames pointing to files, context lines are added during ingestion and symbolication\n * by attempting to download the JS files to the Sentry backend.\n *\n * Use this integration if you have inline JS code in HTML pages that can't be accessed\n * by our backend (e.g. due to a login-protected page).\n */\nexport const contextLinesIntegration = defineIntegration(_contextLinesIntegration);\n\n/**\n * Processes an event and adds context lines.\n */\nfunction addSourceContext(event: Event, contextLines: number): Event {\n const doc = WINDOW.document;\n const htmlFilename = WINDOW.location && stripUrlQueryAndFragment(WINDOW.location.href);\n if (!doc || !htmlFilename) {\n return event;\n }\n\n const exceptions = event.exception?.values;\n if (!exceptions?.length) {\n return event;\n }\n\n const html = doc.documentElement.innerHTML;\n if (!html) {\n return event;\n }\n\n const htmlLines = ['<!DOCTYPE html>', '<html>', ...html.split('\\n'), '</html>'];\n\n exceptions.forEach(exception => {\n const stacktrace = exception.stacktrace;\n if (stacktrace?.frames) {\n stacktrace.frames = stacktrace.frames.map(frame =>\n applySourceContextToFrame(frame, htmlLines, htmlFilename, contextLines),\n );\n }\n });\n\n return event;\n}\n\n/**\n * Only exported for testing\n */\nexport function applySourceContextToFrame(\n frame: StackFrame,\n htmlLines: string[],\n htmlFilename: string,\n linesOfContext: number,\n): StackFrame {\n if (frame.filename !== htmlFilename || !frame.lineno || !htmlLines.length) {\n return frame;\n }\n\n addContextToFrame(htmlLines, frame, linesOfContext);\n\n return frame;\n}\n"],"names":[],"mappings":";;AAGA,MAAM,MAAA,GAAS,UAAA;AAEf,MAAM,wBAAA,GAA2B,CAAA;AAEjC,MAAM,gBAAA,GAAmB,cAAA;AAczB,MAAM,wBAAA,IAA4B,CAAC,OAAA,GAA+B,EAAC,KAAM;AACvE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,YAAA,CAAa,KAAA,EAAO,KAAA,EAAO,MAAA,EAAQ;AACjC,MAAA,MAAM,eACJ,OAAA,CAAQ,iBAAA,IAAqB,MAAA,EAAQ,wBAAA,GAA2B,iBAAA,IAAqB,wBAAA;AACvF,MAAA,OAAO,gBAAA,CAAiB,OAAO,YAAY,CAAA;AAAA,IAC7C;AAAA,GACF;AACF,CAAA,CAAA;AAaO,MAAM,uBAAA,GAA0B,kBAA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AkB,SAAA,EAAW,OAAO,cAAc,CAAA;AAElD,EAAA,OAAO,KAAA;AACT;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineIntegration,
|
|
1
|
+
import { defineIntegration, _INTERNAL_filterKeyValueData, safeSetSpanJSONAttributes, filterCollectedUrl } from '@sentry/core';
|
|
2
2
|
import { WINDOW, getHttpRequestData } from '../helpers.js';
|
|
3
|
-
import { URL_FULL } from '@sentry/conventions/attributes';
|
|
3
|
+
import { HTTP_REQUEST_HEADER_KEY_BASE, URL_FULL, SENTRY_OP, USER_AGENT_ORIGINAL } from '@sentry/conventions/attributes';
|
|
4
4
|
|
|
5
5
|
const httpContextIntegration = defineIntegration(() => {
|
|
6
6
|
return {
|
|
@@ -23,8 +23,7 @@ const httpContextIntegration = defineIntegration(() => {
|
|
|
23
23
|
...Object.keys(headers).length > 0 ? { headers } : { headers: void 0 }
|
|
24
24
|
};
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
const spanOp = span.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP];
|
|
26
|
+
processSpan(span, client) {
|
|
28
27
|
if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {
|
|
29
28
|
return;
|
|
30
29
|
}
|
|
@@ -33,12 +32,18 @@ const httpContextIntegration = defineIntegration(() => {
|
|
|
33
32
|
reqData.headers,
|
|
34
33
|
client.getDataCollectionOptions().httpHeaders.request
|
|
35
34
|
);
|
|
35
|
+
const referer = headers["Referer"];
|
|
36
36
|
safeSetSpanJSONAttributes(span, {
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
[
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
// This attribute is used by the "Filter out events from legacy browsers and crawlers" features on the Sentry backend.
|
|
38
|
+
// Therefore, it's set on every span.
|
|
39
|
+
[USER_AGENT_ORIGINAL]: headers["User-Agent"],
|
|
40
|
+
// These attributes, we only need on the segment span (analogous to the `request` context for events)
|
|
41
|
+
...span.is_segment && {
|
|
42
|
+
// Coerce empty string to undefined so the helper's nullish check drops it,
|
|
43
|
+
// rather than writing an empty `url.full` attribute onto the span.
|
|
44
|
+
[URL_FULL]: span.attributes?.[SENTRY_OP] !== "http.client" ? filterCollectedUrl(reqData.url) : void 0,
|
|
45
|
+
[`${HTTP_REQUEST_HEADER_KEY_BASE}.referer`]: referer ? [referer] : void 0
|
|
46
|
+
}
|
|
42
47
|
});
|
|
43
48
|
}
|
|
44
49
|
};
|
|
@@ -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 { _INTERNAL_filterKeyValueData, defineIntegration, safeSetSpanJSONAttributes } from '@sentry/core';\nimport { getHttpRequestData, WINDOW } from '../helpers';\nimport { filterCollectedUrl } from '@sentry/core';\nimport { HTTP_REQUEST_HEADER_KEY_BASE, SENTRY_OP, URL_FULL, USER_AGENT_ORIGINAL } from '@sentry/conventions/attributes';\n\n/**\n * Collects information about HTTP request headers and\n * attaches them to the event.\n */\nexport const httpContextIntegration = defineIntegration(() => {\n return {\n name: 'HttpContext' as const,\n preprocessEvent(event, _hint, client) {\n // if none of the information we want exists, don't bother\n if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {\n return;\n }\n\n const { url, headers: collectedHeaders } = getHttpRequestData();\n\n // We only filter the headers we collected ourselves, so headers the user set are left alone. Going by key\n // means we also catch these headers when `browserTracingIntegration` already put them on the event.\n const behavior = client.getDataCollectionOptions().httpHeaders.request;\n const userHeaders = Object.entries(event.request?.headers ?? {}).filter(([key]) => !(key in collectedHeaders));\n\n const headers = {\n ..._INTERNAL_filterKeyValueData(collectedHeaders, behavior),\n ...Object.fromEntries(userHeaders),\n };\n\n event.request = {\n // The URL isn't gated by `dataCollection`, same as on the server.\n url,\n ...event.request,\n ...(Object.keys(headers).length > 0 ? { headers } : { headers: undefined }),\n };\n },\n\n processSpan(span, client) {\n // if none of the information we want exists, don't bother\n if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {\n return;\n }\n\n const reqData = getHttpRequestData();\n\n // `httpHeadersToSpanAttributes` would also work here, but its cookie and array handling never runs for these\n // two headers and costs every browser bundle ~400B gzip.\n const headers = _INTERNAL_filterKeyValueData(\n reqData.headers,\n client.getDataCollectionOptions().httpHeaders.request,\n );\n const referer = headers['Referer'];\n\n safeSetSpanJSONAttributes(span, {\n // This attribute is used by the \"Filter out events from legacy browsers and crawlers\" features on the Sentry backend.\n // Therefore, it's set on every span.\n [USER_AGENT_ORIGINAL]: headers['User-Agent'],\n\n // These attributes, we only need on the segment span (analogous to the `request` context for events)\n ...(span.is_segment && {\n // Coerce empty string to undefined so the helper's nullish check drops it,\n // rather than writing an empty `url.full` attribute onto the span.\n [URL_FULL]: span.attributes?.[SENTRY_OP] !== 'http.client' ? filterCollectedUrl(reqData.url) : undefined,\n [`${HTTP_REQUEST_HEADER_KEY_BASE}.referer`]: referer ? [referer] : undefined,\n }),\n });\n },\n };\n});\n"],"names":[],"mappings":";;;;AASO,MAAM,sBAAA,GAAyB,kBAAkB,MAAM;AAC5D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,aAAA;AAAA,IACN,eAAA,CAAgB,KAAA,EAAO,KAAA,EAAO,MAAA,EAAQ;AAEpC,MAAA,IAAI,CAAC,OAAO,SAAA,IAAa,CAAC,OAAO,QAAA,IAAY,CAAC,OAAO,QAAA,EAAU;AAC7D,QAAA;AAAA,MACF;AAEA,MAAA,MAAM,EAAE,GAAA,EAAK,OAAA,EAAS,gBAAA,KAAqB,kBAAA,EAAmB;AAI9D,MAAA,MAAM,QAAA,GAAW,MAAA,CAAO,wBAAA,EAAyB,CAAE,WAAA,CAAY,OAAA;AAC/D,MAAA,MAAM,cAAc,MAAA,CAAO,OAAA,CAAQ,KAAA,CAAM,OAAA,EAAS,WAAW,EAAE,CAAA,CAAE,M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AAU,CAAC,OAAO,CAAA,GAAI;AAAA;AACrE,OACD,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAC;;;;"}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { defineIntegration, hasSpanStreamingEnabled } from '@sentry/core';
|
|
2
|
-
import { registerInpInteractionListener, startTrackingWebVitals, addWebVitalsToSpan, trackLcpAsSpan, trackClsAsSpan, trackInpAsSpan } from '@sentry/browser-utils';
|
|
2
|
+
import { registerInpInteractionListener, supportsSoftNavigations, enableSoftNavigationReporting, startSoftNavigationCorrelation, enableBfcacheReporting, startTrackingWebVitals, addWebVitalsToSpan, trackLcpAsSpan, trackClsAsSpan, trackInpAsSpan } from '@sentry/browser-utils';
|
|
3
3
|
|
|
4
4
|
const WEB_VITALS_INTEGRATION_NAME = "WebVitals";
|
|
5
5
|
const webVitalsIntegration = defineIntegration((options = {}) => {
|
|
6
|
-
const
|
|
6
|
+
const { ignore = [], softNavigations = true, bfcacheNavigations = true } = options;
|
|
7
|
+
const ignored = new Set(ignore);
|
|
7
8
|
return {
|
|
8
9
|
name: WEB_VITALS_INTEGRATION_NAME,
|
|
9
10
|
setup(client) {
|
|
10
11
|
const spanStreamingEnabled = hasSpanStreamingEnabled(client);
|
|
12
|
+
const reportSoftNavs = softNavigations && spanStreamingEnabled && supportsSoftNavigations();
|
|
13
|
+
const reportBfcache = bfcacheNavigations && spanStreamingEnabled;
|
|
14
|
+
const perNavigation = reportSoftNavs || reportBfcache;
|
|
15
|
+
if (reportSoftNavs) {
|
|
16
|
+
enableSoftNavigationReporting();
|
|
17
|
+
startSoftNavigationCorrelation(client);
|
|
18
|
+
}
|
|
19
|
+
if (reportBfcache) {
|
|
20
|
+
enableBfcacheReporting();
|
|
21
|
+
}
|
|
11
22
|
const trackClsOnPageloadSpan = !spanStreamingEnabled && !ignored.has("cls");
|
|
12
23
|
const trackLcpOnPageloadSpan = !spanStreamingEnabled && !ignored.has("lcp");
|
|
13
24
|
const finalizeWebVitals = startTrackingWebVitals({
|
|
@@ -32,14 +43,14 @@ const webVitalsIntegration = defineIntegration((options = {}) => {
|
|
|
32
43
|
});
|
|
33
44
|
if (spanStreamingEnabled) {
|
|
34
45
|
if (!ignored.has("lcp")) {
|
|
35
|
-
trackLcpAsSpan(client);
|
|
46
|
+
trackLcpAsSpan(client, perNavigation);
|
|
36
47
|
}
|
|
37
48
|
if (!ignored.has("cls")) {
|
|
38
|
-
trackClsAsSpan(client);
|
|
49
|
+
trackClsAsSpan(client, perNavigation);
|
|
39
50
|
}
|
|
40
51
|
}
|
|
41
52
|
if (!ignored.has("inp")) {
|
|
42
|
-
trackInpAsSpan(client);
|
|
53
|
+
trackInpAsSpan(client, perNavigation);
|
|
43
54
|
}
|
|
44
55
|
},
|
|
45
56
|
afterAllSetup() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webVitals.js","sources":["../../../../../src/integrations/webVitals.ts"],"sourcesContent":["import type { IntegrationFn, Span } from '@sentry/core';\nimport { defineIntegration, hasSpanStreamingEnabled } from '@sentry/core';\nimport {\n addWebVitalsToSpan,\n registerInpInteractionListener,\n startTrackingWebVitals,\n trackClsAsSpan,\n trackInpAsSpan,\n trackLcpAsSpan,\n} from '@sentry/browser-utils';\n\nexport const WEB_VITALS_INTEGRATION_NAME = 'WebVitals' as const;\n\nexport type WebVitalName = 'cls' | 'inp' | 'lcp';\n\nexport interface WebVitalsOptions {\n /**\n * Web vitals to skip.\n */\n ignore?: WebVitalName[];\n}\n\n/**\n * Captures Core Web Vitals (LCP, CLS, INP) and related pageload vitals.\n *\n * `browserTracingIntegration` auto-registers this integration if no\n * `webVitalsIntegration` is already present, so explicit registration is only\n * needed to customize options or to use it without `browserTracingIntegration`.\n */\nexport const webVitalsIntegration = defineIntegration((options: WebVitalsOptions = {}) => {\n const ignored = new Set(
|
|
1
|
+
{"version":3,"file":"webVitals.js","sources":["../../../../../src/integrations/webVitals.ts"],"sourcesContent":["import type { IntegrationFn, Span } from '@sentry/core';\nimport { defineIntegration, hasSpanStreamingEnabled } from '@sentry/core';\nimport {\n addWebVitalsToSpan,\n enableBfcacheReporting,\n enableSoftNavigationReporting,\n registerInpInteractionListener,\n startSoftNavigationCorrelation,\n startTrackingWebVitals,\n supportsSoftNavigations,\n trackClsAsSpan,\n trackInpAsSpan,\n trackLcpAsSpan,\n} from '@sentry/browser-utils';\n\nexport const WEB_VITALS_INTEGRATION_NAME = 'WebVitals' as const;\n\nexport type WebVitalName = 'cls' | 'inp' | 'lcp';\n\nexport interface WebVitalsOptions {\n /**\n * Web vitals to skip.\n */\n ignore?: WebVitalName[];\n\n /**\n * Give each soft navigation its own set of LCP, CLS and INP, detected through the browser's\n * [Soft Navigations API](https://developer.chrome.com/docs/web-platform/soft-navigations-experiment)\n * (Chromium 151+).\n *\n * Each soft navigation's vitals are reported against the navigation span they belong to. This\n * also changes how the initial page load is measured: its vitals are finalized at the first soft\n * navigation rather than accumulating over the page's lifetime.\n *\n * Soft navigations the browser doesn't detect (programmatic navigations, navigations that never\n * paint) report no vitals at all, so coverage is lower than for page loads. Set this to `false`\n * to report a single set of vitals for the whole page lifetime instead.\n *\n * Requires span streaming (`traceLifecycle: 'stream'`, the default), since soft navigation vitals\n * are finalized long after the navigation span they belong to has ended. Ignored in browsers\n * without support for the Soft Navigations API.\n *\n * Default: `true`\n */\n softNavigations?: boolean;\n\n /**\n * Give each back/forward-cache restore its own set of LCP, CLS and INP.\n *\n * A restore is a new page view measured against a document that was never reloaded, so its vitals\n * are reported against the navigation span `browserTracingIntegration` starts for the restore,\n * and tagged `browser.navigation.type: bfcache`. A restore is near-instant by construction, so\n * these are a distinct population from page load vitals and are meant to be read through that\n * attribute rather than pooled with them. Set this to `false` to leave restores unmeasured.\n *\n * Requires span streaming (`traceLifecycle: 'stream'`, the default) and\n * `browserTracingIntegration`, which supplies the navigation span these attach to.\n *\n * Default: `true`\n */\n bfcacheNavigations?: boolean;\n}\n\n/**\n * Captures Core Web Vitals (LCP, CLS, INP) and related pageload vitals.\n *\n * `browserTracingIntegration` auto-registers this integration if no\n * `webVitalsIntegration` is already present, so explicit registration is only\n * needed to customize options or to use it without `browserTracingIntegration`.\n */\nexport const webVitalsIntegration = defineIntegration((options: WebVitalsOptions = {}) => {\n const { ignore = [], softNavigations = true, bfcacheNavigations = true } = options;\n const ignored = new Set(ignore);\n\n return {\n name: WEB_VITALS_INTEGRATION_NAME,\n setup(client) {\n const spanStreamingEnabled = hasSpanStreamingEnabled(client);\n\n // Soft navigation vitals are finalized at the next soft navigation or on pagehide, long after\n // the navigation span they belong to has ended. Only span streaming can still send them.\n const reportSoftNavs = softNavigations && spanStreamingEnabled && supportsSoftNavigations();\n const reportBfcache = bfcacheNavigations && spanStreamingEnabled;\n\n // Both attribute a vital to the page view it was measured on rather than to the page load, so\n // either one puts the trackers on the per-navigation path.\n const perNavigation = reportSoftNavs || reportBfcache;\n\n // These have to run before any web vital observer is instrumented, since web-vitals only\n // reads its options when the observer is set up.\n if (reportSoftNavs) {\n enableSoftNavigationReporting();\n startSoftNavigationCorrelation(client);\n }\n\n if (reportBfcache) {\n enableBfcacheReporting();\n }\n\n // With span streaming enabled, CLS and LCP are tracked as standalone v2 spans (like INP).\n // Otherwise, they're recorded as measurements on the pageload span.\n const trackClsOnPageloadSpan = !spanStreamingEnabled && !ignored.has('cls');\n const trackLcpOnPageloadSpan = !spanStreamingEnabled && !ignored.has('lcp');\n\n const finalizeWebVitals = startTrackingWebVitals({\n trackCls: trackClsOnPageloadSpan,\n trackLcp: trackLcpOnPageloadSpan,\n client,\n });\n\n const pageloadSpans = new WeakSet<Span>();\n\n client.on('afterStartPageLoadSpan', span => {\n pageloadSpans.add(span);\n });\n\n client.on('spanEnd', span => {\n if (!pageloadSpans.delete(span)) {\n return;\n }\n\n finalizeWebVitals();\n addWebVitalsToSpan(span, {\n recordClsOnPageloadSpan: trackClsOnPageloadSpan,\n recordLcpOnPageloadSpan: trackLcpOnPageloadSpan,\n spanStreamingEnabled,\n });\n });\n\n if (spanStreamingEnabled) {\n if (!ignored.has('lcp')) {\n trackLcpAsSpan(client, perNavigation);\n }\n if (!ignored.has('cls')) {\n trackClsAsSpan(client, perNavigation);\n }\n }\n\n // INP is always sent as a streamed web vital span. When span streaming is disabled, INP still\n // streams (it overrides the static trace lifecycle for INP only), see `trackInpAsSpan`.\n if (!ignored.has('inp')) {\n trackInpAsSpan(client, perNavigation);\n }\n },\n afterAllSetup() {\n if (!ignored.has('inp')) {\n registerInpInteractionListener();\n }\n },\n };\n}) satisfies IntegrationFn;\n"],"names":[],"mappings":";;;AAeO,MAAM,2BAAA,GAA8B;AAuDpC,MAAM,oBAAA,GAAuB,iBAAA,CAAkB,CAAC,OAAA,GAA4B,EAAC,KAAM;AACxF,EAAA,MAAM,EAAE,SAAS,EAAC,EAAG,kBAAkB,IAAA,EAAM,kBAAA,GAAqB,MAAK,GAAI,OAAA;AAC3E,EAAA,MAAM,OAAA,GAAU,IAAI,GAAA,CAAI,MAAM,CAAA;AAE9B,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,2BAAA;AAAA,IACN,MAAM,MAAA,EAAQ;AACZ,MAAA,MAAM,oBAAA,GAAuB,wBAAwB,MAAM,CAAA;AAI3D,MAAA,MAAM,cAAA,GAAiB,eAAA,IAAmB,oBAAA,IAAwB,uBAAA,EAAwB;AAC1F,MAAA,MAAM,gBAAgB,kBAAA,IAAsB,oBAAA;AAI5C,MAAA,MAAM,gBAAgB,cAAA,IAAkB,aAAA;AAIxC,MAAA,IAAI,cAAA,EAAgB;AAClB,QAAA,6BAAA,EAA8B;AAC9B,QAAA,8BAAA,CAA+B,MAAM,CAAA;AAAA,MACvC;AAEA,MAAA,IAAI,aAAA,EAAe;AACjB,QAAA,sBAAA,EAAuB;AAAA,MACzB;AAIA,MAAA,MAAM,yBAAyB,CAAC,oBAAA,IAAwB,CAAC,OAAA,CAAQ,IAAI,KAAK,CAAA;AAC1E,MAAA,MAAM,yBAAyB,CAAC,oBAAA,IAAwB,CAAC,O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,IACF;AAAA,GACF;AACF,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"11.0.0-
|
|
1
|
+
{"type":"module","version":"11.0.0-rc.0","sideEffects":false}
|
package/build/npm/esm/dev/sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { eventFiltersIntegration, functionToStringIntegration, conversationIdIntegration, dedupeIntegration, getIntegrationsToSetup, stackParserFromStackParserOptions, setNormalizeStringifier, initAndBind } from '@sentry/core';
|
|
1
|
+
import { eventFiltersIntegration, functionToStringIntegration, conversationIdIntegration, consoleIntegration, dedupeIntegration, getIntegrationsToSetup, stackParserFromStackParserOptions, setNormalizeStringifier, initAndBind } from '@sentry/core';
|
|
2
2
|
import { BrowserClient } from './client.js';
|
|
3
3
|
import { breadcrumbsIntegration } from './integrations/breadcrumbs.js';
|
|
4
4
|
import { browserApiErrorsIntegration } from './integrations/browserapierrors.js';
|
|
@@ -20,6 +20,7 @@ function getDefaultIntegrations(_options) {
|
|
|
20
20
|
conversationIdIntegration(),
|
|
21
21
|
browserApiErrorsIntegration(),
|
|
22
22
|
breadcrumbsIntegration(),
|
|
23
|
+
consoleIntegration(),
|
|
23
24
|
globalHandlersIntegration(),
|
|
24
25
|
linkedErrorsIntegration(),
|
|
25
26
|
dedupeIntegration(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../../../src/sdk.ts"],"sourcesContent":["import type { Client, Integration, Options } from '@sentry/core';\nimport {\n conversationIdIntegration,\n dedupeIntegration,\n eventFiltersIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n initAndBind,\n setNormalizeStringifier,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { BrowserClientOptions, BrowserOptions } from './client';\nimport { BrowserClient } from './client';\nimport { breadcrumbsIntegration } from './integrations/breadcrumbs';\nimport { browserApiErrorsIntegration } from './integrations/browserapierrors';\nimport { browserSessionIntegration } from './integrations/browsersession';\nimport { cultureContextIntegration } from './integrations/culturecontext';\nimport { globalHandlersIntegration } from './integrations/globalhandlers';\nimport { httpContextIntegration } from './integrations/httpcontext';\nimport { linkedErrorsIntegration } from './integrations/linkederrors';\nimport { spotlightBrowserIntegration } from './integrations/spotlight';\nimport { defaultStackParser } from './stack-parsers';\nimport { makeFetchTransport } from './transports/fetch';\nimport { normalizeStringifyValue } from './normalizeStringifyValue';\nimport { checkAndWarnIfIsEmbeddedBrowserExtension } from './utils/detectBrowserExtension';\n\n/** Get the default integrations for the browser SDK. */\nexport function getDefaultIntegrations(_options: Options): Integration[] {\n /**\n * Note: Please make sure this stays in sync with Angular SDK, which re-exports\n * `getDefaultIntegrations` but with an adjusted set of integrations.\n */\n return [\n eventFiltersIntegration(),\n functionToStringIntegration(),\n conversationIdIntegration(),\n browserApiErrorsIntegration(),\n breadcrumbsIntegration(),\n globalHandlersIntegration(),\n linkedErrorsIntegration(),\n dedupeIntegration(),\n httpContextIntegration(),\n cultureContextIntegration(),\n browserSessionIntegration(),\n ];\n}\n\n/**\n * The Sentry Browser SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the web page. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/browser';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/browser';\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/browser';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link BrowserOptions} for documentation on configuration options.\n */\nexport function init(options: BrowserOptions = {}): Client | undefined {\n const shouldDisableBecauseIsBrowserExtenstion =\n !options.skipBrowserExtensionCheck && checkAndWarnIfIsEmbeddedBrowserExtension();\n\n let defaultIntegrations =\n options.defaultIntegrations == null ? getDefaultIntegrations(options) : options.defaultIntegrations;\n\n /*! rollup-include-development-only */\n if (options.spotlight) {\n if (!defaultIntegrations) {\n defaultIntegrations = [];\n }\n const args = typeof options.spotlight === 'string' ? { sidecarUrl: options.spotlight } : undefined;\n defaultIntegrations.push(spotlightBrowserIntegration(args));\n }\n /*! rollup-include-development-only-end */\n\n const integrations = getIntegrationsToSetup({\n integrations: options.integrations,\n defaultIntegrations,\n });\n\n const clientOptions: BrowserClientOptions = {\n ...options,\n enabled: shouldDisableBecauseIsBrowserExtenstion ? false : options.enabled,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations,\n transport: options.transport || makeFetchTransport,\n };\n\n setNormalizeStringifier(normalizeStringifyValue);\n\n return initAndBind(BrowserClient, clientOptions);\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function forceLoad(): void {\n // Noop\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function onLoad(callback: () => void): void {\n callback();\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../../../src/sdk.ts"],"sourcesContent":["import type { Client, Integration, Options } from '@sentry/core';\nimport {\n consoleIntegration,\n conversationIdIntegration,\n dedupeIntegration,\n eventFiltersIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n initAndBind,\n setNormalizeStringifier,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { BrowserClientOptions, BrowserOptions } from './client';\nimport { BrowserClient } from './client';\nimport { breadcrumbsIntegration } from './integrations/breadcrumbs';\nimport { browserApiErrorsIntegration } from './integrations/browserapierrors';\nimport { browserSessionIntegration } from './integrations/browsersession';\nimport { cultureContextIntegration } from './integrations/culturecontext';\nimport { globalHandlersIntegration } from './integrations/globalhandlers';\nimport { httpContextIntegration } from './integrations/httpcontext';\nimport { linkedErrorsIntegration } from './integrations/linkederrors';\nimport { spotlightBrowserIntegration } from './integrations/spotlight';\nimport { defaultStackParser } from './stack-parsers';\nimport { makeFetchTransport } from './transports/fetch';\nimport { normalizeStringifyValue } from './normalizeStringifyValue';\nimport { checkAndWarnIfIsEmbeddedBrowserExtension } from './utils/detectBrowserExtension';\n\n/** Get the default integrations for the browser SDK. */\nexport function getDefaultIntegrations(_options: Options): Integration[] {\n /**\n * Note: Please make sure this stays in sync with Angular SDK, which re-exports\n * `getDefaultIntegrations` but with an adjusted set of integrations.\n */\n return [\n eventFiltersIntegration(),\n functionToStringIntegration(),\n conversationIdIntegration(),\n browserApiErrorsIntegration(),\n breadcrumbsIntegration(),\n consoleIntegration(),\n globalHandlersIntegration(),\n linkedErrorsIntegration(),\n dedupeIntegration(),\n httpContextIntegration(),\n cultureContextIntegration(),\n browserSessionIntegration(),\n ];\n}\n\n/**\n * The Sentry Browser SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the web page. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/browser';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/browser';\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/browser';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link BrowserOptions} for documentation on configuration options.\n */\nexport function init(options: BrowserOptions = {}): Client | undefined {\n const shouldDisableBecauseIsBrowserExtenstion =\n !options.skipBrowserExtensionCheck && checkAndWarnIfIsEmbeddedBrowserExtension();\n\n let defaultIntegrations =\n options.defaultIntegrations == null ? getDefaultIntegrations(options) : options.defaultIntegrations;\n\n /*! rollup-include-development-only */\n if (options.spotlight) {\n if (!defaultIntegrations) {\n defaultIntegrations = [];\n }\n const args = typeof options.spotlight === 'string' ? { sidecarUrl: options.spotlight } : undefined;\n defaultIntegrations.push(spotlightBrowserIntegration(args));\n }\n /*! rollup-include-development-only-end */\n\n const integrations = getIntegrationsToSetup({\n integrations: options.integrations,\n defaultIntegrations,\n });\n\n const clientOptions: BrowserClientOptions = {\n ...options,\n enabled: shouldDisableBecauseIsBrowserExtenstion ? false : options.enabled,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations,\n transport: options.transport || makeFetchTransport,\n };\n\n setNormalizeStringifier(normalizeStringifyValue);\n\n return initAndBind(BrowserClient, clientOptions);\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function forceLoad(): void {\n // Noop\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function onLoad(callback: () => void): void {\n callback();\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA4BO,SAAS,uBAAuB,QAAA,EAAkC;AAKvE,EAAA,OAAO;AAAA,IACL,uBAAA,EAAwB;AAAA,IACxB,2BAAA,EAA4B;AAAA,IAC5B,yBAAA,EAA0B;AAAA,IAC1B,2BAAA,EAA4B;AAAA,IAC5B,sBAAA,EAAuB;AAAA,IACvB,kBAAA,EAAmB;AAAA,IACnB,yBAAA,EAA0B;AAAA,IAC1B,uBAAA,EAAwB;AAAA,IACxB,iBAAA,EAAkB;AAAA,IAClB,sBAAA,EAAuB;AAAA,IACvB,yBAAA,EAA0B;AAAA,IAC1B,yBAAA;AAA0B,GAC5B;AACF;AAgDO,SAAS,IAAA,CAAK,OAAA,GAA0B,EAAC,EAAuB;AACrE,EAAA,MAAM,uCAAA,GACJ,CAAC,OAAA,CAAQ,yBAAA,IAA6B,wCAAA,EAAyC;AAEjF,EAAA,IAAI,sBACF,OAAA,CAAQ,mBAAA,IAAuB,OAAO,sBAAA,CAA8B,IAAI,OAAA,CAAQ,mBAAA;AAAA;AAGlF,EAAA,IAAI,QAAQ,SAAA,EAAW;AACrB,IAAA,IAAI,CAAC,mBAAA,EAAqB;AACxB,MAAA,mBAAA,GAAsB,EAAC;AAAA,IACzB;AACA,IAAA,MAAM,IAAA,GAAO,OAAO,OAAA,CAAQ,SAAA,KAAc,WAAW,EAAE,UAAA,EAAY,OAAA,CAAQ,SAAA,EAAU,GAAI,MAAA;AACzF,IAAA,mBAAA,CAAoB,IAAA,CAAK,2BAAA,CAA4B,IAAI,CAAC,CAAA;AAAA,EAC5D;AAAA;AAGA,EAAA,MAAM,eAAe,sBAAA,CAAuB;AAAA,IAC1C,cAAc,OAAA,CAAQ,YAAA;AAAA,IACtB;AAAA,GACD,CAAA;AAED,EAAA,MAAM,aAAA,GAAsC;AAAA,IAC1C,GAAG,OAAA;AAAA,IACH,OAAA,EAAS,uCAAA,GAA0C,KAAA,GAAQ,OAAA,CAAQ,OAAA;AAAA,IACnE,WAAA,EAAa,iCAAA,CAAkC,OAAA,CAAQ,WAAA,IAAe,kBAAkB,CAAA;AAAA,IACxF,YAAA;AAAA,IACA,SAAA,EAAW,QAAQ,SAAA,IAAa;AAAA,GAClC;AAEA,EAAA,uBAAA,CAAwB,uBAAuB,CAAA;AAE/C,EAAA,OAAO,WAAA,CAAY,eAAe,aAAa,CAAA;AACjD;AAMO,SAAS,SAAA,GAAkB;AAElC;AAMO,SAAS,OAAO,QAAA,EAA4B;AACjD,EAAA,QAAA,EAAS;AACX;;;;"}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import { TRACING_DEFAULTS, consoleSandbox, hasSpanStreamingEnabled, PAGELOAD_SPAN_NAME_FALLBACK, parseStringToURLObject, NAVIGATION_SPAN_NAME_FALLBACK, debug, registerSpanErrorInstrumentation, GLOBAL_OBJ, getCurrentScope, getDynamicSamplingContextFromSpan, spanIsSampled, getClient, hasSpansEnabled, generateSpanId, generateTraceId, propagationContextFromHeaders,
|
|
1
|
+
import { TRACING_DEFAULTS, consoleSandbox, hasSpanStreamingEnabled, PAGELOAD_SPAN_NAME_FALLBACK, parseStringToURLObject, NAVIGATION_SPAN_NAME_FALLBACK, debug, registerSpanErrorInstrumentation, GLOBAL_OBJ, getCurrentScope, getDynamicSamplingContextFromSpan, spanIsSampled, getClient, hasSpansEnabled, generateSpanId, generateTraceId, propagationContextFromHeaders, spanToJSON, browserPerformanceTimeOrigin, dateTimestampInSeconds, timestampInSeconds, addNonEnumerableProperty, isURLObjectRelative, filterCollectedUrl } from '@sentry/core';
|
|
2
2
|
import { _INTERNAL_ensureBrowserSpanStreaming, startInactiveSpan, startIdleSpan } from '@sentry/core/browser';
|
|
3
3
|
import { isBotUserAgent, getLocationHref, addHistoryInstrumentationHandler, startTrackingLongAnimationFrames, startTrackingLongTasks, addPerformanceEntries } from '@sentry/browser-utils';
|
|
4
|
+
import { SENTRY_IDLE_SPAN_FINISH_REASON, URL_FULL, URL_PATH, SENTRY_OP, SENTRY_SEGMENT_NAME_SOURCE, SENTRY_ORIGIN, BROWSER_NAVIGATION_TYPE } from '@sentry/conventions/attributes';
|
|
4
5
|
import { DEBUG_BUILD } from '../debug-build.js';
|
|
5
6
|
import { WINDOW, getHttpRequestData } from '../helpers.js';
|
|
6
7
|
import { WEB_VITALS_INTEGRATION_NAME, webVitalsIntegration } from '../integrations/webVitals.js';
|
|
7
8
|
import { registerBackgroundTabDetection } from './backgroundtab.js';
|
|
8
9
|
import { linkTraces } from './linkedTraces.js';
|
|
9
|
-
import {
|
|
10
|
-
import { URL_FULL, URL_PATH, SENTRY_OP, SENTRY_SEGMENT_NAME_SOURCE } from '@sentry/conventions/attributes';
|
|
10
|
+
import { defaultRequestInstrumentationOptions, instrumentOutgoingRequests } from './request.js';
|
|
11
11
|
import { NAVIGATION_REDIRECT, NAVIGATION, PAGELOAD } from '@sentry/conventions/op';
|
|
12
12
|
|
|
13
13
|
const BROWSER_TRACING_INTEGRATION_ID = "BrowserTracing";
|
|
14
14
|
const DEFAULT_BROWSER_TRACING_OPTIONS = {
|
|
15
15
|
...TRACING_DEFAULTS,
|
|
16
16
|
instrumentNavigation: true,
|
|
17
|
+
instrumentBfcacheRestore: true,
|
|
17
18
|
instrumentPageLoad: true,
|
|
18
19
|
markBackgroundSpan: true,
|
|
19
20
|
enableLongTask: true,
|
|
20
21
|
enableLongAnimationFrame: true,
|
|
22
|
+
// oxlint-disable-next-line typescript/no-deprecated -- still honoured until it is removed
|
|
21
23
|
enableInp: true,
|
|
22
24
|
ignoreResourceSpans: [],
|
|
23
25
|
detectRedirects: true,
|
|
@@ -36,9 +38,11 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
36
38
|
}
|
|
37
39
|
const optionalWindowDocument = WINDOW.document;
|
|
38
40
|
const {
|
|
41
|
+
// oxlint-disable-next-line typescript/no-deprecated -- still honoured until it is removed
|
|
39
42
|
enableInp,
|
|
40
43
|
enableLongTask,
|
|
41
44
|
enableLongAnimationFrame,
|
|
45
|
+
webVitals,
|
|
42
46
|
beforeStartSpan,
|
|
43
47
|
idleTimeout,
|
|
44
48
|
finalTimeout,
|
|
@@ -51,6 +55,7 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
51
55
|
ignoreResourceSpans,
|
|
52
56
|
instrumentPageLoad,
|
|
53
57
|
instrumentNavigation,
|
|
58
|
+
instrumentBfcacheRestore,
|
|
54
59
|
detectRedirects,
|
|
55
60
|
linkPreviousTrace,
|
|
56
61
|
consistentTraceSampling,
|
|
@@ -135,7 +140,7 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
135
140
|
DEBUG_BUILD && debug.log(
|
|
136
141
|
`[Tracing] Finishing current active span with op: ${spanToJSON(activeSpan).attributes[SENTRY_OP]}`
|
|
137
142
|
);
|
|
138
|
-
activeSpan.setAttribute(
|
|
143
|
+
activeSpan.setAttribute(SENTRY_IDLE_SPAN_FINISH_REASON, "cancelled");
|
|
139
144
|
activeSpan.end();
|
|
140
145
|
}
|
|
141
146
|
}
|
|
@@ -223,10 +228,18 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
223
228
|
});
|
|
224
229
|
client.on("endPageloadSpan", () => {
|
|
225
230
|
if (enableReportPageLoaded && _pageloadSpan) {
|
|
226
|
-
_pageloadSpan.setAttribute(
|
|
231
|
+
_pageloadSpan.setAttribute(SENTRY_IDLE_SPAN_FINISH_REASON, "reportPageLoaded");
|
|
227
232
|
_pageloadSpan.end();
|
|
228
233
|
}
|
|
229
234
|
});
|
|
235
|
+
WINDOW.addEventListener?.("pagehide", () => {
|
|
236
|
+
const activeSpan = getActiveIdleSpan(client);
|
|
237
|
+
if (activeSpan && !spanToJSON(activeSpan).end_timestamp) {
|
|
238
|
+
activeSpan.setAttribute(SENTRY_IDLE_SPAN_FINISH_REASON, "documentHidden");
|
|
239
|
+
activeSpan.end();
|
|
240
|
+
}
|
|
241
|
+
void client.flush();
|
|
242
|
+
});
|
|
230
243
|
},
|
|
231
244
|
afterAllSetup(client) {
|
|
232
245
|
if (_isBot) {
|
|
@@ -234,9 +247,11 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
234
247
|
}
|
|
235
248
|
_INTERNAL_ensureBrowserSpanStreaming(client);
|
|
236
249
|
if (client.addIntegration && !client.getIntegrationByName?.(WEB_VITALS_INTEGRATION_NAME)) {
|
|
250
|
+
const ignore = webVitals?.ignore ?? [];
|
|
237
251
|
client.addIntegration(
|
|
238
252
|
webVitalsIntegration({
|
|
239
|
-
|
|
253
|
+
...webVitals,
|
|
254
|
+
ignore: enableInp || ignore.includes("inp") ? ignore : [...ignore, "inp"]
|
|
240
255
|
})
|
|
241
256
|
);
|
|
242
257
|
}
|
|
@@ -252,13 +267,13 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
252
267
|
name: hasSpanStreamingEnabled(client) ? PAGELOAD_SPAN_NAME_FALLBACK : WINDOW.location.pathname,
|
|
253
268
|
attributes: {
|
|
254
269
|
[SENTRY_SEGMENT_NAME_SOURCE]: "url",
|
|
255
|
-
[
|
|
270
|
+
[SENTRY_ORIGIN]: "auto.pageload.browser"
|
|
256
271
|
}
|
|
257
272
|
});
|
|
258
273
|
}
|
|
259
274
|
if (instrumentNavigation) {
|
|
260
275
|
addHistoryInstrumentationHandler(({ to, from }) => {
|
|
261
|
-
if (from === void 0 && startingUrl
|
|
276
|
+
if (from === void 0 && startingUrl !== void 0 && startingUrl.indexOf(to) !== -1) {
|
|
262
277
|
startingUrl = void 0;
|
|
263
278
|
return;
|
|
264
279
|
}
|
|
@@ -274,13 +289,42 @@ const browserTracingIntegration = ((options = {}) => {
|
|
|
274
289
|
name: hasSpanStreamingEnabled(client) ? NAVIGATION_SPAN_NAME_FALLBACK : parsed?.pathname || WINDOW.location.pathname,
|
|
275
290
|
attributes: {
|
|
276
291
|
[SENTRY_SEGMENT_NAME_SOURCE]: "url",
|
|
277
|
-
[
|
|
292
|
+
[SENTRY_ORIGIN]: "auto.navigation.browser"
|
|
278
293
|
}
|
|
279
294
|
},
|
|
280
295
|
{ url: to, isRedirect: navigationIsRedirect }
|
|
281
296
|
);
|
|
282
297
|
});
|
|
283
298
|
}
|
|
299
|
+
if (instrumentBfcacheRestore) {
|
|
300
|
+
WINDOW.addEventListener?.("pageshow", (event) => {
|
|
301
|
+
if (!event.persisted) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
startingUrl = void 0;
|
|
305
|
+
startBrowserTracingNavigationSpan(
|
|
306
|
+
client,
|
|
307
|
+
{
|
|
308
|
+
// Deliberately no `startTime`: the span starts now, at the restore. The
|
|
309
|
+
// `PerformanceNavigationTiming` entry still describes the original document load and
|
|
310
|
+
// would date the span to before the page was frozen.
|
|
311
|
+
//
|
|
312
|
+
// TODO(routing): resolve the parameterized route via the route provider (#23551) and set
|
|
313
|
+
// the source from it. No router event fires on a restore, so in a framework app this is
|
|
314
|
+
// the only navigation span still named from a raw pathname.
|
|
315
|
+
name: hasSpanStreamingEnabled(client) ? NAVIGATION_SPAN_NAME_FALLBACK : WINDOW.location?.pathname || "/",
|
|
316
|
+
attributes: {
|
|
317
|
+
[SENTRY_SEGMENT_NAME_SOURCE]: "url",
|
|
318
|
+
[SENTRY_ORIGIN]: "auto.navigation.browser.bfcache",
|
|
319
|
+
// A bfcache restore is near-instant, so these spans would otherwise drag
|
|
320
|
+
// navigation duration percentiles down with no way to tell them apart.
|
|
321
|
+
[BROWSER_NAVIGATION_TYPE]: "bfcache"
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
{ url: WINDOW.location?.href }
|
|
325
|
+
);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
284
328
|
}
|
|
285
329
|
if (markBackgroundSpan) {
|
|
286
330
|
registerBackgroundTabDetection();
|