1
- /*! Raven.js 1.1.16 (463f68f ) | github.com/getsentry/raven-js */
1
+ /*! Raven.js 1.1.17 (aa35178 ) | github.com/getsentry/raven-js */
2
2
3
3
/*
4
4
* Includes TraceKit
5
5
* https://github.com/getsentry/TraceKit
6
6
*
7
- * Copyright 2014 Matt Robenolt and other contributors
7
+ * Copyright 2015 Matt Robenolt and other contributors
8
8
* Released under the BSD license
9
9
* https://github.com/getsentry/raven-js/blob/master/LICENSE
10
10
*
@@ -270,7 +270,6 @@ TraceKit.report = (function reportModuleWrapper() {
270
270
* TraceKit.computeStackTrace: cross-browser stack traces in JavaScript
271
271
*
272
272
* Syntax:
273
- * s = TraceKit.computeStackTrace.ofCaller([depth])
274
273
* s = TraceKit.computeStackTrace(exception) // consider using TraceKit.report instead (see below)
275
274
* Returns:
276
275
* s.name - exception name
@@ -318,19 +317,6 @@ TraceKit.report = (function reportModuleWrapper() {
318
317
* exceptions (because your catch block will likely be far away from the
319
318
* inner function that actually caused the exception).
320
319
*
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
- * }
334
320
*/
335
321
TraceKit . computeStackTrace = ( function computeStackTraceWrapper ( ) {
336
322
var debug = false ,
@@ -645,8 +631,8 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
645
631
return null ;
646
632
}
647
633
648
- var chrome = / ^ \s * a t (?: ( (?: \[ o b j e c t o b j e c t \] ) ? \S + (?: \[ a s \S + \] ) ? ) ) ? \( ? ( (?: f i l e | h t t p s ? | c h r o m e - e x t e n s i o n ) : .* ?) : ( \d + ) (?: : ( \d + ) ) ? \) ? \s * $ / i,
649
- gecko = / ^ \s * ( \S * ) (?: \( ( .* ?) \) ) ? @ ( (?: f i l e | h t t p s ? | c h r o m e ) .* ?) : ( \d + ) (?: : ( \d + ) ) ? \s * $ / i,
634
+ var chrome = / ^ \s * a t ( . * ? ) ? \( ? ( (?: f i l e | h t t p s ? | c h r o m e - e x t e n s i o n ) : .* ?) : ( \d + ) (?: : ( \d + ) ) ? \) ? \s * $ / i,
635
+ gecko = / ^ \s * ( . * ? ) (?: \( ( .* ?) \) ) ? @ ( (?: f i l e | h t t p s ? | c h r o m e ) .* ?) : ( \d + ) (?: : ( \d + ) ) ? \s * $ / i,
650
636
lines = ex . stack . split ( '\n' ) ,
651
637
stack = [ ] ,
652
638
parts ,
@@ -1063,24 +1049,10 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1063
1049
return { } ;
1064
1050
}
1065
1051
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
-
1080
1052
computeStackTrace . augmentStackTraceWithInitialElement = augmentStackTraceWithInitialElement ;
1053
+ computeStackTrace . computeStackTraceFromStackProp = computeStackTraceFromStackProp ;
1081
1054
computeStackTrace . guessFunctionName = guessFunctionName ;
1082
1055
computeStackTrace . gatherContext = gatherContext ;
1083
- computeStackTrace . ofCaller = computeStackTraceOfCaller ;
1084
1056
1085
1057
return computeStackTrace ;
1086
1058
} ( ) ) ;
@@ -1091,7 +1063,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1091
1063
// If there is no JSON, we no-op the core features of Raven
1092
1064
// since JSON is required to encode the payload
1093
1065
var _Raven = window . Raven ,
1094
- hasJSON = ! ! ( window . JSON && window . JSON . stringify ) ,
1066
+ hasJSON = ! ! ( typeof JSON === 'object' && JSON . stringify ) ,
1095
1067
lastCapturedException ,
1096
1068
lastEventId ,
1097
1069
globalServer ,
@@ -1106,18 +1078,22 @@ var _Raven = window.Raven,
1106
1078
includePaths : [ ] ,
1107
1079
collectWindowErrors : true ,
1108
1080
tags : { } ,
1081
+ maxMessageLength : 100 ,
1109
1082
extra : { }
1110
1083
} ,
1111
1084
authQueryString ,
1112
- isRavenInstalled = false ;
1085
+ isRavenInstalled = false ,
1086
+
1087
+ objectPrototype = Object . prototype ,
1088
+ startTime = now ( ) ;
1113
1089
1114
1090
/*
1115
1091
* The core Raven singleton
1116
1092
*
1117
1093
* @this {Raven}
1118
1094
*/
1119
1095
var Raven = {
1120
- VERSION : '1.1.16 ' ,
1096
+ VERSION : '1.1.17 ' ,
1121
1097
1122
1098
debug : true ,
1123
1099
@@ -1159,12 +1135,8 @@ var Raven = {
1159
1135
1160
1136
// "Script error." is hard coded into browsers for errors that it can't read.
1161
1137
// 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 ( / ^ S c r i p t e r r o r \. ? $ / ) ;
1139
+ globalOptions . ignoreErrors . push ( / ^ J a v a s c r i p t e r r o r : S c r i p t e r r o r \. ? o n l i n e 0 $ / ) ;
1168
1140
1169
1141
// join regexp rules into one big rule
1170
1142
globalOptions . ignoreErrors = joinRegExp ( globalOptions . ignoreErrors ) ;
@@ -1319,7 +1291,7 @@ var Raven = {
1319
1291
*/
1320
1292
captureException : function ( ex , options ) {
1321
1293
// 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 ) ;
1323
1295
1324
1296
// Store the raw exception object for potential debugging and introspection
1325
1297
lastCapturedException = ex ;
@@ -1348,6 +1320,13 @@ var Raven = {
1348
1320
* @return {Raven }
1349
1321
*/
1350
1322
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
+
1351
1330
// Fire away!
1352
1331
send (
1353
1332
objectMerge ( {
@@ -1365,9 +1344,9 @@ var Raven = {
1365
1344
* @return {Raven }
1366
1345
*/
1367
1346
setUserContext : function ( user ) {
1368
- globalUser = user ;
1347
+ globalUser = user ;
1369
1348
1370
- return Raven ;
1349
+ return Raven ;
1371
1350
} ,
1372
1351
1373
1352
/*
@@ -1377,9 +1356,9 @@ var Raven = {
1377
1356
* @return {Raven }
1378
1357
*/
1379
1358
setExtraContext : function ( extra ) {
1380
- globalOptions . extra = extra || { } ;
1359
+ globalOptions . extra = extra || { } ;
1381
1360
1382
- return Raven ;
1361
+ return Raven ;
1383
1362
} ,
1384
1363
1385
1364
/*
@@ -1389,9 +1368,21 @@ var Raven = {
1389
1368
* @return {Raven }
1390
1369
*/
1391
1370
setTagsContext : function ( tags ) {
1392
- globalOptions . tags = tags || { } ;
1371
+ globalOptions . tags = tags || { } ;
1393
1372
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 ;
1395
1386
} ,
1396
1387
1397
1388
/*
@@ -1410,6 +1401,15 @@ var Raven = {
1410
1401
*/
1411
1402
lastEventId : function ( ) {
1412
1403
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 ( ) ;
1413
1413
}
1414
1414
} ;
1415
1415
@@ -1486,11 +1486,23 @@ function isString(what) {
1486
1486
return typeof what === 'string' ;
1487
1487
}
1488
1488
1489
+ function isObject ( what ) {
1490
+ return typeof what === 'object' && what !== null ;
1491
+ }
1492
+
1489
1493
function isEmptyObject ( what ) {
1490
1494
for ( var k in what ) return false ;
1491
1495
return true ;
1492
1496
}
1493
1497
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
+
1494
1506
/**
1495
1507
* hasKey, a better form of hasOwnProperty
1496
1508
* Example: hasKey(MainHostObject, property) === true/false
@@ -1499,7 +1511,7 @@ function isEmptyObject(what) {
1499
1511
* @param {string } key to check
1500
1512
*/
1501
1513
function hasKey ( object , key ) {
1502
- return Object . prototype . hasOwnProperty . call ( object , key ) ;
1514
+ return objectPrototype . hasOwnProperty . call ( object , key ) ;
1503
1515
}
1504
1516
1505
1517
function each ( obj , callback ) {
@@ -1658,7 +1670,7 @@ function processException(type, message, fileurl, lineno, frames, options) {
1658
1670
}
1659
1671
1660
1672
// Truncate the message to a max of characters
1661
- message = truncate ( message , 100 ) ;
1673
+ message = truncate ( message , globalOptions . maxMessageLength ) ;
1662
1674
1663
1675
if ( globalOptions . ignoreUrls && globalOptions . ignoreUrls . test ( fileurl ) ) return ;
1664
1676
if ( globalOptions . whitelistUrls && ! globalOptions . whitelistUrls . test ( fileurl ) ) return ;
@@ -1695,6 +1707,10 @@ function truncate(str, max) {
1695
1707
return str . length <= max ? str : str . substr ( 0 , max ) + '\u2026' ;
1696
1708
}
1697
1709
1710
+ function now ( ) {
1711
+ return + new Date ( ) ;
1712
+ }
1713
+
1698
1714
function getHttpData ( ) {
1699
1715
var http = {
1700
1716
url : document . location . href ,
@@ -1716,25 +1732,31 @@ function send(data) {
1716
1732
data = objectMerge ( {
1717
1733
project : globalProject ,
1718
1734
logger : globalOptions . logger ,
1719
- site : globalOptions . site ,
1720
1735
platform : 'javascript' ,
1721
1736
// sentry.interfaces.Http
1722
1737
request : getHttpData ( )
1723
1738
} , data ) ;
1724
1739
1725
1740
// 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 ) ;
1728
1748
1729
1749
// If there are no tags/extra, strip the key from the payload alltogther.
1730
1750
if ( isEmptyObject ( data . tags ) ) delete data . tags ;
1731
- if ( isEmptyObject ( data . extra ) ) delete data . extra ;
1732
1751
1733
1752
if ( globalUser ) {
1734
1753
// sentry.interfaces.User
1735
1754
data . user = globalUser ;
1736
1755
}
1737
1756
1757
+ // Include the release iff it's defined in globalOptions
1758
+ if ( globalOptions . release ) data . release = globalOptions . release ;
1759
+
1738
1760
if ( isFunction ( globalOptions . dataCallback ) ) {
1739
1761
data = globalOptions . dataCallback ( data ) ;
1740
1762
}
@@ -1757,6 +1779,7 @@ function makeRequest(data) {
1757
1779
var img = new Image ( ) ,
1758
1780
src = globalServer + authQueryString + '&sentry_data=' + encodeURIComponent ( JSON . stringify ( data ) ) ;
1759
1781
1782
+ img . crossOrigin = 'anonymous' ;
1760
1783
img . onload = function success ( ) {
1761
1784
triggerEvent ( 'success' , {
1762
1785
data : data ,
@@ -1828,11 +1851,21 @@ function afterLoad() {
1828
1851
afterLoad ( ) ;
1829
1852
1830
1853
// Expose Raven to the world
1831
- window . Raven = Raven ;
1832
-
1833
- // AMD
1834
1854
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 ;
1836
1869
}
1837
1870
1838
- } ) ( this ) ;
1871
+ } ) ( window ) ;
0 commit comments