@@ -26,7 +26,7 @@ function extractTransaction(req: { [key: string]: any }, type: boolean | Transac
26
26
stack : [
27
27
{
28
28
name : string ;
29
- }
29
+ } ,
30
30
] ;
31
31
} ;
32
32
} ;
@@ -51,7 +51,7 @@ function extractTransaction(req: { [key: string]: any }, type: boolean | Transac
51
51
}
52
52
53
53
/** JSDoc */
54
- function extractRequestData ( req : { [ key : string ] : any } ) : { [ key : string ] : string } {
54
+ function extractRequestData ( req : { [ key : string ] : any } , keys : boolean | string [ ] ) : { [ key : string ] : string } {
55
55
// headers:
56
56
// node, express: req.headers
57
57
// koa: req.header
@@ -112,6 +112,17 @@ function extractRequestData(req: { [key: string]: any }): { [key: string]: strin
112
112
url : absoluteUrl ,
113
113
} ;
114
114
115
+ const attributes = Array . isArray ( keys ) ? keys : [ ] ;
116
+
117
+ if ( attributes . length ) {
118
+ Object . keys ( request ) . forEach ( key => {
119
+ /** Remove any of the unspecified keys in the options from the request interface */
120
+ if ( ! attributes . includes ( key ) ) {
121
+ delete request [ key ] ;
122
+ }
123
+ } ) ;
124
+ }
125
+
115
126
return request ;
116
127
}
117
128
@@ -161,7 +172,7 @@ export function parseRequest(
161
172
[ key : string ] : any ;
162
173
} ,
163
174
options ?: {
164
- request ?: boolean ;
175
+ request ?: boolean | string [ ] ;
165
176
serverName ?: boolean ;
166
177
transaction ?: boolean | TransactionTypes ;
167
178
user ?: boolean | string [ ] ;
@@ -188,7 +199,7 @@ export function parseRequest(
188
199
if ( options . request ) {
189
200
event . request = {
190
201
...event . request ,
191
- ...extractRequestData ( req ) ,
202
+ ...extractRequestData ( req , options . request ) ,
192
203
} ;
193
204
}
194
205
0 commit comments