Skip to main content

[JavaScript] Why is Sentry not catching console errors?

Issue

I call console.error or throw an error in the browser console, and nothing appears in Sentry.

Applies To

  • All SaaS Customers and Self-Hosted Users

  • JavaScript SDK

  • Error Monitoring

Resolution

Sentry does not capture console.* calls by default. Errors you type into browser DevTools also are not captured.

If your app code calls console.error() (or another console method) and you want those events in Sentry, add captureConsoleIntegration:

Sentry.init({
  dsn: "https://[email protected]/0",
  integrations: [Sentry.captureConsoleIntegration()],
});

If you are throwing or logging errors manually in the browser DevTools console while inspecting the page, the Sentry SDK cannot capture those. Test with an error thrown from your application code instead.

To capture only some console levels, set the levels option on captureConsoleIntegration. See the CaptureConsole integration docs. If every console message is filling your quota, see Why are all my console logs sent as errors?.

If you use the Loader Script, load the integration with Sentry.lazyLoadIntegration("captureConsoleIntegration"). See Why are my integrations not working with the Loader Script?.

Did this answer your question?