Skip to content

Commit

Permalink
fix: default fingerprinting when using synthetic stacktraces
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jorge Cruz authored and kamilogorek committed Mar 8, 2018
1 parent c2b377e commit 8f8a624
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,11 @@ Raven.prototype = {
}

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

var data = objectMerge(
{
message: msg + '' // Make sure it's actually a string
message: msg
},
options
);
Expand Down Expand Up @@ -555,11 +556,11 @@ Raven.prototype = {
}

if (this._globalOptions.stacktrace || (options && options.stacktrace)) {
// fingerprint on msg, not stack trace (legacy behavior, could be revisited)
data.fingerprint = data.fingerprint == null ? msg : data.fingerprint;

options = objectMerge(
{
// fingerprint on msg, not stack trace (legacy behavior, could be
// revisited)
fingerprint: msg,
trimHeadFrames: 0
},
options
Expand All @@ -577,6 +578,13 @@ Raven.prototype = {
};
}

// Make sure that fingerprint is always wrapped in an array
if (data.fingerprint) {
data.fingerprint = isArray(data.fingerprint)
? data.fingerprint
: [data.fingerprint];
}

// Fire away!
this._send(data);

Expand Down
13 changes: 13 additions & 0 deletions test/raven.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3044,6 +3044,19 @@ describe('Raven (public API)', function() {
var frames = Raven._send.lastCall.args[0].stacktrace.frames;
assertSynthetic(frames);
});

it('should send a default fingerprint if stacktrace:true is set via globalOptions', function() {
this.sinon.stub(Raven, 'isSetup').returns(true);
this.sinon.stub(Raven, '_send');

Raven._globalOptions.stacktrace = true;
Raven.captureMessage('foo');

var fingerprint = Raven._send.lastCall.args[0].fingerprint;
// the fingerprint should be the same as the message
// but wrapped in an array
assert.deepEqual(fingerprint, ['foo']);
});
});
});

Expand Down

0 comments on commit 8f8a624

Please sign in to comment.