Skip to content

Commit

Permalink
3.12.0 (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
benvinegar authored Feb 27, 2017
1 parent 5da31e6 commit b8d9670
Show file tree
Hide file tree
Showing 20 changed files with 149 additions and 36 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 3.12.0
* NEW: Raven.js now attempts to suppress back-to-back duplicate errors by default. See: https://github.com/getsentry/raven-js/pull/861
* BUGFIX: Fix case where breadcrumb instrumention could sometimes throw errors on custom DOM events. See: https://github.com/getsentry/raven-js/pull/857
* BUGFIX: Fix Raven.js incorrectly interpreting Retry-After header in ms; should be seconds. See: https://github.com/getsentry/raven-js/pull/862

## 3.11.0
* CHANGE: Raven.js no longer auto-wraps jQuery.ready (if present); fixes jQuery deprecation warnings. See: https://github.com/getsentry/raven-js/pull/849
* BUGFIX: Fix User-Agent not collected in web worker environment. See: https://github.com/getsentry/raven-js/issues/853
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raven-js",
"version": "3.11.0",
"version": "3.12.0",
"dependencies": {},
"main": "dist/raven.js",
"ignore": [
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/angular.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.11.0 (c2f43d7) | github.com/getsentry/raven-js */
/*! Raven.js 3.11.0 (cb87941) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/angular.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/console.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.11.0 (c2f43d7) | github.com/getsentry/raven-js */
/*! Raven.js 3.11.0 (cb87941) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/console.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/ember.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.11.0 (c2f43d7) | github.com/getsentry/raven-js */
/*! Raven.js 3.11.0 (cb87941) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/ember.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/require.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.11.0 (c2f43d7) | github.com/getsentry/raven-js */
/*! Raven.js 3.11.0 (cb87941) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/require.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/vue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.11.0 (c2f43d7) | github.com/getsentry/raven-js */
/*! Raven.js 3.11.0 (cb87941) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/vue.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

130 changes: 119 additions & 11 deletions dist/raven.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.11.0 (c2f43d7) | github.com/getsentry/raven-js */
/*! Raven.js 3.11.0 (cb87941) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down Expand Up @@ -125,6 +125,7 @@ function Raven() {
this._hasDocument = !isUndefined(_document);
this._hasNavigator = !isUndefined(_navigator);
this._lastCapturedException = null;
this._lastData = null;
this._lastEventId = null;
this._globalServer = null;
this._globalKey = null;
Expand Down Expand Up @@ -840,14 +841,14 @@ Raven.prototype = {
return;

self._lastCapturedEvent = evt;
var elem = evt.target;

// try/catch both:
// - accessing evt.target (see getsentry/raven-js#838, #768)
// - `htmlTreeAsString` because it's complex, and just accessing the DOM incorrectly
// can throw an exception in some circumstances.
var target;

// try/catch htmlTreeAsString because it's particularly complicated, and
// just accessing the DOM incorrectly can throw an exception in some circumstances.
try {
target = htmlTreeAsString(elem);
target = htmlTreeAsString(evt.target);
} catch (e) {
target = '<unknown>';
}
Expand All @@ -872,8 +873,15 @@ Raven.prototype = {
// debounce timeout is triggered, we will only capture
// a single breadcrumb from the FIRST target (acceptable?)
return function (evt) {
var target = evt.target,
tagName = target && target.tagName;
var target;
try {
target = evt.target;
} catch (e) {
// just accessing event properties can throw an exception in some rare circumstances
// see: https://github.com/getsentry/raven-js/issues/838
return;
}
var tagName = target && target.tagName;

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

if (evt.type === 'click')
var eventType;
try {
eventType = evt.type
} catch (e) {
// just accessing event properties can throw an exception in some rare circumstances
// see: https://github.com/getsentry/raven-js/issues/838
return;
}
if (eventType === 'click')
return clickHandler(evt);
else if (evt.type === 'keypress')
else if (eventType === 'keypress')
return keypressHandler(evt);
};
}
Expand Down Expand Up @@ -1428,6 +1444,35 @@ Raven.prototype = {
return this._backoffDuration && now() - this._backoffStart < this._backoffDuration;
},

/**
* Returns true if the in-process data payload matches the signature
* of the previously-sent data
*
* NOTE: This has to be done at this level because TraceKit can generate
* data from window.onerror WITHOUT an exception object (IE8, IE9,
* other old browsers). This can take the form of an "exception"
* data object with a single frame (derived from the onerror args).
*/
_isRepeatData: function (current) {
var last = this._lastData;

if (!last ||
current.message !== last.message || // defined for captureMessage
current.culprit !== last.culprit) // defined for captureException/onerror
return false;

// Stacktrace interface (i.e. from captureMessage)
if (current.stacktrace || last.stacktrace) {
return isSameStacktrace(current.stacktrace, last.stacktrace);
}
// Exception interface (i.e. from captureException/onerror)
else if (current.exception || last.exception) {
return isSameException(current.exception, last.exception);
}

return true;
},

_setBackoffState: function(request) {
// If we are already in a backoff state, don't change anything
if (this._shouldBackoff()) {
Expand All @@ -1447,7 +1492,7 @@ Raven.prototype = {
// If Retry-After is not in Access-Control-Expose-Headers, most
// browsers will throw an exception trying to access it
retry = request.getResponseHeader('Retry-After');
retry = parseInt(retry, 10);
retry = parseInt(retry, 10) * 1000; // Retry-After is returned in seconds
} catch (e) {
/* eslint no-empty:0 */
}
Expand Down Expand Up @@ -1554,6 +1599,17 @@ Raven.prototype = {
// Try and clean up the packet before sending by truncating long values
data = this._trimPacket(data);

// ideally duplicate error testing should occur *before* dataCallback/shouldSendCallback,
// but this would require copying an un-truncated copy of the data packet, which can be
// arbitrarily deep (extra_data) -- could be worthwhile? will revisit
if (!this._globalOptions.allowDuplicates && this._isRepeatData(data)) {
this._logDebug('warn', 'Raven dropped repeat event: ', data);
return;
}

// Store outbound payload after trim
this._lastData = data;

this._logDebug('debug', 'Raven about to send:', data);

var auth = {
Expand Down Expand Up @@ -1915,6 +1971,58 @@ function htmlElementAsString(elem) {
return out.join('');
}

/**
* Returns true if either a OR b is truthy, but not both
*/
function isOnlyOneTruthy(a, b) {
return !!(!!a ^ !!b);
}

/**
* Returns true if the two input exception interfaces have the same content
*/
function isSameException(ex1, ex2) {
if (isOnlyOneTruthy(ex1, ex2))
return false;

ex1 = ex1.values[0];
ex2 = ex2.values[0];

if (ex1.type !== ex2.type ||
ex1.value !== ex2.value)
return false;

return isSameStacktrace(ex1.stacktrace, ex2.stacktrace);
}

/**
* Returns true if the two input stack trace interfaces have the same content
*/
function isSameStacktrace(stack1, stack2) {
if (isOnlyOneTruthy(stack1, stack2))
return false;

var frames1 = stack1.frames;
var frames2 = stack2.frames;

// Exit early if frame count differs
if (frames1.length !== frames2.length)
return false;

// Iterate through every frame; bail out if anything differs
var a, b;
for (var i = 0; i < frames1.length; i++) {
a = frames1[i];
b = frames2[i];
if (a.filename !== b.filename ||
a.lineno !== b.lineno ||
a.colno !== b.colno ||
a['function'] !== b['function'])
return false;
}
return true;
}

/**
* Polyfill a method
* @param obj object e.g. `document`
Expand Down
4 changes: 2 additions & 2 deletions dist/raven.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/raven.min.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/sri.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"@dist/raven.js": {
"hashes": {
"sha256": "LKT3OdNraYkxKmB9k9ZiKlTEDMnJdc9+COkzSzsmRyY=",
"sha512": "V5ZsDgGRam2T5E2tdlZQKpy7SNhZoeQm3DtKCMeAo7lIWkOrcwuTLLsVUu2ZBp+LqYHWa28Z4LApjceG16hfzA=="
"sha256": "Dwnqh7Kf/MtddZEib7nlf8EgV02obB2QNJwJrgmleCw=",
"sha512": "rFBEzM66OQgGkmJ1HjHmAH3SyX8Li7U1DHeFHKFytJEdgFBOp+A+JTiWTzR02DSOQbx3rGOZLSBO0LaFskiXQA=="
},
"type": null,
"integrity": "sha256-LKT3OdNraYkxKmB9k9ZiKlTEDMnJdc9+COkzSzsmRyY= sha512-V5ZsDgGRam2T5E2tdlZQKpy7SNhZoeQm3DtKCMeAo7lIWkOrcwuTLLsVUu2ZBp+LqYHWa28Z4LApjceG16hfzA==",
"integrity": "sha256-Dwnqh7Kf/MtddZEib7nlf8EgV02obB2QNJwJrgmleCw= sha512-rFBEzM66OQgGkmJ1HjHmAH3SyX8Li7U1DHeFHKFytJEdgFBOp+A+JTiWTzR02DSOQbx3rGOZLSBO0LaFskiXQA==",
"path": "dist/raven.js"
},
"@dist/raven.min.js": {
"hashes": {
"sha256": "1I93p/Pk00vGdxcfVAcLwQihGOcv1wcEQg9x1Nqreqo=",
"sha512": "VY7jH0NhSchsVmKb3nf/Vy+ZSkNR38CjBVTxDLDZN3xzlOa57MCC11MdhanV/ZKIPASuS3bTQ0nr7T2GuTxb3w=="
"sha256": "bNou8nfAvackB8vWBJLCEarwQsiyHAZ6doKQz+lH+G8=",
"sha512": "VyEfGJStPnFTCFYIGp0EdsWnKEUGgk2xjkI5dW2EzFFKwngACxlCSNvSiOelovr1CqjOeJGKkU99988ZZoNNYw=="
},
"type": null,
"integrity": "sha256-1I93p/Pk00vGdxcfVAcLwQihGOcv1wcEQg9x1Nqreqo= sha512-VY7jH0NhSchsVmKb3nf/Vy+ZSkNR38CjBVTxDLDZN3xzlOa57MCC11MdhanV/ZKIPASuS3bTQ0nr7T2GuTxb3w==",
"integrity": "sha256-bNou8nfAvackB8vWBJLCEarwQsiyHAZ6doKQz+lH+G8= sha512-VyEfGJStPnFTCFYIGp0EdsWnKEUGgk2xjkI5dW2EzFFKwngACxlCSNvSiOelovr1CqjOeJGKkU99988ZZoNNYw==",
"path": "dist/raven.min.js"
}
}
2 changes: 1 addition & 1 deletion docs/sentry-doc-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
}
},
"vars": {
"RAVEN_VERSION": "3.11.0"
"RAVEN_VERSION": "3.12.0"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raven-js",
"version": "3.11.0",
"version": "3.12.0",
"license": "BSD-2-Clause",
"homepage": "https://github.com/getsentry/raven-js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Raven.prototype = {
// webpack (using a build step causes webpack #1617). Grunt verifies that
// this value matches package.json during build.
// See: https://github.com/getsentry/raven-js/issues/465
VERSION: '3.11.0',
VERSION: '3.12.0',

debug: false,

Expand Down
4 changes: 2 additions & 2 deletions test/raven.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ describe('globals', function() {
extra: {'session:duration': 100},
});
assert.deepEqual(opts.auth, {
sentry_client: 'raven-js/3.11.0',
sentry_client: 'raven-js/3.12.0',
sentry_key: 'abc',
sentry_version: '7'
});
Expand Down Expand Up @@ -1057,7 +1057,7 @@ describe('globals', function() {
extra: {'session:duration': 100},
});
assert.deepEqual(opts.auth, {
sentry_client: 'raven-js/3.11.0',
sentry_client: 'raven-js/3.12.0',
sentry_key: 'abc',
sentry_secret: 'def',
sentry_version: '7'
Expand Down

0 comments on commit b8d9670

Please sign in to comment.