Skip to content

Commit b8d9670

Browse files
authored
3.12.0 (#867)
1 parent 5da31e6 commit b8d9670

20 files changed

+149
-36
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 3.12.0
4+
* NEW: Raven.js now attempts to suppress back-to-back duplicate errors by default. See: https://github.com/getsentry/raven-js/pull/861
5+
* BUGFIX: Fix case where breadcrumb instrumention could sometimes throw errors on custom DOM events. See: https://github.com/getsentry/raven-js/pull/857
6+
* BUGFIX: Fix Raven.js incorrectly interpreting Retry-After header in ms; should be seconds. See: https://github.com/getsentry/raven-js/pull/862
7+
38
## 3.11.0
49
* CHANGE: Raven.js no longer auto-wraps jQuery.ready (if present); fixes jQuery deprecation warnings. See: https://github.com/getsentry/raven-js/pull/849
510
* BUGFIX: Fix User-Agent not collected in web worker environment. See: https://github.com/getsentry/raven-js/issues/853

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "raven-js",
3-
"version": "3.11.0",
3+
"version": "3.12.0",
44
"dependencies": {},
55
"main": "dist/raven.js",
66
"ignore": [

dist/plugins/angular.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Raven.js 3.11.0 (c2f43d7) | github.com/getsentry/raven-js */
1+
/*! Raven.js 3.11.0 (cb87941) | github.com/getsentry/raven-js */
22

33
/*
44
* Includes TraceKit

dist/plugins/angular.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugins/console.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Raven.js 3.11.0 (c2f43d7) | github.com/getsentry/raven-js */
1+
/*! Raven.js 3.11.0 (cb87941) | github.com/getsentry/raven-js */
22

33
/*
44
* Includes TraceKit

dist/plugins/console.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugins/ember.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Raven.js 3.11.0 (c2f43d7) | github.com/getsentry/raven-js */
1+
/*! Raven.js 3.11.0 (cb87941) | github.com/getsentry/raven-js */
22

33
/*
44
* Includes TraceKit

dist/plugins/ember.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugins/require.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Raven.js 3.11.0 (c2f43d7) | github.com/getsentry/raven-js */
1+
/*! Raven.js 3.11.0 (cb87941) | github.com/getsentry/raven-js */
22

33
/*
44
* Includes TraceKit

dist/plugins/require.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugins/vue.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Raven.js 3.11.0 (c2f43d7) | github.com/getsentry/raven-js */
1+
/*! Raven.js 3.11.0 (cb87941) | github.com/getsentry/raven-js */
22

33
/*
44
* Includes TraceKit

dist/plugins/vue.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/raven.js

+119-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Raven.js 3.11.0 (c2f43d7) | github.com/getsentry/raven-js */
1+
/*! Raven.js 3.11.0 (cb87941) | github.com/getsentry/raven-js */
22

33
/*
44
* Includes TraceKit
@@ -125,6 +125,7 @@ function Raven() {
125125
this._hasDocument = !isUndefined(_document);
126126
this._hasNavigator = !isUndefined(_navigator);
127127
this._lastCapturedException = null;
128+
this._lastData = null;
128129
this._lastEventId = null;
129130
this._globalServer = null;
130131
this._globalKey = null;
@@ -840,14 +841,14 @@ Raven.prototype = {
840841
return;
841842

842843
self._lastCapturedEvent = evt;
843-
var elem = evt.target;
844844

845+
// try/catch both:
846+
// - accessing evt.target (see getsentry/raven-js#838, #768)
847+
// - `htmlTreeAsString` because it's complex, and just accessing the DOM incorrectly
848+
// can throw an exception in some circumstances.
845849
var target;
846-
847-
// try/catch htmlTreeAsString because it's particularly complicated, and
848-
// just accessing the DOM incorrectly can throw an exception in some circumstances.
849850
try {
850-
target = htmlTreeAsString(elem);
851+
target = htmlTreeAsString(evt.target);
851852
} catch (e) {
852853
target = '<unknown>';
853854
}
@@ -872,8 +873,15 @@ Raven.prototype = {
872873
// debounce timeout is triggered, we will only capture
873874
// a single breadcrumb from the FIRST target (acceptable?)
874875
return function (evt) {
875-
var target = evt.target,
876-
tagName = target && target.tagName;
876+
var target;
877+
try {
878+
target = evt.target;
879+
} catch (e) {
880+
// just accessing event properties can throw an exception in some rare circumstances
881+
// see: https://github.com/getsentry/raven-js/issues/838
882+
return;
883+
}
884+
var tagName = target && target.tagName;
877885

878886
// only consider keypress events on actual input elements
879887
// this will disregard keypresses targeting body (e.g. tabbing
@@ -990,9 +998,17 @@ Raven.prototype = {
990998
// see #724
991999
if (!evt) return;
9921000

993-
if (evt.type === 'click')
1001+
var eventType;
1002+
try {
1003+
eventType = evt.type
1004+
} catch (e) {
1005+
// just accessing event properties can throw an exception in some rare circumstances
1006+
// see: https://github.com/getsentry/raven-js/issues/838
1007+
return;
1008+
}
1009+
if (eventType === 'click')
9941010
return clickHandler(evt);
995-
else if (evt.type === 'keypress')
1011+
else if (eventType === 'keypress')
9961012
return keypressHandler(evt);
9971013
};
9981014
}
@@ -1428,6 +1444,35 @@ Raven.prototype = {
14281444
return this._backoffDuration && now() - this._backoffStart < this._backoffDuration;
14291445
},
14301446

1447+
/**
1448+
* Returns true if the in-process data payload matches the signature
1449+
* of the previously-sent data
1450+
*
1451+
* NOTE: This has to be done at this level because TraceKit can generate
1452+
* data from window.onerror WITHOUT an exception object (IE8, IE9,
1453+
* other old browsers). This can take the form of an "exception"
1454+
* data object with a single frame (derived from the onerror args).
1455+
*/
1456+
_isRepeatData: function (current) {
1457+
var last = this._lastData;
1458+
1459+
if (!last ||
1460+
current.message !== last.message || // defined for captureMessage
1461+
current.culprit !== last.culprit) // defined for captureException/onerror
1462+
return false;
1463+
1464+
// Stacktrace interface (i.e. from captureMessage)
1465+
if (current.stacktrace || last.stacktrace) {
1466+
return isSameStacktrace(current.stacktrace, last.stacktrace);
1467+
}
1468+
// Exception interface (i.e. from captureException/onerror)
1469+
else if (current.exception || last.exception) {
1470+
return isSameException(current.exception, last.exception);
1471+
}
1472+
1473+
return true;
1474+
},
1475+
14311476
_setBackoffState: function(request) {
14321477
// If we are already in a backoff state, don't change anything
14331478
if (this._shouldBackoff()) {
@@ -1447,7 +1492,7 @@ Raven.prototype = {
14471492
// If Retry-After is not in Access-Control-Expose-Headers, most
14481493
// browsers will throw an exception trying to access it
14491494
retry = request.getResponseHeader('Retry-After');
1450-
retry = parseInt(retry, 10);
1495+
retry = parseInt(retry, 10) * 1000; // Retry-After is returned in seconds
14511496
} catch (e) {
14521497
/* eslint no-empty:0 */
14531498
}
@@ -1554,6 +1599,17 @@ Raven.prototype = {
15541599
// Try and clean up the packet before sending by truncating long values
15551600
data = this._trimPacket(data);
15561601

1602+
// ideally duplicate error testing should occur *before* dataCallback/shouldSendCallback,
1603+
// but this would require copying an un-truncated copy of the data packet, which can be
1604+
// arbitrarily deep (extra_data) -- could be worthwhile? will revisit
1605+
if (!this._globalOptions.allowDuplicates && this._isRepeatData(data)) {
1606+
this._logDebug('warn', 'Raven dropped repeat event: ', data);
1607+
return;
1608+
}
1609+
1610+
// Store outbound payload after trim
1611+
this._lastData = data;
1612+
15571613
this._logDebug('debug', 'Raven about to send:', data);
15581614

15591615
var auth = {
@@ -1915,6 +1971,58 @@ function htmlElementAsString(elem) {
19151971
return out.join('');
19161972
}
19171973

1974+
/**
1975+
* Returns true if either a OR b is truthy, but not both
1976+
*/
1977+
function isOnlyOneTruthy(a, b) {
1978+
return !!(!!a ^ !!b);
1979+
}
1980+
1981+
/**
1982+
* Returns true if the two input exception interfaces have the same content
1983+
*/
1984+
function isSameException(ex1, ex2) {
1985+
if (isOnlyOneTruthy(ex1, ex2))
1986+
return false;
1987+
1988+
ex1 = ex1.values[0];
1989+
ex2 = ex2.values[0];
1990+
1991+
if (ex1.type !== ex2.type ||
1992+
ex1.value !== ex2.value)
1993+
return false;
1994+
1995+
return isSameStacktrace(ex1.stacktrace, ex2.stacktrace);
1996+
}
1997+
1998+
/**
1999+
* Returns true if the two input stack trace interfaces have the same content
2000+
*/
2001+
function isSameStacktrace(stack1, stack2) {
2002+
if (isOnlyOneTruthy(stack1, stack2))
2003+
return false;
2004+
2005+
var frames1 = stack1.frames;
2006+
var frames2 = stack2.frames;
2007+
2008+
// Exit early if frame count differs
2009+
if (frames1.length !== frames2.length)
2010+
return false;
2011+
2012+
// Iterate through every frame; bail out if anything differs
2013+
var a, b;
2014+
for (var i = 0; i < frames1.length; i++) {
2015+
a = frames1[i];
2016+
b = frames2[i];
2017+
if (a.filename !== b.filename ||
2018+
a.lineno !== b.lineno ||
2019+
a.colno !== b.colno ||
2020+
a['function'] !== b['function'])
2021+
return false;
2022+
}
2023+
return true;
2024+
}
2025+
19182026
/**
19192027
* Polyfill a method
19202028
* @param obj object e.g. `document`

dist/raven.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/raven.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/sri.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
22
"@dist/raven.js": {
33
"hashes": {
4-
"sha256": "LKT3OdNraYkxKmB9k9ZiKlTEDMnJdc9+COkzSzsmRyY=",
5-
"sha512": "V5ZsDgGRam2T5E2tdlZQKpy7SNhZoeQm3DtKCMeAo7lIWkOrcwuTLLsVUu2ZBp+LqYHWa28Z4LApjceG16hfzA=="
4+
"sha256": "Dwnqh7Kf/MtddZEib7nlf8EgV02obB2QNJwJrgmleCw=",
5+
"sha512": "rFBEzM66OQgGkmJ1HjHmAH3SyX8Li7U1DHeFHKFytJEdgFBOp+A+JTiWTzR02DSOQbx3rGOZLSBO0LaFskiXQA=="
66
},
77
"type": null,
8-
"integrity": "sha256-LKT3OdNraYkxKmB9k9ZiKlTEDMnJdc9+COkzSzsmRyY= sha512-V5ZsDgGRam2T5E2tdlZQKpy7SNhZoeQm3DtKCMeAo7lIWkOrcwuTLLsVUu2ZBp+LqYHWa28Z4LApjceG16hfzA==",
8+
"integrity": "sha256-Dwnqh7Kf/MtddZEib7nlf8EgV02obB2QNJwJrgmleCw= sha512-rFBEzM66OQgGkmJ1HjHmAH3SyX8Li7U1DHeFHKFytJEdgFBOp+A+JTiWTzR02DSOQbx3rGOZLSBO0LaFskiXQA==",
99
"path": "dist/raven.js"
1010
},
1111
"@dist/raven.min.js": {
1212
"hashes": {
13-
"sha256": "1I93p/Pk00vGdxcfVAcLwQihGOcv1wcEQg9x1Nqreqo=",
14-
"sha512": "VY7jH0NhSchsVmKb3nf/Vy+ZSkNR38CjBVTxDLDZN3xzlOa57MCC11MdhanV/ZKIPASuS3bTQ0nr7T2GuTxb3w=="
13+
"sha256": "bNou8nfAvackB8vWBJLCEarwQsiyHAZ6doKQz+lH+G8=",
14+
"sha512": "VyEfGJStPnFTCFYIGp0EdsWnKEUGgk2xjkI5dW2EzFFKwngACxlCSNvSiOelovr1CqjOeJGKkU99988ZZoNNYw=="
1515
},
1616
"type": null,
17-
"integrity": "sha256-1I93p/Pk00vGdxcfVAcLwQihGOcv1wcEQg9x1Nqreqo= sha512-VY7jH0NhSchsVmKb3nf/Vy+ZSkNR38CjBVTxDLDZN3xzlOa57MCC11MdhanV/ZKIPASuS3bTQ0nr7T2GuTxb3w==",
17+
"integrity": "sha256-bNou8nfAvackB8vWBJLCEarwQsiyHAZ6doKQz+lH+G8= sha512-VyEfGJStPnFTCFYIGp0EdsWnKEUGgk2xjkI5dW2EzFFKwngACxlCSNvSiOelovr1CqjOeJGKkU99988ZZoNNYw==",
1818
"path": "dist/raven.min.js"
1919
}
2020
}

docs/sentry-doc-config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@
6666
}
6767
},
6868
"vars": {
69-
"RAVEN_VERSION": "3.11.0"
69+
"RAVEN_VERSION": "3.12.0"
7070
}
7171
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "raven-js",
3-
"version": "3.11.0",
3+
"version": "3.12.0",
44
"license": "BSD-2-Clause",
55
"homepage": "https://github.com/getsentry/raven-js",
66
"scripts": {

src/raven.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Raven.prototype = {
8282
// webpack (using a build step causes webpack #1617). Grunt verifies that
8383
// this value matches package.json during build.
8484
// See: https://github.com/getsentry/raven-js/issues/465
85-
VERSION: '3.11.0',
85+
VERSION: '3.12.0',
8686

8787
debug: false,
8888

test/raven.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ describe('globals', function() {
10101010
extra: {'session:duration': 100},
10111011
});
10121012
assert.deepEqual(opts.auth, {
1013-
sentry_client: 'raven-js/3.11.0',
1013+
sentry_client: 'raven-js/3.12.0',
10141014
sentry_key: 'abc',
10151015
sentry_version: '7'
10161016
});
@@ -1057,7 +1057,7 @@ describe('globals', function() {
10571057
extra: {'session:duration': 100},
10581058
});
10591059
assert.deepEqual(opts.auth, {
1060-
sentry_client: 'raven-js/3.11.0',
1060+
sentry_client: 'raven-js/3.12.0',
10611061
sentry_key: 'abc',
10621062
sentry_secret: 'def',
10631063
sentry_version: '7'

0 commit comments

Comments
 (0)