Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion test/raven.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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 = {
Expand Down