From 96e291d3c2365283bb5d55ac1d109f097ee1e896 Mon Sep 17 00:00:00 2001 From: Hugo Montenegro Date: Wed, 20 Nov 2024 21:03:43 +0700 Subject: [PATCH] chore: better logging --- .github/workflows/prettier.yml | 2 +- sentry.client.config.ts | 33 +++++++++++-------- sentry.edge.config.ts | 20 ++++++----- .../create-external-account/route.ts | 2 ++ 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 450df4c08..0257f0ebb 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -1,7 +1,7 @@ name: Code Formatting on: - pull_request: + # pull_request: push: branches: ['**'] diff --git a/sentry.client.config.ts b/sentry.client.config.ts index ca705e6f1..2ed03e01b 100644 --- a/sentry.client.config.ts +++ b/sentry.client.config.ts @@ -7,27 +7,32 @@ import * as Sentry from '@sentry/nextjs' if (process.env.NODE_ENV !== 'development') { Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, - tracesSampleRate: 1, enabled: true, - - // Setting this option to true will print useful information to the console while you're setting up Sentry. + tracesSampleRate: 1, debug: false, - replaysOnErrorSampleRate: 1.0, - // This sets the sample rate to be 10%. You may want this to be 100% while - // in development and sample at a lower rate in production - replaysSessionSampleRate: 0.1, + beforeSend(event) { + // Clean client-side events + if (event.request?.headers) { + delete event.request.headers['Authorization'] + delete event.request.headers['api-key'] + } + return event + }, - // You can remove this option if you're not planning to use the Sentry Session Replay feature: integrations: [ - // Sentry.replayIntegration({ - // // Additional Replay configuration goes in here, for example: - // maskAllText: true, - // blockAllMedia: true, - // }), + Sentry.browserTracingIntegration(), + Sentry.replayIntegration({ + maskAllText: true, + blockAllMedia: true, + }), Sentry.captureConsoleIntegration({ - levels: ['error'], + levels: ['error', 'warn'], }), ], + + // Session replay settings + replaysOnErrorSampleRate: 1.0, + replaysSessionSampleRate: 0.1, }) } diff --git a/sentry.edge.config.ts b/sentry.edge.config.ts index 74078803d..fd766a3fa 100644 --- a/sentry.edge.config.ts +++ b/sentry.edge.config.ts @@ -9,19 +9,21 @@ if (process.env.NODE_ENV !== 'development') { Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, enabled: true, - // Adjust this value in production, or use tracesSampler for greater control tracesSampleRate: 1, - - // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, + + beforeSend(event) { + if (event.request?.headers) { + delete event.request.headers['Authorization'] + delete event.request.headers['api-key'] + } + return event + }, + integrations: [ - // Sentry.replayIntegration({ - // // Additional Replay configuration goes in here, for example: - // maskAllText: true, - // blockAllMedia: true, - // }), + Sentry.httpIntegration(), Sentry.captureConsoleIntegration({ - levels: ['error'], + levels: ['error', 'warn'], }), ], }) diff --git a/src/app/api/bridge/external-account/create-external-account/route.ts b/src/app/api/bridge/external-account/create-external-account/route.ts index 237faa5f1..c8359bd90 100644 --- a/src/app/api/bridge/external-account/create-external-account/route.ts +++ b/src/app/api/bridge/external-account/create-external-account/route.ts @@ -66,6 +66,8 @@ export async function POST(request: NextRequest) { }) if (!response.ok) { + // log the error response & request body for debugging + console.error('Error creating external account', response) try { const data = await response.json() if (data.code && data.code == 'duplicate_external_account') {