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(
134134 const options = getClient ( ) ?. getOptions ( ) as RemixOptions | undefined ;
135135
136136 if ( options ?. sendDefaultPii && options . captureActionFormDataKeys ) {
137- await storeFormDataKeys ( args , span ) ;
137+ await storeFormDataKeys ( args , span , options . captureActionFormDataKeys ) ;
138138 }
139139 }
140140
Original file line number Diff line number Diff line change @@ -10,7 +10,11 @@ type ServerRouteManifest = ServerBuild['routes'];
1010/**
1111 *
1212 */
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 > {
1418 try {
1519 // We clone the request for Remix be able to read the FormData later.
1620 const clonedRequest = args . request . clone ( ) ;
@@ -21,7 +25,17 @@ export async function storeFormDataKeys(args: LoaderFunctionArgs | ActionFunctio
2125 const formData = await clonedRequest . formData ( ) ;
2226
2327 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+ }
2539 } ) ;
2640 } catch ( e ) {
2741 DEBUG_BUILD && logger . warn ( 'Failed to read FormData from request' , e ) ;
You can’t perform that action at this time.
0 commit comments