@sentry/browser 8.39.0 → 8.41.0-beta.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/client.js +2 -3
- package/build/npm/cjs/client.js.map +1 -1
- package/build/npm/cjs/eventbuilder.js +18 -19
- package/build/npm/cjs/eventbuilder.js.map +1 -1
- package/build/npm/cjs/helpers.js +6 -7
- package/build/npm/cjs/helpers.js.map +1 -1
- package/build/npm/cjs/index.js +9 -0
- package/build/npm/cjs/index.js.map +1 -1
- package/build/npm/cjs/integrations/breadcrumbs.js +14 -15
- package/build/npm/cjs/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/cjs/integrations/browserapierrors.js +14 -15
- package/build/npm/cjs/integrations/browserapierrors.js.map +1 -1
- package/build/npm/cjs/integrations/contextlines.js +3 -4
- package/build/npm/cjs/integrations/contextlines.js.map +1 -1
- package/build/npm/cjs/integrations/featureFlags/launchdarkly/integration.js +55 -0
- package/build/npm/cjs/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
- package/build/npm/cjs/integrations/featureFlags/openfeature/integration.js +37 -0
- package/build/npm/cjs/integrations/featureFlags/openfeature/integration.js.map +1 -0
- package/build/npm/cjs/integrations/globalhandlers.js +7 -8
- package/build/npm/cjs/integrations/globalhandlers.js.map +1 -1
- package/build/npm/cjs/integrations/httpclient.js +8 -9
- package/build/npm/cjs/integrations/httpclient.js.map +1 -1
- package/build/npm/cjs/integrations/linkederrors.js +1 -2
- package/build/npm/cjs/integrations/linkederrors.js.map +1 -1
- package/build/npm/cjs/integrations/reportingobserver.js +2 -3
- package/build/npm/cjs/integrations/reportingobserver.js.map +1 -1
- package/build/npm/cjs/integrations/spotlight.js +4 -5
- package/build/npm/cjs/integrations/spotlight.js.map +1 -1
- package/build/npm/cjs/profiling/integration.js +3 -4
- package/build/npm/cjs/profiling/integration.js.map +1 -1
- package/build/npm/cjs/profiling/startProfileForSpan.js +7 -8
- package/build/npm/cjs/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/cjs/profiling/utils.js +21 -22
- package/build/npm/cjs/profiling/utils.js.map +1 -1
- package/build/npm/cjs/sdk.js +8 -9
- package/build/npm/cjs/sdk.js.map +1 -1
- package/build/npm/cjs/stack-parsers.js +17 -10
- package/build/npm/cjs/stack-parsers.js.map +1 -1
- package/build/npm/cjs/tracing/backgroundtab.js +2 -3
- package/build/npm/cjs/tracing/backgroundtab.js.map +1 -1
- package/build/npm/cjs/tracing/browserTracingIntegration.js +10 -11
- package/build/npm/cjs/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/tracing/request.js +12 -13
- package/build/npm/cjs/tracing/request.js.map +1 -1
- package/build/npm/cjs/transports/fetch.js +2 -3
- package/build/npm/cjs/transports/fetch.js.map +1 -1
- package/build/npm/cjs/transports/offline.js +3 -4
- package/build/npm/cjs/transports/offline.js.map +1 -1
- package/build/npm/cjs/userfeedback.js +3 -3
- package/build/npm/cjs/userfeedback.js.map +1 -1
- package/build/npm/cjs/utils/featureFlags.js +97 -0
- package/build/npm/cjs/utils/featureFlags.js.map +1 -0
- package/build/npm/esm/client.js +1 -2
- package/build/npm/esm/client.js.map +1 -1
- package/build/npm/esm/eventbuilder.js +1 -2
- package/build/npm/esm/eventbuilder.js.map +1 -1
- package/build/npm/esm/helpers.js +1 -2
- package/build/npm/esm/helpers.js.map +1 -1
- package/build/npm/esm/index.js +3 -0
- package/build/npm/esm/index.js.map +1 -1
- package/build/npm/esm/integrations/breadcrumbs.js +1 -2
- package/build/npm/esm/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/esm/integrations/browserapierrors.js +1 -2
- package/build/npm/esm/integrations/browserapierrors.js.map +1 -1
- package/build/npm/esm/integrations/contextlines.js +1 -2
- package/build/npm/esm/integrations/contextlines.js.map +1 -1
- package/build/npm/esm/integrations/featureFlags/launchdarkly/integration.js +52 -0
- package/build/npm/esm/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
- package/build/npm/esm/integrations/featureFlags/openfeature/integration.js +34 -0
- package/build/npm/esm/integrations/featureFlags/openfeature/integration.js.map +1 -0
- package/build/npm/esm/integrations/globalhandlers.js +1 -2
- package/build/npm/esm/integrations/globalhandlers.js.map +1 -1
- package/build/npm/esm/integrations/httpclient.js +1 -2
- package/build/npm/esm/integrations/httpclient.js.map +1 -1
- package/build/npm/esm/integrations/linkederrors.js +1 -2
- package/build/npm/esm/integrations/linkederrors.js.map +1 -1
- package/build/npm/esm/integrations/reportingobserver.js +1 -2
- package/build/npm/esm/integrations/reportingobserver.js.map +1 -1
- package/build/npm/esm/integrations/spotlight.js +1 -2
- package/build/npm/esm/integrations/spotlight.js.map +1 -1
- package/build/npm/esm/package.json +1 -1
- package/build/npm/esm/profiling/integration.js +1 -2
- package/build/npm/esm/profiling/integration.js.map +1 -1
- package/build/npm/esm/profiling/startProfileForSpan.js +1 -2
- package/build/npm/esm/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/esm/profiling/utils.js +1 -2
- package/build/npm/esm/profiling/utils.js.map +1 -1
- package/build/npm/esm/sdk.js +1 -2
- package/build/npm/esm/sdk.js.map +1 -1
- package/build/npm/esm/stack-parsers.js +8 -1
- package/build/npm/esm/stack-parsers.js.map +1 -1
- package/build/npm/esm/tracing/backgroundtab.js +1 -2
- package/build/npm/esm/tracing/backgroundtab.js.map +1 -1
- package/build/npm/esm/tracing/browserTracingIntegration.js +1 -2
- package/build/npm/esm/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/tracing/request.js +1 -2
- package/build/npm/esm/tracing/request.js.map +1 -1
- package/build/npm/esm/transports/fetch.js +1 -2
- package/build/npm/esm/transports/fetch.js.map +1 -1
- package/build/npm/esm/transports/offline.js +1 -2
- package/build/npm/esm/transports/offline.js.map +1 -1
- package/build/npm/esm/userfeedback.js +1 -1
- package/build/npm/esm/userfeedback.js.map +1 -1
- package/build/npm/esm/utils/featureFlags.js +92 -0
- package/build/npm/esm/utils/featureFlags.js.map +1 -0
- package/build/npm/types/client.d.ts.map +1 -1
- package/build/npm/types/eventbuilder.d.ts.map +1 -1
- package/build/npm/types/helpers.d.ts +1 -1
- package/build/npm/types/helpers.d.ts.map +1 -1
- package/build/npm/types/index.d.ts +6 -3
- package/build/npm/types/index.d.ts.map +1 -1
- package/build/npm/types/integrations/contextlines.d.ts.map +1 -1
- package/build/npm/types/integrations/featureFlags/launchdarkly/index.d.ts +2 -0
- package/build/npm/types/integrations/featureFlags/launchdarkly/index.d.ts.map +1 -0
- package/build/npm/types/integrations/featureFlags/launchdarkly/integration.d.ts +25 -0
- package/build/npm/types/integrations/featureFlags/launchdarkly/integration.d.ts.map +1 -0
- package/build/npm/types/integrations/featureFlags/launchdarkly/types.d.ts +44 -0
- package/build/npm/types/integrations/featureFlags/launchdarkly/types.d.ts.map +1 -0
- package/build/npm/types/integrations/featureFlags/openfeature/index.d.ts +2 -0
- package/build/npm/types/integrations/featureFlags/openfeature/index.d.ts.map +1 -0
- package/build/npm/types/integrations/featureFlags/openfeature/integration.d.ts +16 -0
- package/build/npm/types/integrations/featureFlags/openfeature/integration.d.ts.map +1 -0
- package/build/npm/types/integrations/featureFlags/openfeature/types.d.ts +86 -0
- package/build/npm/types/integrations/featureFlags/openfeature/types.d.ts.map +1 -0
- package/build/npm/types/integrations/spotlight.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.debug.d.ts.map +1 -1
- package/build/npm/types/integrations-bundle/index.sessiontiming.d.ts.map +1 -1
- package/build/npm/types/profiling/startProfileForSpan.d.ts.map +1 -1
- package/build/npm/types/profiling/utils.d.ts.map +1 -1
- package/build/npm/types/sdk.d.ts.map +1 -1
- package/build/npm/types/stack-parsers.d.ts.map +1 -1
- package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
- package/build/npm/types/tracing/request.d.ts.map +1 -1
- package/build/npm/types/transports/fetch.d.ts.map +1 -1
- package/build/npm/types/transports/offline.d.ts.map +1 -1
- package/build/npm/types/userfeedback.d.ts.map +1 -1
- package/build/npm/types/utils/featureFlags.d.ts +34 -0
- package/build/npm/types/utils/featureFlags.d.ts.map +1 -0
- package/build/npm/types-ts3.8/helpers.d.ts +1 -1
- package/build/npm/types-ts3.8/index.d.ts +6 -3
- package/build/npm/types-ts3.8/integrations/featureFlags/launchdarkly/index.d.ts +2 -0
- package/build/npm/types-ts3.8/integrations/featureFlags/launchdarkly/integration.d.ts +25 -0
- package/build/npm/types-ts3.8/integrations/featureFlags/launchdarkly/types.d.ts +44 -0
- package/build/npm/types-ts3.8/integrations/featureFlags/openfeature/index.d.ts +2 -0
- package/build/npm/types-ts3.8/integrations/featureFlags/openfeature/integration.d.ts +16 -0
- package/build/npm/types-ts3.8/integrations/featureFlags/openfeature/types.d.ts +86 -0
- package/build/npm/types-ts3.8/utils/featureFlags.d.ts +34 -0
- package/package.json +8 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpclient.js","sources":["../../../../src/integrations/httpclient.ts"],"sourcesContent":["import { SENTRY_XHR_DATA_KEY, addXhrInstrumentationHandler } from '@sentry-internal/browser-utils';\nimport { captureEvent, defineIntegration, getClient, isSentryRequestUrl } from '@sentry/core';\nimport type { Client, Event as SentryEvent, IntegrationFn, SentryWrappedXMLHttpRequest } from '@sentry/types';\nimport {\n GLOBAL_OBJ,\n addExceptionMechanism,\n addFetchInstrumentationHandler,\n logger,\n supportsNativeFetch,\n} from '@sentry/utils';\n\nimport { DEBUG_BUILD } from '../debug-build';\n\nexport type HttpStatusCodeRange = [number, number] | number;\nexport type HttpRequestTarget = string | RegExp;\n\nconst INTEGRATION_NAME = 'HttpClient';\n\ninterface HttpClientOptions {\n /**\n * HTTP status codes that should be considered failed.\n * This array can contain tuples of `[begin, end]` (both inclusive),\n * single status codes, or a combinations of both\n *\n * Example: [[500, 505], 507]\n * Default: [[500, 599]]\n */\n failedRequestStatusCodes: HttpStatusCodeRange[];\n\n /**\n * Targets to track for failed requests.\n * This array can contain strings or regular expressions.\n *\n * Example: ['http://localhost', /api\\/.*\\/]\n * Default: [/.*\\/]\n */\n failedRequestTargets: HttpRequestTarget[];\n}\n\nconst _httpClientIntegration = ((options: Partial<HttpClientOptions> = {}) => {\n const _options: HttpClientOptions = {\n failedRequestStatusCodes: [[500, 599]],\n failedRequestTargets: [/.*/],\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client): void {\n _wrapFetch(client, _options);\n _wrapXHR(client, _options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Create events for failed client side HTTP requests.\n */\nexport const httpClientIntegration = defineIntegration(_httpClientIntegration);\n\n/**\n * Interceptor function for fetch requests\n *\n * @param requestInfo The Fetch API request info\n * @param response The Fetch API response\n * @param requestInit The request init object\n */\nfunction _fetchResponseHandler(\n options: HttpClientOptions,\n requestInfo: RequestInfo,\n response: Response,\n requestInit?: RequestInit,\n): void {\n if (_shouldCaptureResponse(options, response.status, response.url)) {\n const request = _getRequest(requestInfo, requestInit);\n\n let requestHeaders, responseHeaders, requestCookies, responseCookies;\n\n if (_shouldSendDefaultPii()) {\n [requestHeaders, requestCookies] = _parseCookieHeaders('Cookie', request);\n [responseHeaders, responseCookies] = _parseCookieHeaders('Set-Cookie', response);\n }\n\n const event = _createEvent({\n url: request.url,\n method: request.method,\n status: response.status,\n requestHeaders,\n responseHeaders,\n requestCookies,\n responseCookies,\n });\n\n captureEvent(event);\n }\n}\n\nfunction _parseCookieHeaders(\n cookieHeader: string,\n obj: Request | Response,\n): [Record<string, string>, Record<string, string> | undefined] {\n const headers = _extractFetchHeaders(obj.headers);\n let cookies;\n\n try {\n const cookieString = headers[cookieHeader] || headers[cookieHeader.toLowerCase()] || undefined;\n\n if (cookieString) {\n cookies = _parseCookieString(cookieString);\n }\n } catch (e) {\n DEBUG_BUILD && logger.log(`Could not extract cookies from header ${cookieHeader}`);\n }\n\n return [headers, cookies];\n}\n\n/**\n * Interceptor function for XHR requests\n *\n * @param xhr The XHR request\n * @param method The HTTP method\n * @param headers The HTTP headers\n */\nfunction _xhrResponseHandler(\n options: HttpClientOptions,\n xhr: XMLHttpRequest,\n method: string,\n headers: Record<string, string>,\n): void {\n if (_shouldCaptureResponse(options, xhr.status, xhr.responseURL)) {\n let requestHeaders, responseCookies, responseHeaders;\n\n if (_shouldSendDefaultPii()) {\n try {\n const cookieString = xhr.getResponseHeader('Set-Cookie') || xhr.getResponseHeader('set-cookie') || undefined;\n\n if (cookieString) {\n responseCookies = _parseCookieString(cookieString);\n }\n } catch (e) {\n DEBUG_BUILD && logger.log('Could not extract cookies from response headers');\n }\n\n try {\n responseHeaders = _getXHRResponseHeaders(xhr);\n } catch (e) {\n DEBUG_BUILD && logger.log('Could not extract headers from response');\n }\n\n requestHeaders = headers;\n }\n\n const event = _createEvent({\n url: xhr.responseURL,\n method,\n status: xhr.status,\n requestHeaders,\n // Can't access request cookies from XHR\n responseHeaders,\n responseCookies,\n });\n\n captureEvent(event);\n }\n}\n\n/**\n * Extracts response size from `Content-Length` header when possible\n *\n * @param headers\n * @returns The response size in bytes or undefined\n */\nfunction _getResponseSizeFromHeaders(headers?: Record<string, string>): number | undefined {\n if (headers) {\n const contentLength = headers['Content-Length'] || headers['content-length'];\n\n if (contentLength) {\n return parseInt(contentLength, 10);\n }\n }\n\n return undefined;\n}\n\n/**\n * Creates an object containing cookies from the given cookie string\n *\n * @param cookieString The cookie string to parse\n * @returns The parsed cookies\n */\nfunction _parseCookieString(cookieString: string): Record<string, string> {\n return cookieString.split('; ').reduce((acc: Record<string, string>, cookie: string) => {\n const [key, value] = cookie.split('=');\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Extracts the headers as an object from the given Fetch API request or response object\n *\n * @param headers The headers to extract\n * @returns The extracted headers as an object\n */\nfunction _extractFetchHeaders(headers: Headers): Record<string, string> {\n const result: Record<string, string> = {};\n\n headers.forEach((value, key) => {\n result[key] = value;\n });\n\n return result;\n}\n\n/**\n * Extracts the response headers as an object from the given XHR object\n *\n * @param xhr The XHR object to extract the response headers from\n * @returns The response headers as an object\n */\nfunction _getXHRResponseHeaders(xhr: XMLHttpRequest): Record<string, string> {\n const headers = xhr.getAllResponseHeaders();\n\n if (!headers) {\n return {};\n }\n\n return headers.split('\\r\\n').reduce((acc: Record<string, string>, line: string) => {\n const [key, value] = line.split(': ');\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Checks if the given target url is in the given list of targets\n *\n * @param target The target url to check\n * @returns true if the target url is in the given list of targets, false otherwise\n */\nfunction _isInGivenRequestTargets(\n failedRequestTargets: HttpClientOptions['failedRequestTargets'],\n target: string,\n): boolean {\n return failedRequestTargets.some((givenRequestTarget: HttpRequestTarget) => {\n if (typeof givenRequestTarget === 'string') {\n return target.includes(givenRequestTarget);\n }\n\n return givenRequestTarget.test(target);\n });\n}\n\n/**\n * Checks if the given status code is in the given range\n *\n * @param status The status code to check\n * @returns true if the status code is in the given range, false otherwise\n */\nfunction _isInGivenStatusRanges(\n failedRequestStatusCodes: HttpClientOptions['failedRequestStatusCodes'],\n status: number,\n): boolean {\n return failedRequestStatusCodes.some((range: HttpStatusCodeRange) => {\n if (typeof range === 'number') {\n return range === status;\n }\n\n return status >= range[0] && status <= range[1];\n });\n}\n\n/**\n * Wraps `fetch` function to capture request and response data\n */\nfunction _wrapFetch(client: Client, options: HttpClientOptions): void {\n if (!supportsNativeFetch()) {\n return;\n }\n\n addFetchInstrumentationHandler(handlerData => {\n if (getClient() !== client) {\n return;\n }\n\n const { response, args } = handlerData;\n const [requestInfo, requestInit] = args as [RequestInfo, RequestInit | undefined];\n\n if (!response) {\n return;\n }\n\n _fetchResponseHandler(options, requestInfo, response as Response, requestInit);\n });\n}\n\n/**\n * Wraps XMLHttpRequest to capture request and response data\n */\nfunction _wrapXHR(client: Client, options: HttpClientOptions): void {\n if (!('XMLHttpRequest' in GLOBAL_OBJ)) {\n return;\n }\n\n addXhrInstrumentationHandler(handlerData => {\n if (getClient() !== client) {\n return;\n }\n\n const xhr = handlerData.xhr as SentryWrappedXMLHttpRequest & XMLHttpRequest;\n\n const sentryXhrData = xhr[SENTRY_XHR_DATA_KEY];\n\n if (!sentryXhrData) {\n return;\n }\n\n const { method, request_headers: headers } = sentryXhrData;\n\n try {\n _xhrResponseHandler(options, xhr, method, headers);\n } catch (e) {\n DEBUG_BUILD && logger.warn('Error while extracting response event form XHR response', e);\n }\n });\n}\n\n/**\n * Checks whether to capture given response as an event\n *\n * @param status response status code\n * @param url response url\n */\nfunction _shouldCaptureResponse(options: HttpClientOptions, status: number, url: string): boolean {\n return (\n _isInGivenStatusRanges(options.failedRequestStatusCodes, status) &&\n _isInGivenRequestTargets(options.failedRequestTargets, url) &&\n !isSentryRequestUrl(url, getClient())\n );\n}\n\n/**\n * Creates a synthetic Sentry event from given response data\n *\n * @param data response data\n * @returns event\n */\nfunction _createEvent(data: {\n url: string;\n method: string;\n status: number;\n responseHeaders?: Record<string, string>;\n responseCookies?: Record<string, string>;\n requestHeaders?: Record<string, string>;\n requestCookies?: Record<string, string>;\n}): SentryEvent {\n const message = `HTTP Client Error with status code: ${data.status}`;\n\n const event: SentryEvent = {\n message,\n exception: {\n values: [\n {\n type: 'Error',\n value: message,\n },\n ],\n },\n request: {\n url: data.url,\n method: data.method,\n headers: data.requestHeaders,\n cookies: data.requestCookies,\n },\n contexts: {\n response: {\n status_code: data.status,\n headers: data.responseHeaders,\n cookies: data.responseCookies,\n body_size: _getResponseSizeFromHeaders(data.responseHeaders),\n },\n },\n };\n\n addExceptionMechanism(event, {\n type: 'http.client',\n handled: false,\n });\n\n return event;\n}\n\nfunction _getRequest(requestInfo: RequestInfo, requestInit?: RequestInit): Request {\n if (!requestInit && requestInfo instanceof Request) {\n return requestInfo;\n }\n\n // If both are set, we try to construct a new Request with the given arguments\n // However, if e.g. the original request has a `body`, this will throw an error because it was already accessed\n // In this case, as a fallback, we just use the original request - using both is rather an edge case\n if (requestInfo instanceof Request && requestInfo.bodyUsed) {\n return requestInfo;\n }\n\n return new Request(requestInfo, requestInit);\n}\n\nfunction _shouldSendDefaultPii(): boolean {\n const client = getClient();\n return client ? Boolean(client.getOptions().sendDefaultPii) : false;\n}\n"],"names":["defineIntegration","captureEvent","DEBUG_BUILD","logger","supportsNativeFetch","addFetchInstrumentationHandler","getClient","GLOBAL_OBJ","addXhrInstrumentationHandler","SENTRY_XHR_DATA_KEY","isSentryRequestUrl","addExceptionMechanism"],"mappings":";;;;;;;AAgBA,MAAM,gBAAA,GAAmB,YAAY;;AAuBrC,MAAM,sBAAA,IAA0B,CAAC,OAAO,GAA+B,EAAE,KAAK;AAC9E,EAAE,MAAM,QAAQ,GAAsB;AACtC,IAAI,wBAAwB,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1C,IAAI,oBAAoB,EAAE,CAAC,IAAI,CAAC;AAChC,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAQ;AACxB,MAAM,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC;AAClC,MAAM,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;AAChC,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;MACa,qBAAsB,GAAEA,sBAAiB,CAAC,sBAAsB;;AAE7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,qBAAqB;AAC9B,EAAE,OAAO;AACT,EAAE,WAAW;AACb,EAAE,QAAQ;AACV,EAAE,WAAW;AACb,EAAQ;AACR,EAAE,IAAI,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE;AACtE,IAAI,MAAM,UAAU,WAAW,CAAC,WAAW,EAAE,WAAW,CAAC;;AAEzD,IAAI,IAAI,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe;;AAExE,IAAI,IAAI,qBAAqB,EAAE,EAAE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AA,KAAA,EAAA,OAAA;AACA,SAAA;AACA,OAAA;AACA,KAAA;AACA,IAAA,OAAA,EAAA;AACA,MAAA,GAAA,EAAA,IAAA,CAAA,GAAA;AACA,MAAA,MAAA,EAAA,IAAA,CAAA,MAAA;AACA,MAAA,OAAA,EAAA,IAAA,CAAA,cAAA;AACA,MAAA,OAAA,EAAA,IAAA,CAAA,cAAA;AACA,KAAA;AACA,IAAA,QAAA,EAAA;AACA,MAAA,QAAA,EAAA;AACA,QAAA,WAAA,EAAA,IAAA,CAAA,MAAA;AACA,QAAA,OAAA,EAAA,IAAA,CAAA,eAAA;AACA,QAAA,OAAA,EAAA,IAAA,CAAA,eAAA;AACA,QAAA,SAAA,EAAA,2BAAA,CAAA,IAAA,CAAA,eAAA,CAAA;AACA,OAAA;AACA,KAAA;AACA,GAAA;;AAEA,EAAAK,2BAAA,CAAA,KAAA,EAAA;AACA,IAAA,IAAA,EAAA,aAAA;AACA,IAAA,OAAA,EAAA,KAAA;AACA,GAAA,CAAA;;AAEA,EAAA,OAAA,KAAA;AACA;;AAEA,SAAA,WAAA,CAAA,WAAA,EAAA,WAAA,EAAA;AACA,EAAA,IAAA,CAAA,WAAA,IAAA,WAAA,YAAA,OAAA,EAAA;AACA,IAAA,OAAA,WAAA;AACA;;AAEA;AACA;AACA;AACA,EAAA,IAAA,WAAA,YAAA,OAAA,IAAA,WAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,WAAA;AACA;;AAEA,EAAA,OAAA,IAAA,OAAA,CAAA,WAAA,EAAA,WAAA,CAAA;AACA;;AAEA,SAAA,qBAAA,GAAA;AACA,EAAA,MAAA,MAAA,GAAAL,cAAA,EAAA;AACA,EAAA,OAAA,MAAA,GAAA,OAAA,CAAA,MAAA,CAAA,UAAA,EAAA,CAAA,cAAA,CAAA,GAAA,KAAA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"httpclient.js","sources":["../../../../src/integrations/httpclient.ts"],"sourcesContent":["import { SENTRY_XHR_DATA_KEY, addXhrInstrumentationHandler } from '@sentry-internal/browser-utils';\nimport { captureEvent, defineIntegration, getClient, isSentryRequestUrl } from '@sentry/core';\nimport {\n GLOBAL_OBJ,\n addExceptionMechanism,\n addFetchInstrumentationHandler,\n logger,\n supportsNativeFetch,\n} from '@sentry/core';\nimport type { Client, Event as SentryEvent, IntegrationFn, SentryWrappedXMLHttpRequest } from '@sentry/types';\n\nimport { DEBUG_BUILD } from '../debug-build';\n\nexport type HttpStatusCodeRange = [number, number] | number;\nexport type HttpRequestTarget = string | RegExp;\n\nconst INTEGRATION_NAME = 'HttpClient';\n\ninterface HttpClientOptions {\n /**\n * HTTP status codes that should be considered failed.\n * This array can contain tuples of `[begin, end]` (both inclusive),\n * single status codes, or a combinations of both\n *\n * Example: [[500, 505], 507]\n * Default: [[500, 599]]\n */\n failedRequestStatusCodes: HttpStatusCodeRange[];\n\n /**\n * Targets to track for failed requests.\n * This array can contain strings or regular expressions.\n *\n * Example: ['http://localhost', /api\\/.*\\/]\n * Default: [/.*\\/]\n */\n failedRequestTargets: HttpRequestTarget[];\n}\n\nconst _httpClientIntegration = ((options: Partial<HttpClientOptions> = {}) => {\n const _options: HttpClientOptions = {\n failedRequestStatusCodes: [[500, 599]],\n failedRequestTargets: [/.*/],\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client): void {\n _wrapFetch(client, _options);\n _wrapXHR(client, _options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Create events for failed client side HTTP requests.\n */\nexport const httpClientIntegration = defineIntegration(_httpClientIntegration);\n\n/**\n * Interceptor function for fetch requests\n *\n * @param requestInfo The Fetch API request info\n * @param response The Fetch API response\n * @param requestInit The request init object\n */\nfunction _fetchResponseHandler(\n options: HttpClientOptions,\n requestInfo: RequestInfo,\n response: Response,\n requestInit?: RequestInit,\n): void {\n if (_shouldCaptureResponse(options, response.status, response.url)) {\n const request = _getRequest(requestInfo, requestInit);\n\n let requestHeaders, responseHeaders, requestCookies, responseCookies;\n\n if (_shouldSendDefaultPii()) {\n [requestHeaders, requestCookies] = _parseCookieHeaders('Cookie', request);\n [responseHeaders, responseCookies] = _parseCookieHeaders('Set-Cookie', response);\n }\n\n const event = _createEvent({\n url: request.url,\n method: request.method,\n status: response.status,\n requestHeaders,\n responseHeaders,\n requestCookies,\n responseCookies,\n });\n\n captureEvent(event);\n }\n}\n\nfunction _parseCookieHeaders(\n cookieHeader: string,\n obj: Request | Response,\n): [Record<string, string>, Record<string, string> | undefined] {\n const headers = _extractFetchHeaders(obj.headers);\n let cookies;\n\n try {\n const cookieString = headers[cookieHeader] || headers[cookieHeader.toLowerCase()] || undefined;\n\n if (cookieString) {\n cookies = _parseCookieString(cookieString);\n }\n } catch (e) {\n DEBUG_BUILD && logger.log(`Could not extract cookies from header ${cookieHeader}`);\n }\n\n return [headers, cookies];\n}\n\n/**\n * Interceptor function for XHR requests\n *\n * @param xhr The XHR request\n * @param method The HTTP method\n * @param headers The HTTP headers\n */\nfunction _xhrResponseHandler(\n options: HttpClientOptions,\n xhr: XMLHttpRequest,\n method: string,\n headers: Record<string, string>,\n): void {\n if (_shouldCaptureResponse(options, xhr.status, xhr.responseURL)) {\n let requestHeaders, responseCookies, responseHeaders;\n\n if (_shouldSendDefaultPii()) {\n try {\n const cookieString = xhr.getResponseHeader('Set-Cookie') || xhr.getResponseHeader('set-cookie') || undefined;\n\n if (cookieString) {\n responseCookies = _parseCookieString(cookieString);\n }\n } catch (e) {\n DEBUG_BUILD && logger.log('Could not extract cookies from response headers');\n }\n\n try {\n responseHeaders = _getXHRResponseHeaders(xhr);\n } catch (e) {\n DEBUG_BUILD && logger.log('Could not extract headers from response');\n }\n\n requestHeaders = headers;\n }\n\n const event = _createEvent({\n url: xhr.responseURL,\n method,\n status: xhr.status,\n requestHeaders,\n // Can't access request cookies from XHR\n responseHeaders,\n responseCookies,\n });\n\n captureEvent(event);\n }\n}\n\n/**\n * Extracts response size from `Content-Length` header when possible\n *\n * @param headers\n * @returns The response size in bytes or undefined\n */\nfunction _getResponseSizeFromHeaders(headers?: Record<string, string>): number | undefined {\n if (headers) {\n const contentLength = headers['Content-Length'] || headers['content-length'];\n\n if (contentLength) {\n return parseInt(contentLength, 10);\n }\n }\n\n return undefined;\n}\n\n/**\n * Creates an object containing cookies from the given cookie string\n *\n * @param cookieString The cookie string to parse\n * @returns The parsed cookies\n */\nfunction _parseCookieString(cookieString: string): Record<string, string> {\n return cookieString.split('; ').reduce((acc: Record<string, string>, cookie: string) => {\n const [key, value] = cookie.split('=');\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Extracts the headers as an object from the given Fetch API request or response object\n *\n * @param headers The headers to extract\n * @returns The extracted headers as an object\n */\nfunction _extractFetchHeaders(headers: Headers): Record<string, string> {\n const result: Record<string, string> = {};\n\n headers.forEach((value, key) => {\n result[key] = value;\n });\n\n return result;\n}\n\n/**\n * Extracts the response headers as an object from the given XHR object\n *\n * @param xhr The XHR object to extract the response headers from\n * @returns The response headers as an object\n */\nfunction _getXHRResponseHeaders(xhr: XMLHttpRequest): Record<string, string> {\n const headers = xhr.getAllResponseHeaders();\n\n if (!headers) {\n return {};\n }\n\n return headers.split('\\r\\n').reduce((acc: Record<string, string>, line: string) => {\n const [key, value] = line.split(': ');\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Checks if the given target url is in the given list of targets\n *\n * @param target The target url to check\n * @returns true if the target url is in the given list of targets, false otherwise\n */\nfunction _isInGivenRequestTargets(\n failedRequestTargets: HttpClientOptions['failedRequestTargets'],\n target: string,\n): boolean {\n return failedRequestTargets.some((givenRequestTarget: HttpRequestTarget) => {\n if (typeof givenRequestTarget === 'string') {\n return target.includes(givenRequestTarget);\n }\n\n return givenRequestTarget.test(target);\n });\n}\n\n/**\n * Checks if the given status code is in the given range\n *\n * @param status The status code to check\n * @returns true if the status code is in the given range, false otherwise\n */\nfunction _isInGivenStatusRanges(\n failedRequestStatusCodes: HttpClientOptions['failedRequestStatusCodes'],\n status: number,\n): boolean {\n return failedRequestStatusCodes.some((range: HttpStatusCodeRange) => {\n if (typeof range === 'number') {\n return range === status;\n }\n\n return status >= range[0] && status <= range[1];\n });\n}\n\n/**\n * Wraps `fetch` function to capture request and response data\n */\nfunction _wrapFetch(client: Client, options: HttpClientOptions): void {\n if (!supportsNativeFetch()) {\n return;\n }\n\n addFetchInstrumentationHandler(handlerData => {\n if (getClient() !== client) {\n return;\n }\n\n const { response, args } = handlerData;\n const [requestInfo, requestInit] = args as [RequestInfo, RequestInit | undefined];\n\n if (!response) {\n return;\n }\n\n _fetchResponseHandler(options, requestInfo, response as Response, requestInit);\n });\n}\n\n/**\n * Wraps XMLHttpRequest to capture request and response data\n */\nfunction _wrapXHR(client: Client, options: HttpClientOptions): void {\n if (!('XMLHttpRequest' in GLOBAL_OBJ)) {\n return;\n }\n\n addXhrInstrumentationHandler(handlerData => {\n if (getClient() !== client) {\n return;\n }\n\n const xhr = handlerData.xhr as SentryWrappedXMLHttpRequest & XMLHttpRequest;\n\n const sentryXhrData = xhr[SENTRY_XHR_DATA_KEY];\n\n if (!sentryXhrData) {\n return;\n }\n\n const { method, request_headers: headers } = sentryXhrData;\n\n try {\n _xhrResponseHandler(options, xhr, method, headers);\n } catch (e) {\n DEBUG_BUILD && logger.warn('Error while extracting response event form XHR response', e);\n }\n });\n}\n\n/**\n * Checks whether to capture given response as an event\n *\n * @param status response status code\n * @param url response url\n */\nfunction _shouldCaptureResponse(options: HttpClientOptions, status: number, url: string): boolean {\n return (\n _isInGivenStatusRanges(options.failedRequestStatusCodes, status) &&\n _isInGivenRequestTargets(options.failedRequestTargets, url) &&\n !isSentryRequestUrl(url, getClient())\n );\n}\n\n/**\n * Creates a synthetic Sentry event from given response data\n *\n * @param data response data\n * @returns event\n */\nfunction _createEvent(data: {\n url: string;\n method: string;\n status: number;\n responseHeaders?: Record<string, string>;\n responseCookies?: Record<string, string>;\n requestHeaders?: Record<string, string>;\n requestCookies?: Record<string, string>;\n}): SentryEvent {\n const message = `HTTP Client Error with status code: ${data.status}`;\n\n const event: SentryEvent = {\n message,\n exception: {\n values: [\n {\n type: 'Error',\n value: message,\n },\n ],\n },\n request: {\n url: data.url,\n method: data.method,\n headers: data.requestHeaders,\n cookies: data.requestCookies,\n },\n contexts: {\n response: {\n status_code: data.status,\n headers: data.responseHeaders,\n cookies: data.responseCookies,\n body_size: _getResponseSizeFromHeaders(data.responseHeaders),\n },\n },\n };\n\n addExceptionMechanism(event, {\n type: 'http.client',\n handled: false,\n });\n\n return event;\n}\n\nfunction _getRequest(requestInfo: RequestInfo, requestInit?: RequestInit): Request {\n if (!requestInit && requestInfo instanceof Request) {\n return requestInfo;\n }\n\n // If both are set, we try to construct a new Request with the given arguments\n // However, if e.g. the original request has a `body`, this will throw an error because it was already accessed\n // In this case, as a fallback, we just use the original request - using both is rather an edge case\n if (requestInfo instanceof Request && requestInfo.bodyUsed) {\n return requestInfo;\n }\n\n return new Request(requestInfo, requestInit);\n}\n\nfunction _shouldSendDefaultPii(): boolean {\n const client = getClient();\n return client ? Boolean(client.getOptions().sendDefaultPii) : false;\n}\n"],"names":["defineIntegration","captureEvent","DEBUG_BUILD","logger","supportsNativeFetch","addFetchInstrumentationHandler","getClient","GLOBAL_OBJ","addXhrInstrumentationHandler","SENTRY_XHR_DATA_KEY","isSentryRequestUrl","addExceptionMechanism"],"mappings":";;;;;;AAgBA,MAAM,gBAAA,GAAmB,YAAY;;AAuBrC,MAAM,sBAAA,IAA0B,CAAC,OAAO,GAA+B,EAAE,KAAK;AAC9E,EAAE,MAAM,QAAQ,GAAsB;AACtC,IAAI,wBAAwB,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1C,IAAI,oBAAoB,EAAE,CAAC,IAAI,CAAC;AAChC,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAQ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EA,EAAA,OAAA,KAAA;AACA;;AAEA,SAAA,WAAA,CAAA,WAAA,EAAA,WAAA,EAAA;AACA,EAAA,IAAA,CAAA,WAAA,IAAA,WAAA,YAAA,OAAA,EAAA;AACA,IAAA,OAAA,WAAA;AACA;;AAEA;AACA;AACA;AACA,EAAA,IAAA,WAAA,YAAA,OAAA,IAAA,WAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,WAAA;AACA;;AAEA,EAAA,OAAA,IAAA,OAAA,CAAA,WAAA,EAAA,WAAA,CAAA;AACA;;AAEA,SAAA,qBAAA,GAAA;AACA,EAAA,MAAA,MAAA,GAAAL,cAAA,EAAA;AACA,EAAA,OAAA,MAAA,GAAA,OAAA,CAAA,MAAA,CAAA,UAAA,EAAA,CAAA,cAAA,CAAA,GAAA,KAAA;AACA;;;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
|
-
const utils = require('@sentry/utils');
|
|
5
4
|
const eventbuilder = require('../eventbuilder.js');
|
|
6
5
|
|
|
7
6
|
const DEFAULT_KEY = 'cause';
|
|
@@ -18,7 +17,7 @@ const _linkedErrorsIntegration = ((options = {}) => {
|
|
|
18
17
|
preprocessEvent(event, hint, client) {
|
|
19
18
|
const options = client.getOptions();
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
core.applyAggregateErrorsToEvent(
|
|
22
21
|
// This differs from the LinkedErrors integration in core by using a different exceptionFromError function
|
|
23
22
|
eventbuilder.exceptionFromError,
|
|
24
23
|
options.stackParser,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkederrors.js","sources":["../../../../src/integrations/linkederrors.ts"],"sourcesContent":["import { defineIntegration } from '@sentry/core';\nimport
|
|
1
|
+
{"version":3,"file":"linkederrors.js","sources":["../../../../src/integrations/linkederrors.ts"],"sourcesContent":["import { defineIntegration } from '@sentry/core';\nimport { applyAggregateErrorsToEvent } from '@sentry/core';\nimport type { IntegrationFn } from '@sentry/types';\nimport { exceptionFromError } from '../eventbuilder';\n\ninterface LinkedErrorsOptions {\n key?: string;\n limit?: number;\n}\n\nconst DEFAULT_KEY = 'cause';\nconst DEFAULT_LIMIT = 5;\n\nconst INTEGRATION_NAME = 'LinkedErrors';\n\nconst _linkedErrorsIntegration = ((options: LinkedErrorsOptions = {}) => {\n const limit = options.limit || DEFAULT_LIMIT;\n const key = options.key || DEFAULT_KEY;\n\n return {\n name: INTEGRATION_NAME,\n preprocessEvent(event, hint, client) {\n const options = client.getOptions();\n\n applyAggregateErrorsToEvent(\n // This differs from the LinkedErrors integration in core by using a different exceptionFromError function\n exceptionFromError,\n options.stackParser,\n options.maxValueLength,\n key,\n limit,\n event,\n hint,\n );\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Aggregrate linked errors in an event.\n */\nexport const linkedErrorsIntegration = defineIntegration(_linkedErrorsIntegration);\n"],"names":["applyAggregateErrorsToEvent","exceptionFromError","defineIntegration"],"mappings":";;;;;AAUA,MAAM,WAAA,GAAc,OAAO;AAC3B,MAAM,aAAA,GAAgB,CAAC;;AAEvB,MAAM,gBAAA,GAAmB,cAAc;;AAEvC,MAAM,wBAAA,IAA4B,CAAC,OAAO,GAAwB,EAAE,KAAK;AACzE,EAAE,MAAM,KAAM,GAAE,OAAO,CAAC,KAAA,IAAS,aAAa;AAC9C,EAAE,MAAM,GAAI,GAAE,OAAO,CAAC,GAAA,IAAO,WAAW;;AAExC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;AACzC,MAAM,MAAM,OAAQ,GAAE,MAAM,CAAC,UAAU,EAAE;;AAEzC,MAAMA,gCAA2B;AACjC;AACA,QAAQC,+BAAkB;AAC1B,QAAQ,OAAO,CAAC,WAAW;AAC3B,QAAQ,OAAO,CAAC,cAAc;AAC9B,QAAQ,GAAG;AACX,QAAQ,KAAK;AACb,QAAQ,KAAK;AACb,QAAQ,IAAI;AACZ,OAAO;AACP,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;MACa,uBAAwB,GAAEC,sBAAiB,CAAC,wBAAwB;;;;"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
|
-
const utils = require('@sentry/utils');
|
|
5
4
|
|
|
6
|
-
const WINDOW =
|
|
5
|
+
const WINDOW = core.GLOBAL_OBJ ;
|
|
7
6
|
|
|
8
7
|
const INTEGRATION_NAME = 'ReportingObserver';
|
|
9
8
|
|
|
@@ -56,7 +55,7 @@ const _reportingObserverIntegration = ((options = {}) => {
|
|
|
56
55
|
return {
|
|
57
56
|
name: INTEGRATION_NAME,
|
|
58
57
|
setupOnce() {
|
|
59
|
-
if (!
|
|
58
|
+
if (!core.supportsReportingObserver()) {
|
|
60
59
|
return;
|
|
61
60
|
}
|
|
62
61
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportingobserver.js","sources":["../../../../src/integrations/reportingobserver.ts"],"sourcesContent":["import { captureMessage, defineIntegration, getClient, withScope } from '@sentry/core';\nimport
|
|
1
|
+
{"version":3,"file":"reportingobserver.js","sources":["../../../../src/integrations/reportingobserver.ts"],"sourcesContent":["import { captureMessage, defineIntegration, getClient, withScope } from '@sentry/core';\nimport { GLOBAL_OBJ, supportsReportingObserver } from '@sentry/core';\nimport type { Client, IntegrationFn } from '@sentry/types';\n\nconst WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nconst INTEGRATION_NAME = 'ReportingObserver';\n\ninterface Report {\n [key: string]: unknown;\n type: ReportTypes;\n url: string;\n body?: ReportBody;\n}\n\ntype ReportTypes = 'crash' | 'deprecation' | 'intervention';\n\ntype ReportBody = CrashReportBody | DeprecationReportBody | InterventionReportBody;\n\ninterface CrashReportBody {\n [key: string]: unknown;\n crashId: string;\n reason?: string;\n}\n\ninterface DeprecationReportBody {\n [key: string]: unknown;\n id: string;\n anticipatedRemoval?: Date;\n message: string;\n sourceFile?: string;\n lineNumber?: number;\n columnNumber?: number;\n}\n\ninterface InterventionReportBody {\n [key: string]: unknown;\n id: string;\n message: string;\n sourceFile?: string;\n lineNumber?: number;\n columnNumber?: number;\n}\n\ninterface ReportingObserverOptions {\n types?: ReportTypes[];\n}\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _reportingObserverIntegration = ((options: ReportingObserverOptions = {}) => {\n const types = options.types || ['crash', 'deprecation', 'intervention'];\n\n /** Handler for the reporting observer. */\n function handler(reports: Report[]): void {\n if (!SETUP_CLIENTS.has(getClient() as Client)) {\n return;\n }\n\n for (const report of reports) {\n withScope(scope => {\n scope.setExtra('url', report.url);\n\n const label = `ReportingObserver [${report.type}]`;\n let details = 'No details available';\n\n if (report.body) {\n // Object.keys doesn't work on ReportBody, as all properties are inherited\n const plainBody: {\n [key: string]: unknown;\n } = {};\n\n // eslint-disable-next-line guard-for-in\n for (const prop in report.body) {\n plainBody[prop] = report.body[prop];\n }\n\n scope.setExtra('body', plainBody);\n\n if (report.type === 'crash') {\n const body = report.body as CrashReportBody;\n // A fancy way to create a message out of crashId OR reason OR both OR fallback\n details = [body.crashId || '', body.reason || ''].join(' ').trim() || details;\n } else {\n const body = report.body as DeprecationReportBody | InterventionReportBody;\n details = body.message || details;\n }\n }\n\n captureMessage(`${label}: ${details}`);\n });\n }\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!supportsReportingObserver()) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const observer = new (WINDOW as any).ReportingObserver(handler, {\n buffered: true,\n types,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n observer.observe();\n },\n\n setup(client): void {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Reporting API integration - https://w3c.github.io/reporting/\n */\nexport const reportingObserverIntegration = defineIntegration(_reportingObserverIntegration);\n"],"names":["GLOBAL_OBJ","getClient","withScope","captureMessage","supportsReportingObserver","defineIntegration"],"mappings":";;;;AAIA,MAAM,MAAA,GAASA,eAAW;;AAE1B,MAAM,gBAAA,GAAmB,mBAAmB;;AA0C5C,MAAM,aAAc,GAAE,IAAI,OAAO,EAAmB;;AAEpD,MAAM,6BAAA,IAAiC,CAAC,OAAO,GAA6B,EAAE,KAAK;AACnF,EAAE,MAAM,KAAA,GAAQ,OAAO,CAAC,KAAA,IAAS,CAAC,OAAO,EAAE,aAAa,EAAE,cAAc,CAAC;;AAEzE;AACA,EAAE,SAAS,OAAO,CAAC,OAAO,EAAkB;AAC5C,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAACC,cAAS,EAAG,EAAU,EAAE;AACnD,MAAM;AACN;;AAEA,IAAI,KAAK,MAAM,MAAO,IAAG,OAAO,EAAE;AAClC,MAAMC,cAAS,CAAC,KAAA,IAAS;AACzB,QAAQ,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC;;AAEzC,QAAQ,MAAM,KAAM,GAAE,CAAC,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1D,QAAQ,IAAI,OAAQ,GAAE,sBAAsB;;AAE5C,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE;AACzB;AACA,UAAU,MAAM;;AAEN,GAAI,EAAE;;AAEhB;AACA,UAAU,KAAK,MAAM,IAAA,IAAQ,MAAM,CAAC,IAAI,EAAE;AAC1C,YAAY,SAAS,CAAC,IAAI,CAAE,GAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AAC/C;;AAEA,UAAU,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;;AAE3C,UAAU,IAAI,MAAM,CAAC,IAAK,KAAI,OAAO,EAAE;AACvC,YAAY,MAAM,IAAA,GAAO,MAAM,CAAC,IAAK;AACrC;AACA,YAAY,OAAA,GAAU,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,MAAA,IAAU,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAG,IAAG,OAAO;AACzF,iBAAiB;AACjB,YAAY,MAAM,IAAA,GAAO,MAAM,CAAC,IAAK;AACrC,YAAY,UAAU,IAAI,CAAC,OAAA,IAAW,OAAO;AAC7C;AACA;;AAEA,QAAQC,mBAAc,CAAC,CAAC,EAAA,KAAA,CAAA,EAAA,EAAA,OAAA,CAAA,CAAA,CAAA;AACA,OAAA,CAAA;AACA;AACA;;AAEA,EAAA,OAAA;AACA,IAAA,IAAA,EAAA,gBAAA;AACA,IAAA,SAAA,GAAA;AACA,MAAA,IAAA,CAAAC,8BAAA,EAAA,EAAA;AACA,QAAA;AACA;;AAEA;AACA,MAAA,MAAA,QAAA,GAAA,IAAA,CAAA,MAAA,GAAA,iBAAA,CAAA,OAAA,EAAA;AACA,QAAA,QAAA,EAAA,IAAA;AACA,QAAA,KAAA;AACA,OAAA,CAAA;;AAEA;AACA,MAAA,QAAA,CAAA,OAAA,EAAA;AACA,KAAA;;AAEA,IAAA,KAAA,CAAA,MAAA,EAAA;AACA,MAAA,aAAA,CAAA,GAAA,CAAA,MAAA,EAAA,IAAA,CAAA;AACA,KAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA,MAAA,4BAAA,GAAAC,sBAAA,CAAA,6BAAA;;;;"}
|
|
@@ -2,7 +2,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2
2
|
|
|
3
3
|
const browserUtils = require('@sentry-internal/browser-utils');
|
|
4
4
|
const core = require('@sentry/core');
|
|
5
|
-
const utils = require('@sentry/utils');
|
|
6
5
|
const debugBuild = require('../debug-build.js');
|
|
7
6
|
|
|
8
7
|
const INTEGRATION_NAME = 'SpotlightBrowser';
|
|
@@ -13,7 +12,7 @@ const _spotlightIntegration = ((options = {}) => {
|
|
|
13
12
|
return {
|
|
14
13
|
name: INTEGRATION_NAME,
|
|
15
14
|
setup: () => {
|
|
16
|
-
debugBuild.DEBUG_BUILD &&
|
|
15
|
+
debugBuild.DEBUG_BUILD && core.logger.log('Using Sidecar URL', sidecarUrl);
|
|
17
16
|
},
|
|
18
17
|
// We don't want to send interaction transactions/root spans created from
|
|
19
18
|
// clicks within Spotlight to Sentry. Neither do we want them to be sent to
|
|
@@ -31,13 +30,13 @@ function setupSidecarForwarding(client, sidecarUrl) {
|
|
|
31
30
|
|
|
32
31
|
client.on('beforeEnvelope', (envelope) => {
|
|
33
32
|
if (failCount > 3) {
|
|
34
|
-
|
|
33
|
+
core.logger.warn('[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests:', failCount);
|
|
35
34
|
return;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
makeFetch(sidecarUrl, {
|
|
39
38
|
method: 'POST',
|
|
40
|
-
body:
|
|
39
|
+
body: core.serializeEnvelope(envelope),
|
|
41
40
|
headers: {
|
|
42
41
|
'Content-Type': 'application/x-sentry-envelope',
|
|
43
42
|
},
|
|
@@ -51,7 +50,7 @@ function setupSidecarForwarding(client, sidecarUrl) {
|
|
|
51
50
|
},
|
|
52
51
|
err => {
|
|
53
52
|
failCount++;
|
|
54
|
-
|
|
53
|
+
core.logger.error(
|
|
55
54
|
"Sentry SDK can't connect to Sidecar is it running? See: https://spotlightjs.com/sidecar/npx/",
|
|
56
55
|
err,
|
|
57
56
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotlight.js","sources":["../../../../src/integrations/spotlight.ts"],"sourcesContent":["import { getNativeImplementation } from '@sentry-internal/browser-utils';\nimport { defineIntegration } from '@sentry/core';\nimport
|
|
1
|
+
{"version":3,"file":"spotlight.js","sources":["../../../../src/integrations/spotlight.ts"],"sourcesContent":["import { getNativeImplementation } from '@sentry-internal/browser-utils';\nimport { defineIntegration } from '@sentry/core';\nimport { logger, serializeEnvelope } from '@sentry/core';\nimport type { Client, Envelope, Event, IntegrationFn } from '@sentry/types';\nimport type { WINDOW } from '../helpers';\n\nimport { DEBUG_BUILD } from '../debug-build';\n\nexport type SpotlightConnectionOptions = {\n /**\n * Set this if the Spotlight Sidecar is not running on localhost:8969\n * By default, the Url is set to http://localhost:8969/stream\n */\n sidecarUrl?: string;\n};\n\nexport const INTEGRATION_NAME = 'SpotlightBrowser';\n\nconst _spotlightIntegration = ((options: Partial<SpotlightConnectionOptions> = {}) => {\n const sidecarUrl = options.sidecarUrl || 'http://localhost:8969/stream';\n\n return {\n name: INTEGRATION_NAME,\n setup: () => {\n DEBUG_BUILD && logger.log('Using Sidecar URL', sidecarUrl);\n },\n // We don't want to send interaction transactions/root spans created from\n // clicks within Spotlight to Sentry. Neither do we want them to be sent to\n // spotlight.\n processEvent: event => (isSpotlightInteraction(event) ? null : event),\n afterAllSetup: (client: Client) => {\n setupSidecarForwarding(client, sidecarUrl);\n },\n };\n}) satisfies IntegrationFn;\n\nfunction setupSidecarForwarding(client: Client, sidecarUrl: string): void {\n const makeFetch: typeof WINDOW.fetch | undefined = getNativeImplementation('fetch');\n let failCount = 0;\n\n client.on('beforeEnvelope', (envelope: Envelope) => {\n if (failCount > 3) {\n logger.warn('[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests:', failCount);\n return;\n }\n\n makeFetch(sidecarUrl, {\n method: 'POST',\n body: serializeEnvelope(envelope),\n headers: {\n 'Content-Type': 'application/x-sentry-envelope',\n },\n mode: 'cors',\n }).then(\n res => {\n if (res.status >= 200 && res.status < 400) {\n // Reset failed requests counter on success\n failCount = 0;\n }\n },\n err => {\n failCount++;\n logger.error(\n \"Sentry SDK can't connect to Sidecar is it running? See: https://spotlightjs.com/sidecar/npx/\",\n err,\n );\n },\n );\n });\n}\n\n/**\n * Use this integration to send errors and transactions to Spotlight.\n *\n * Learn more about spotlight at https://spotlightjs.com\n */\nexport const spotlightBrowserIntegration = defineIntegration(_spotlightIntegration);\n\n/**\n * Flags if the event is a transaction created from an interaction with the spotlight UI.\n */\nexport function isSpotlightInteraction(event: Event): boolean {\n return Boolean(\n event.type === 'transaction' &&\n event.spans &&\n event.contexts &&\n event.contexts.trace &&\n event.contexts.trace.op === 'ui.action.click' &&\n event.spans.some(({ description }) => description && description.includes('#sentry-spotlight')),\n );\n}\n"],"names":["DEBUG_BUILD","logger","getNativeImplementation","serializeEnvelope","defineIntegration"],"mappings":";;;;;;AAgBO,MAAM,gBAAiB,GAAE;;AAEhC,MAAM,qBAAA,IAAyB,CAAC,OAAO,GAAwC,EAAE,KAAK;AACtF,EAAE,MAAM,UAAW,GAAE,OAAO,CAAC,UAAA,IAAc,8BAA8B;;AAEzE,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,EAAE,MAAM;AACjB,MAAMA,sBAAA,IAAeC,WAAM,CAAC,GAAG,CAAC,mBAAmB,EAAE,UAAU,CAAC;AAChE,KAAK;AACL;AACA;AACA;AACA,IAAI,YAAY,EAAE,KAAM,KAAI,sBAAsB,CAAC,KAAK,CAAE,GAAE,IAAK,GAAE,KAAK,CAAC;AACzE,IAAI,aAAa,EAAE,CAAC,MAAM,KAAa;AACvC,MAAM,sBAAsB,CAAC,MAAM,EAAE,UAAU,CAAC;AAChD,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH,SAAS,sBAAsB,CAAC,MAAM,EAAU,UAAU,EAAgB;AAC1E,EAAE,MAAM,SAAS,GAAoCC,oCAAuB,CAAC,OAAO,CAAC;AACrF,EAAE,IAAI,SAAU,GAAE,CAAC;;AAEnB,EAAE,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,QAAQ,KAAe;AACtD,IAAI,IAAI,SAAU,GAAE,CAAC,EAAE;AACvB,MAAMD,WAAM,CAAC,IAAI,CAAC,uFAAuF,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= require('@sentry/core');
|
|
4
|
-
const utils$1 = require('@sentry/utils');
|
|
5
4
|
const debugBuild = require('../debug-build.js');
|
|
6
5
|
const startProfileForSpan = require('./startProfileForSpan.js');
|
|
7
6
|
const utils = require('./utils.js');
|
|
@@ -46,12 +45,12 @@ const _browserProfilingIntegration = (() => {
|
|
|
46
45
|
const start_timestamp = context && context['profile'] && context['profile']['start_timestamp'];
|
|
47
46
|
|
|
48
47
|
if (typeof profile_id !== 'string') {
|
|
49
|
-
debugBuild.DEBUG_BUILD &&
|
|
48
|
+
debugBuild.DEBUG_BUILD && core.logger.log('[Profiling] cannot find profile for a span without a profile context');
|
|
50
49
|
continue;
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
if (!profile_id) {
|
|
54
|
-
debugBuild.DEBUG_BUILD &&
|
|
53
|
+
debugBuild.DEBUG_BUILD && core.logger.log('[Profiling] cannot find profile for a span without a profile context');
|
|
55
54
|
continue;
|
|
56
55
|
}
|
|
57
56
|
|
|
@@ -62,7 +61,7 @@ const _browserProfilingIntegration = (() => {
|
|
|
62
61
|
|
|
63
62
|
const profile = utils.takeProfileFromGlobalCache(profile_id);
|
|
64
63
|
if (!profile) {
|
|
65
|
-
debugBuild.DEBUG_BUILD &&
|
|
64
|
+
debugBuild.DEBUG_BUILD && core.logger.log(`[Profiling] Could not retrieve profile for span: ${profile_id}`);
|
|
66
65
|
continue;
|
|
67
66
|
}
|
|
68
67
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.js","sources":["../../../../src/profiling/integration.ts"],"sourcesContent":["import { defineIntegration, getActiveSpan, getRootSpan } from '@sentry/core';\nimport
|
|
1
|
+
{"version":3,"file":"integration.js","sources":["../../../../src/profiling/integration.ts"],"sourcesContent":["import { defineIntegration, getActiveSpan, getRootSpan } from '@sentry/core';\nimport { logger } from '@sentry/core';\nimport type { EventEnvelope, IntegrationFn, Profile, Span } from '@sentry/types';\n\nimport { DEBUG_BUILD } from '../debug-build';\nimport { startProfileForSpan } from './startProfileForSpan';\nimport type { ProfiledEvent } from './utils';\nimport { isAutomatedPageLoadSpan, shouldProfileSpan } from './utils';\nimport {\n addProfilesToEnvelope,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n getActiveProfilesCount,\n takeProfileFromGlobalCache,\n} from './utils';\n\nconst INTEGRATION_NAME = 'BrowserProfiling';\n\nconst _browserProfilingIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n\n if (rootSpan && isAutomatedPageLoadSpan(rootSpan)) {\n if (shouldProfileSpan(rootSpan)) {\n startProfileForSpan(rootSpan);\n }\n }\n\n client.on('spanStart', (span: Span) => {\n if (span === getRootSpan(span) && shouldProfileSpan(span)) {\n startProfileForSpan(span);\n }\n });\n\n client.on('beforeEnvelope', (envelope): void => {\n // if not profiles are in queue, there is nothing to add to the envelope.\n if (!getActiveProfilesCount()) {\n return;\n }\n\n const profiledTransactionEvents = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactionEvents.length) {\n return;\n }\n\n const profilesToAddToEnvelope: Profile[] = [];\n\n for (const profiledTransaction of profiledTransactionEvents) {\n const context = profiledTransaction && profiledTransaction.contexts;\n const profile_id = context && context['profile'] && context['profile']['profile_id'];\n const start_timestamp = context && context['profile'] && context['profile']['start_timestamp'];\n\n if (typeof profile_id !== 'string') {\n DEBUG_BUILD && logger.log('[Profiling] cannot find profile for a span without a profile context');\n continue;\n }\n\n if (!profile_id) {\n DEBUG_BUILD && logger.log('[Profiling] cannot find profile for a span without a profile context');\n continue;\n }\n\n // Remove the profile from the span context before sending, relay will take care of the rest.\n if (context && context['profile']) {\n delete context.profile;\n }\n\n const profile = takeProfileFromGlobalCache(profile_id);\n if (!profile) {\n DEBUG_BUILD && logger.log(`[Profiling] Could not retrieve profile for span: ${profile_id}`);\n continue;\n }\n\n const profileEvent = createProfilingEvent(\n profile_id,\n start_timestamp as number | undefined,\n profile,\n profiledTransaction as ProfiledEvent,\n );\n if (profileEvent) {\n profilesToAddToEnvelope.push(profileEvent);\n }\n }\n\n addProfilesToEnvelope(envelope as EventEnvelope, profilesToAddToEnvelope);\n });\n },\n };\n}) satisfies IntegrationFn;\n\nexport const browserProfilingIntegration = defineIntegration(_browserProfilingIntegration);\n"],"names":["getActiveSpan","getRootSpan","isAutomatedPageLoadSpan","shouldProfileSpan","startProfileForSpan","getActiveProfilesCount","findProfiledTransactionsFromEnvelope","DEBUG_BUILD","logger","takeProfileFromGlobalCache","createProfilingEvent","addProfilesToEnvelope","defineIntegration"],"mappings":";;;;;;;AAgBA,MAAM,gBAAA,GAAmB,kBAAkB;;AAE3C,MAAM,4BAA6B,IAAG,MAAM;AAC5C,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,UAAA,GAAaA,kBAAa,EAAE;AACxC,MAAM,MAAM,WAAW,UAAA,IAAcC,gBAAW,CAAC,UAAU,CAAC;;AAE5D,MAAM,IAAI,QAAS,IAAGC,6BAAuB,CAAC,QAAQ,CAAC,EAAE;AACzD,QAAQ,IAAIC,uBAAiB,CAAC,QAAQ,CAAC,EAAE;AACzC,UAAUC,uCAAmB,CAAC,QAAQ,CAAC;AACvC;AACA;;AAEA,MAAM,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,IAAI,KAAW;AAC7C,QAAQ,IAAI,IAAK,KAAIH,gBAAW,CAAC,IAAI,CAAA,IAAKE,uBAAiB,CAAC,IAAI,CAAC,EAAE;AACnE,UAAUC,uCAAmB,CAAC,IAAI,CAAC;AACnC;AACA,OAAO,CAAC;;AAER,MAAM,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,QAAQ,KAAW;AACtD;AACA,QAAQ,IAAI,CAACC,4BAAsB,EAAE,EAAE;AACvC,UAAU;AACV;;AAEA,QAAQ,MAAM,yBAA0B,G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CAAA,IAAA,CAAA,YAAA,CAAA;AACA;AACA;;AAEA,QAAAC,2BAAA,CAAA,QAAA,GAAA,uBAAA,CAAA;AACA,OAAA,CAAA;AACA,KAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA,MAAA,2BAAA,GAAAC,sBAAA,CAAA,4BAAA;;;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
|
-
const utils$1 = require('@sentry/utils');
|
|
5
4
|
const debugBuild = require('../debug-build.js');
|
|
6
5
|
const helpers = require('../helpers.js');
|
|
7
6
|
const utils = require('./utils.js');
|
|
@@ -15,7 +14,7 @@ function startProfileForSpan(span) {
|
|
|
15
14
|
// Start the profiler and get the profiler instance.
|
|
16
15
|
let startTimestamp;
|
|
17
16
|
if (utils.isAutomatedPageLoadSpan(span)) {
|
|
18
|
-
startTimestamp =
|
|
17
|
+
startTimestamp = core.timestampInSeconds() * 1000;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
const profiler = utils.startJSSelfProfile();
|
|
@@ -27,13 +26,13 @@ function startProfileForSpan(span) {
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
if (debugBuild.DEBUG_BUILD) {
|
|
30
|
-
|
|
29
|
+
core.logger.log(`[Profiling] started profiling span: ${core.spanToJSON(span).description}`);
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
// We create "unique" span names to avoid concurrent spans with same names
|
|
34
33
|
// from being ignored by the profiler. From here on, only this span name should be used when
|
|
35
34
|
// calling the profiler methods. Note: we log the original name to the user to avoid confusion.
|
|
36
|
-
const profileId =
|
|
35
|
+
const profileId = core.uuid4();
|
|
37
36
|
|
|
38
37
|
core.getCurrentScope().setContext('profile', {
|
|
39
38
|
profile_id: profileId,
|
|
@@ -62,13 +61,13 @@ function startProfileForSpan(span) {
|
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
if (debugBuild.DEBUG_BUILD) {
|
|
65
|
-
|
|
64
|
+
core.logger.log(`[Profiling] stopped profiling of span: ${core.spanToJSON(span).description}`);
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
// In case of an overlapping span, stopProfiling may return null and silently ignore the overlapping profile.
|
|
69
68
|
if (!profile) {
|
|
70
69
|
if (debugBuild.DEBUG_BUILD) {
|
|
71
|
-
|
|
70
|
+
core.logger.log(
|
|
72
71
|
`[Profiling] profiler returned null profile for: ${core.spanToJSON(span).description}`,
|
|
73
72
|
'this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started',
|
|
74
73
|
);
|
|
@@ -80,7 +79,7 @@ function startProfileForSpan(span) {
|
|
|
80
79
|
})
|
|
81
80
|
.catch(error => {
|
|
82
81
|
if (debugBuild.DEBUG_BUILD) {
|
|
83
|
-
|
|
82
|
+
core.logger.log('[Profiling] error while stopping profiler:', error);
|
|
84
83
|
}
|
|
85
84
|
});
|
|
86
85
|
}
|
|
@@ -88,7 +87,7 @@ function startProfileForSpan(span) {
|
|
|
88
87
|
// Enqueue a timeout to prevent profiles from running over max duration.
|
|
89
88
|
let maxDurationTimeoutID = helpers.WINDOW.setTimeout(() => {
|
|
90
89
|
if (debugBuild.DEBUG_BUILD) {
|
|
91
|
-
|
|
90
|
+
core.logger.log('[Profiling] max profile duration elapsed, stopping profiling for:', core.spanToJSON(span).description);
|
|
92
91
|
}
|
|
93
92
|
// If the timeout exceeds, we want to stop profiling, but not finish the span
|
|
94
93
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startProfileForSpan.js","sources":["../../../../src/profiling/startProfileForSpan.ts"],"sourcesContent":["import { getCurrentScope, spanToJSON } from '@sentry/core';\nimport
|
|
1
|
+
{"version":3,"file":"startProfileForSpan.js","sources":["../../../../src/profiling/startProfileForSpan.ts"],"sourcesContent":["import { getCurrentScope, spanToJSON } from '@sentry/core';\nimport { logger, timestampInSeconds, uuid4 } from '@sentry/core';\nimport type { Span } from '@sentry/types';\n\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\nimport type { JSSelfProfile } from './jsSelfProfiling';\nimport { MAX_PROFILE_DURATION_MS, addProfileToGlobalCache, isAutomatedPageLoadSpan, startJSSelfProfile } from './utils';\n\n/**\n * Wraps startTransaction and stopTransaction with profiling related logic.\n * startProfileForTransaction is called after the call to startTransaction in order to avoid our own code from\n * being profiled. Because of that same reason, stopProfiling is called before the call to stopTransaction.\n */\nexport function startProfileForSpan(span: Span): void {\n // Start the profiler and get the profiler instance.\n let startTimestamp: number | undefined;\n if (isAutomatedPageLoadSpan(span)) {\n startTimestamp = timestampInSeconds() * 1000;\n }\n\n const profiler = startJSSelfProfile();\n\n // We failed to construct the profiler, so we skip.\n // No need to log anything as this has already been logged in startProfile.\n if (!profiler) {\n return;\n }\n\n if (DEBUG_BUILD) {\n logger.log(`[Profiling] started profiling span: ${spanToJSON(span).description}`);\n }\n\n // We create \"unique\" span names to avoid concurrent spans with same names\n // from being ignored by the profiler. From here on, only this span name should be used when\n // calling the profiler methods. Note: we log the original name to the user to avoid confusion.\n const profileId = uuid4();\n\n // A couple of important things to note here:\n // `CpuProfilerBindings.stopProfiling` will be scheduled to run in 30seconds in order to exceed max profile duration.\n // Whichever of the two (span.finish/timeout) is first to run, the profiling will be stopped and the gathered profile\n // will be processed when the original span is finished. Since onProfileHandler can be invoked multiple times in the\n // event of an error or user mistake (calling span.finish multiple times), it is important that the behavior of onProfileHandler\n // is idempotent as we do not want any timings or profiles to be overridden by the last call to onProfileHandler.\n // After the original finish method is called, the event will be reported through the integration and delegated to transport.\n const processedProfile: JSSelfProfile | null = null;\n\n getCurrentScope().setContext('profile', {\n profile_id: profileId,\n start_timestamp: startTimestamp,\n });\n\n /**\n * Idempotent handler for profile stop\n */\n async function onProfileHandler(): Promise<void> {\n // Check if the profile exists and return it the behavior has to be idempotent as users may call span.finish multiple times.\n if (!span) {\n return;\n }\n // Satisfy the type checker, but profiler will always be defined here.\n if (!profiler) {\n return;\n }\n if (processedProfile) {\n if (DEBUG_BUILD) {\n logger.log('[Profiling] profile for:', spanToJSON(span).description, 'already exists, returning early');\n }\n return;\n }\n\n return profiler\n .stop()\n .then((profile: JSSelfProfile): void => {\n if (maxDurationTimeoutID) {\n WINDOW.clearTimeout(maxDurationTimeoutID);\n maxDurationTimeoutID = undefined;\n }\n\n if (DEBUG_BUILD) {\n logger.log(`[Profiling] stopped profiling of span: ${spanToJSON(span).description}`);\n }\n\n // In case of an overlapping span, stopProfiling may return null and silently ignore the overlapping profile.\n if (!profile) {\n if (DEBUG_BUILD) {\n logger.log(\n `[Profiling] profiler returned null profile for: ${spanToJSON(span).description}`,\n 'this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started',\n );\n }\n return;\n }\n\n addProfileToGlobalCache(profileId, profile);\n })\n .catch(error => {\n if (DEBUG_BUILD) {\n logger.log('[Profiling] error while stopping profiler:', error);\n }\n });\n }\n\n // Enqueue a timeout to prevent profiles from running over max duration.\n let maxDurationTimeoutID: number | undefined = WINDOW.setTimeout(() => {\n if (DEBUG_BUILD) {\n logger.log('[Profiling] max profile duration elapsed, stopping profiling for:', spanToJSON(span).description);\n }\n // If the timeout exceeds, we want to stop profiling, but not finish the span\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n onProfileHandler();\n }, MAX_PROFILE_DURATION_MS);\n\n // We need to reference the original end call to avoid creating an infinite loop\n const originalEnd = span.end.bind(span);\n\n /**\n * Wraps span `end()` with profiling related logic.\n * startProfiling is called after the call to spanStart in order to avoid our own code from\n * being profiled. Because of that same reason, stopProfiling is called before the call to spanEnd.\n */\n function profilingWrappedSpanEnd(): Span {\n if (!span) {\n return originalEnd();\n }\n // onProfileHandler should always return the same profile even if this is called multiple times.\n // Always call onProfileHandler to ensure stopProfiling is called and the timeout is cleared.\n void onProfileHandler().then(\n () => {\n originalEnd();\n },\n () => {\n // If onProfileHandler fails, we still want to call the original finish method.\n originalEnd();\n },\n );\n\n return span;\n }\n\n span.end = profilingWrappedSpanEnd;\n}\n"],"names":["isAutomatedPageLoadSpan","timestampInSeconds","startJSSelfProfile","DEBUG_BUILD","logger","spanToJSON","uuid4","getCurrentScope","WINDOW","addProfileToGlobalCache","MAX_PROFILE_DURATION_MS"],"mappings":";;;;;;;AASA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,IAAI,EAAc;AACtD;AACA,EAAE,IAAI,cAAc;AACpB,EAAE,IAAIA,6BAAuB,CAAC,IAAI,CAAC,EAAE;AACrC,IAAI,iBAAiBC,uBAAkB,EAAC,GAAI,IAAI;AAChD;;AAEA,EAAE,MAAM,QAAA,GAAWC,wBAAkB,EAAE;;AAEvC;AACA;AACA,EAAE,IAAI,CAAC,QAAQ,EAAE;AACjB,IAAI;AACJ;;AAEA,EAAE,IAAIC,sBAAW,EAAE;AACnB,IAAIC,WAAM,CAAC,GAAG,CAAC,CAAC,oCAAoC,EAAEC,eAAU,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA,EAAA,MAAA,SAAA,GAAAC,UAAA,EAAA;;AAWA,EAAAC,oBAAA,EAAA,CAAA,UAAA,CAAA,SAAA,EAAA;AACA,IAAA,UAAA,EAAA,SAAA;AACA,IAAA,eAAA,EAAA,cAAA;AACA,GAAA,CAAA;;AAEA;AACA;AACA;AACA,EAAA,eAAA,gBAAA,GAAA;AACA;AACA,IAAA,IAAA,CAAA,IAAA,EAAA;AACA,MAAA;AACA;AACA;AACA,IAAA,IAAA,CAAA,QAAA,EAAA;AACA,MAAA;AACA;;AAQA,IAAA,OAAA;AACA,OAAA,IAAA;AACA,OAAA,IAAA,CAAA,CAAA,OAAA,KAAA;AACA,QAAA,IAAA,oBAAA,EAAA;AACA,UAAAC,cAAA,CAAA,YAAA,CAAA,oBAAA,CAAA;AACA,UAAA,oBAAA,GAAA,SAAA;AACA;;AAEA,QAAA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,IAAA,OAAA,IAAA;AACA;;AAEA,EAAA,IAAA,CAAA,GAAA,GAAA,uBAAA;AACA;;;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
|
-
const utils = require('@sentry/utils');
|
|
5
4
|
const debugBuild = require('../debug-build.js');
|
|
6
5
|
const helpers = require('../helpers.js');
|
|
7
6
|
|
|
@@ -77,7 +76,7 @@ function getTraceId(event) {
|
|
|
77
76
|
// warn users that this is happening if they enable debug flag
|
|
78
77
|
if (typeof traceId === 'string' && traceId.length !== 32) {
|
|
79
78
|
if (debugBuild.DEBUG_BUILD) {
|
|
80
|
-
|
|
79
|
+
core.logger.log(`[Profiling] Invalid traceId: ${traceId} on profiled event`);
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
if (typeof traceId !== 'string') {
|
|
@@ -123,8 +122,8 @@ function createProfilePayload(
|
|
|
123
122
|
? start_timestamp
|
|
124
123
|
: typeof event.start_timestamp === 'number'
|
|
125
124
|
? event.start_timestamp * 1000
|
|
126
|
-
:
|
|
127
|
-
const transactionEndMs = typeof event.timestamp === 'number' ? event.timestamp * 1000 :
|
|
125
|
+
: core.timestampInSeconds() * 1000;
|
|
126
|
+
const transactionEndMs = typeof event.timestamp === 'number' ? event.timestamp * 1000 : core.timestampInSeconds() * 1000;
|
|
128
127
|
|
|
129
128
|
const profile = {
|
|
130
129
|
event_id: profile_id,
|
|
@@ -156,7 +155,7 @@ function createProfilePayload(
|
|
|
156
155
|
transactions: [
|
|
157
156
|
{
|
|
158
157
|
name: event.transaction || '',
|
|
159
|
-
id: event.event_id ||
|
|
158
|
+
id: event.event_id || core.uuid4(),
|
|
160
159
|
trace_id: traceId,
|
|
161
160
|
active_thread_id: THREAD_ID_STRING,
|
|
162
161
|
relative_start_ns: '0',
|
|
@@ -208,8 +207,8 @@ function convertJSSelfProfileToSampledFormat(input) {
|
|
|
208
207
|
// Since JS self profiling time origin is always initialized to performance.timeOrigin, we need to adjust for
|
|
209
208
|
// the drift between the SDK selected value and our profile time origin.
|
|
210
209
|
const origin =
|
|
211
|
-
typeof performance.timeOrigin === 'number' ? performance.timeOrigin :
|
|
212
|
-
const adjustForOriginChange = origin - (
|
|
210
|
+
typeof performance.timeOrigin === 'number' ? performance.timeOrigin : core.browserPerformanceTimeOrigin || 0;
|
|
211
|
+
const adjustForOriginChange = origin - (core.browserPerformanceTimeOrigin || origin);
|
|
213
212
|
|
|
214
213
|
input.samples.forEach((jsSample, i) => {
|
|
215
214
|
// If sample has no stack, add an empty sample
|
|
@@ -291,7 +290,7 @@ function addProfilesToEnvelope(envelope, profiles) {
|
|
|
291
290
|
function findProfiledTransactionsFromEnvelope(envelope) {
|
|
292
291
|
const events = [];
|
|
293
292
|
|
|
294
|
-
|
|
293
|
+
core.forEachEnvelopeItem(envelope, (item, type) => {
|
|
295
294
|
if (type !== 'transaction') {
|
|
296
295
|
return;
|
|
297
296
|
}
|
|
@@ -320,7 +319,7 @@ function applyDebugMetadata(resource_paths) {
|
|
|
320
319
|
return [];
|
|
321
320
|
}
|
|
322
321
|
|
|
323
|
-
return
|
|
322
|
+
return core.getDebugImagesForResources(stackParser, resource_paths);
|
|
324
323
|
}
|
|
325
324
|
|
|
326
325
|
/**
|
|
@@ -330,7 +329,7 @@ function isValidSampleRate(rate) {
|
|
|
330
329
|
// we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck
|
|
331
330
|
if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && isNaN(rate))) {
|
|
332
331
|
debugBuild.DEBUG_BUILD &&
|
|
333
|
-
|
|
332
|
+
core.logger.warn(
|
|
334
333
|
`[Profiling] Invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(
|
|
335
334
|
rate,
|
|
336
335
|
)} of type ${JSON.stringify(typeof rate)}.`,
|
|
@@ -345,7 +344,7 @@ function isValidSampleRate(rate) {
|
|
|
345
344
|
|
|
346
345
|
// in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false
|
|
347
346
|
if (rate < 0 || rate > 1) {
|
|
348
|
-
debugBuild.DEBUG_BUILD &&
|
|
347
|
+
debugBuild.DEBUG_BUILD && core.logger.warn(`[Profiling] Invalid sample rate. Sample rate must be between 0 and 1. Got ${rate}.`);
|
|
349
348
|
return false;
|
|
350
349
|
}
|
|
351
350
|
return true;
|
|
@@ -357,14 +356,14 @@ function isValidProfile(profile) {
|
|
|
357
356
|
// Log a warning if the profile has less than 2 samples so users can know why
|
|
358
357
|
// they are not seeing any profiling data and we cant avoid the back and forth
|
|
359
358
|
// of asking them to provide us with a dump of the profile data.
|
|
360
|
-
|
|
359
|
+
core.logger.log('[Profiling] Discarding profile because it contains less than 2 samples');
|
|
361
360
|
}
|
|
362
361
|
return false;
|
|
363
362
|
}
|
|
364
363
|
|
|
365
364
|
if (!profile.frames.length) {
|
|
366
365
|
if (debugBuild.DEBUG_BUILD) {
|
|
367
|
-
|
|
366
|
+
core.logger.log('[Profiling] Discarding profile because it contains no frames');
|
|
368
367
|
}
|
|
369
368
|
return false;
|
|
370
369
|
}
|
|
@@ -394,7 +393,7 @@ function startJSSelfProfile() {
|
|
|
394
393
|
|
|
395
394
|
if (!isJSProfilerSupported(JSProfilerConstructor)) {
|
|
396
395
|
if (debugBuild.DEBUG_BUILD) {
|
|
397
|
-
|
|
396
|
+
core.logger.log(
|
|
398
397
|
'[Profiling] Profiling is not supported by this browser, Profiler interface missing on window object.',
|
|
399
398
|
);
|
|
400
399
|
}
|
|
@@ -413,10 +412,10 @@ function startJSSelfProfile() {
|
|
|
413
412
|
return new JSProfilerConstructor({ sampleInterval: samplingIntervalMS, maxBufferSize: maxSamples });
|
|
414
413
|
} catch (e) {
|
|
415
414
|
if (debugBuild.DEBUG_BUILD) {
|
|
416
|
-
|
|
415
|
+
core.logger.log(
|
|
417
416
|
"[Profiling] Failed to initialize the Profiling constructor, this is likely due to a missing 'Document-Policy': 'js-profiling' header.",
|
|
418
417
|
);
|
|
419
|
-
|
|
418
|
+
core.logger.log('[Profiling] Disabling profiling for current user session.');
|
|
420
419
|
}
|
|
421
420
|
PROFILING_CONSTRUCTOR_FAILED = true;
|
|
422
421
|
}
|
|
@@ -431,14 +430,14 @@ function shouldProfileSpan(span) {
|
|
|
431
430
|
// If constructor failed once, it will always fail, so we can early return.
|
|
432
431
|
if (PROFILING_CONSTRUCTOR_FAILED) {
|
|
433
432
|
if (debugBuild.DEBUG_BUILD) {
|
|
434
|
-
|
|
433
|
+
core.logger.log('[Profiling] Profiling has been disabled for the duration of the current user session.');
|
|
435
434
|
}
|
|
436
435
|
return false;
|
|
437
436
|
}
|
|
438
437
|
|
|
439
438
|
if (!span.isRecording()) {
|
|
440
439
|
if (debugBuild.DEBUG_BUILD) {
|
|
441
|
-
|
|
440
|
+
core.logger.log('[Profiling] Discarding profile because transaction was not sampled.');
|
|
442
441
|
}
|
|
443
442
|
return false;
|
|
444
443
|
}
|
|
@@ -446,7 +445,7 @@ function shouldProfileSpan(span) {
|
|
|
446
445
|
const client = core.getClient();
|
|
447
446
|
const options = client && client.getOptions();
|
|
448
447
|
if (!options) {
|
|
449
|
-
debugBuild.DEBUG_BUILD &&
|
|
448
|
+
debugBuild.DEBUG_BUILD && core.logger.log('[Profiling] Profiling disabled, no options found.');
|
|
450
449
|
return false;
|
|
451
450
|
}
|
|
452
451
|
|
|
@@ -456,14 +455,14 @@ function shouldProfileSpan(span) {
|
|
|
456
455
|
// Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The
|
|
457
456
|
// only valid values are booleans or numbers between 0 and 1.)
|
|
458
457
|
if (!isValidSampleRate(profilesSampleRate)) {
|
|
459
|
-
debugBuild.DEBUG_BUILD &&
|
|
458
|
+
debugBuild.DEBUG_BUILD && core.logger.warn('[Profiling] Discarding profile because of invalid sample rate.');
|
|
460
459
|
return false;
|
|
461
460
|
}
|
|
462
461
|
|
|
463
462
|
// if the function returned 0 (or false), or if `profileSampleRate` is 0, it's a sign the profile should be dropped
|
|
464
463
|
if (!profilesSampleRate) {
|
|
465
464
|
debugBuild.DEBUG_BUILD &&
|
|
466
|
-
|
|
465
|
+
core.logger.log(
|
|
467
466
|
'[Profiling] Discarding profile because a negative sampling decision was inherited or profileSampleRate is set to 0',
|
|
468
467
|
);
|
|
469
468
|
return false;
|
|
@@ -475,7 +474,7 @@ function shouldProfileSpan(span) {
|
|
|
475
474
|
// Check if we should sample this profile
|
|
476
475
|
if (!sampled) {
|
|
477
476
|
debugBuild.DEBUG_BUILD &&
|
|
478
|
-
|
|
477
|
+
core.logger.log(
|
|
479
478
|
`[Profiling] Discarding profile because it's not included in the random sample (sampling rate = ${Number(
|
|
480
479
|
profilesSampleRate,
|
|
481
480
|
)})`,
|