1
- import type { Client , IntegrationFn , Span } from '@sentry/types' ;
1
+ import type { IntegrationFn } from '@sentry/types' ;
2
2
import type { AddRequestDataToEventOptions , TransactionNamingScheme } from '@sentry/utils' ;
3
- import { addRequestDataToEvent , extractPathForTransaction } from '@sentry/utils' ;
3
+ import { addRequestDataToEvent } from '@sentry/utils' ;
4
4
import { defineIntegration } from '../integration' ;
5
- import { spanToJSON } from '../utils/spanUtils' ;
6
5
7
6
export type RequestDataIntegrationOptions = {
8
7
/**
@@ -67,12 +66,11 @@ const _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) =
67
66
68
67
return {
69
68
name : INTEGRATION_NAME ,
70
- processEvent ( event , _hint , client ) {
69
+ processEvent ( event ) {
71
70
// Note: In the long run, most of the logic here should probably move into the request data utility functions. For
72
71
// 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
74
73
// that's happened, it will be easier to add this logic in without worrying about unexpected side effects.)
75
- const { transactionNamingScheme } = _options ;
76
74
77
75
const { sdkProcessingMetadata = { } } = event ;
78
76
const req = sdkProcessingMetadata . request ;
@@ -83,38 +81,7 @@ const _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) =
83
81
84
82
const addRequestDataOptions = convertReqDataIntegrationOptsToAddReqDataOpts ( _options ) ;
85
83
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 ) ;
118
85
} ,
119
86
} ;
120
87
} ) satisfies IntegrationFn ;
@@ -166,15 +133,3 @@ function convertReqDataIntegrationOptsToAddReqDataOpts(
166
133
} ,
167
134
} ;
168
135
}
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