1- import type { Client , IntegrationFn , Span } from '@sentry/types' ;
1+ import type { IntegrationFn } from '@sentry/types' ;
22import type { AddRequestDataToEventOptions , TransactionNamingScheme } from '@sentry/utils' ;
3- import { addRequestDataToEvent , extractPathForTransaction } from '@sentry/utils' ;
3+ import { addRequestDataToEvent } from '@sentry/utils' ;
44import { defineIntegration } from '../integration' ;
5- import { spanToJSON } from '../utils/spanUtils' ;
65
76export type RequestDataIntegrationOptions = {
87 /**
@@ -67,12 +66,11 @@ const _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) =
6766
6867 return {
6968 name : INTEGRATION_NAME ,
70- processEvent ( event , _hint , client ) {
69+ processEvent ( event ) {
7170 // Note: In the long run, most of the logic here should probably move into the request data utility functions. For
7271 // the moment it lives here, though, until https://github.com/getsentry/sentry-javascript/issues/5718 is addressed.
73- // (TL;DR: Those functions touch many parts of the repo in many different ways, and need to be clened up. Once
72+ // (TL;DR: Those functions touch many parts of the repo in many different ways, and need to be cleaned up. Once
7473 // that's happened, it will be easier to add this logic in without worrying about unexpected side effects.)
75- const { transactionNamingScheme } = _options ;
7674
7775 const { sdkProcessingMetadata = { } } = event ;
7876 const req = sdkProcessingMetadata . request ;
@@ -83,38 +81,7 @@ const _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) =
8381
8482 const addRequestDataOptions = convertReqDataIntegrationOptsToAddReqDataOpts ( _options ) ;
8583
86- const processedEvent = addRequestDataToEvent ( event , req , addRequestDataOptions ) ;
87-
88- // Transaction events already have the right `transaction` value
89- if ( event . type === 'transaction' || transactionNamingScheme === 'handler' ) {
90- return processedEvent ;
91- }
92-
93- // In all other cases, use the request's associated transaction (if any) to overwrite the event's `transaction`
94- // value with a high-quality one
95- const reqWithTransaction = req as { _sentryTransaction ?: Span } ;
96- const transaction = reqWithTransaction . _sentryTransaction ;
97- if ( transaction ) {
98- const name = spanToJSON ( transaction ) . description || '' ;
99-
100- // TODO (v8): Remove the nextjs check and just base it on `transactionNamingScheme` for all SDKs. (We have to
101- // keep it the way it is for the moment, because changing the names of transactions in Sentry has the potential
102- // to break things like alert rules.)
103- const shouldIncludeMethodInTransactionName =
104- getSDKName ( client ) === 'sentry.javascript.nextjs'
105- ? name . startsWith ( '/api' )
106- : transactionNamingScheme !== 'path' ;
107-
108- const [ transactionValue ] = extractPathForTransaction ( req , {
109- path : true ,
110- method : shouldIncludeMethodInTransactionName ,
111- customRoute : name ,
112- } ) ;
113-
114- processedEvent . transaction = transactionValue ;
115- }
116-
117- return processedEvent ;
84+ return addRequestDataToEvent ( event , req , addRequestDataOptions ) ;
11885 } ,
11986 } ;
12087} ) satisfies IntegrationFn ;
@@ -166,15 +133,3 @@ function convertReqDataIntegrationOptsToAddReqDataOpts(
166133 } ,
167134 } ;
168135}
169-
170- function getSDKName ( client : Client ) : string | undefined {
171- try {
172- // For a long chain like this, it's fewer bytes to combine a try-catch with assuming everything is there than to
173- // write out a long chain of `a && a.b && a.b.c && ...`
174- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
175- return client . getOptions ( ) . _metadata ! . sdk ! . name ;
176- } catch ( err ) {
177- // In theory we should never get here
178- return undefined ;
179- }
180- }
0 commit comments