Skip to content

Console errors are not captured with custom client and hub #2606

Closed
@3zzy

Description

@3zzy

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

5.15.5

Description

<script src="https://browser.sentry-cdn.com/5.15.5/bundle.min.js" integrity="sha384-wF7Jc4ZlWVxe/L8Ji3hOIBeTgo/HwFuaeEfjGmS3EXAG7Y+7Kjjr91gJpJtr+PAT" crossorigin="anonymous"></script>
<script src="https://browser.sentry-cdn.com/5.15.5/reportingobserver.min.js" crossorigin="anonymous"></script>
<script src="https://browser.sentry-cdn.com/5.15.5/captureconsole.min.js" crossorigin="anonymous"></script>
<script src="https://browser.sentry-cdn.com/5.15.5/dedupe.min.js" crossorigin="anonymous"></script>

var SentryClientGlobal = new Sentry.BrowserClient({
        environment: 'development',
        dsn: 'secret',
        integrations: [
            ...Sentry.defaultIntegrations,
            new Sentry.Integrations.ReportingObserver(),
            new Sentry.Integrations.CaptureConsole({
                levels: ['error', 'warn']
            }),
            new Sentry.Integrations.Dedupe()
        ]
    }),
    SentryHubGlobal = new Sentry.Hub(SentryClientGlobal);    

// Capture additional data 
SentryHubGlobal.configureScope(function(scope) {
    scope.setTag("siteid", SITEID);
    scope.setTag('cID', CID);
    if (LOGGED_IN) {
        scope.setUser({ id: "<?= $u->uID ?>" });
    }
});

console.error('Boom!'); // this is not captured in Sentry

Initializing a client and hub manually like this doesn't capture the console errors that are otherwise logged if I just use Sentry.init() and Sentry.configureScope normally as mentioned in the docs.

What am I doing wrong here or is it a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions