From feab8afa2c7e270270548a0a478adcd8ff12089f Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 2 Apr 2024 17:11:39 +0200 Subject: [PATCH] ref(v8): Remove `addRequestDataToTransaction` util (#11369) See https://github.com/getsentry/sentry-javascript/pull/11368, where this is deprecated on v7. --- packages/utils/src/requestdata.ts | 51 ------------------------------- 1 file changed, 51 deletions(-) diff --git a/packages/utils/src/requestdata.ts b/packages/utils/src/requestdata.ts index f6a4129fac2a..807bc0541c2c 100644 --- a/packages/utils/src/requestdata.ts +++ b/packages/utils/src/requestdata.ts @@ -2,7 +2,6 @@ import type { Event, ExtractedNodeRequestData, PolymorphicRequest, - Transaction, TransactionSource, WebFetchHeaders, WebFetchRequest, @@ -24,17 +23,6 @@ const DEFAULT_INCLUDES = { const DEFAULT_REQUEST_INCLUDES = ['cookies', 'data', 'headers', 'method', 'query_string', 'url']; export const DEFAULT_USER_INCLUDES = ['id', 'username', 'email']; -type InjectedNodeDeps = { - cookie: { - parse: (cookieStr: string) => Record; - }; - url: { - parse: (urlStr: string) => { - query: string | null; - }; - }; -}; - /** * Options deciding what parts of the request to use when enhancing an event */ @@ -62,45 +50,6 @@ export type AddRequestDataToEventOptions = { export type TransactionNamingScheme = 'path' | 'methodPath' | 'handler'; -/** - * Sets parameterized route as transaction name e.g.: `GET /users/:id` - * Also adds more context data on the transaction from the request - */ -export function addRequestDataToTransaction( - transaction: Transaction | undefined, - req: PolymorphicRequest, - // TODO(v8): Remove this parameter in v8 - _deps?: InjectedNodeDeps, -): void { - if (!transaction) return; - - // TODO(v8): SEMANTIC_ATTRIBUTE_SENTRY_SOURCE is in core, align this once we merge utils & core - // eslint-disable-next-line deprecation/deprecation - if (!transaction.attributes['sentry.source'] || transaction.attributes['sentry.source'] === 'url') { - // Attempt to grab a parameterized route off of the request - const [name, source] = extractPathForTransaction(req, { path: true, method: true }); - transaction.updateName(name); - // TODO(v8): SEMANTIC_ATTRIBUTE_SENTRY_SOURCE is in core, align this once we merge utils & core - transaction.setAttribute('sentry.source', source); - } - transaction.setAttribute('url', req.originalUrl || req.url); - if (req.baseUrl) { - transaction.setAttribute('baseUrl', req.baseUrl); - } - - const query = extractQueryParams(req); - if (typeof query === 'string') { - transaction.setAttribute('query', query); - } else if (query) { - Object.keys(query).forEach(key => { - const val = query[key]; - if (typeof val === 'string' || typeof val === 'number') { - transaction.setAttribute(`query.${key}`, val); - } - }); - } -} - /** * Extracts a complete and parameterized path from the request object and uses it to construct transaction name. * If the parameterized transaction name cannot be extracted, we fall back to the raw URL.