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