Skip to content

Commit 8f8a624

Browse files
Jorge Cruzkamilogorek
authored andcommitted
fix: default fingerprinting when using synthetic stacktraces
When stracktrace:true is set via globalOptions there is an attempt to create a default fingerprint value but it gets dropped from the request to sentry. This ensures the fingerprint value is included in the data sent to sentry.
1 parent c2b377e commit 8f8a624

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/raven.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,11 @@ Raven.prototype = {
513513
}
514514

515515
options = options || {};
516+
msg = msg + ''; // Make sure it's actually a string
516517

517518
var data = objectMerge(
518519
{
519-
message: msg + '' // Make sure it's actually a string
520+
message: msg
520521
},
521522
options
522523
);
@@ -555,11 +556,11 @@ Raven.prototype = {
555556
}
556557

557558
if (this._globalOptions.stacktrace || (options && options.stacktrace)) {
559+
// fingerprint on msg, not stack trace (legacy behavior, could be revisited)
560+
data.fingerprint = data.fingerprint == null ? msg : data.fingerprint;
561+
558562
options = objectMerge(
559563
{
560-
// fingerprint on msg, not stack trace (legacy behavior, could be
561-
// revisited)
562-
fingerprint: msg,
563564
trimHeadFrames: 0
564565
},
565566
options
@@ -577,6 +578,13 @@ Raven.prototype = {
577578
};
578579
}
579580

581+
// Make sure that fingerprint is always wrapped in an array
582+
if (data.fingerprint) {
583+
data.fingerprint = isArray(data.fingerprint)
584+
? data.fingerprint
585+
: [data.fingerprint];
586+
}
587+
580588
// Fire away!
581589
this._send(data);
582590

test/raven.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3044,6 +3044,19 @@ describe('Raven (public API)', function() {
30443044
var frames = Raven._send.lastCall.args[0].stacktrace.frames;
30453045
assertSynthetic(frames);
30463046
});
3047+
3048+
it('should send a default fingerprint if stacktrace:true is set via globalOptions', function() {
3049+
this.sinon.stub(Raven, 'isSetup').returns(true);
3050+
this.sinon.stub(Raven, '_send');
3051+
3052+
Raven._globalOptions.stacktrace = true;
3053+
Raven.captureMessage('foo');
3054+
3055+
var fingerprint = Raven._send.lastCall.args[0].fingerprint;
3056+
// the fingerprint should be the same as the message
3057+
// but wrapped in an array
3058+
assert.deepEqual(fingerprint, ['foo']);
3059+
});
30473060
});
30483061
});
30493062

0 commit comments

Comments
 (0)