CaptureConsole
Captures all Console API calls via `captureException` or `captureMessage`.
Import name: Sentry.captureConsoleIntegration
This integration captures all Console API calls and redirects them to Sentry using the SDK's captureMessage or captureException call, depending on the log level. It then re-triggers to preserve default native behavior:
Copied
import * as Sentry from "___SDK_PACKAGE___";
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [Sentry.captureConsoleIntegration()],
});
import * as Sentry from "___SDK_PACKAGE___";
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [Sentry.captureConsoleIntegration()],
});
<script>
// Configure sentryOnLoad before adding the Loader Script
window.sentryOnLoad = function () {
Sentry.init({});
if (Sentry.captureConsoleIntegration) {
Sentry.addIntegration(Sentry.captureConsoleIntegration());
}
};
</script>
<script
src="https://js.sentry-cdn.com/___PUBLIC_KEY___.min.js"
crossorigin="anonymous"
></script>
<script
src="https://browser.sentry-cdn.com/7.118.0/captureconsole.min.js"
integrity="sha384-VFallslCjDR2cuAcmExABGThuV4+sfW+06c+UaqO4Fe6unI7ZD1CofpFWEwO2rQK"
crossorigin="anonymous"
></script>
<script>
// Configure sentryOnLoad before adding the Loader Script
window.sentryOnLoad = function () {
Sentry.init({});
Sentry.lazyLoadIntegration("captureConsoleIntegration").then(
(integration) => {
Sentry.addIntegration(integration());
},
);
};
</script>
<script
src="https://js.sentry-cdn.com/___PUBLIC_KEY___.min.js"
crossorigin="anonymous"
></script>
<script
src="https://browser.sentry-cdn.com/10.57.0/bundle.tracing.min.js"
integrity="sha384-fm7orKrUHTJhAKcdqNq6Kb/0qIpMNYz3TbwoEoiA3hdbnHqSBhIqMAZ4XS09pCU5"
crossorigin="anonymous"
></script>
<script
src="https://browser.sentry-cdn.com/10.57.0/captureconsole.min.js"
integrity="sha384-8KC6Bn8WkiI+RhTVk5vof8AD/AMtxOMDCl6Jdf1eK5xwd1iFDBomxnsCt0oRr7df"
crossorigin="anonymous"
></script>
<script>
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [Sentry.captureConsoleIntegration()],
});
</script>
Type: string[]
Array of methods that should be captured. Defaults to ['log', 'info', 'warn', 'error', 'debug', 'assert']
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").