UNPKG

@sentry/nextjs

Version:
30 lines (27 loc) 1.28 kB
import { getClient } from '@sentry/core'; import { URL_PATH } from '@sentry/conventions/attributes'; import { getSanitizedRequestUrl } from './urls.js'; function setUrlProcessingMetadata(event) { if (event.type !== "transaction" || event.contexts?.trace?.op !== "http.server" || !event.contexts?.trace?.data) { return; } const client = getClient(); if (!client) { return; } const traceData = event.contexts.trace.data; const componentRoute = traceData["next.route"] || traceData["http.route"]; const httpTarget = traceData["http.target"] || traceData[URL_PATH]; if (!componentRoute) { return; } const isolationScopeData = event.sdkProcessingMetadata?.capturedSpanIsolationScope?.getScopeData(); const headersDict = isolationScopeData?.sdkProcessingMetadata?.normalizedRequest?.headers; const url = getSanitizedRequestUrl(componentRoute, void 0, headersDict, httpTarget?.toString()); if (url && isolationScopeData?.sdkProcessingMetadata) { isolationScopeData.sdkProcessingMetadata.normalizedRequest = isolationScopeData.sdkProcessingMetadata.normalizedRequest || {}; isolationScopeData.sdkProcessingMetadata.normalizedRequest.url = url; } } export { setUrlProcessingMetadata }; //# sourceMappingURL=setUrlProcessingMetadata.js.map