Skip to content

Commit 531f3d5

Browse files
committed
Update interfaces to new style
1 parent c6883ce commit 531f3d5

File tree

3 files changed

+57
-61
lines changed

3 files changed

+57
-61
lines changed

lib/parsers.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ module.exports.parseText = function parseText(message, kwargs) {
1212
module.exports.parseError = function parseError(err, kwargs, cb) {
1313
utils.parseStack(err, function(frames) {
1414
if (kwargs.message === undefined) {
15-
kwargs.message = err.name + ': ' + (err.message || '<no message>');
15+
kwargs.message = err.name + ': ' + (err.message || '<no message>');
1616
}
17-
kwargs['sentry.interfaces.Exception'] = {
17+
kwargs['exception'] = [{
1818
type: err.name,
19-
value:err.message
20-
};
21-
kwargs['sentry.interfaces.Stacktrace'] = {frames: frames};
19+
value:err.message,
20+
stacktrace: {frames: frames}
21+
}];
2222

2323
// Save additional error properties to `extra` under the error type (e.g. `extra.AttributeError`)
2424
var extraErrorProps;
@@ -49,7 +49,7 @@ module.exports.parseError = function parseError(err, kwargs, cb) {
4949
module.exports.parseQuery = function parseQuery(query, engine, kwargs) {
5050
kwargs = kwargs || {};
5151
kwargs.message = query;
52-
kwargs['sentry.interfaces.Query'] = {
52+
kwargs['query'] = {
5353
query: query,
5454
engine: engine
5555
};
@@ -149,7 +149,7 @@ module.exports.parseRequest = function parseRequest(req, kwargs) {
149149
http.env.REMOTE_ADDR = ip;
150150

151151
// expose http interface
152-
kwargs['sentry.interfaces.Http'] = http;
152+
kwargs['http'] = http;
153153

154154
return kwargs;
155155
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"raven": "./bin/raven"
1919
},
2020
"scripts": {
21+
"pretest": "npm install",
2122
"test": "NODE_ENV=test mocha --reporter dot && NODE_ENV=test coffee ./test/run.coffee"
2223
},
2324
"engines": {

test/raven.parsers.js

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ describe('raven.parsers', function(){
2424
var engine = 'mysql';
2525
var parsed = raven.parsers.parseQuery(query, engine);
2626
parsed['message'].should.equal('SELECT * FROM `something`');
27-
parsed.should.have.property('sentry.interfaces.Query');
28-
parsed['sentry.interfaces.Query'].query.should.equal('SELECT * FROM `something`');
29-
parsed['sentry.interfaces.Query'].engine.should.equal('mysql');
27+
parsed.should.have.property('query');
28+
parsed['query'].query.should.equal('SELECT * FROM `something`');
29+
parsed['query'].engine.should.equal('mysql');
3030
});
3131
});
3232

@@ -48,10 +48,10 @@ describe('raven.parsers', function(){
4848
}
4949
};
5050
var parsed = raven.parsers.parseRequest(mockReq);
51-
parsed.should.have.property('sentry.interfaces.Http');
52-
parsed['sentry.interfaces.Http'].url.should.equal('https://mattrobenolt.com/some/path?key=value');
53-
parsed['sentry.interfaces.Http'].env.NODE_ENV.should.equal(process.env.NODE_ENV);
54-
parsed['sentry.interfaces.Http'].env.REMOTE_ADDR.should.equal('69.69.69.69');
51+
parsed.should.have.property('http');
52+
parsed['http'].url.should.equal('https://mattrobenolt.com/some/path?key=value');
53+
parsed['http'].env.NODE_ENV.should.equal(process.env.NODE_ENV);
54+
parsed['http'].env.REMOTE_ADDR.should.equal('69.69.69.69');
5555
});
5656

5757
describe('`headers` detection', function() {
@@ -67,7 +67,7 @@ describe('raven.parsers', function(){
6767

6868
var parsed = raven.parsers.parseRequest(mockReq);
6969

70-
parsed['sentry.interfaces.Http'].headers.should.eql({ foo: 'bar' });
70+
parsed['http'].headers.should.eql({ foo: 'bar' });
7171
});
7272

7373
it('should detect headers via `req.header`', function(){
@@ -82,7 +82,7 @@ describe('raven.parsers', function(){
8282

8383
var parsed = raven.parsers.parseRequest(mockReq);
8484

85-
parsed['sentry.interfaces.Http'].headers.should.eql({ foo: 'bar' });
85+
parsed['http'].headers.should.eql({ foo: 'bar' });
8686
});
8787
});
8888

@@ -96,7 +96,7 @@ describe('raven.parsers', function(){
9696

9797
var parsed = raven.parsers.parseRequest(mockReq);
9898

99-
parsed['sentry.interfaces.Http'].method.should.equal('GET');
99+
parsed['http'].method.should.equal('GET');
100100
});
101101
});
102102

@@ -110,7 +110,7 @@ describe('raven.parsers', function(){
110110

111111
var parsed = raven.parsers.parseRequest(mockReq);
112112

113-
parsed['sentry.interfaces.Http'].url.should.equal('http://mattrobenolt.com/some/path?key=value');
113+
parsed['http'].url.should.equal('http://mattrobenolt.com/some/path?key=value');
114114
});
115115

116116
it('should detect host via `req.header.host`', function(){
@@ -124,7 +124,7 @@ describe('raven.parsers', function(){
124124

125125
var parsed = raven.parsers.parseRequest(mockReq);
126126

127-
parsed['sentry.interfaces.Http'].url.should.equal('http://mattrobenolt.com/some/path?key=value');
127+
parsed['http'].url.should.equal('http://mattrobenolt.com/some/path?key=value');
128128
});
129129

130130
it('should detect host via `req.headers.host`', function(){
@@ -138,7 +138,7 @@ describe('raven.parsers', function(){
138138

139139
var parsed = raven.parsers.parseRequest(mockReq);
140140

141-
parsed['sentry.interfaces.Http'].url.should.equal('http://mattrobenolt.com/some/path?key=value');
141+
parsed['http'].url.should.equal('http://mattrobenolt.com/some/path?key=value');
142142
});
143143

144144
it('should fallback to <no host> if host is not available', function(){
@@ -149,7 +149,7 @@ describe('raven.parsers', function(){
149149

150150
var parsed = raven.parsers.parseRequest(mockReq);
151151

152-
parsed['sentry.interfaces.Http'].url.should.equal('http://<no host>/some/path?key=value');
152+
parsed['http'].url.should.equal('http://<no host>/some/path?key=value');
153153
});
154154
});
155155

@@ -169,7 +169,7 @@ describe('raven.parsers', function(){
169169

170170
var parsed = raven.parsers.parseRequest(mockReq);
171171

172-
parsed['sentry.interfaces.Http'].url.should.equal('https://mattrobenolt.com/some/path?key=value');
172+
parsed['http'].url.should.equal('https://mattrobenolt.com/some/path?key=value');
173173
});
174174

175175
it('should detect protocol via `req.secure`', function(){
@@ -187,7 +187,7 @@ describe('raven.parsers', function(){
187187

188188
var parsed = raven.parsers.parseRequest(mockReq);
189189

190-
parsed['sentry.interfaces.Http'].url.should.equal('https://mattrobenolt.com/some/path?key=value');
190+
parsed['http'].url.should.equal('https://mattrobenolt.com/some/path?key=value');
191191
});
192192

193193
it('should detect protocol via `req.socket.encrypted`', function(){
@@ -204,7 +204,7 @@ describe('raven.parsers', function(){
204204

205205
var parsed = raven.parsers.parseRequest(mockReq);
206206

207-
parsed['sentry.interfaces.Http'].url.should.equal('https://mattrobenolt.com/some/path?key=value');
207+
parsed['http'].url.should.equal('https://mattrobenolt.com/some/path?key=value');
208208
});
209209
});
210210

@@ -220,7 +220,7 @@ describe('raven.parsers', function(){
220220
};
221221

222222
var parsed = raven.parsers.parseRequest(mockReq);
223-
parsed['sentry.interfaces.Http'].cookies.should.eql({ foo: 'bar' });
223+
parsed['http'].cookies.should.eql({ foo: 'bar' });
224224
});
225225

226226
it('should parse `req.header.cookie`', function(){
@@ -234,7 +234,7 @@ describe('raven.parsers', function(){
234234
};
235235

236236
var parsed = raven.parsers.parseRequest(mockReq);
237-
parsed['sentry.interfaces.Http'].cookies.should.eql({ foo: 'bar' });
237+
parsed['http'].cookies.should.eql({ foo: 'bar' });
238238
});
239239

240240
});
@@ -250,7 +250,7 @@ describe('raven.parsers', function(){
250250

251251
var parsed = raven.parsers.parseRequest(mockReq);
252252

253-
parsed['sentry.interfaces.Http'].query_string.should.eql({ some: 'key' });
253+
parsed['http'].query_string.should.eql({ some: 'key' });
254254
});
255255

256256
it('should detect query via `req.url`', function(){
@@ -262,7 +262,7 @@ describe('raven.parsers', function(){
262262

263263
var parsed = raven.parsers.parseRequest(mockReq);
264264

265-
parsed['sentry.interfaces.Http'].query_string.should.eql({ foo: 'bar' });
265+
parsed['http'].query_string.should.eql({ foo: 'bar' });
266266
});
267267
});
268268

@@ -279,7 +279,7 @@ describe('raven.parsers', function(){
279279

280280
var parsed = raven.parsers.parseRequest(mockReq);
281281

282-
parsed['sentry.interfaces.Http'].env.REMOTE_ADDR.should.equal('69.69.69.69');
282+
parsed['http'].env.REMOTE_ADDR.should.equal('69.69.69.69');
283283
});
284284

285285
it('should detect ip via `req.connection.remoteAddress`', function(){
@@ -296,7 +296,7 @@ describe('raven.parsers', function(){
296296

297297
var parsed = raven.parsers.parseRequest(mockReq);
298298

299-
parsed['sentry.interfaces.Http'].env.REMOTE_ADDR.should.equal('69.69.69.69');
299+
parsed['http'].env.REMOTE_ADDR.should.equal('69.69.69.69');
300300
});
301301
});
302302

@@ -311,7 +311,7 @@ describe('raven.parsers', function(){
311311

312312
var parsed = raven.parsers.parseRequest(mockReq);
313313

314-
parsed['sentry.interfaces.Http'].url.should.equal('https://mattrobenolt.com/some/path?key=value');
314+
parsed['http'].url.should.equal('https://mattrobenolt.com/some/path?key=value');
315315
});
316316

317317
it('should detect url via `req.url`', function(){
@@ -324,7 +324,7 @@ describe('raven.parsers', function(){
324324

325325
var parsed = raven.parsers.parseRequest(mockReq);
326326

327-
parsed['sentry.interfaces.Http'].url.should.equal('https://mattrobenolt.com/some/path?key=value');
327+
parsed['http'].url.should.equal('https://mattrobenolt.com/some/path?key=value');
328328
});
329329
});
330330

@@ -339,7 +339,7 @@ describe('raven.parsers', function(){
339339

340340
var parsed = raven.parsers.parseRequest(mockReq);
341341

342-
parsed['sentry.interfaces.Http'].data.should.equal('foo=bar');
342+
parsed['http'].data.should.equal('foo=bar');
343343
});
344344

345345
it('should fallback to <unavailable> if body is not available', function(){
@@ -352,7 +352,7 @@ describe('raven.parsers', function(){
352352

353353
var parsed = raven.parsers.parseRequest(mockReq);
354354

355-
parsed['sentry.interfaces.Http'].data.should.equal('<unavailable>');
355+
parsed['http'].data.should.equal('<unavailable>');
356356
});
357357
});
358358
});
@@ -361,35 +361,32 @@ describe('raven.parsers', function(){
361361
it('should parse plain Error object', function(done){
362362
raven.parsers.parseError(new Error(), {}, function(parsed){
363363
parsed['message'].should.equal('Error: <no message>');
364-
parsed.should.have.property('sentry.interfaces.Exception');
365-
parsed['sentry.interfaces.Exception']['type'].should.equal('Error');
366-
parsed['sentry.interfaces.Exception']['value'].should.equal('');
367-
parsed.should.have.property('sentry.interfaces.Stacktrace');
368-
parsed['sentry.interfaces.Stacktrace'].should.have.property('frames');
364+
parsed.should.have.property('exception');
365+
parsed['exception'][0]['type'].should.equal('Error');
366+
parsed['exception'][0]['value'].should.equal('');
367+
parsed['exception'][0]['stacktrace'].should.have.property('frames');
369368
done();
370369
});
371370
});
372371

373372
it('should parse Error with message', function(done){
374373
raven.parsers.parseError(new Error('Crap'), {}, function(parsed){
375374
parsed['message'].should.equal('Error: Crap');
376-
parsed.should.have.property('sentry.interfaces.Exception');
377-
parsed['sentry.interfaces.Exception']['type'].should.equal('Error');
378-
parsed['sentry.interfaces.Exception']['value'].should.equal('Crap');
379-
parsed.should.have.property('sentry.interfaces.Stacktrace');
380-
parsed['sentry.interfaces.Stacktrace'].should.have.property('frames');
375+
parsed.should.have.property('exception');
376+
parsed['exception'][0]['type'].should.equal('Error');
377+
parsed['exception'][0]['value'].should.equal('Crap');
378+
parsed['exception'][0]['stacktrace'].should.have.property('frames');
381379
done();
382380
});
383381
});
384382

385383
it('should parse TypeError with message', function(done){
386384
raven.parsers.parseError(new TypeError('Crap'), {}, function(parsed){
387385
parsed['message'].should.equal('TypeError: Crap');
388-
parsed.should.have.property('sentry.interfaces.Exception');
389-
parsed['sentry.interfaces.Exception']['type'].should.equal('TypeError');
390-
parsed['sentry.interfaces.Exception']['value'].should.equal('Crap');
391-
parsed.should.have.property('sentry.interfaces.Stacktrace');
392-
parsed['sentry.interfaces.Stacktrace'].should.have.property('frames');
386+
parsed.should.have.property('exception');
387+
parsed['exception'][0]['type'].should.equal('TypeError');
388+
parsed['exception'][0]['value'].should.equal('Crap');
389+
parsed['exception'][0]['stacktrace'].should.have.property('frames');
393390
done();
394391
});
395392
});
@@ -400,11 +397,10 @@ describe('raven.parsers', function(){
400397
} catch(e) {
401398
raven.parsers.parseError(e, {}, function(parsed){
402399
parsed['message'].should.equal('Error: Derp');
403-
parsed.should.have.property('sentry.interfaces.Exception');
404-
parsed['sentry.interfaces.Exception']['type'].should.equal('Error');
405-
parsed['sentry.interfaces.Exception']['value'].should.equal('Derp');
406-
parsed.should.have.property('sentry.interfaces.Stacktrace');
407-
parsed['sentry.interfaces.Stacktrace'].should.have.property('frames');
400+
parsed.should.have.property('exception');
401+
parsed['exception'][0]['type'].should.equal('Error');
402+
parsed['exception'][0]['value'].should.equal('Derp');
403+
parsed['exception'][0]['stacktrace'].should.have.property('frames');
408404
done();
409405
});
410406
}
@@ -429,11 +425,10 @@ describe('raven.parsers', function(){
429425
raven.parsers.parseError(e, {}, function(parsed){
430426
parsed['message'].should.containEql('TypeError');
431427
parsed['message'].should.containEql('Derp');
432-
parsed.should.have.property('sentry.interfaces.Exception');
433-
parsed['sentry.interfaces.Exception']['type'].should.equal('TypeError');
434-
parsed['sentry.interfaces.Exception']['value'].should.containEql('Derp');
435-
parsed.should.have.property('sentry.interfaces.Stacktrace');
436-
parsed['sentry.interfaces.Stacktrace'].should.have.property('frames');
428+
parsed.should.have.property('exception');
429+
parsed['exception'][0]['type'].should.equal('TypeError');
430+
parsed['exception'][0]['value'].should.containEql('Derp');
431+
parsed['exception'][0]['stacktrace'].should.have.property('frames');
437432
done();
438433
});
439434
}
@@ -444,8 +439,8 @@ describe('raven.parsers', function(){
444439
assert.strictEqual(1, 2);
445440
} catch(e) {
446441
raven.parsers.parseError(e, {}, function(parsed){
447-
parsed.should.have.property('sentry.interfaces.Stacktrace');
448-
parsed['sentry.interfaces.Stacktrace'].should.have.property('frames');
442+
parsed.should.have.property('exception');
443+
parsed['exception'][0]['stacktrace'].should.have.property('frames');
449444
parsed.should.have.property('extra');
450445
parsed['extra'].should.have.property('AssertionError');
451446
parsed['extra']['AssertionError'].should.have.property('actual');

0 commit comments

Comments
 (0)