@@ -2,7 +2,6 @@ import type {
22 Event ,
33 ExtractedNodeRequestData ,
44 PolymorphicRequest ,
5- Transaction ,
65 TransactionSource ,
76 WebFetchHeaders ,
87 WebFetchRequest ,
@@ -24,17 +23,6 @@ const DEFAULT_INCLUDES = {
2423const DEFAULT_REQUEST_INCLUDES = [ 'cookies' , 'data' , 'headers' , 'method' , 'query_string' , 'url' ] ;
2524export const DEFAULT_USER_INCLUDES = [ 'id' , 'username' , 'email' ] ;
2625
27- type InjectedNodeDeps = {
28- cookie : {
29- parse : ( cookieStr : string ) => Record < string , string > ;
30- } ;
31- url : {
32- parse : ( urlStr : string ) => {
33- query : string | null ;
34- } ;
35- } ;
36- } ;
37-
3826/**
3927 * Options deciding what parts of the request to use when enhancing an event
4028 */
@@ -62,45 +50,6 @@ export type AddRequestDataToEventOptions = {
6250
6351export type TransactionNamingScheme = 'path' | 'methodPath' | 'handler' ;
6452
65- /**
66- * Sets parameterized route as transaction name e.g.: `GET /users/:id`
67- * Also adds more context data on the transaction from the request
68- */
69- export function addRequestDataToTransaction (
70- transaction : Transaction | undefined ,
71- req : PolymorphicRequest ,
72- // TODO(v8): Remove this parameter in v8
73- _deps ?: InjectedNodeDeps ,
74- ) : void {
75- if ( ! transaction ) return ;
76-
77- // TODO(v8): SEMANTIC_ATTRIBUTE_SENTRY_SOURCE is in core, align this once we merge utils & core
78- // eslint-disable-next-line deprecation/deprecation
79- if ( ! transaction . attributes [ 'sentry.source' ] || transaction . attributes [ 'sentry.source' ] === 'url' ) {
80- // Attempt to grab a parameterized route off of the request
81- const [ name , source ] = extractPathForTransaction ( req , { path : true , method : true } ) ;
82- transaction . updateName ( name ) ;
83- // TODO(v8): SEMANTIC_ATTRIBUTE_SENTRY_SOURCE is in core, align this once we merge utils & core
84- transaction . setAttribute ( 'sentry.source' , source ) ;
85- }
86- transaction . setAttribute ( 'url' , req . originalUrl || req . url ) ;
87- if ( req . baseUrl ) {
88- transaction . setAttribute ( 'baseUrl' , req . baseUrl ) ;
89- }
90-
91- const query = extractQueryParams ( req ) ;
92- if ( typeof query === 'string' ) {
93- transaction . setAttribute ( 'query' , query ) ;
94- } else if ( query ) {
95- Object . keys ( query ) . forEach ( key => {
96- const val = query [ key ] ;
97- if ( typeof val === 'string' || typeof val === 'number' ) {
98- transaction . setAttribute ( `query.${ key } ` , val ) ;
99- }
100- } ) ;
101- }
102- }
103-
10453/**
10554 * Extracts a complete and parameterized path from the request object and uses it to construct transaction name.
10655 * If the parameterized transaction name cannot be extracted, we fall back to the raw URL.
0 commit comments