Skip to content

Commit 7c0bb7c

Browse files
committed
1.1.7
1 parent 1a6c054 commit 7c0bb7c

File tree

6 files changed

+60
-40
lines changed

6 files changed

+60
-40
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "raven-js",
3-
"version": "1.1.6",
3+
"version": "1.1.7",
44
"dependencies": {},
55
"main": "dist/raven.js"
66
}

dist/raven.js

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Raven.js 1.1.6 (4e078a0) | github.com/getsentry/raven-js */
1+
/*! Raven.js 1.1.7 (1a6c054) | github.com/getsentry/raven-js */
22

33
/*
44
* Includes TraceKit
@@ -14,7 +14,7 @@
1414
MIT license
1515
*/
1616

17-
;(function(window, undefined) {
17+
(function(window, undefined) {
1818

1919

2020
var TraceKit = {};
@@ -166,19 +166,29 @@ TraceKit.report = (function reportModuleWrapper() {
166166
* @param {string} url URL of script that generated the exception.
167167
* @param {(number|string)} lineNo The line number at which the error
168168
* occurred.
169+
* @param {?(number|string)} colNo The column number at which the error
170+
* occurred.
171+
* @param {?Error} ex The actual Error object.
169172
*/
170-
function traceKitWindowOnError(message, url, lineNo) {
171-
var stack = null;
172-
173-
if (lastExceptionStack) {
173+
function traceKitWindowOnError(message, url, lineNo, colNo, ex) {
174+
var stack = null, skipNotify = false;
175+
176+
if (!_isUndefined(ex)) {
177+
// New chrome and blink send along a real error object
178+
// Let's just report that like a normal error.
179+
// See: https://mikewest.org/2013/08/debugging-runtime-errors-with-window-onerror
180+
report(ex, false);
181+
skipNotify = true;
182+
} else if (lastExceptionStack) {
174183
TraceKit.computeStackTrace.augmentStackTraceWithInitialElement(lastExceptionStack, url, lineNo, message);
175184
stack = lastExceptionStack;
176185
lastExceptionStack = null;
177186
lastException = null;
178187
} else {
179188
var location = {
180189
'url': url,
181-
'line': lineNo
190+
'line': lineNo,
191+
'column': colNo
182192
};
183193
location.func = TraceKit.computeStackTrace.guessFunctionName(location.url, location.line);
184194
location.context = TraceKit.computeStackTrace.gatherContext(location.url, location.line);
@@ -191,7 +201,9 @@ TraceKit.report = (function reportModuleWrapper() {
191201
};
192202
}
193203

194-
notifyHandlers(stack, 'from window.onerror');
204+
if (!skipNotify) {
205+
notifyHandlers(stack, 'from window.onerror');
206+
}
195207

196208
if (_oldOnerrorHandler) {
197209
return _oldOnerrorHandler.apply(this, arguments);
@@ -213,8 +225,11 @@ TraceKit.report = (function reportModuleWrapper() {
213225
/**
214226
* Reports an unhandled Error to TraceKit.
215227
* @param {Error} ex
228+
* @param {?boolean} rethrow If false, do not re-throw the exception.
229+
* Only used for window.onerror to not cause an infinite loop of
230+
* rethrowing.
216231
*/
217-
function report(ex) {
232+
function report(ex, rethrow) {
218233
var args = _slice.call(arguments, 1);
219234
if (lastExceptionStack) {
220235
if (lastException === ex) {
@@ -243,7 +258,9 @@ TraceKit.report = (function reportModuleWrapper() {
243258
}
244259
}, (stack.incomplete ? 2000 : 0));
245260

246-
throw ex; // re-throw to propagate to the top level (and cause window.onerror)
261+
if (rethrow !== false) {
262+
throw ex; // re-throw to propagate to the top level (and cause window.onerror)
263+
}
247264
}
248265

249266
report.subscribe = subscribe;
@@ -333,14 +350,14 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
333350
return '';
334351
}
335352
try {
336-
function getXHR() {
353+
var getXHR = function() {
337354
try {
338355
return new window.XMLHttpRequest();
339356
} catch (e) {
340357
// explicitly bubble up the exception if not found
341358
return new window.ActiveXObject('Microsoft.XMLHTTP');
342359
}
343-
}
360+
};
344361

345362
var request = getXHR();
346363
request.open('GET', url, false);
@@ -629,8 +646,8 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
629646
return null;
630647
}
631648

632-
var chrome = /^\s*at (?:((?:\[object object\])?\S+) )?\(?((?:file|http|https):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
633-
gecko = /^\s*(\S*)(?:\((.*?)\))?@((?:file|http|https).*?):(\d+)(?::(\d+))?\s*$/i,
649+
var chrome = /^\s*at (?:((?:\[object object\])?\S+(?: \[as \S+\])?) )?\(?((?:file|https?):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
650+
gecko = /^\s*(\S*)(?:\((.*?)\))?@((?:file|https?).*?):(\d+)(?::(\d+))?\s*$/i,
634651
lines = ex.stack.split('\n'),
635652
stack = [],
636653
parts,
@@ -773,8 +790,8 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
773790
return null;
774791
}
775792

776-
var lineRE1 = /^\s*Line (\d+) of linked script ((?:file|http|https)\S+)(?:: in function (\S+))?\s*$/i,
777-
lineRE2 = /^\s*Line (\d+) of inline#(\d+) script in ((?:file|http|https)\S+)(?:: in function (\S+))?\s*$/i,
793+
var lineRE1 = /^\s*Line (\d+) of linked script ((?:file|https?)\S+)(?:: in function (\S+))?\s*$/i,
794+
lineRE2 = /^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?)\S+)(?:: in function (\S+))?\s*$/i,
778795
lineRE3 = /^\s*Line (\d+) of function script\s*$/i,
779796
stack = [],
780797
scripts = document.getElementsByTagName('script'),
@@ -1064,8 +1081,6 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
10641081
} catch (ex) {
10651082
return computeStackTrace(ex, depth + 1);
10661083
}
1067-
1068-
return null;
10691084
}
10701085

10711086
computeStackTrace.augmentStackTraceWithInitialElement = augmentStackTraceWithInitialElement;
@@ -1132,7 +1147,7 @@ TK.remoteFetching = false;
11321147
* @this {Raven}
11331148
*/
11341149
var Raven = {
1135-
VERSION: '1.1.6',
1150+
VERSION: '1.1.7',
11361151

11371152
// Expose TraceKit to the Raven namespace
11381153
TraceKit: TK,
@@ -1361,7 +1376,7 @@ var Raven = {
13611376
captureMessage: function(msg, options) {
13621377
// Fire away!
13631378
send(
1364-
arrayMerge({
1379+
objectMerge({
13651380
message: msg
13661381
}, options)
13671382
);
@@ -1462,6 +1477,11 @@ function isString(what) {
14621477
return typeof what === 'string';
14631478
}
14641479

1480+
function isEmptyObject(what) {
1481+
for (var k in what) return false;
1482+
return true;
1483+
}
1484+
14651485
function each(obj, callback) {
14661486
var i, j;
14671487

@@ -1627,7 +1647,7 @@ function processException(type, message, fileurl, lineno, frames, options) {
16271647

16281648
// Fire away!
16291649
send(
1630-
arrayMerge({
1650+
objectMerge({
16311651
// sentry.interfaces.Exception
16321652
exception: {
16331653
type: type,
@@ -1641,14 +1661,14 @@ function processException(type, message, fileurl, lineno, frames, options) {
16411661
);
16421662
}
16431663

1644-
function arrayMerge(arr1, arr2) {
1645-
if (!arr2) {
1646-
return arr1;
1664+
function objectMerge(obj1, obj2) {
1665+
if (!obj2) {
1666+
return obj1;
16471667
}
1648-
each(arr2, function(key, value){
1649-
arr1[key] = value;
1668+
each(obj2, function(key, value){
1669+
obj1[key] = value;
16501670
});
1651-
return arr1;
1671+
return obj1;
16521672
}
16531673

16541674
function getHttpData() {
@@ -1669,7 +1689,7 @@ function getHttpData() {
16691689
function send(data) {
16701690
if (!isSetup()) return;
16711691

1672-
data = arrayMerge({
1692+
data = objectMerge({
16731693
project: globalProject,
16741694
logger: globalOptions.logger,
16751695
site: globalOptions.site,
@@ -1678,13 +1698,13 @@ function send(data) {
16781698
request: getHttpData()
16791699
}, data);
16801700

1681-
// Merge in the tags and extra separately since arrayMerge doesn't handle a deep merge
1682-
data.tags = arrayMerge(globalOptions.tags, data.tags);
1683-
data.extra = arrayMerge(globalOptions.extra, data.extra);
1701+
// Merge in the tags and extra separately since objectMerge doesn't handle a deep merge
1702+
data.tags = objectMerge(globalOptions.tags, data.tags);
1703+
data.extra = objectMerge(globalOptions.extra, data.extra);
16841704

16851705
// If there are no tags/extra, strip the key from the payload alltogther.
1686-
if (!data.tags) delete data.tags;
1687-
if (!data.extra) delete data.extra;
1706+
if (isEmptyObject(data.tags)) delete data.tags;
1707+
if (isEmptyObject(data.extra)) delete data.extra;
16881708

16891709
if (globalUser) {
16901710
// sentry.interfaces.User

0 commit comments

Comments
 (0)