getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.97k stars 1.57k forks source link

Sentry global client can be initialized without required configuration #1691

Closed WojciechRydel closed 1 year ago

WojciechRydel commented 6 years ago

Package + Version

Version:

4.2.3

Description

There is a possibility to call Sentry.init() without any arguments/config. It would be great to be notify when one initilize the client without any configuration. Such behaviour also allow to execute e.g. Sentry.captureException(err) without initializing the client - uuid is returned, but it would be nice to an Error be thrown when one calls such a method with Sentry client which has not been initialized.

lobsterkatie commented 5 years ago

We on Support have also gotten a request to throw an error when the DSN is missing or invalid.

ebekebe commented 4 years ago

I would like to add that it is not possible for a library user to determine whether the configuration is correct, even if a DSN is provided. The following snippet uses a fantasy DSN, but there is no indication, that the configuration is broken:

const Sentry = require('@sentry/node');

Sentry.init({
    dsn: 'https://foobar@sentry.io/baz',
});

const errorId = Sentry.captureException(new Error('some error'));
console.dir({errorId})

Sentry.flush(1000)
    .then(result => console.dir({result}))
    .catch(error => console.dir({error}))

// Output:
// { errorId: '<someid>' }
// { result: true }

I understand that even if client code is able to detect a broken configuration it might be unable to report that error, since sentry is the very tool that is supposed to report errors.

That is why I would like to see a some kind of heart beat implemented. The client lib could send a heart beat when running and the sentry service could notify about missing heartbeats for a DSN. That would allow backend services to be certain that their sentry config is working.

Is there already such a heart beat system that I am unaware of?

kamilogorek commented 4 years ago

That is why I would like to see a some kind of heart beat implemented. Is there already such a heart beat system that I am unaware of?

Not yet, but we have actively discussed it few times already. No clear conclusion yet though. Will update it here if we get more info.

ebekebe commented 4 years ago

Thanks for the quick reply. We would be very happy to see some solution soon.