Skip to content

Commit 2a87bf9

Browse files
kevinehosfordkamilogorek
authored andcommitted
feat: compare fingerprints for repeated message-based events
1 parent 18e252a commit 2a87bf9

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

packages/raven-js/src/raven.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,9 @@ Raven.prototype = {
19211921
} else if (current.exception || last.exception) {
19221922
// Exception interface (i.e. from captureException/onerror)
19231923
return isSameException(current.exception, last.exception);
1924+
} else if (current.fingerprint || last.fingerprint) {
1925+
return Boolean(current.fingerprint && last.fingerprint) &&
1926+
JSON.stringify(current.fingerprint) === JSON.stringify(last.fingerprint)
19241927
}
19251928

19261929
return true;

packages/raven-js/test/raven.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,6 +3856,30 @@ describe('Raven (private methods)', function() {
38563856
assert.isFalse(Raven._isRepeatData(data));
38573857
});
38583858

3859+
it('should return false for different fingerprints', function() {
3860+
var data = JSON.parse(JSON.stringify(Raven._lastData)); // copy
3861+
data.fingerprint = ['{{ default }}', 'grouping-identifier'];
3862+
3863+
assert.isFalse(Raven._isRepeatData(data));
3864+
3865+
Raven._lastData.fingerprint = ['{{ default }}', 'other-grouping-identifier'];
3866+
3867+
assert.isFalse(Raven._isRepeatData(data));
3868+
3869+
delete data.fingerprint;
3870+
3871+
assert.isFalse(Raven._isRepeatData(data));
3872+
});
3873+
3874+
it('should return false for different messages and identical fingerprints', function () {
3875+
Raven._lastData.message = 'the thing broke';
3876+
Raven._lastData.fingerprint = ['{{ default }}', 'grouping-identifier'];
3877+
var data = JSON.parse(JSON.stringify(Raven._lastData)); // copy
3878+
data.message = 'the other thing broke';
3879+
3880+
assert.isFalse(Raven._isRepeatData(data));
3881+
});
3882+
38593883
it('should return false for different captureMessage payloads w/ synthetic traces', function() {
38603884
Raven._lastData.stacktrace = {
38613885
frames: [

0 commit comments

Comments
 (0)