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

Commit

Permalink
ref: Emit transaction instead of culprit (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-auer committed May 15, 2018
1 parent 6373464 commit f64ad74
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
4 changes: 2 additions & 2 deletions bin/raven
Expand Up @@ -46,7 +46,7 @@ try {
message: 'This is a test message generated using ``raven test``',
level: 'info',
logger: 'sentry.test',
culprit: 'bin:raven at main',
transaction: 'bin:raven at main',
request: {
method: 'GET',
url: 'http://example.com'
Expand All @@ -56,4 +56,4 @@ try {
loadavg: os.loadavg()
}
});
}
}
10 changes: 6 additions & 4 deletions lib/parsers.js
Expand Up @@ -45,10 +45,12 @@ module.exports.parseError = function parseError(err, kwargs, cb) {
kwargs.extra[name] = extraErrorProps;
}

for (var n = frames.length - 1; n >= 0; n--) {
if (frames[n].in_app) {
kwargs.culprit = kwargs.culprit || utils.getCulprit(frames[n]);
break;
if (!kwargs.transaction && !kwargs.culprit) {
for (var n = frames.length - 1; n >= 0; n--) {
if (frames[n].in_app) {
kwargs.transaction = utils.getTransaction(frames[n]);
break;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Expand Up @@ -206,7 +206,7 @@ module.exports.parseDSN = function parseDSN(dsn) {
}
};

module.exports.getCulprit = function getCulprit(frame) {
module.exports.getTransaction = function getTransaction(frame) {
if (frame.module || frame.function) {
return (frame.module || '?') + ' at ' + (frame.function || '?');
}
Expand Down
17 changes: 17 additions & 0 deletions test/raven.parsers.js
Expand Up @@ -561,6 +561,23 @@ describe('raven.parsers', function() {
}
});

it('should allow specifying a custom `transaction`', function(done) {
try {
throw new Error('Foobar');
} catch (e) {
raven.parsers.parseError(
e,
{
transaction: 'foobar'
},
function(parsed) {
parsed.transaction.should.equal('foobar');
done();
}
);
}
});

it('should have a string stack after parsing', function(done) {
try {
throw new Error('Derp');
Expand Down
10 changes: 5 additions & 5 deletions test/raven.utils.js
Expand Up @@ -309,30 +309,30 @@ describe('raven.utils', function() {
});
});

describe('#getCulprit()', function() {
describe('#getTransaction()', function() {
it('should handle empty', function() {
raven.utils.getCulprit({}).should.eql('<unknown>');
raven.utils.getTransaction({}).should.eql('<unknown>');
});

it('should handle missing module', function() {
raven.utils
.getCulprit({
.getTransaction({
function: 'foo'
})
.should.eql('? at foo');
});

it('should handle missing function', function() {
raven.utils
.getCulprit({
.getTransaction({
module: 'foo'
})
.should.eql('foo at ?');
});

it('should work', function() {
raven.utils
.getCulprit({
.getTransaction({
module: 'foo',
function: 'bar'
})
Expand Down

0 comments on commit f64ad74

Please sign in to comment.