Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allowing Raven to be run in environments other than production. #34

Closed
wants to merge 2 commits into from

3 participants

Dominiek ter Heide Matt Robenolt Alex Zylman
Dominiek ter Heide

Doesn't run in test and development environments unless explicitly stated.

Addresses this issue: #33

Matt Robenolt
Owner

This whole NODE_ENV stuff is getting kinda ridiculous (unrelated to this diff). I think I'm just going to remove it entirely and leave that up to the user to enable or disable it however they see fit, and I'll bump a new release. The problem is that NODE_ENV is not a standard anywhere, and it's really arbitrarily used, so I'd like to remove this logic entirely since everyone seems to use it differently.

What are your opinions on that?

Alex Zylman

I like that idea, for what it's worth.

Matt Robenolt
Owner

I yanked NODE_ENV in d95cdbc. So feel free to just implement this at the app level. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 25, 2013
  1. Dominiek ter Heide

    Allowing Raven to be run in environments other than production. Doesn…

    dominiek authored
    …'t run in test and development environments unless explicitly stated.
  2. Dominiek ter Heide
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 5 deletions.
  1. +4 −4 lib/client.js
  2. +10 −1 test/raven.client.js
8 lib/client.js
View
@@ -26,14 +26,14 @@ var Client = function Client(dsn, options) {
this.site = options.site || process.env.SENTRY_SITE;
this.root = options.root || process.cwd();
this.loggerName = options.logger || '';
- if(!this.dsn || !process.env.NODE_ENV || process.env.NODE_ENV !== 'production') {
+ if(!this.dsn) {
this._enabled = false;
} else {
this._enabled = true;
}
- if(this.dsn && !this._enabled) {
- // we want to be silent only when FALSE is explicitly passed for a DSN value
- console.warn('Warning: Sentry logging is disabled, please set NODE_ENV=production');
+ if(this.dsn && !options.enableInDevelopment && (!process.env.NODE_ENV || ['test', 'development'].indexOf(process.env.NODE_ENV) != -1)) {
+ this._enabled = false;
+ console.warn('Warning: Sentry logging is disabled in test and development environments. Use enableInDevelopment if you really want this');
}
this.on('error', function(e) {}); // noop
11 test/raven.client.js
View
@@ -30,7 +30,7 @@ describe('raven.version', function(){
describe('raven.Client', function(){
var client;
beforeEach(function(){
- process.env.NODE_ENV='production';
+ process.env.NODE_ENV='staging';
client = new raven.Client(dsn);
});
@@ -122,6 +122,15 @@ describe('raven.Client', function(){
restoreConsoleWarn();
});
+ it('should be enabled and not warn when NODE_ENV=development and option enableInDevelopment is set', function(){
+ mockConsoleWarn();
+ process.env.NODE_ENV = 'development';
+ var client = new raven.Client(dsn, {enableInDevelopment: true});
+ client._enabled.should.eql(true);
+ console.warn._called.should.eql(false);
+ restoreConsoleWarn();
+ });
+
describe('#getIdent()', function(){
it('should match', function(){
var result = {
Something went wrong with that request. Please try again.