diff --git a/src/raven.js b/src/raven.js index 8611bc35e34d..b20de308080b 100644 --- a/src/raven.js +++ b/src/raven.js @@ -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 ); @@ -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 @@ -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); diff --git a/test/raven.test.js b/test/raven.test.js index 0586b6937210..4d0d7095dfc1 100644 --- a/test/raven.test.js +++ b/test/raven.test.js @@ -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']); + }); }); });