Skip to content

Commit f64ad74

Browse files
authored
ref: Emit transaction instead of culprit (#458)
1 parent 6373464 commit f64ad74

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

bin/raven

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ try {
4646
message: 'This is a test message generated using ``raven test``',
4747
level: 'info',
4848
logger: 'sentry.test',
49-
culprit: 'bin:raven at main',
49+
transaction: 'bin:raven at main',
5050
request: {
5151
method: 'GET',
5252
url: 'http://example.com'
@@ -56,4 +56,4 @@ try {
5656
loadavg: os.loadavg()
5757
}
5858
});
59-
}
59+
}

lib/parsers.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ module.exports.parseError = function parseError(err, kwargs, cb) {
4545
kwargs.extra[name] = extraErrorProps;
4646
}
4747

48-
for (var n = frames.length - 1; n >= 0; n--) {
49-
if (frames[n].in_app) {
50-
kwargs.culprit = kwargs.culprit || utils.getCulprit(frames[n]);
51-
break;
48+
if (!kwargs.transaction && !kwargs.culprit) {
49+
for (var n = frames.length - 1; n >= 0; n--) {
50+
if (frames[n].in_app) {
51+
kwargs.transaction = utils.getTransaction(frames[n]);
52+
break;
53+
}
5254
}
5355
}
5456

lib/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ module.exports.parseDSN = function parseDSN(dsn) {
206206
}
207207
};
208208

209-
module.exports.getCulprit = function getCulprit(frame) {
209+
module.exports.getTransaction = function getTransaction(frame) {
210210
if (frame.module || frame.function) {
211211
return (frame.module || '?') + ' at ' + (frame.function || '?');
212212
}

test/raven.parsers.js

+17
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,23 @@ describe('raven.parsers', function() {
561561
}
562562
});
563563

564+
it('should allow specifying a custom `transaction`', function(done) {
565+
try {
566+
throw new Error('Foobar');
567+
} catch (e) {
568+
raven.parsers.parseError(
569+
e,
570+
{
571+
transaction: 'foobar'
572+
},
573+
function(parsed) {
574+
parsed.transaction.should.equal('foobar');
575+
done();
576+
}
577+
);
578+
}
579+
});
580+
564581
it('should have a string stack after parsing', function(done) {
565582
try {
566583
throw new Error('Derp');

test/raven.utils.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -309,30 +309,30 @@ describe('raven.utils', function() {
309309
});
310310
});
311311

312-
describe('#getCulprit()', function() {
312+
describe('#getTransaction()', function() {
313313
it('should handle empty', function() {
314-
raven.utils.getCulprit({}).should.eql('<unknown>');
314+
raven.utils.getTransaction({}).should.eql('<unknown>');
315315
});
316316

317317
it('should handle missing module', function() {
318318
raven.utils
319-
.getCulprit({
319+
.getTransaction({
320320
function: 'foo'
321321
})
322322
.should.eql('? at foo');
323323
});
324324

325325
it('should handle missing function', function() {
326326
raven.utils
327-
.getCulprit({
327+
.getTransaction({
328328
module: 'foo'
329329
})
330330
.should.eql('foo at ?');
331331
});
332332

333333
it('should work', function() {
334334
raven.utils
335-
.getCulprit({
335+
.getTransaction({
336336
module: 'foo',
337337
function: 'bar'
338338
})

0 commit comments

Comments
 (0)