Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(browser): Add console logging integration #15828

Closed
wants to merge 1 commit into from

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Mar 25, 2025

ref #15526

Adds consoleLoggingIntegration integration that takes calls to console.X and flushes them as logs. See below about why this is a new integration.

I made this a separate integration because calls we needed to access the capturing methods through the browser SDK, which causes the SDK to start it's flushing mechanisms.

import * as Sentry from '@sentry/browser';

Sentry.init({
  integrations: [Sentry.consoleLoggingIntegration({ levels: ['error', 'warn'] })],
});

Notes

In general we have inconsistencies with console instrumentation across our different SDKs. #4532.

  • In browser we have console instrumentation as part of the Breadcrumbs integration.
  • In node we have console instrumentation that generates breadcrumbs in the Console integration
  • In core we have console instrumentation, which generates errors and messages via the CaptureConsole integration

This makes it hard for me to tell where to add the logging instrumentation for consoles. I found the easiest way around this was to add brand new logging integrations, separate from breadcrumbs and errors functionality.

After this PR gets merged in, I'll take a look at doing the same for Node.js.

@AbhiPrasad AbhiPrasad self-assigned this Mar 25, 2025
@AbhiPrasad
Copy link
Member Author

Closing this, we settled on another approach for this.

@AbhiPrasad AbhiPrasad closed this Mar 26, 2025
@AbhiPrasad AbhiPrasad deleted the abhi-console-logging-integration-browser branch March 26, 2025 15:49
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant