dist.bundle.js 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447
  1. /******/ (function(modules) {
  2. // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {}; // The require function
  5. /******/
  6. /******/ /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if (installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/
  12. } // Create a new module (and put it into the cache)
  13. /******/ /******/ var module = (installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {},
  17. /******/
  18. }); // Execute the module function
  19. /******/
  20. /******/ /******/ modules[moduleId].call(
  21. module.exports,
  22. module,
  23. module.exports,
  24. __webpack_require__
  25. ); // Flag the module as loaded
  26. /******/
  27. /******/ /******/ module.l = true; // Return the exports of the module
  28. /******/
  29. /******/ /******/ return module.exports;
  30. /******/
  31. } // expose the modules object (__webpack_modules__)
  32. /******/
  33. /******/
  34. /******/ /******/ __webpack_require__.m = modules; // expose the module cache
  35. /******/
  36. /******/ /******/ __webpack_require__.c = installedModules; // define getter function for harmony exports
  37. /******/
  38. /******/ /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if (!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, {
  41. /******/ configurable: false,
  42. /******/ enumerable: true,
  43. /******/ get: getter,
  44. /******/
  45. });
  46. /******/
  47. }
  48. /******/
  49. }; // getDefaultExport function for compatibility with non-harmony modules
  50. /******/
  51. /******/ /******/ __webpack_require__.n = function(module) {
  52. /******/ var getter =
  53. module && module.__esModule
  54. ? /******/ function getDefault() {
  55. return module['default'];
  56. }
  57. : /******/ function getModuleExports() {
  58. return module;
  59. };
  60. /******/ __webpack_require__.d(getter, 'a', getter);
  61. /******/ return getter;
  62. /******/
  63. }; // Object.prototype.hasOwnProperty.call
  64. /******/
  65. /******/ /******/ __webpack_require__.o = function(object, property) {
  66. return Object.prototype.hasOwnProperty.call(object, property);
  67. }; // __webpack_public_path__
  68. /******/
  69. /******/ /******/ __webpack_require__.p = ''; // Load entry module and return exports
  70. /******/
  71. /******/ /******/ return __webpack_require__((__webpack_require__.s = 15));
  72. /******/
  73. })(
  74. /************************************************************************/
  75. /******/ [
  76. /* 0 */
  77. /***/ function(module, exports, __webpack_require__) {
  78. 'use strict';
  79. var fs = __webpack_require__(8);
  80. var url = __webpack_require__(7);
  81. var transports = __webpack_require__(3);
  82. var path = __webpack_require__(2);
  83. var lsmod = __webpack_require__(21);
  84. var stacktrace = __webpack_require__(22);
  85. var ravenVersion = __webpack_require__(11).version;
  86. var protocolMap = {
  87. http: 80,
  88. https: 443,
  89. };
  90. var consoleAlerts = {};
  91. module.exports.disableConsoleAlerts = function disableConsoleAlerts() {
  92. consoleAlerts = false;
  93. };
  94. module.exports.consoleAlert = function consoleAlert(msg) {
  95. if (consoleAlerts) {
  96. console.log('raven@' + ravenVersion + ' alert: ' + msg);
  97. }
  98. };
  99. module.exports.consoleAlertOnce = function consoleAlertOnce(msg) {
  100. if (consoleAlerts && !(msg in consoleAlerts)) {
  101. consoleAlerts[msg] = true;
  102. console.log('raven@' + ravenVersion + ' alert: ' + msg);
  103. }
  104. };
  105. module.exports.extend =
  106. Object.assign ||
  107. function(target) {
  108. for (var i = 1; i < arguments.length; i++) {
  109. var source = arguments[i];
  110. for (var key in source) {
  111. if (Object.prototype.hasOwnProperty.call(source, key)) {
  112. target[key] = source[key];
  113. }
  114. }
  115. }
  116. return target;
  117. };
  118. module.exports.getAuthHeader = function getAuthHeader(
  119. timestamp,
  120. apiKey,
  121. apiSecret
  122. ) {
  123. var header = ['Sentry sentry_version=5'];
  124. header.push('sentry_timestamp=' + timestamp);
  125. header.push('sentry_client=raven-node/' + ravenVersion);
  126. header.push('sentry_key=' + apiKey);
  127. if (apiSecret) header.push('sentry_secret=' + apiSecret);
  128. return header.join(', ');
  129. };
  130. module.exports.parseDSN = function parseDSN(dsn) {
  131. if (!dsn) {
  132. // Let a falsey value return false explicitly
  133. return false;
  134. }
  135. try {
  136. var parsed = url.parse(dsn),
  137. response = {
  138. protocol: parsed.protocol.slice(0, -1),
  139. public_key: parsed.auth.split(':')[0],
  140. host: parsed.host.split(':')[0],
  141. };
  142. if (parsed.auth.split(':')[1]) {
  143. response.private_key = parsed.auth.split(':')[1];
  144. }
  145. if (~response.protocol.indexOf('+')) {
  146. response.protocol = response.protocol.split('+')[1];
  147. }
  148. if (!transports.hasOwnProperty(response.protocol)) {
  149. throw new Error('Invalid transport');
  150. }
  151. var index = parsed.pathname.lastIndexOf('/');
  152. response.path = parsed.pathname.substr(0, index + 1);
  153. response.project_id = parsed.pathname.substr(index + 1);
  154. response.port = ~~parsed.port || protocolMap[response.protocol] || 443;
  155. return response;
  156. } catch (e) {
  157. throw new Error('Invalid Sentry DSN: ' + dsn);
  158. }
  159. };
  160. module.exports.getCulprit = function getCulprit(frame) {
  161. if (frame.module || frame.function) {
  162. return (frame.module || '?') + ' at ' + (frame.function || '?');
  163. }
  164. return '<unknown>';
  165. };
  166. var moduleCache;
  167. module.exports.getModules = function getModules() {
  168. if (!moduleCache) {
  169. moduleCache = lsmod();
  170. }
  171. return moduleCache;
  172. };
  173. module.exports.fill = function(obj, name, replacement, track) {
  174. var orig = obj[name];
  175. obj[name] = replacement(orig);
  176. if (track) {
  177. track.push([obj, name, orig]);
  178. }
  179. };
  180. var LINES_OF_CONTEXT = 7;
  181. function getFunction(line) {
  182. try {
  183. return (
  184. line.getFunctionName() ||
  185. line.getTypeName() + '.' + (line.getMethodName() || '<anonymous>')
  186. );
  187. } catch (e) {
  188. // This seems to happen sometimes when using 'use strict',
  189. // stemming from `getTypeName`.
  190. // [TypeError: Cannot read property 'constructor' of undefined]
  191. return '<anonymous>';
  192. }
  193. }
  194. var mainModule =
  195. ((__webpack_require__.c[__webpack_require__.s] &&
  196. __webpack_require__.c[__webpack_require__.s].filename &&
  197. path.dirname(__webpack_require__.c[__webpack_require__.s].filename)) ||
  198. process.cwd()) + '/';
  199. function getModule(filename, base) {
  200. if (!base) base = mainModule;
  201. // It's specifically a module
  202. var file = path.basename(filename, '.js');
  203. filename = path.dirname(filename);
  204. var n = filename.lastIndexOf('/node_modules/');
  205. if (n > -1) {
  206. // /node_modules/ is 14 chars
  207. return filename.substr(n + 14).replace(/\//g, '.') + ':' + file;
  208. }
  209. // Let's see if it's a part of the main module
  210. // To be a part of main module, it has to share the same base
  211. n = (filename + '/').lastIndexOf(base, 0);
  212. if (n === 0) {
  213. var module = filename.substr(base.length).replace(/\//g, '.');
  214. if (module) module += ':';
  215. module += file;
  216. return module;
  217. }
  218. return file;
  219. }
  220. function readSourceFiles(filenames, cb) {
  221. // we're relying on filenames being de-duped already
  222. if (filenames.length === 0) return setTimeout(cb, 0, {});
  223. var sourceFiles = {};
  224. var numFilesToRead = filenames.length;
  225. return filenames.forEach(function(filename) {
  226. fs.readFile(filename, function(readErr, file) {
  227. if (!readErr) sourceFiles[filename] = file.toString().split('\n');
  228. if (--numFilesToRead === 0) cb(sourceFiles);
  229. });
  230. });
  231. }
  232. // This is basically just `trim_line` from https://github.com/getsentry/sentry/blob/master/src/sentry/lang/javascript/processor.py#L67
  233. function snipLine(line, colno) {
  234. var ll = line.length;
  235. if (ll <= 150) return line;
  236. if (colno > ll) colno = ll;
  237. var start = Math.max(colno - 60, 0);
  238. if (start < 5) start = 0;
  239. var end = Math.min(start + 140, ll);
  240. if (end > ll - 5) end = ll;
  241. if (end === ll) start = Math.max(end - 140, 0);
  242. line = line.slice(start, end);
  243. if (start > 0) line = '{snip} ' + line;
  244. if (end < ll) line += ' {snip}';
  245. return line;
  246. }
  247. function snipLine0(line) {
  248. return snipLine(line, 0);
  249. }
  250. function parseStack(err, cb) {
  251. if (!err) return cb([]);
  252. var stack = stacktrace.parse(err);
  253. if (!stack || !Array.isArray(stack) || !stack.length || !stack[0].getFileName) {
  254. // the stack is not the useful thing we were expecting :/
  255. return cb([]);
  256. }
  257. // Sentry expects the stack trace to be oldest -> newest, v8 provides newest -> oldest
  258. stack.reverse();
  259. var frames = [];
  260. var filesToRead = {};
  261. stack.forEach(function(line) {
  262. var frame = {
  263. filename: line.getFileName() || '',
  264. lineno: line.getLineNumber(),
  265. colno: line.getColumnNumber(),
  266. function: getFunction(line),
  267. };
  268. var isInternal =
  269. line.isNative() ||
  270. (frame.filename[0] !== '/' &&
  271. frame.filename[0] !== '.' &&
  272. frame.filename.indexOf(':\\') !== 1);
  273. // in_app is all that's not an internal Node function or a module within node_modules
  274. // note that isNative appears to return true even for node core libraries
  275. // see https://github.com/getsentry/raven-node/issues/176
  276. frame.in_app = !isInternal && frame.filename.indexOf('node_modules/') === -1;
  277. // Extract a module name based on the filename
  278. if (frame.filename) {
  279. frame.module = getModule(frame.filename);
  280. if (!isInternal) filesToRead[frame.filename] = true;
  281. }
  282. frames.push(frame);
  283. });
  284. return readSourceFiles(Object.keys(filesToRead), function(sourceFiles) {
  285. frames.forEach(function(frame) {
  286. if (frame.filename && sourceFiles[frame.filename]) {
  287. var lines = sourceFiles[frame.filename];
  288. try {
  289. frame.pre_context = lines
  290. .slice(
  291. Math.max(0, frame.lineno - (LINES_OF_CONTEXT + 1)),
  292. frame.lineno - 1
  293. )
  294. .map(snipLine0);
  295. frame.context_line = snipLine(lines[frame.lineno - 1], frame.colno);
  296. frame.post_context = lines
  297. .slice(frame.lineno, frame.lineno + LINES_OF_CONTEXT)
  298. .map(snipLine0);
  299. } catch (e) {
  300. // anomaly, being defensive in case
  301. // unlikely to ever happen in practice but can definitely happen in theory
  302. }
  303. }
  304. });
  305. cb(frames);
  306. });
  307. }
  308. // expose basically for testing because I don't know what I'm doing
  309. module.exports.parseStack = parseStack;
  310. module.exports.getModule = getModule;
  311. /***/
  312. },
  313. /* 1 */
  314. /***/ function(module, exports) {
  315. module.exports = require('util');
  316. /***/
  317. },
  318. /* 2 */
  319. /***/ function(module, exports) {
  320. module.exports = require('path');
  321. /***/
  322. },
  323. /* 3 */
  324. /***/ function(module, exports, __webpack_require__) {
  325. 'use strict';
  326. var events = __webpack_require__(9);
  327. var util = __webpack_require__(1);
  328. var timeoutReq = __webpack_require__(19);
  329. var http = __webpack_require__(10);
  330. var https = __webpack_require__(20);
  331. var agentOptions = {keepAlive: true, maxSockets: 100};
  332. var httpAgent = new http.Agent(agentOptions);
  333. var httpsAgent = new https.Agent(agentOptions);
  334. function Transport() {}
  335. util.inherits(Transport, events.EventEmitter);
  336. function HTTPTransport(options) {
  337. this.defaultPort = 80;
  338. this.transport = http;
  339. this.options = options || {};
  340. this.agent = httpAgent;
  341. }
  342. util.inherits(HTTPTransport, Transport);
  343. HTTPTransport.prototype.send = function(client, message, headers, eventId, cb) {
  344. var options = {
  345. hostname: client.dsn.host,
  346. path: client.dsn.path + 'api/' + client.dsn.project_id + '/store/',
  347. headers: headers,
  348. method: 'POST',
  349. port: client.dsn.port || this.defaultPort,
  350. ca: client.ca,
  351. agent: this.agent,
  352. };
  353. for (var key in this.options) {
  354. if (this.options.hasOwnProperty(key)) {
  355. options[key] = this.options[key];
  356. }
  357. }
  358. // prevent off heap memory explosion
  359. var _name = this.agent.getName({host: client.dsn.host, port: client.dsn.port});
  360. var _requests = this.agent.requests[_name];
  361. if (_requests && Object.keys(_requests).length > client.maxReqQueueCount) {
  362. // other feedback strategy
  363. client.emit('error', new Error('client req queue is full..'));
  364. return;
  365. }
  366. var req = this.transport.request(options, function(res) {
  367. res.setEncoding('utf8');
  368. if (res.statusCode >= 200 && res.statusCode < 300) {
  369. client.emit('logged', eventId);
  370. cb && cb(null, eventId);
  371. } else {
  372. var reason = res.headers['x-sentry-error'];
  373. var e = new Error('HTTP Error (' + res.statusCode + '): ' + reason);
  374. e.response = res;
  375. e.statusCode = res.statusCode;
  376. e.reason = reason;
  377. e.sendMessage = message;
  378. e.requestHeaders = headers;
  379. e.eventId = eventId;
  380. client.emit('error', e);
  381. cb && cb(e);
  382. }
  383. // force the socket to drain
  384. var noop = function() {};
  385. res.on('data', noop);
  386. res.on('end', noop);
  387. });
  388. timeoutReq(req, client.sendTimeout * 1000);
  389. var cbFired = false;
  390. req.on('error', function(e) {
  391. client.emit('error', e);
  392. if (!cbFired) {
  393. cb && cb(e);
  394. cbFired = true;
  395. }
  396. });
  397. req.end(message);
  398. };
  399. function HTTPSTransport(options) {
  400. this.defaultPort = 443;
  401. this.transport = https;
  402. this.options = options || {};
  403. this.agent = httpsAgent;
  404. }
  405. util.inherits(HTTPSTransport, HTTPTransport);
  406. module.exports.http = new HTTPTransport();
  407. module.exports.https = new HTTPSTransport();
  408. module.exports.Transport = Transport;
  409. module.exports.HTTPTransport = HTTPTransport;
  410. module.exports.HTTPSTransport = HTTPSTransport;
  411. /***/
  412. },
  413. /* 4 */
  414. /***/ function(module, exports, __webpack_require__) {
  415. 'use strict';
  416. var utils = __webpack_require__(0);
  417. var defaultOnConfig = {
  418. console: true,
  419. };
  420. var defaultConfig = {
  421. console: false,
  422. http: false,
  423. pg: false,
  424. };
  425. function instrument(Raven, config) {
  426. if (config === false) {
  427. return;
  428. } else if (config === true) {
  429. config = defaultOnConfig;
  430. } else {
  431. config = utils.extend({}, defaultConfig, config);
  432. }
  433. Raven.instrumentedOriginals = [];
  434. Raven.instrumentedModules = [];
  435. var Module = __webpack_require__(28);
  436. utils.fill(
  437. Module,
  438. '_load',
  439. function(origLoad) {
  440. return function(moduleId, parent, isMain) {
  441. var origModule = origLoad.apply(this, arguments);
  442. if (
  443. config[moduleId] &&
  444. Raven.instrumentedModules.indexOf(moduleId) === -1
  445. ) {
  446. Raven.instrumentedModules.push(moduleId);
  447. return __webpack_require__(29)('./' + moduleId)(
  448. Raven,
  449. origModule,
  450. Raven.instrumentedOriginals
  451. );
  452. }
  453. return origModule;
  454. };
  455. },
  456. Raven.instrumentedOriginals
  457. );
  458. // special case: since console is built-in and app-level code won't require() it, do that here
  459. if (config.console) {
  460. __webpack_require__(30);
  461. }
  462. // observation: when the https module does its own require('http'), it *does not* hit our hooked require to instrument http on the fly
  463. // but if we've previously instrumented http, https *does* get our already-instrumented version
  464. // this is because raven's transports are required before this instrumentation takes place, which loads https (and http)
  465. // so module cache will have uninstrumented http; proactively loading it here ensures instrumented version is in module cache
  466. // alternatively we could refactor to load our transports later, but this is easier and doesn't have much drawback
  467. if (config.http) {
  468. __webpack_require__(10);
  469. }
  470. }
  471. function deinstrument(Raven) {
  472. if (!Raven.instrumentedOriginals) return;
  473. var original;
  474. // eslint-disable-next-line no-cond-assign
  475. while ((original = Raven.instrumentedOriginals.shift())) {
  476. var obj = original[0];
  477. var name = original[1];
  478. var orig = original[2];
  479. obj[name] = orig;
  480. }
  481. }
  482. module.exports = {
  483. instrument: instrument,
  484. deinstrument: deinstrument,
  485. };
  486. /***/
  487. },
  488. /* 5 */
  489. /***/ function(module, exports, __webpack_require__) {
  490. 'use strict';
  491. /*
  492. json-stringify-safe
  493. Like JSON.stringify, but doesn't throw on circular references.
  494. Originally forked from https://github.com/isaacs/json-stringify-safe
  495. version 5.0.1 on 2017-09-21 and modified to handle Errors serialization.
  496. Tests for this are in test/vendor.
  497. ISC license: https://github.com/isaacs/json-stringify-safe/blob/master/LICENSE
  498. */
  499. exports = module.exports = stringify;
  500. exports.getSerialize = serializer;
  501. function stringify(obj, replacer, spaces, cycleReplacer) {
  502. return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces);
  503. }
  504. // https://github.com/ftlabs/js-abbreviate/blob/fa709e5f139e7770a71827b1893f22418097fbda/index.js#L95-L106
  505. function stringifyError(value) {
  506. var err = {
  507. // These properties are implemented as magical getters and don't show up in for in
  508. stack: value.stack,
  509. message: value.message,
  510. name: value.name,
  511. };
  512. for (var i in value) {
  513. if (Object.prototype.hasOwnProperty.call(value, i)) {
  514. err[i] = value[i];
  515. }
  516. }
  517. return err;
  518. }
  519. function serializer(replacer, cycleReplacer) {
  520. var stack = [];
  521. var keys = [];
  522. if (cycleReplacer == null) {
  523. cycleReplacer = function(key, value) {
  524. if (stack[0] === value) {
  525. return '[Circular ~]';
  526. }
  527. return '[Circular ~.' + keys.slice(0, stack.indexOf(value)).join('.') + ']';
  528. };
  529. }
  530. return function(key, value) {
  531. if (stack.length > 0) {
  532. var thisPos = stack.indexOf(this);
  533. ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
  534. ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
  535. if (~stack.indexOf(value)) {
  536. value = cycleReplacer.call(this, key, value);
  537. }
  538. } else {
  539. stack.push(value);
  540. }
  541. return replacer == null
  542. ? value instanceof Error ? stringifyError(value) : value
  543. : replacer.call(this, key, value);
  544. };
  545. }
  546. /***/
  547. },
  548. /* 6 */
  549. /***/ function(module, exports, __webpack_require__) {
  550. 'use strict';
  551. var cookie = __webpack_require__(18);
  552. var urlParser = __webpack_require__(7);
  553. var stringify = __webpack_require__(5);
  554. var utils = __webpack_require__(0);
  555. module.exports.parseText = function parseText(message, kwargs) {
  556. kwargs = kwargs || {};
  557. kwargs.message = message;
  558. return kwargs;
  559. };
  560. module.exports.parseError = function parseError(err, kwargs, cb) {
  561. utils.parseStack(err, function(frames) {
  562. var name =
  563. ({}.hasOwnProperty.call(err, 'name') ? err.name : err.constructor.name) + '';
  564. if (typeof kwargs.message === 'undefined') {
  565. kwargs.message = name + ': ' + (err.message || '<no message>');
  566. }
  567. kwargs.exception = [
  568. {
  569. type: name,
  570. value: err.message,
  571. stacktrace: {
  572. frames: frames,
  573. },
  574. },
  575. ];
  576. // Save additional error properties to `extra` under the error type (e.g. `extra.AttributeError`)
  577. var extraErrorProps;
  578. for (var key in err) {
  579. if (err.hasOwnProperty(key)) {
  580. if (
  581. key !== 'name' &&
  582. key !== 'message' &&
  583. key !== 'stack' &&
  584. key !== 'domain'
  585. ) {
  586. extraErrorProps = extraErrorProps || {};
  587. extraErrorProps[key] = err[key];
  588. }
  589. }
  590. }
  591. if (extraErrorProps) {
  592. kwargs.extra = kwargs.extra || {};
  593. kwargs.extra[name] = extraErrorProps;
  594. }
  595. for (var n = frames.length - 1; n >= 0; n--) {
  596. if (frames[n].in_app) {
  597. kwargs.culprit = kwargs.culprit || utils.getCulprit(frames[n]);
  598. break;
  599. }
  600. }
  601. cb(kwargs);
  602. });
  603. };
  604. module.exports.parseRequest = function parseRequest(req, parseUser) {
  605. var kwargs = {};
  606. // headers:
  607. // node, express: req.headers
  608. // koa: req.header
  609. var headers = req.headers || req.header || {};
  610. // method:
  611. // node, express, koa: req.method
  612. var method = req.method;
  613. // host:
  614. // express: req.hostname in > 4 and req.host in < 4
  615. // koa: req.host
  616. // node: req.headers.host
  617. var host = req.hostname || req.host || headers.host || '<no host>';
  618. // protocol:
  619. // node: <n/a>
  620. // express, koa: req.protocol
  621. var protocol =
  622. req.protocol === 'https' || req.secure || (req.socket || {}).encrypted
  623. ? 'https'
  624. : 'http';
  625. // url (including path and query string):
  626. // node, express: req.originalUrl
  627. // koa: req.url
  628. var originalUrl = req.originalUrl || req.url;
  629. // absolute url
  630. var absoluteUrl = protocol + '://' + host + originalUrl;
  631. // query string:
  632. // node: req.url (raw)
  633. // express, koa: req.query
  634. var query = req.query || urlParser.parse(originalUrl || '', true).query;
  635. // cookies:
  636. // node, express, koa: req.headers.cookie
  637. var cookies = cookie.parse(headers.cookie || '');
  638. // body data:
  639. // node, express, koa: req.body
  640. var data = req.body;
  641. if (['GET', 'HEAD'].indexOf(method) === -1) {
  642. if (typeof data === 'undefined') {
  643. data = '<unavailable>';
  644. }
  645. }
  646. if (
  647. data &&
  648. typeof data !== 'string' &&
  649. {}.toString.call(data) !== '[object String]'
  650. ) {
  651. // Make sure the request body is a string
  652. data = stringify(data);
  653. }
  654. // http interface
  655. var http = {
  656. method: method,
  657. query_string: query,
  658. headers: headers,
  659. cookies: cookies,
  660. data: data,
  661. url: absoluteUrl,
  662. };
  663. // expose http interface
  664. kwargs.request = http;
  665. // user: typically found on req.user in express/passport patterns
  666. // five cases for parseUser value:
  667. // absent: grab only id, username, email from req.user
  668. // false: capture nothing
  669. // true: capture all keys from req.user
  670. // array: provided whitelisted keys to grab from req.user
  671. // function :: req -> user: custom parsing function
  672. if (parseUser == null) parseUser = ['id', 'username', 'email'];
  673. if (parseUser) {
  674. var user = {};
  675. if (typeof parseUser === 'function') {
  676. user = parseUser(req);
  677. } else if (req.user) {
  678. if (parseUser === true) {
  679. for (var key in req.user) {
  680. if ({}.hasOwnProperty.call(req.user, key)) {
  681. user[key] = req.user[key];
  682. }
  683. }
  684. } else {
  685. parseUser.forEach(function(fieldName) {
  686. if ({}.hasOwnProperty.call(req.user, fieldName)) {
  687. user[fieldName] = req.user[fieldName];
  688. }
  689. });
  690. }
  691. }
  692. // client ip:
  693. // node: req.connection.remoteAddress
  694. // express, koa: req.ip
  695. var ip = req.ip || (req.connection && req.connection.remoteAddress);
  696. if (ip) {
  697. user.ip_address = ip;
  698. }
  699. kwargs.user = user;
  700. }
  701. return kwargs;
  702. };
  703. /***/
  704. },
  705. /* 7 */
  706. /***/ function(module, exports) {
  707. module.exports = require('url');
  708. /***/
  709. },
  710. /* 8 */
  711. /***/ function(module, exports) {
  712. module.exports = require('fs');
  713. /***/
  714. },
  715. /* 9 */
  716. /***/ function(module, exports) {
  717. module.exports = require('events');
  718. /***/
  719. },
  720. /* 10 */
  721. /***/ function(module, exports) {
  722. module.exports = require('http');
  723. /***/
  724. },
  725. /* 11 */
  726. /***/ function(module, exports) {
  727. module.exports = {
  728. _from: 'raven@^2.2.1',
  729. _id: 'raven@2.2.1',
  730. _inBundle: false,
  731. _integrity: 'sha1-V8f75oqAFH7FJ97z18AVdc+Uj+M=',
  732. _location: '/raven',
  733. _phantomChildren: {},
  734. _requested: {
  735. type: 'range',
  736. registry: true,
  737. raw: 'raven@^2.2.1',
  738. name: 'raven',
  739. escapedName: 'raven',
  740. rawSpec: '^2.2.1',
  741. saveSpec: null,
  742. fetchSpec: '^2.2.1',
  743. },
  744. _requiredBy: ['#USER', '/'],
  745. _resolved: 'https://registry.npmjs.org/raven/-/raven-2.2.1.tgz',
  746. _shasum: '57c7fbe68a80147ec527def3d7c01575cf948fe3',
  747. _spec: 'raven@^2.2.1',
  748. _where: '/Users/kamilogorek/Projects/sentry/repros/node-sourcemaps',
  749. author: {name: 'Matt Robenolt', email: 'matt@ydekproductions.com'},
  750. bin: {raven: './bin/raven'},
  751. bugs: {url: 'https://github.com/getsentry/raven-node/issues'},
  752. bundleDependencies: false,
  753. dependencies: {
  754. cookie: '0.3.1',
  755. lsmod: '1.0.0',
  756. 'stack-trace': '0.0.9',
  757. 'timed-out': '4.0.1',
  758. uuid: '3.0.0',
  759. },
  760. deprecated: false,
  761. description: 'A standalone (Node.js) client for Sentry',
  762. devDependencies: {
  763. 'coffee-script': '~1.10.0',
  764. connect: '*',
  765. eslint: '^4.5.0',
  766. 'eslint-config-prettier': '^2.3.0',
  767. express: '*',
  768. glob: '~3.1.13',
  769. husky: '^0.14.3',
  770. istanbul: '^0.4.3',
  771. 'lint-staged': '^4.0.4',
  772. mocha: '~3.1.2',
  773. nock: '~9.0.0',
  774. prettier: '^1.6.1',
  775. should: '11.2.0',
  776. sinon: '^3.3.0',
  777. },
  778. engines: {node: '>= 4.0.0'},
  779. homepage: 'https://github.com/getsentry/raven-node',
  780. keywords: ['debugging', 'errors', 'exceptions', 'logging', 'raven', 'sentry'],
  781. license: 'BSD-2-Clause',
  782. 'lint-staged': {'*.js': ['prettier --write', 'git add']},
  783. main: 'index.js',
  784. name: 'raven',
  785. prettier: {singleQuote: true, bracketSpacing: false, printWidth: 90},
  786. repository: {type: 'git', url: 'git://github.com/getsentry/raven-node.git'},
  787. scripts: {
  788. lint: 'node_modules/eslint/bin/eslint.js .',
  789. precommit: 'lint-staged',
  790. pretest: 'npm install && npm run lint',
  791. test:
  792. 'NODE_ENV=test istanbul cover _mocha -- --reporter dot && NODE_ENV=test node_modules/coffee-script/bin/coffee ./test/run.coffee',
  793. 'test-full': 'npm run test && cd test/instrumentation && ./run.sh',
  794. 'test-mocha': 'NODE_ENV=test mocha',
  795. },
  796. version: '2.2.1',
  797. };
  798. /***/
  799. },
  800. /* 12 */
  801. /***/ function(module, exports, __webpack_require__) {
  802. 'use strict';
  803. var util = __webpack_require__(1);
  804. var utils = __webpack_require__(0);
  805. module.exports = function(Raven, console, originals) {
  806. var wrapConsoleMethod = function(level) {
  807. if (!(level in console)) {
  808. return;
  809. }
  810. utils.fill(
  811. console,
  812. level,
  813. function(originalConsoleLevel) {
  814. var sentryLevel = level === 'warn' ? 'warning' : level;
  815. return function() {
  816. var args = [].slice.call(arguments);
  817. Raven.captureBreadcrumb({
  818. message: util.format.apply(null, args),
  819. level: sentryLevel,
  820. category: 'console',
  821. });
  822. originalConsoleLevel.apply(console, args);
  823. };
  824. },
  825. originals
  826. );
  827. };
  828. ['debug', 'info', 'warn', 'error', 'log'].forEach(wrapConsoleMethod);
  829. return console;
  830. };
  831. /***/
  832. },
  833. /* 13 */
  834. /***/ function(module, exports, __webpack_require__) {
  835. 'use strict';
  836. var util = __webpack_require__(1);
  837. var utils = __webpack_require__(0);
  838. module.exports = function(Raven, http, originals) {
  839. var OrigClientRequest = http.ClientRequest;
  840. var ClientRequest = function(options, cb) {
  841. // Note: this won't capture a breadcrumb if a response never comes
  842. // It would be useful to know if that was the case, though, so
  843. // todo: revisit to see if we can capture sth indicating response never came
  844. // possibility: capture one breadcrumb for "req sent" and one for "res recvd"
  845. // seems excessive but solves the problem and *is* strictly more information
  846. // could be useful for weird response sequencing bug scenarios
  847. OrigClientRequest.call(this, options, cb);
  848. // We could just always reconstruct this from this.agent, this._headers, this.path, etc
  849. // but certain other http-instrumenting libraries (like nock, which we use for tests) fail to
  850. // maintain the guarantee that after calling OrigClientRequest, those fields will be populated
  851. if (typeof options === 'string') {
  852. this.__ravenBreadcrumbUrl = options;
  853. } else {
  854. this.__ravenBreadcrumbUrl =
  855. (options.protocol || '') +
  856. '//' +
  857. (options.hostname || options.host || '') +
  858. (options.path || '/');
  859. }
  860. };
  861. util.inherits(ClientRequest, OrigClientRequest);
  862. utils.fill(ClientRequest.prototype, 'emit', function(origEmit) {
  863. return function(evt, maybeResp) {
  864. if (evt === 'response' && this.__ravenBreadcrumbUrl) {
  865. if (
  866. !Raven.dsn ||
  867. this.__ravenBreadcrumbUrl.indexOf(Raven.dsn.host) === -1
  868. ) {
  869. Raven.captureBreadcrumb({
  870. type: 'http',
  871. category: 'http',
  872. data: {
  873. method: this.method,
  874. url: this.__ravenBreadcrumbUrl,
  875. status_code: maybeResp.statusCode,
  876. },
  877. });
  878. }
  879. }
  880. return origEmit.apply(this, arguments);
  881. };
  882. });
  883. utils.fill(
  884. http,
  885. 'ClientRequest',
  886. function() {
  887. return ClientRequest;
  888. },
  889. originals
  890. );
  891. // http.request orig refs module-internal ClientRequest, not exported one, so
  892. // it still points at orig ClientRequest after our monkeypatch; these reimpls
  893. // just get that reference updated to use our new ClientRequest
  894. utils.fill(
  895. http,
  896. 'request',
  897. function() {
  898. return function(options, cb) {
  899. return new http.ClientRequest(options, cb);
  900. };
  901. },
  902. originals
  903. );
  904. utils.fill(
  905. http,
  906. 'get',
  907. function() {
  908. return function(options, cb) {
  909. var req = http.request(options, cb);
  910. req.end();
  911. return req;
  912. };
  913. },
  914. originals
  915. );
  916. return http;
  917. };
  918. /***/
  919. },
  920. /* 14 */
  921. /***/ function(module, exports, __webpack_require__) {
  922. 'use strict';
  923. module.exports = function(Raven, pg, originals) {
  924. // Using fill helper here is hard because of `this` binding
  925. var origQuery = pg.Connection.prototype.query;
  926. pg.Connection.prototype.query = function(text) {
  927. Raven.captureBreadcrumb({
  928. category: 'postgres',
  929. message: text,
  930. });
  931. origQuery.call(this, text);
  932. };
  933. // todo thread this through
  934. // originals.push([pg.Connection.prototype, 'query', origQuery]);
  935. };
  936. /***/
  937. },
  938. /* 15 */
  939. /***/ function(module, exports, __webpack_require__) {
  940. var Raven = __webpack_require__(16);
  941. var path = __webpack_require__(2);
  942. var foo = __webpack_require__(32);
  943. Raven.config(
  944. 'http://36dfaa7c54664f429aac79ac89d7fb68:b4505a72a8ce4ecd8deb8038124b0909@localhost:8000/8',
  945. {
  946. release: process.env.RELEASE,
  947. dataCallback: function(data) {
  948. var stacktrace = data.exception && data.exception[0].stacktrace;
  949. if (stacktrace && stacktrace.frames) {
  950. stacktrace.frames.forEach(function(frame) {
  951. if (frame.filename.startsWith('/')) {
  952. frame.filename = 'app:///' + path.basename(frame.filename);
  953. }
  954. });
  955. }
  956. console.log(JSON.stringify(data, null, 2));
  957. return data;
  958. },
  959. shouldSendCallback: function() {
  960. return 'false';
  961. },
  962. }
  963. ).install();
  964. function App() {
  965. foo();
  966. }
  967. App();
  968. setTimeout(function() {
  969. App();
  970. }, 500);
  971. /***/
  972. },
  973. /* 16 */
  974. /***/ function(module, exports, __webpack_require__) {
  975. 'use strict';
  976. module.exports = __webpack_require__(17);
  977. module.exports.utils = __webpack_require__(0);
  978. module.exports.transports = __webpack_require__(3);
  979. module.exports.parsers = __webpack_require__(6);
  980. // To infinity and beyond
  981. Error.stackTraceLimit = Infinity;
  982. /***/
  983. },
  984. /* 17 */
  985. /***/ function(module, exports, __webpack_require__) {
  986. 'use strict';
  987. var stringify = __webpack_require__(5);
  988. var parsers = __webpack_require__(6);
  989. var zlib = __webpack_require__(23);
  990. var utils = __webpack_require__(0);
  991. var uuid = __webpack_require__(24);
  992. var transports = __webpack_require__(3);
  993. var nodeUtil = __webpack_require__(1); // nodeUtil to avoid confusion with "utils"
  994. var events = __webpack_require__(9);
  995. var domain = __webpack_require__(27);
  996. var instrumentor = __webpack_require__(4);
  997. var extend = utils.extend;
  998. function Raven() {
  999. this.breadcrumbs = {
  1000. record: this.captureBreadcrumb.bind(this),
  1001. };
  1002. }
  1003. nodeUtil.inherits(Raven, events.EventEmitter);
  1004. extend(Raven.prototype, {
  1005. config: function config(dsn, options) {
  1006. // We get lots of users using raven-node when they want raven-js, hence this warning if it seems like a browser
  1007. if (
  1008. typeof window !== 'undefined' &&
  1009. typeof document !== 'undefined' &&
  1010. typeof navigator !== 'undefined'
  1011. ) {
  1012. utils.consoleAlertOnce(
  1013. "This looks like a browser environment; are you sure you don't want Raven.js for browser JavaScript? https://sentry.io/for/javascript"
  1014. );
  1015. }
  1016. if (arguments.length === 0) {
  1017. // no arguments, use default from environment
  1018. dsn = process.env.SENTRY_DSN;
  1019. options = {};
  1020. }
  1021. if (typeof dsn === 'object') {
  1022. // They must only be passing through options
  1023. options = dsn;
  1024. dsn = process.env.SENTRY_DSN;
  1025. }
  1026. options = options || {};
  1027. this.raw_dsn = dsn;
  1028. this.dsn = utils.parseDSN(dsn);
  1029. this.name =
  1030. options.name || process.env.SENTRY_NAME || __webpack_require__(31).hostname();
  1031. this.root = options.root || process.cwd();
  1032. this.transport = options.transport || transports[this.dsn.protocol];
  1033. this.sendTimeout = options.sendTimeout || 1;
  1034. this.release = options.release || process.env.SENTRY_RELEASE || '';
  1035. this.environment =
  1036. options.environment ||
  1037. process.env.SENTRY_ENVIRONMENT ||
  1038. process.env.NODE_ENV ||
  1039. '';
  1040. // autoBreadcrumbs: true enables all, autoBreadcrumbs: false disables all
  1041. // autoBreadcrumbs: { http: true } enables a single type
  1042. this.autoBreadcrumbs = options.autoBreadcrumbs || false;
  1043. // default to 30, don't allow higher than 100
  1044. this.maxBreadcrumbs = Math.max(0, Math.min(options.maxBreadcrumbs || 30, 100));
  1045. this.captureUnhandledRejections = options.captureUnhandledRejections;
  1046. this.loggerName = options.logger || '';
  1047. this.dataCallback = options.dataCallback;
  1048. this.shouldSendCallback = options.shouldSendCallback;
  1049. this.sampleRate =
  1050. typeof options.sampleRate === 'undefined' ? 1 : options.sampleRate;
  1051. this.maxReqQueueCount = options.maxReqQueueCount || 100;
  1052. this.parseUser = options.parseUser;
  1053. if (!this.dsn) {
  1054. utils.consoleAlert('no DSN provided, error reporting disabled');
  1055. }
  1056. if (this.dsn.protocol === 'https') {
  1057. // In case we want to provide our own SSL certificates / keys
  1058. this.ca = options.ca || null;
  1059. }
  1060. // enabled if a dsn is set
  1061. this._enabled = !!this.dsn;
  1062. var globalContext = (this._globalContext = {});
  1063. if (options.tags) {
  1064. globalContext.tags = options.tags;
  1065. }
  1066. if (options.extra) {
  1067. globalContext.extra = options.extra;
  1068. }
  1069. this.onFatalError = this.defaultOnFatalError = function(err, sendErr, eventId) {
  1070. console.error(err && err.stack ? err.stack : err);
  1071. process.exit(1);
  1072. };
  1073. this.uncaughtErrorHandler = this.makeErrorHandler();
  1074. this.on('error', function(err) {
  1075. utils.consoleAlert('failed to send exception to sentry: ' + err.message);
  1076. });
  1077. return this;
  1078. },
  1079. install: function install(cb) {
  1080. if (this.installed) return this;
  1081. if (typeof cb === 'function') {
  1082. this.onFatalError = cb;
  1083. }
  1084. process.on('uncaughtException', this.uncaughtErrorHandler);
  1085. if (this.captureUnhandledRejections) {
  1086. var self = this;
  1087. process.on('unhandledRejection', function(reason) {
  1088. self.captureException(reason, function(sendErr, eventId) {
  1089. if (!sendErr)
  1090. utils.consoleAlert('unhandledRejection captured: ' + eventId);
  1091. });
  1092. });
  1093. }
  1094. instrumentor.instrument(this, this.autoBreadcrumbs);
  1095. this.installed = true;
  1096. return this;
  1097. },
  1098. uninstall: function uninstall() {
  1099. if (!this.installed) return this;
  1100. instrumentor.deinstrument(this);
  1101. // todo: this works for tests for now, but isn't what we ultimately want to be doing
  1102. process.removeAllListeners('uncaughtException');
  1103. process.removeAllListeners('unhandledRejection');
  1104. this.installed = false;
  1105. return this;
  1106. },
  1107. makeErrorHandler: function() {
  1108. var self = this;
  1109. var caughtFirstError = false;
  1110. var caughtSecondError = false;
  1111. var calledFatalError = false;
  1112. var firstError;
  1113. return function(err) {
  1114. if (!caughtFirstError) {
  1115. // this is the first uncaught error and the ultimate reason for shutting down
  1116. // we want to do absolutely everything possible to ensure it gets captured
  1117. // also we want to make sure we don't go recursion crazy if more errors happen after this one
  1118. firstError = err;
  1119. caughtFirstError = true;
  1120. self.captureException(err, function(sendErr, eventId) {
  1121. if (!calledFatalError) {
  1122. calledFatalError = true;
  1123. self.onFatalError(err, sendErr, eventId);
  1124. }
  1125. });
  1126. } else if (calledFatalError) {
  1127. // we hit an error *after* calling onFatalError - pretty boned at this point, just shut it down
  1128. utils.consoleAlert(
  1129. 'uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown'
  1130. );
  1131. self.defaultOnFatalError(err);
  1132. } else if (!caughtSecondError) {
  1133. // two cases for how we can hit this branch:
  1134. // - capturing of first error blew up and we just caught the exception from that
  1135. // - quit trying to capture, proceed with shutdown
  1136. // - a second independent error happened while waiting for first error to capture
  1137. // - want to avoid causing premature shutdown before first error capture finishes
  1138. // it's hard to immediately tell case 1 from case 2 without doing some fancy/questionable domain stuff
  1139. // so let's instead just delay a bit before we proceed with our action here
  1140. // in case 1, we just wait a bit unnecessarily but ultimately do the same thing
  1141. // in case 2, the delay hopefully made us wait long enough for the capture to finish
  1142. // two potential nonideal outcomes:
  1143. // nonideal case 1: capturing fails fast, we sit around for a few seconds unnecessarily before proceeding correctly by calling onFatalError
  1144. // nonideal case 2: case 2 happens, 1st error is captured but slowly, timeout completes before capture and we treat second error as the sendErr of (nonexistent) failure from trying to capture first error
  1145. // note that after hitting this branch, we might catch more errors where (caughtSecondError && !calledFatalError)
  1146. // we ignore them - they don't matter to us, we're just waiting for the second error timeout to finish
  1147. caughtSecondError = true;
  1148. setTimeout(function() {
  1149. if (!calledFatalError) {
  1150. // it was probably case 1, let's treat err as the sendErr and call onFatalError
  1151. calledFatalError = true;
  1152. self.onFatalError(firstError, err);
  1153. } else {
  1154. // it was probably case 2, our first error finished capturing while we waited, cool, do nothing
  1155. }
  1156. }, (self.sendTimeout + 1) * 1000); // capturing could take at least sendTimeout to fail, plus an arbitrary second for how long it takes to collect surrounding source etc
  1157. }
  1158. };
  1159. },
  1160. generateEventId: function generateEventId() {
  1161. return uuid().replace(/-/g, '');
  1162. },
  1163. process: function process(eventId, kwargs, cb) {
  1164. // prod codepaths shouldn't hit this branch, for testing
  1165. if (typeof eventId === 'object') {
  1166. cb = kwargs;
  1167. kwargs = eventId;
  1168. eventId = this.generateEventId();
  1169. }
  1170. var domainContext = (domain.active && domain.active.sentryContext) || {};
  1171. kwargs.user = extend(
  1172. {},
  1173. this._globalContext.user,
  1174. domainContext.user,
  1175. kwargs.user
  1176. );
  1177. kwargs.tags = extend(
  1178. {},
  1179. this._globalContext.tags,
  1180. domainContext.tags,
  1181. kwargs.tags
  1182. );
  1183. kwargs.extra = extend(
  1184. {},
  1185. this._globalContext.extra,
  1186. domainContext.extra,
  1187. kwargs.extra
  1188. );
  1189. kwargs.breadcrumbs = {
  1190. values: domainContext.breadcrumbs || this._globalContext.breadcrumbs || [],
  1191. };
  1192. /*
  1193. `request` is our specified property name for the http interface: https://docs.sentry.io/clientdev/interfaces/http/
  1194. `req` is the conventional name for a request object in node/express/etc
  1195. we want to enable someone to pass a `request` property to kwargs according to http interface
  1196. but also want to provide convenience for passing a req object and having us parse it out
  1197. so we only parse a `req` property if the `request` property is absent/empty (and hence we won't clobber)
  1198. parseUser returns a partial kwargs object with a `request` property and possibly a `user` property
  1199. */
  1200. kwargs.request = this._createRequestObject(
  1201. this._globalContext.request,
  1202. domainContext.request,
  1203. kwargs.request
  1204. );
  1205. if (Object.keys(kwargs.request).length === 0) {
  1206. var req = this._createRequestObject(
  1207. this._globalContext.req,
  1208. domainContext.req,
  1209. kwargs.req
  1210. );
  1211. if (Object.keys(req).length > 0) {
  1212. var parseUser =
  1213. Object.keys(kwargs.user).length === 0 ? this.parseUser : false;
  1214. extend(kwargs, parsers.parseRequest(req, parseUser));
  1215. delete kwargs.req;
  1216. }
  1217. }
  1218. kwargs.modules = utils.getModules();
  1219. kwargs.server_name = kwargs.server_name || this.name;
  1220. if (typeof process.version !== 'undefined') {
  1221. kwargs.extra.node = process.version;
  1222. }
  1223. kwargs.environment = kwargs.environment || this.environment;
  1224. kwargs.logger = kwargs.logger || this.loggerName;
  1225. kwargs.event_id = eventId;
  1226. kwargs.timestamp = new Date().toISOString().split('.')[0];
  1227. kwargs.project = this.dsn.project_id;
  1228. kwargs.platform = 'node';
  1229. // Only include release information if it is set
  1230. if (this.release) {
  1231. kwargs.release = this.release;
  1232. }
  1233. if (this.dataCallback) {
  1234. kwargs = this.dataCallback(kwargs);
  1235. }
  1236. var shouldSend = true;
  1237. if (!this._enabled) shouldSend = false;
  1238. if (this.shouldSendCallback && !this.shouldSendCallback(kwargs))
  1239. shouldSend = false;
  1240. if (Math.random() >= this.sampleRate) shouldSend = false;
  1241. if (shouldSend) {
  1242. this.send(kwargs, cb);
  1243. } else {
  1244. // wish there was a good way to communicate to cb why we didn't send; worth considering cb api change?
  1245. // could be shouldSendCallback, could be disabled, could be sample rate
  1246. // avoiding setImmediate here because node 0.8
  1247. cb &&
  1248. setTimeout(function() {
  1249. cb(null, eventId);
  1250. }, 0);
  1251. }
  1252. },
  1253. send: function send(kwargs, cb) {
  1254. var self = this;
  1255. var skwargs = stringify(kwargs);
  1256. var eventId = kwargs.event_id;
  1257. zlib.deflate(skwargs, function(err, buff) {
  1258. var message = buff.toString('base64'),
  1259. timestamp = new Date().getTime(),
  1260. headers = {
  1261. 'X-Sentry-Auth': utils.getAuthHeader(
  1262. timestamp,
  1263. self.dsn.public_key,
  1264. self.dsn.private_key
  1265. ),
  1266. 'Content-Type': 'application/octet-stream',
  1267. 'Content-Length': message.length,
  1268. };
  1269. self.transport.send(self, message, headers, eventId, cb);
  1270. });
  1271. },
  1272. captureMessage: function captureMessage(message, kwargs, cb) {
  1273. if (!cb && typeof kwargs === 'function') {
  1274. cb = kwargs;
  1275. kwargs = {};
  1276. } else {
  1277. kwargs = kwargs || {};
  1278. }
  1279. var eventId = this.generateEventId();
  1280. this.process(eventId, parsers.parseText(message, kwargs), cb);
  1281. return eventId;
  1282. },
  1283. captureException: function captureException(err, kwargs, cb) {
  1284. if (!(err instanceof Error)) {
  1285. // This handles when someone does:
  1286. // throw "something awesome";
  1287. // We synthesize an Error here so we can extract a (rough) stack trace.
  1288. err = new Error(err);
  1289. }
  1290. if (!cb && typeof kwargs === 'function') {
  1291. cb = kwargs;
  1292. kwargs = {};
  1293. } else {
  1294. kwargs = kwargs || {};
  1295. }
  1296. var self = this;
  1297. var eventId = this.generateEventId();
  1298. parsers.parseError(err, kwargs, function(kw) {
  1299. self.process(eventId, kw, cb);
  1300. });
  1301. return eventId;
  1302. },
  1303. context: function(ctx, func) {
  1304. if (!func && typeof ctx === 'function') {
  1305. func = ctx;
  1306. ctx = {};
  1307. }
  1308. // todo/note: raven-js takes an args param to do apply(this, args)
  1309. // i don't think it's correct/necessary to bind this to the wrap call
  1310. // and i don't know if we need to support the args param; it's undocumented
  1311. return this.wrap(ctx, func).apply(null);
  1312. },
  1313. wrap: function(options, func) {
  1314. if (!func && typeof options === 'function') {
  1315. func = options;
  1316. options = {};
  1317. }
  1318. var wrapDomain = domain.create();
  1319. // todo: better property name than sentryContext, maybe __raven__ or sth?
  1320. wrapDomain.sentryContext = options;
  1321. wrapDomain.on('error', this.uncaughtErrorHandler);
  1322. var wrapped = wrapDomain.bind(func);
  1323. for (var property in func) {
  1324. if ({}.hasOwnProperty.call(func, property)) {
  1325. wrapped[property] = func[property];
  1326. }
  1327. }
  1328. wrapped.prototype = func.prototype;
  1329. wrapped.__raven__ = true;
  1330. wrapped.__inner__ = func;
  1331. // note: domain.bind sets wrapped.domain, but it's not documented, unsure if we should rely on that
  1332. wrapped.__domain__ = wrapDomain;
  1333. return wrapped;
  1334. },
  1335. interceptErr: function(options, func) {
  1336. if (!func && typeof options === 'function') {
  1337. func = options;
  1338. options = {};
  1339. }
  1340. var self = this;
  1341. var wrapped = function() {
  1342. var err = arguments[0];
  1343. if (err instanceof Error) {
  1344. self.captureException(err, options);
  1345. } else {
  1346. func.apply(null, arguments);
  1347. }
  1348. };
  1349. // repetitive with wrap
  1350. for (var property in func) {
  1351. if ({}.hasOwnProperty.call(func, property)) {
  1352. wrapped[property] = func[property];
  1353. }
  1354. }
  1355. wrapped.prototype = func.prototype;
  1356. wrapped.__raven__ = true;
  1357. wrapped.__inner__ = func;
  1358. return wrapped;
  1359. },
  1360. setContext: function setContext(ctx) {
  1361. if (domain.active) {
  1362. domain.active.sentryContext = ctx;
  1363. } else {
  1364. this._globalContext = ctx;
  1365. }
  1366. return this;
  1367. },
  1368. mergeContext: function mergeContext(ctx) {
  1369. extend(this.getContext(), ctx);
  1370. return this;
  1371. },
  1372. getContext: function getContext() {
  1373. if (domain.active) {
  1374. if (!domain.active.sentryContext) {
  1375. domain.active.sentryContext = {};
  1376. utils.consoleAlert('sentry context not found on active domain');
  1377. }
  1378. return domain.active.sentryContext;
  1379. }
  1380. return this._globalContext;
  1381. },
  1382. setCallbackHelper: function(propertyName, callback) {
  1383. var original = this[propertyName];
  1384. if (typeof callback === 'function') {
  1385. this[propertyName] = function(data) {
  1386. return callback(data, original);
  1387. };
  1388. } else {
  1389. this[propertyName] = callback;
  1390. }
  1391. return this;
  1392. },
  1393. /*
  1394. * Set the dataCallback option
  1395. *
  1396. * @param {function} callback The callback to run which allows the
  1397. * data blob to be mutated before sending
  1398. * @return {Raven}
  1399. */
  1400. setDataCallback: function(callback) {
  1401. return this.setCallbackHelper('dataCallback', callback);
  1402. },
  1403. /*
  1404. * Set the shouldSendCallback option
  1405. *
  1406. * @param {function} callback The callback to run which allows
  1407. * introspecting the blob before sending
  1408. * @return {Raven}
  1409. */
  1410. setShouldSendCallback: function(callback) {
  1411. return this.setCallbackHelper('shouldSendCallback', callback);
  1412. },
  1413. requestHandler: function() {
  1414. var self = this;
  1415. return function(req, res, next) {
  1416. self.context({req: req}, function() {
  1417. domain.active.add(req);
  1418. domain.active.add(res);
  1419. next();
  1420. });
  1421. };
  1422. },
  1423. errorHandler: function() {
  1424. var self = this;
  1425. return function(err, req, res, next) {
  1426. var status = err.status || err.statusCode || err.status_code || 500;
  1427. // skip anything not marked as an internal server error
  1428. if (status < 500) return next(err);
  1429. var eventId = self.captureException(err, {req: req});
  1430. res.sentry = eventId;
  1431. return next(err);
  1432. };
  1433. },
  1434. captureBreadcrumb: function(breadcrumb) {
  1435. // Avoid capturing global-scoped breadcrumbs before instrumentation finishes
  1436. if (!this.installed) return;
  1437. breadcrumb = extend(
  1438. {
  1439. timestamp: +new Date() / 1000,
  1440. },
  1441. breadcrumb
  1442. );
  1443. var currCtx = this.getContext();
  1444. if (!currCtx.breadcrumbs) currCtx.breadcrumbs = [];
  1445. currCtx.breadcrumbs.push(breadcrumb);
  1446. if (currCtx.breadcrumbs.length > this.maxBreadcrumbs) {
  1447. currCtx.breadcrumbs.shift();
  1448. }
  1449. this.setContext(currCtx);
  1450. },
  1451. _createRequestObject: function() {
  1452. /**
  1453. * When using proxy, some of the attributes of req/request objects are non-enumerable.
  1454. * To make sure, that they are still available to us after we consolidate our sources
  1455. * (eg. globalContext.request + domainContext.request + kwargs.request),
  1456. * we manually pull them out from original objects.
  1457. *
  1458. * We don't use Object.assign/extend as it's only merging over objects own properties,
  1459. * and we don't want to go through all of the properties as well, as we simply don't
  1460. * need all of them.
  1461. *
  1462. * So far the only missing piece is `ip`, but we can specify what properties should
  1463. * be pulled by extending `nonEnumerables` array.
  1464. **/
  1465. var sources = Array.from(arguments).filter(function(source) {
  1466. return Object.prototype.toString.call(source) === '[object Object]';
  1467. });
  1468. sources = [{}].concat(sources);
  1469. var request = extend.apply(null, sources);
  1470. var nonEnumberables = ['ip'];
  1471. nonEnumberables.forEach(function(key) {
  1472. sources.forEach(function(source) {
  1473. if (source[key]) request[key] = source[key];
  1474. });
  1475. });
  1476. return request;
  1477. },
  1478. });
  1479. // Maintain old API compat, need to make sure arguments length is preserved
  1480. function Client(dsn, options) {
  1481. if (dsn instanceof Client) return dsn;
  1482. var ravenInstance = new Raven();
  1483. return ravenInstance.config.apply(ravenInstance, arguments);
  1484. }
  1485. nodeUtil.inherits(Client, Raven);
  1486. // Singleton-by-default but not strictly enforced
  1487. // todo these extra export props are sort of an adhoc mess, better way to manage?
  1488. var defaultInstance = new Raven();
  1489. defaultInstance.Client = Client;
  1490. defaultInstance.version = __webpack_require__(11).version;
  1491. defaultInstance.disableConsoleAlerts = utils.disableConsoleAlerts;
  1492. module.exports = defaultInstance;
  1493. /***/
  1494. },
  1495. /* 18 */
  1496. /***/ function(module, exports, __webpack_require__) {
  1497. 'use strict';
  1498. /*!
  1499. * cookie
  1500. * Copyright(c) 2012-2014 Roman Shtylman
  1501. * Copyright(c) 2015 Douglas Christopher Wilson
  1502. * MIT Licensed
  1503. */
  1504. /**
  1505. * Module exports.
  1506. * @public
  1507. */
  1508. exports.parse = parse;
  1509. exports.serialize = serialize;
  1510. /**
  1511. * Module variables.
  1512. * @private
  1513. */
  1514. var decode = decodeURIComponent;
  1515. var encode = encodeURIComponent;
  1516. var pairSplitRegExp = /; */;
  1517. /**
  1518. * RegExp to match field-content in RFC 7230 sec 3.2
  1519. *
  1520. * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
  1521. * field-vchar = VCHAR / obs-text
  1522. * obs-text = %x80-FF
  1523. */
  1524. var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
  1525. /**
  1526. * Parse a cookie header.
  1527. *
  1528. * Parse the given cookie header string into an object
  1529. * The object has the various cookies as keys(names) => values
  1530. *
  1531. * @param {string} str
  1532. * @param {object} [options]
  1533. * @return {object}
  1534. * @public
  1535. */
  1536. function parse(str, options) {
  1537. if (typeof str !== 'string') {
  1538. throw new TypeError('argument str must be a string');
  1539. }
  1540. var obj = {};
  1541. var opt = options || {};
  1542. var pairs = str.split(pairSplitRegExp);
  1543. var dec = opt.decode || decode;
  1544. for (var i = 0; i < pairs.length; i++) {
  1545. var pair = pairs[i];
  1546. var eq_idx = pair.indexOf('=');
  1547. // skip things that don't look like key=value
  1548. if (eq_idx < 0) {
  1549. continue;
  1550. }
  1551. var key = pair.substr(0, eq_idx).trim();
  1552. var val = pair.substr(++eq_idx, pair.length).trim();
  1553. // quoted values
  1554. if ('"' == val[0]) {
  1555. val = val.slice(1, -1);
  1556. }
  1557. // only assign once
  1558. if (undefined == obj[key]) {
  1559. obj[key] = tryDecode(val, dec);
  1560. }
  1561. }
  1562. return obj;
  1563. }
  1564. /**
  1565. * Serialize data into a cookie header.
  1566. *
  1567. * Serialize the a name value pair into a cookie string suitable for
  1568. * http headers. An optional options object specified cookie parameters.
  1569. *
  1570. * serialize('foo', 'bar', { httpOnly: true })
  1571. * => "foo=bar; httpOnly"
  1572. *
  1573. * @param {string} name
  1574. * @param {string} val
  1575. * @param {object} [options]
  1576. * @return {string}
  1577. * @public
  1578. */
  1579. function serialize(name, val, options) {
  1580. var opt = options || {};
  1581. var enc = opt.encode || encode;
  1582. if (typeof enc !== 'function') {
  1583. throw new TypeError('option encode is invalid');
  1584. }
  1585. if (!fieldContentRegExp.test(name)) {
  1586. throw new TypeError('argument name is invalid');
  1587. }
  1588. var value = enc(val);
  1589. if (value && !fieldContentRegExp.test(value)) {
  1590. throw new TypeError('argument val is invalid');
  1591. }
  1592. var str = name + '=' + value;
  1593. if (null != opt.maxAge) {
  1594. var maxAge = opt.maxAge - 0;
  1595. if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
  1596. str += '; Max-Age=' + Math.floor(maxAge);
  1597. }
  1598. if (opt.domain) {
  1599. if (!fieldContentRegExp.test(opt.domain)) {
  1600. throw new TypeError('option domain is invalid');
  1601. }
  1602. str += '; Domain=' + opt.domain;
  1603. }
  1604. if (opt.path) {
  1605. if (!fieldContentRegExp.test(opt.path)) {
  1606. throw new TypeError('option path is invalid');
  1607. }
  1608. str += '; Path=' + opt.path;
  1609. }
  1610. if (opt.expires) {
  1611. if (typeof opt.expires.toUTCString !== 'function') {
  1612. throw new TypeError('option expires is invalid');
  1613. }
  1614. str += '; Expires=' + opt.expires.toUTCString();
  1615. }
  1616. if (opt.httpOnly) {
  1617. str += '; HttpOnly';
  1618. }
  1619. if (opt.secure) {
  1620. str += '; Secure';
  1621. }
  1622. if (opt.sameSite) {
  1623. var sameSite =
  1624. typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;
  1625. switch (sameSite) {
  1626. case true:
  1627. str += '; SameSite=Strict';
  1628. break;
  1629. case 'lax':
  1630. str += '; SameSite=Lax';
  1631. break;
  1632. case 'strict':
  1633. str += '; SameSite=Strict';
  1634. break;
  1635. default:
  1636. throw new TypeError('option sameSite is invalid');
  1637. }
  1638. }
  1639. return str;
  1640. }
  1641. /**
  1642. * Try decoding a string using a decoding function.
  1643. *
  1644. * @param {string} str
  1645. * @param {function} decode
  1646. * @private
  1647. */
  1648. function tryDecode(str, decode) {
  1649. try {
  1650. return decode(str);
  1651. } catch (e) {
  1652. return str;
  1653. }
  1654. }
  1655. /***/
  1656. },
  1657. /* 19 */
  1658. /***/ function(module, exports, __webpack_require__) {
  1659. 'use strict';
  1660. module.exports = function(req, time) {
  1661. if (req.timeoutTimer) {
  1662. return req;
  1663. }
  1664. var delays = isNaN(time) ? time : {socket: time, connect: time};
  1665. var host = req._headers ? ' to ' + req._headers.host : '';
  1666. if (delays.connect !== undefined) {
  1667. req.timeoutTimer = setTimeout(function timeoutHandler() {
  1668. req.abort();
  1669. var e = new Error('Connection timed out on request' + host);
  1670. e.code = 'ETIMEDOUT';
  1671. req.emit('error', e);
  1672. }, delays.connect);
  1673. }
  1674. // Clear the connection timeout timer once a socket is assigned to the
  1675. // request and is connected.
  1676. req.on('socket', function assign(socket) {
  1677. // Socket may come from Agent pool and may be already connected.
  1678. if (!(socket.connecting || socket._connecting)) {
  1679. connect();
  1680. return;
  1681. }
  1682. socket.once('connect', connect);
  1683. });
  1684. function clear() {
  1685. if (req.timeoutTimer) {
  1686. clearTimeout(req.timeoutTimer);
  1687. req.timeoutTimer = null;
  1688. }
  1689. }
  1690. function connect() {
  1691. clear();
  1692. if (delays.socket !== undefined) {
  1693. // Abort the request if there is no activity on the socket for more
  1694. // than `delays.socket` milliseconds.
  1695. req.setTimeout(delays.socket, function socketTimeoutHandler() {
  1696. req.abort();
  1697. var e = new Error('Socket timed out on request' + host);
  1698. e.code = 'ESOCKETTIMEDOUT';
  1699. req.emit('error', e);
  1700. });
  1701. }
  1702. }
  1703. return req.on('error', clear);
  1704. };
  1705. /***/
  1706. },
  1707. /* 20 */
  1708. /***/ function(module, exports) {
  1709. module.exports = require('https');
  1710. /***/
  1711. },
  1712. /* 21 */
  1713. /***/ function(module, exports, __webpack_require__) {
  1714. // builtin
  1715. var fs = __webpack_require__(8);
  1716. var path = __webpack_require__(2);
  1717. // node 0.6 support
  1718. fs.existsSync = fs.existsSync || path.existsSync;
  1719. // main_paths are the paths where our mainprog will be able to load from
  1720. // we store these to avoid grabbing the modules that were loaded as a result
  1721. // of a dependency module loading its dependencies, we only care about deps our
  1722. // mainprog loads
  1723. var main_paths =
  1724. (__webpack_require__.c[__webpack_require__.s] &&
  1725. __webpack_require__.c[__webpack_require__.s].paths) ||
  1726. [];
  1727. module.exports = function() {
  1728. var paths = Object.keys(__webpack_require__.c || []);
  1729. // module information
  1730. var infos = {};
  1731. // paths we have already inspected to avoid traversing again
  1732. var seen = {};
  1733. paths.forEach(function(p) {
  1734. var dir = p;
  1735. (function updir() {
  1736. var orig = dir;
  1737. dir = path.dirname(orig);
  1738. if (!dir || orig === dir || seen[orig]) {
  1739. return;
  1740. } else if (main_paths.indexOf(dir) < 0) {
  1741. return updir();
  1742. }
  1743. var pkgfile = path.join(orig, 'package.json');
  1744. var exists = fs.existsSync(pkgfile);
  1745. seen[orig] = true;
  1746. // travel up the tree if no package.json here
  1747. if (!exists) {
  1748. return updir();
  1749. }
  1750. try {
  1751. var info = JSON.parse(fs.readFileSync(pkgfile, 'utf8'));
  1752. infos[info.name] = info.version;
  1753. } catch (e) {}
  1754. })();
  1755. });
  1756. return infos;
  1757. };
  1758. /***/
  1759. },
  1760. /* 22 */
  1761. /***/ function(module, exports) {
  1762. exports.get = function(belowFn) {
  1763. var oldLimit = Error.stackTraceLimit;
  1764. Error.stackTraceLimit = Infinity;
  1765. var dummyObject = {};
  1766. var v8Handler = Error.prepareStackTrace;
  1767. Error.prepareStackTrace = function(dummyObject, v8StackTrace) {
  1768. return v8StackTrace;
  1769. };
  1770. Error.captureStackTrace(dummyObject, belowFn || exports.get);
  1771. var v8StackTrace = dummyObject.stack;
  1772. Error.prepareStackTrace = v8Handler;
  1773. Error.stackTraceLimit = oldLimit;
  1774. return v8StackTrace;
  1775. };
  1776. exports.parse = function(err) {
  1777. if (!err.stack) {
  1778. return [];
  1779. }
  1780. var self = this;
  1781. var lines = err.stack.split('\n').slice(1);
  1782. return lines
  1783. .map(function(line) {
  1784. if (line.match(/^\s*[-]{4,}$/)) {
  1785. return self._createParsedCallSite({
  1786. fileName: line,
  1787. lineNumber: null,
  1788. functionName: null,
  1789. typeName: null,
  1790. methodName: null,
  1791. columnNumber: null,
  1792. native: null,
  1793. });
  1794. }
  1795. var lineMatch = line.match(
  1796. /at (?:(.+)\s+)?\(?(?:(.+?):(\d+):(\d+)|([^)]+))\)?/
  1797. );
  1798. if (!lineMatch) {
  1799. return;
  1800. }
  1801. var object = null;
  1802. var method = null;
  1803. var functionName = null;
  1804. var typeName = null;
  1805. var methodName = null;
  1806. var isNative = lineMatch[5] === 'native';
  1807. if (lineMatch[1]) {
  1808. var methodMatch = lineMatch[1].match(/([^\.]+)(?:\.(.+))?/);
  1809. object = methodMatch[1];
  1810. method = methodMatch[2];
  1811. functionName = lineMatch[1];
  1812. typeName = 'Object';
  1813. }
  1814. if (method) {
  1815. typeName = object;
  1816. methodName = method;
  1817. }
  1818. if (method === '<anonymous>') {
  1819. methodName = null;
  1820. functionName = '';
  1821. }
  1822. var properties = {
  1823. fileName: lineMatch[2] || null,
  1824. lineNumber: parseInt(lineMatch[3], 10) || null,
  1825. functionName: functionName,
  1826. typeName: typeName,
  1827. methodName: methodName,
  1828. columnNumber: parseInt(lineMatch[4], 10) || null,
  1829. native: isNative,
  1830. };
  1831. return self._createParsedCallSite(properties);
  1832. })
  1833. .filter(function(callSite) {
  1834. return !!callSite;
  1835. });
  1836. };
  1837. exports._createParsedCallSite = function(properties) {
  1838. var methods = {};
  1839. for (var property in properties) {
  1840. var prefix = 'get';
  1841. if (property === 'native') {
  1842. prefix = 'is';
  1843. }
  1844. var method = prefix + property.substr(0, 1).toUpperCase() + property.substr(1);
  1845. (function(property) {
  1846. methods[method] = function() {
  1847. return properties[property];
  1848. };
  1849. })(property);
  1850. }
  1851. var callSite = Object.create(methods);
  1852. for (var property in properties) {
  1853. callSite[property] = properties[property];
  1854. }
  1855. return callSite;
  1856. };
  1857. /***/
  1858. },
  1859. /* 23 */
  1860. /***/ function(module, exports) {
  1861. module.exports = require('zlib');
  1862. /***/
  1863. },
  1864. /* 24 */
  1865. /***/ function(module, exports, __webpack_require__) {
  1866. // Unique ID creation requires a high quality random # generator. We feature
  1867. // detect to determine the best RNG source, normalizing to a function that
  1868. // returns 128-bits of randomness, since that's what's usually required
  1869. var _rng = __webpack_require__(25);
  1870. // Maps for number <-> hex string conversion
  1871. var _byteToHex = [];
  1872. var _hexToByte = {};
  1873. for (var i = 0; i < 256; ++i) {
  1874. _byteToHex[i] = (i + 0x100).toString(16).substr(1);
  1875. _hexToByte[_byteToHex[i]] = i;
  1876. }
  1877. function buff_to_string(buf, offset) {
  1878. var i = offset || 0;
  1879. var bth = _byteToHex;
  1880. return (
  1881. bth[buf[i++]] +
  1882. bth[buf[i++]] +
  1883. bth[buf[i++]] +
  1884. bth[buf[i++]] +
  1885. '-' +
  1886. bth[buf[i++]] +
  1887. bth[buf[i++]] +
  1888. '-' +
  1889. bth[buf[i++]] +
  1890. bth[buf[i++]] +
  1891. '-' +
  1892. bth[buf[i++]] +
  1893. bth[buf[i++]] +
  1894. '-' +
  1895. bth[buf[i++]] +
  1896. bth[buf[i++]] +
  1897. bth[buf[i++]] +
  1898. bth[buf[i++]] +
  1899. bth[buf[i++]] +
  1900. bth[buf[i++]]
  1901. );
  1902. }
  1903. // **`v1()` - Generate time-based UUID**
  1904. //
  1905. // Inspired by https://github.com/LiosK/UUID.js
  1906. // and http://docs.python.org/library/uuid.html
  1907. // random #'s we need to init node and clockseq
  1908. var _seedBytes = _rng();
  1909. // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
  1910. var _nodeId = [
  1911. _seedBytes[0] | 0x01,
  1912. _seedBytes[1],
  1913. _seedBytes[2],
  1914. _seedBytes[3],
  1915. _seedBytes[4],
  1916. _seedBytes[5],
  1917. ];
  1918. // Per 4.2.2, randomize (14 bit) clockseq
  1919. var _clockseq = ((_seedBytes[6] << 8) | _seedBytes[7]) & 0x3fff;
  1920. // Previous uuid creation time
  1921. var _lastMSecs = 0,
  1922. _lastNSecs = 0;
  1923. // See https://github.com/broofa/node-uuid for API details
  1924. function v1(options, buf, offset) {
  1925. var i = (buf && offset) || 0;
  1926. var b = buf || [];
  1927. options = options || {};
  1928. var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
  1929. // UUID timestamps are 100 nano-second units since the Gregorian epoch,
  1930. // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
  1931. // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
  1932. // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
  1933. var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();
  1934. // Per 4.2.1.2, use count of uuid's generated during the current clock
  1935. // cycle to simulate higher resolution clock
  1936. var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
  1937. // Time since last uuid creation (in msecs)
  1938. var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000;
  1939. // Per 4.2.1.2, Bump clockseq on clock regression
  1940. if (dt < 0 && options.clockseq === undefined) {
  1941. clockseq = (clockseq + 1) & 0x3fff;
  1942. }
  1943. // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
  1944. // time interval
  1945. if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
  1946. nsecs = 0;
  1947. }
  1948. // Per 4.2.1.2 Throw error if too many uuids are requested
  1949. if (nsecs >= 10000) {
  1950. throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
  1951. }
  1952. _lastMSecs = msecs;
  1953. _lastNSecs = nsecs;
  1954. _clockseq = clockseq;
  1955. // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
  1956. msecs += 12219292800000;
  1957. // `time_low`
  1958. var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
  1959. b[i++] = (tl >>> 24) & 0xff;
  1960. b[i++] = (tl >>> 16) & 0xff;
  1961. b[i++] = (tl >>> 8) & 0xff;
  1962. b[i++] = tl & 0xff;
  1963. // `time_mid`
  1964. var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
  1965. b[i++] = (tmh >>> 8) & 0xff;
  1966. b[i++] = tmh & 0xff;
  1967. // `time_high_and_version`
  1968. b[i++] = ((tmh >>> 24) & 0xf) | 0x10; // include version
  1969. b[i++] = (tmh >>> 16) & 0xff;
  1970. // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
  1971. b[i++] = (clockseq >>> 8) | 0x80;
  1972. // `clock_seq_low`
  1973. b[i++] = clockseq & 0xff;
  1974. // `node`
  1975. var node = options.node || _nodeId;
  1976. for (var n = 0; n < 6; ++n) {
  1977. b[i + n] = node[n];
  1978. }
  1979. return buf ? buf : buff_to_string(b);
  1980. }
  1981. // **`v4()` - Generate random UUID**
  1982. // See https://github.com/broofa/node-uuid for API details
  1983. function v4(options, buf, offset) {
  1984. // Deprecated - 'format' argument, as supported in v1.2
  1985. var i = (buf && offset) || 0;
  1986. if (typeof options == 'string') {
  1987. buf = options == 'binary' ? new Array(16) : null;
  1988. options = null;
  1989. }
  1990. options = options || {};
  1991. var rnds = options.random || (options.rng || _rng)();
  1992. // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  1993. rnds[6] = (rnds[6] & 0x0f) | 0x40;
  1994. rnds[8] = (rnds[8] & 0x3f) | 0x80;
  1995. // Copy bytes to buffer, if provided
  1996. if (buf) {
  1997. for (var ii = 0; ii < 16; ++ii) {
  1998. buf[i + ii] = rnds[ii];
  1999. }
  2000. }
  2001. return buf || buff_to_string(rnds);
  2002. }
  2003. // Export public API
  2004. var uuid = v4;
  2005. uuid.v1 = v1;
  2006. uuid.v4 = v4;
  2007. module.exports = uuid;
  2008. /***/
  2009. },
  2010. /* 25 */
  2011. /***/ function(module, exports, __webpack_require__) {
  2012. var rb = __webpack_require__(26).randomBytes;
  2013. module.exports = function() {
  2014. return rb(16);
  2015. };
  2016. /***/
  2017. },
  2018. /* 26 */
  2019. /***/ function(module, exports) {
  2020. module.exports = require('crypto');
  2021. /***/
  2022. },
  2023. /* 27 */
  2024. /***/ function(module, exports) {
  2025. module.exports = require('domain');
  2026. /***/
  2027. },
  2028. /* 28 */
  2029. /***/ function(module, exports) {
  2030. module.exports = require('module');
  2031. /***/
  2032. },
  2033. /* 29 */
  2034. /***/ function(module, exports, __webpack_require__) {
  2035. var map = {
  2036. './console': 12,
  2037. './console.js': 12,
  2038. './http': 13,
  2039. './http.js': 13,
  2040. './instrumentor': 4,
  2041. './instrumentor.js': 4,
  2042. './pg': 14,
  2043. './pg.js': 14,
  2044. };
  2045. function webpackContext(req) {
  2046. return __webpack_require__(webpackContextResolve(req));
  2047. }
  2048. function webpackContextResolve(req) {
  2049. var id = map[req];
  2050. if (!(id + 1))
  2051. // check for number or string
  2052. throw new Error("Cannot find module '" + req + "'.");
  2053. return id;
  2054. }
  2055. webpackContext.keys = function webpackContextKeys() {
  2056. return Object.keys(map);
  2057. };
  2058. webpackContext.resolve = webpackContextResolve;
  2059. module.exports = webpackContext;
  2060. webpackContext.id = 29;
  2061. /***/
  2062. },
  2063. /* 30 */
  2064. /***/ function(module, exports) {
  2065. module.exports = require('console');
  2066. /***/
  2067. },
  2068. /* 31 */
  2069. /***/ function(module, exports) {
  2070. module.exports = require('os');
  2071. /***/
  2072. },
  2073. /* 32 */
  2074. /***/ function(module, exports, __webpack_require__) {
  2075. var bar = __webpack_require__(33);
  2076. function foo() {
  2077. bar();
  2078. }
  2079. module.exports = foo;
  2080. /***/
  2081. },
  2082. /* 33 */
  2083. /***/ function(module, exports, __webpack_require__) {
  2084. var path = __webpack_require__(2);
  2085. module.exports = function bar() {
  2086. throw new Error(path.join('foo', 'bar'));
  2087. };
  2088. /***/
  2089. },
  2090. /******/
  2091. ]
  2092. );
  2093. //# sourceMappingURL=dist.bundle.js.map