sentry: stringify input data

This commit is contained in:
vchikalkin 2023-07-11 21:55:20 +03:00
parent 4be0020424
commit 4bb9508762
2 changed files with 8 additions and 2 deletions

View File

@ -25,7 +25,11 @@ export default trpcNext.createNextApiHandler({
// send to bug reporting
withScope((scope) => {
(Object.keys(opts) as Array<keyof typeof opts>).forEach((key) => {
if (key !== 'req') scope.setExtra(key, opts[key]);
if (key !== 'req') {
let extra = opts[key];
if (key === 'input') extra = JSON.stringify(extra);
scope.setExtra(key, extra);
}
});
captureException(error);
});

View File

@ -26,7 +26,9 @@ export async function withHandleError<T>(fn: Promise<T>) {
withScope((scope) => {
(Object.keys(opts) as Array<keyof typeof opts>).forEach((key) => {
scope.setExtra(key, opts[key]);
let extra = opts[key];
if (key === 'data') extra = JSON.stringify(extra);
scope.setExtra(key, extra);
});
captureMessage(`${error_.message} | ${message}`);
});