In case this helps anyone, use Sentry's CaptureConsole integration for this:
Sentry.Integrations.CaptureConsole
Official Documentation:
https://docs.sentry.io/platforms/javascript/configuration/integrations/plugin/#captureconsole
Refer to this post:
How to report console.error with Sentry?
Example Code:
import { CaptureConsole as CaptureConsoleIntegration } from "@sentry/integrations";
Sentry.init({
dsn: 'https://your-sentry-server-dsn',
debug: true, // If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production
integrations: [new CaptureConsoleIntegration(
{
// array of methods that should be captured
// defaults to ['log', 'info', 'warn', 'error', 'debug', 'assert']
levels: ['log', 'info', 'warn', 'error', 'debug', 'assert']
}
)]
});