Sentry-javascript: Feature: ability to fully disable Raven for local development

Created on 19 Sep 2014  路  5Comments  路  Source: getsentry/sentry-javascript

I'd like to fully disable Raven for local development. Raven-node does this by allowing null to be passed for the DSN: https://github.com/getsentry/raven-node#user-content-disable-raven

However, this doesn't work in raven-js because then I get the error Error: Raven has not been configured every time my code calls captureMessage. It would be nice if raven-js special-cased a null DSN as disabling Raven altogether, with no error message.

My current workaround is to wrap Raven.captureMessage in a function that checks if I'm on the local environment. I also conditionally call the install() method.

Most helpful comment

I guess this feature request is just asking to suppress that error message if debug: true. Otherwise I need to do:

var clientDSN = MyEnvironment.isLocal() ? false /* Disable */ : 'https://<key>@app.getsentry.com/30415';
Raven.config(clientDSN, {});

// Suppress the 'Error: Raven not configured' when disabled on localhost.
Raven.debug = false;

// Install after 'debug' has been disabled.
Raven.install();

All 5 comments

@bradvogel that's not actually really an error, its just logging it. Were you seeing actual problems from this?

I guess this feature request is just asking to suppress that error message if debug: true. Otherwise I need to do:

var clientDSN = MyEnvironment.isLocal() ? false /* Disable */ : 'https://<key>@app.getsentry.com/30415';
Raven.config(clientDSN, {});

// Suppress the 'Error: Raven not configured' when disabled on localhost.
Raven.debug = false;

// Install after 'debug' has been disabled.
Raven.install();

That's literally the point of debug. If you don't want the message, set debug to false. In normal cases, people would like to know that something is disabled. That's why it's only done when debug is true.

Seems strange then that debug is enabled by default?

It was done that way for backwards compatibility since people expect that. I'll change it in 1.2.

Was this page helpful?
0 / 5 - 0 ratings