Skip to content

Commit 14401a2

Browse files
James Baxleybenvinegar
James Baxley
authored andcommitted
add in environment option (#179)
1 parent c1035b5 commit 14401a2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/client.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ var Client = function Client(dsn, options) {
4141
this.root = options.root || process.cwd();
4242
this.transport = options.transport || transports[this.dsn.protocol];
4343
this.release = options.release || process.env.SENTRY_RELEASE || '';
44+
this.environment = options.environment || process.env.SENTRY_ENVIRONMENT || '';
4445

4546
this.loggerName = options.logger || '';
4647
this.dataCallback = options.dataCallback;

test/raven.client.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ describe('raven.Client', function() {
127127
delete process.env.SENTRY_RELEASE;
128128
});
129129

130+
it('should pull environment from options if present', function() {
131+
var client = new raven.Client(dsn, {
132+
environment: 'staging'
133+
});
134+
client.environment.should.eql('staging');
135+
});
136+
137+
it('should pull SENTRY_ENVIRONMENT from environment', function() {
138+
process.env.SENTRY_ENVIRONMENT = 'staging';
139+
var client = new raven.Client(dsn);
140+
client.environment.should.eql('staging');
141+
delete process.env.SENTRY_ENVIRONMENT;
142+
});
143+
130144
describe('#getIdent()', function() {
131145
it('should match', function() {
132146
var result = {

0 commit comments

Comments
 (0)