File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ export async function errorHandleDataFunction(
134
134
const options = getClient ( ) ?. getOptions ( ) as RemixOptions | undefined ;
135
135
136
136
if ( options ?. sendDefaultPii && options . captureActionFormDataKeys ) {
137
- await storeFormDataKeys ( args , span ) ;
137
+ await storeFormDataKeys ( args , span , options . captureActionFormDataKeys ) ;
138
138
}
139
139
}
140
140
Original file line number Diff line number Diff line change @@ -10,7 +10,11 @@ type ServerRouteManifest = ServerBuild['routes'];
10
10
/**
11
11
*
12
12
*/
13
- export async function storeFormDataKeys ( args : LoaderFunctionArgs | ActionFunctionArgs , span : Span ) : Promise < void > {
13
+ export async function storeFormDataKeys (
14
+ args : LoaderFunctionArgs | ActionFunctionArgs ,
15
+ span : Span ,
16
+ formDataKeys ?: Record < string , string | boolean > | undefined ,
17
+ ) : Promise < void > {
14
18
try {
15
19
// We clone the request for Remix be able to read the FormData later.
16
20
const clonedRequest = args . request . clone ( ) ;
@@ -21,7 +25,17 @@ export async function storeFormDataKeys(args: LoaderFunctionArgs | ActionFunctio
21
25
const formData = await clonedRequest . formData ( ) ;
22
26
23
27
formData . forEach ( ( value , key ) => {
24
- span . setAttribute ( `remix.action_form_data.${ key } ` , typeof value === 'string' ? value : '[non-string value]' ) ;
28
+ let attrKey = key ;
29
+
30
+ if ( formDataKeys ?. [ key ] ) {
31
+ if ( formDataKeys [ key ] === false ) {
32
+ return ;
33
+ } else if ( typeof value === 'string' ) {
34
+ attrKey = key ;
35
+ }
36
+
37
+ span . setAttribute ( `remix.action_form_data.${ attrKey } ` , typeof value === 'string' ? value : '[non-string value]' ) ;
38
+ }
25
39
} ) ;
26
40
} catch ( e ) {
27
41
DEBUG_BUILD && logger . warn ( 'Failed to read FormData from request' , e ) ;
You can’t perform that action at this time.
0 commit comments