diff --git a/apps/web/utils/axios.ts b/apps/web/utils/axios.ts index 51d7272..d1678eb 100644 --- a/apps/web/utils/axios.ts +++ b/apps/web/utils/axios.ts @@ -1,7 +1,8 @@ import { HttpError } from './error'; -import { captureException } from '@sentry/nextjs'; +import { captureException, getCurrentScope } from '@sentry/nextjs'; import type { AxiosError } from 'axios'; import { isAxiosError } from 'axios'; +import { pick } from 'radash'; function getErrorMessage( error: AxiosError @@ -18,8 +19,11 @@ export async function withHandleError(fn: Promise) { return fn.catch((error_: AxiosError | Error) => { if (isAxiosError(error_)) { const message = getErrorMessage(error_); - - if (error_.response?.status && error_.response?.status >= 500) { + if (error_.config && error_.response?.status && error_.response?.status >= 500) { + const scope = getCurrentScope(); + const extras = pick(error_.config, ['url', 'data', 'params']); + scope.setExtras(extras); + scope.setTag('target_url', extras.url); error_.message += ` | ${message}`; captureException(error_);