Skip to content

Commit bb2addc

Browse files
committed
refactor: streamline logging in authActionClient by excluding file data
- Updated logging in authActionClient and authActionClientWithoutOrg to exclude file data from client input, enhancing data privacy. - Improved clarity in logs by focusing on relevant user and action information while maintaining validation error logging.
1 parent e1f309f commit bb2addc

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

apps/app/src/actions/safe-action.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,13 @@ export const authActionClient = actionClientWithMeta
6868
},
6969
});
7070

71-
if (process.env.NODE_ENV === 'development') {
72-
logger.info('Input ->', JSON.stringify(clientInput, null, 2));
73-
logger.info('Result ->', JSON.stringify(result.data, null, 2));
71+
const { fileData: _, ...inputForLog } = clientInput as any;
72+
logger.info('Input ->', JSON.stringify(inputForLog, null, 2));
73+
logger.info('Result ->', JSON.stringify(result.data, null, 2));
7474

75-
// Also log validation errors if they exist
76-
if (result.validationErrors) {
77-
logger.warn('Validation Errors ->', JSON.stringify(result.validationErrors, null, 2));
78-
}
79-
80-
return result;
75+
// Also log validation errors if they exist
76+
if (result.validationErrors) {
77+
logger.warn('Validation Errors ->', JSON.stringify(result.validationErrors, null, 2));
8178
}
8279

8380
return result;
@@ -275,16 +272,13 @@ export const authActionClientWithoutOrg = actionClientWithMeta
275272
},
276273
});
277274

278-
if (process.env.NODE_ENV === 'development') {
279-
logger.info('Input ->', JSON.stringify(clientInput, null, 2));
280-
logger.info('Result ->', JSON.stringify(result.data, null, 2));
281-
282-
// Also log validation errors if they exist
283-
if (result.validationErrors) {
284-
logger.warn('Validation Errors ->', JSON.stringify(result.validationErrors, null, 2));
285-
}
275+
const { fileData: _, ...inputForLog } = clientInput as any;
276+
logger.info('Input ->', JSON.stringify(inputForLog, null, 2));
277+
logger.info('Result ->', JSON.stringify(result.data, null, 2));
286278

287-
return result;
279+
// Also log validation errors if they exist
280+
if (result.validationErrors) {
281+
logger.warn('Validation Errors ->', JSON.stringify(result.validationErrors, null, 2));
288282
}
289283

290284
return result;

0 commit comments

Comments
 (0)