Skip to content

Commit cbf0a05

Browse files
committed
1.1.17
1 parent aa35178 commit cbf0a05

File tree

6 files changed

+115
-65
lines changed

6 files changed

+115
-65
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.16",
3+
"version": "1.1.17",
44
"dependencies": {},
55
"main": "dist/raven.js",
66
"ignore": {}

dist/raven.js

Lines changed: 93 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*! Raven.js 1.1.16 (463f68f) | github.com/getsentry/raven-js */
1+
/*! Raven.js 1.1.17 (aa35178) | github.com/getsentry/raven-js */
22

33
/*
44
* Includes TraceKit
55
* https://github.com/getsentry/TraceKit
66
*
7-
* Copyright 2014 Matt Robenolt and other contributors
7+
* Copyright 2015 Matt Robenolt and other contributors
88
* Released under the BSD license
99
* https://github.com/getsentry/raven-js/blob/master/LICENSE
1010
*
@@ -270,7 +270,6 @@ TraceKit.report = (function reportModuleWrapper() {
270270
* TraceKit.computeStackTrace: cross-browser stack traces in JavaScript
271271
*
272272
* Syntax:
273-
* s = TraceKit.computeStackTrace.ofCaller([depth])
274273
* s = TraceKit.computeStackTrace(exception) // consider using TraceKit.report instead (see below)
275274
* Returns:
276275
* s.name - exception name
@@ -318,19 +317,6 @@ TraceKit.report = (function reportModuleWrapper() {
318317
* exceptions (because your catch block will likely be far away from the
319318
* inner function that actually caused the exception).
320319
*
321-
* Tracing example:
322-
* function trace(message) {
323-
* var stackInfo = TraceKit.computeStackTrace.ofCaller();
324-
* var data = message + "\n";
325-
* for(var i in stackInfo.stack) {
326-
* var item = stackInfo.stack[i];
327-
* data += (item.func || '[anonymous]') + "() in " + item.url + ":" + (item.line || '0') + "\n";
328-
* }
329-
* if (window.console)
330-
* console.info(data);
331-
* else
332-
* alert(data);
333-
* }
334320
*/
335321
TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
336322
var debug = false,
@@ -645,8 +631,8 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
645631
return null;
646632
}
647633

648-
var chrome = /^\s*at (?:((?:\[object object\])?\S+(?: \[as \S+\])?) )?\(?((?:file|https?|chrome-extension):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
649-
gecko = /^\s*(\S*)(?:\((.*?)\))?@((?:file|https?|chrome).*?):(\d+)(?::(\d+))?\s*$/i,
634+
var chrome = /^\s*at (.*?) ?\(?((?:file|https?|chrome-extension):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
635+
gecko = /^\s*(.*?)(?:\((.*?)\))?@((?:file|https?|chrome).*?):(\d+)(?::(\d+))?\s*$/i,
650636
lines = ex.stack.split('\n'),
651637
stack = [],
652638
parts,
@@ -1063,24 +1049,10 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
10631049
return {};
10641050
}
10651051

1066-
/**
1067-
* Logs a stacktrace starting from the previous call and working down.
1068-
* @param {(number|string)=} depth How many frames deep to trace.
1069-
* @return {Object.<string, *>} Stack trace information.
1070-
*/
1071-
function computeStackTraceOfCaller(depth) {
1072-
depth = (depth == null ? 0 : +depth) + 1; // "+ 1" because "ofCaller" should drop one frame
1073-
try {
1074-
throw new Error();
1075-
} catch (ex) {
1076-
return computeStackTrace(ex, depth + 1);
1077-
}
1078-
}
1079-
10801052
computeStackTrace.augmentStackTraceWithInitialElement = augmentStackTraceWithInitialElement;
1053+
computeStackTrace.computeStackTraceFromStackProp = computeStackTraceFromStackProp;
10811054
computeStackTrace.guessFunctionName = guessFunctionName;
10821055
computeStackTrace.gatherContext = gatherContext;
1083-
computeStackTrace.ofCaller = computeStackTraceOfCaller;
10841056

10851057
return computeStackTrace;
10861058
}());
@@ -1091,7 +1063,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
10911063
// If there is no JSON, we no-op the core features of Raven
10921064
// since JSON is required to encode the payload
10931065
var _Raven = window.Raven,
1094-
hasJSON = !!(window.JSON && window.JSON.stringify),
1066+
hasJSON = !!(typeof JSON === 'object' && JSON.stringify),
10951067
lastCapturedException,
10961068
lastEventId,
10971069
globalServer,
@@ -1106,18 +1078,22 @@ var _Raven = window.Raven,
11061078
includePaths: [],
11071079
collectWindowErrors: true,
11081080
tags: {},
1081+
maxMessageLength: 100,
11091082
extra: {}
11101083
},
11111084
authQueryString,
1112-
isRavenInstalled = false;
1085+
isRavenInstalled = false,
1086+
1087+
objectPrototype = Object.prototype,
1088+
startTime = now();
11131089

11141090
/*
11151091
* The core Raven singleton
11161092
*
11171093
* @this {Raven}
11181094
*/
11191095
var Raven = {
1120-
VERSION: '1.1.16',
1096+
VERSION: '1.1.17',
11211097

11221098
debug: true,
11231099

@@ -1159,12 +1135,8 @@ var Raven = {
11591135

11601136
// "Script error." is hard coded into browsers for errors that it can't read.
11611137
// this is the result of a script being pulled in from an external domain and CORS.
1162-
globalOptions.ignoreErrors.push('Script error.');
1163-
globalOptions.ignoreErrors.push('Script error');
1164-
1165-
// Other variants of external script errors:
1166-
globalOptions.ignoreErrors.push('Javascript error: Script error on line 0');
1167-
globalOptions.ignoreErrors.push('Javascript error: Script error. on line 0');
1138+
globalOptions.ignoreErrors.push(/^Script error\.?$/);
1139+
globalOptions.ignoreErrors.push(/^Javascript error: Script error\.? on line 0$/);
11681140

11691141
// join regexp rules into one big rule
11701142
globalOptions.ignoreErrors = joinRegExp(globalOptions.ignoreErrors);
@@ -1319,7 +1291,7 @@ var Raven = {
13191291
*/
13201292
captureException: function(ex, options) {
13211293
// If not an Error is passed through, recall as a message instead
1322-
if (!(ex instanceof Error)) return Raven.captureMessage(ex, options);
1294+
if (!isError(ex)) return Raven.captureMessage(ex, options);
13231295

13241296
// Store the raw exception object for potential debugging and introspection
13251297
lastCapturedException = ex;
@@ -1348,6 +1320,13 @@ var Raven = {
13481320
* @return {Raven}
13491321
*/
13501322
captureMessage: function(msg, options) {
1323+
// config() automagically converts ignoreErrors from a list to a RegExp so we need to test for an
1324+
// early call; we'll error on the side of logging anything called before configuration since it's
1325+
// probably something you should see:
1326+
if (!!globalOptions.ignoreErrors.test && globalOptions.ignoreErrors.test(msg)) {
1327+
return;
1328+
}
1329+
13511330
// Fire away!
13521331
send(
13531332
objectMerge({
@@ -1365,9 +1344,9 @@ var Raven = {
13651344
* @return {Raven}
13661345
*/
13671346
setUserContext: function(user) {
1368-
globalUser = user;
1347+
globalUser = user;
13691348

1370-
return Raven;
1349+
return Raven;
13711350
},
13721351

13731352
/*
@@ -1377,9 +1356,9 @@ var Raven = {
13771356
* @return {Raven}
13781357
*/
13791358
setExtraContext: function(extra) {
1380-
globalOptions.extra = extra || {};
1359+
globalOptions.extra = extra || {};
13811360

1382-
return Raven;
1361+
return Raven;
13831362
},
13841363

13851364
/*
@@ -1389,9 +1368,21 @@ var Raven = {
13891368
* @return {Raven}
13901369
*/
13911370
setTagsContext: function(tags) {
1392-
globalOptions.tags = tags || {};
1371+
globalOptions.tags = tags || {};
13931372

1394-
return Raven;
1373+
return Raven;
1374+
},
1375+
1376+
/*
1377+
* Set release version of application
1378+
*
1379+
* @param {string} release Typically something like a git SHA to identify version
1380+
* @return {Raven}
1381+
*/
1382+
setReleaseContext: function(release) {
1383+
globalOptions.release = release;
1384+
1385+
return Raven;
13951386
},
13961387

13971388
/*
@@ -1410,6 +1401,15 @@ var Raven = {
14101401
*/
14111402
lastEventId: function() {
14121403
return lastEventId;
1404+
},
1405+
1406+
/*
1407+
* Determine if Raven is setup and ready to go.
1408+
*
1409+
* @return {boolean}
1410+
*/
1411+
isSetup: function() {
1412+
return isSetup();
14131413
}
14141414
};
14151415

@@ -1486,11 +1486,23 @@ function isString(what) {
14861486
return typeof what === 'string';
14871487
}
14881488

1489+
function isObject(what) {
1490+
return typeof what === 'object' && what !== null;
1491+
}
1492+
14891493
function isEmptyObject(what) {
14901494
for (var k in what) return false;
14911495
return true;
14921496
}
14931497

1498+
// Sorta yanked from https://github.com/joyent/node/blob/aa3b4b4/lib/util.js#L560
1499+
// with some tiny modifications
1500+
function isError(what) {
1501+
return isObject(what) &&
1502+
objectPrototype.toString.call(what) === '[object Error]' ||
1503+
what instanceof Error;
1504+
}
1505+
14941506
/**
14951507
* hasKey, a better form of hasOwnProperty
14961508
* Example: hasKey(MainHostObject, property) === true/false
@@ -1499,7 +1511,7 @@ function isEmptyObject(what) {
14991511
* @param {string} key to check
15001512
*/
15011513
function hasKey(object, key) {
1502-
return Object.prototype.hasOwnProperty.call(object, key);
1514+
return objectPrototype.hasOwnProperty.call(object, key);
15031515
}
15041516

15051517
function each(obj, callback) {
@@ -1658,7 +1670,7 @@ function processException(type, message, fileurl, lineno, frames, options) {
16581670
}
16591671

16601672
// Truncate the message to a max of characters
1661-
message = truncate(message, 100);
1673+
message = truncate(message, globalOptions.maxMessageLength);
16621674

16631675
if (globalOptions.ignoreUrls && globalOptions.ignoreUrls.test(fileurl)) return;
16641676
if (globalOptions.whitelistUrls && !globalOptions.whitelistUrls.test(fileurl)) return;
@@ -1695,6 +1707,10 @@ function truncate(str, max) {
16951707
return str.length <= max ? str : str.substr(0, max) + '\u2026';
16961708
}
16971709

1710+
function now() {
1711+
return +new Date();
1712+
}
1713+
16981714
function getHttpData() {
16991715
var http = {
17001716
url: document.location.href,
@@ -1716,25 +1732,31 @@ function send(data) {
17161732
data = objectMerge({
17171733
project: globalProject,
17181734
logger: globalOptions.logger,
1719-
site: globalOptions.site,
17201735
platform: 'javascript',
17211736
// sentry.interfaces.Http
17221737
request: getHttpData()
17231738
}, data);
17241739

17251740
// Merge in the tags and extra separately since objectMerge doesn't handle a deep merge
1726-
data.tags = objectMerge(globalOptions.tags, data.tags);
1727-
data.extra = objectMerge(globalOptions.extra, data.extra);
1741+
data.tags = objectMerge(objectMerge({}, globalOptions.tags), data.tags);
1742+
data.extra = objectMerge(objectMerge({}, globalOptions.extra), data.extra);
1743+
1744+
// Send along our own collected metadata with extra
1745+
data.extra = objectMerge({
1746+
'session:duration': now() - startTime,
1747+
}, data.extra);
17281748

17291749
// If there are no tags/extra, strip the key from the payload alltogther.
17301750
if (isEmptyObject(data.tags)) delete data.tags;
1731-
if (isEmptyObject(data.extra)) delete data.extra;
17321751

17331752
if (globalUser) {
17341753
// sentry.interfaces.User
17351754
data.user = globalUser;
17361755
}
17371756

1757+
// Include the release iff it's defined in globalOptions
1758+
if (globalOptions.release) data.release = globalOptions.release;
1759+
17381760
if (isFunction(globalOptions.dataCallback)) {
17391761
data = globalOptions.dataCallback(data);
17401762
}
@@ -1757,6 +1779,7 @@ function makeRequest(data) {
17571779
var img = new Image(),
17581780
src = globalServer + authQueryString + '&sentry_data=' + encodeURIComponent(JSON.stringify(data));
17591781

1782+
img.crossOrigin = 'anonymous';
17601783
img.onload = function success() {
17611784
triggerEvent('success', {
17621785
data: data,
@@ -1828,11 +1851,21 @@ function afterLoad() {
18281851
afterLoad();
18291852

18301853
// Expose Raven to the world
1831-
window.Raven = Raven;
1832-
1833-
// AMD
18341854
if (typeof define === 'function' && define.amd) {
1835-
define('raven', [], function() { return Raven; });
1855+
// AMD
1856+
window.Raven = Raven;
1857+
define('raven', [], function() {
1858+
return Raven;
1859+
});
1860+
} else if (typeof module === 'object') {
1861+
// browserify
1862+
module.exports = Raven;
1863+
} else if (typeof exports === 'object') {
1864+
// CommonJS
1865+
exports = Raven;
1866+
} else {
1867+
// Everything else
1868+
window.Raven = Raven;
18361869
}
18371870

1838-
})(this);
1871+
})(window);

0 commit comments

Comments
 (0)