Skip to content

Commit

Permalink
Capture console.error in dApp with Sentry (#875)
Browse files Browse the repository at this point in the history
The dApp sometime catches errors and logs them to console without
bubbling it up. This makes Sentry miss some errors. This PR captures
console.error and sends it to Sentry using the `CaptureConsole` plugin:
https://docs.sentry.io/platforms/javascript/configuration/integrations/captureconsole/
  • Loading branch information
michalinacienciala authored Nov 18, 2024
2 parents 92f66fd + 157017c commit 6fb6b56
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dapp/src/sentry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import * as Sentry from "@sentry/react"
const initialize = (dsn: string) => {
Sentry.init({
dsn,
integrations: [Sentry.browserTracingIntegration()],
integrations: [
Sentry.browserTracingIntegration(),
Sentry.captureConsoleIntegration({ levels: ["error"] }),
],
// Attach stacktrace to errors logged by `console.error`. This is useful for
// the `captureConsoleIntegration` integration.
attachStacktrace: true,
// Performance Monitoring
tracesSampleRate: 0.1,
})
Expand Down

0 comments on commit 6fb6b56

Please sign in to comment.