UNPKG

logrocket

Version:

JavaScript SDK for [LogRocket](https://logrocket.com/)

1,551 lines (1,304 loc) 89.8 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else { var a = factory(); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 8); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = mapValues; function mapValues(obj, f) { if (obj == null) { return {}; } var res = {}; Object.keys(obj).forEach(function (key) { res[key] = f(obj[key]); }); return res; } /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setActive = setActive; exports.default = registerXHR; var _mapValues = __webpack_require__(0); var _mapValues2 = _interopRequireDefault(_mapValues); var _enhanceFunc = __webpack_require__(2); var _enhanceFunc2 = _interopRequireDefault(_enhanceFunc); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var isActive = true; function setActive(shouldBeActive) { isActive = shouldBeActive; } var currentXHRId = 0; function registerXHR(_ref) { var addRequest = _ref.addRequest, addResponse = _ref.addResponse, _ref$shouldCloneRespo = _ref.shouldCloneResponse, shouldCloneResponse = _ref$shouldCloneRespo === undefined ? false : _ref$shouldCloneRespo; var _XHR = XMLHttpRequest; var xhrMap = new WeakMap(); var unsubscribedFromXhr = false; var LOGROCKET_XHR_LABEL = 'xhr-'; window._lrXMLHttpRequest = XMLHttpRequest; // eslint-disable-next-line no-native-reassign XMLHttpRequest = function XMLHttpRequest(mozAnon, mozSystem) { var xhrObject = new _XHR(mozAnon, mozSystem); if (!isActive) { return xhrObject; } xhrMap.set(xhrObject, { xhrId: ++currentXHRId, headers: {} }); // ..., 'open', (method, url, async, username, password) => { (0, _enhanceFunc2.default)(xhrObject, 'open', function (method, url) { if (unsubscribedFromXhr) return; var currentXHR = xhrMap.get(xhrObject); currentXHR.method = method; currentXHR.url = url; }); (0, _enhanceFunc2.default)(xhrObject, 'send', function (data) { if (unsubscribedFromXhr) return; var currentXHR = xhrMap.get(xhrObject); if (!currentXHR) return; var request = { url: currentXHR.url, method: currentXHR.method && currentXHR.method.toUpperCase(), headers: (0, _mapValues2.default)(currentXHR.headers || {}, function (headerValues) { return headerValues.join(', '); }), body: data }; addRequest('' + LOGROCKET_XHR_LABEL + currentXHR.xhrId, request); }); (0, _enhanceFunc2.default)(xhrObject, 'setRequestHeader', function (header, value) { if (unsubscribedFromXhr) return; var currentXHR = xhrMap.get(xhrObject); if (!currentXHR) return; currentXHR.headers = currentXHR.headers || {}; currentXHR.headers[header] = currentXHR.headers[header] || []; currentXHR.headers[header].push(value); }); var xhrListeners = { readystatechange: function readystatechange() { if (unsubscribedFromXhr) return; if (xhrObject.readyState === 4) { var currentXHR = xhrMap.get(xhrObject); if (!currentXHR) return; var headerString = xhrObject.getAllResponseHeaders(); var headers = headerString.split(/[\r\n]+/).reduce(function (previous, current) { var next = previous; var headerParts = current.split(': '); if (headerParts.length > 0) { var key = headerParts.shift(); // first index of the array var value = headerParts.join(': '); // rest of the array repaired if (previous[key]) { next[key] += ', ' + value; } else { next[key] = value; } } return next; }, {}); var body = void 0; // IE 11 sometimes throws when trying to access large responses try { switch (xhrObject.responseType) { case 'json': body = shouldCloneResponse ? JSON.parse(JSON.stringify(xhrObject.response)) : xhrObject.response; break; case 'arraybuffer': case 'blob': { body = xhrObject.response; break; } case 'document': { body = xhrObject.responseXML; break; } case 'text': case '': { body = xhrObject.responseText; break; } default: { body = ''; } } } catch (err) { body = 'LogRocket: Error accessing response.'; } var response = { url: currentXHR.url, status: xhrObject.status, headers: headers, body: body, method: (currentXHR.method || '').toUpperCase() }; addResponse('' + LOGROCKET_XHR_LABEL + currentXHR.xhrId, response); } } // // Unused Event Listeners // loadstart: () => {}, // progress: () => {}, // abort: () => {}, // error: () => {}, // load: () => {}, // timeout: () => {}, // loadend: () => {}, }; Object.keys(xhrListeners).forEach(function (key) { xhrObject.addEventListener(key, xhrListeners[key]); }); return xhrObject; }; // this allows "instanceof XMLHttpRequest" to work XMLHttpRequest.prototype = _XHR.prototype; // Persist the static variables. ['UNSENT', 'OPENED', 'HEADERS_RECEIVED', 'LOADING', 'DONE'].forEach(function (variable) { XMLHttpRequest[variable] = _XHR[variable]; }); return function () { unsubscribedFromXhr = true; // eslint-disable-next-line no-native-reassign XMLHttpRequest = _XHR; }; } /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = enhanceFunc; /* eslint no-param-reassign: ["error", { "props": false }] */ function enhanceFunc(obj, method, handler) { var original = obj[method]; function shim() { var res = void 0; for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (original) { res = original.apply(this, args); } handler.apply(this, args); return res; } obj[method] = shim; return function () { obj[method] = original; }; } /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Capture = exports.registerExceptions = undefined; var _registerExceptions = __webpack_require__(15); var _registerExceptions2 = _interopRequireDefault(_registerExceptions); var _Capture = __webpack_require__(6); var Capture = _interopRequireWildcard(_Capture); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.registerExceptions = _registerExceptions2.default; exports.Capture = Capture; /***/ }), /* 4 */ /***/ (function(module, exports) { var g; // This works in non-strict mode g = (function() { return this; })(); try { // This works if eval is allowed (see CSP) g = g || Function("return this")() || (1, eval)("this"); } catch (e) { // This works if the window reference is available if (typeof window === "object") g = window; } // g can still be undefined, but nothing to do about it... // We return undefined, instead of nothing here, so it's // easier to handle this case. if(!global) { ...} module.exports = g; /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(global) {/* eslint-disable */ /* TraceKit - Cross brower stack traces - github.com/occ/TraceKit This was originally forked from github.com/occ/TraceKit, but has since been largely re-written and is now maintained as part of raven-js. Tests for this are in test/vendor. MIT license */ var TraceKit = { collectWindowErrors: true, debug: false }; // This is to be defensive in environments where window does not exist (see https://github.com/getsentry/raven-js/pull/785) var _window = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; // global reference to slice var _slice = [].slice; var UNKNOWN_FUNCTION = '?'; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types var ERROR_TYPES_RE = /^(?:Uncaught (?:exception: )?)?((?:Eval|Internal|Range|Reference|Syntax|Type|URI)Error): ?(.*)$/; function getLocationHref() { if (typeof document === 'undefined' || typeof document.location === 'undefined') return ''; return document.location.href; } /** * TraceKit.report: cross-browser processing of unhandled exceptions * * Syntax: * TraceKit.report.subscribe(function(stackInfo) { ... }) * TraceKit.report.unsubscribe(function(stackInfo) { ... }) * TraceKit.report(exception) * try { ...code... } catch(ex) { TraceKit.report(ex); } * * Supports: * - Firefox: full stack trace with line numbers, plus column number * on top frame; column number is not guaranteed * - Opera: full stack trace with line and column numbers * - Chrome: full stack trace with line and column numbers * - Safari: line and column number for the top frame only; some frames * may be missing, and column number is not guaranteed * - IE: line and column number for the top frame only; some frames * may be missing, and column number is not guaranteed * * In theory, TraceKit should work on all of the following versions: * - IE5.5+ (only 8.0 tested) * - Firefox 0.9+ (only 3.5+ tested) * - Opera 7+ (only 10.50 tested; versions 9 and earlier may require * Exceptions Have Stacktrace to be enabled in opera:config) * - Safari 3+ (only 4+ tested) * - Chrome 1+ (only 5+ tested) * - Konqueror 3.5+ (untested) * * Requires TraceKit.computeStackTrace. * * Tries to catch all unhandled exceptions and report them to the * subscribed handlers. Please note that TraceKit.report will rethrow the * exception. This is REQUIRED in order to get a useful stack trace in IE. * If the exception does not reach the top of the browser, you will only * get a stack trace from the point where TraceKit.report was called. * * Handlers receive a stackInfo object as described in the * TraceKit.computeStackTrace docs. */ TraceKit.report = function reportModuleWrapper() { var handlers = [], lastArgs = null, lastException = null, lastExceptionStack = null; /** * Add a crash handler. * @param {Function} handler */ function subscribe(handler) { installGlobalHandler(); handlers.push(handler); } /** * Remove a crash handler. * @param {Function} handler */ function unsubscribe(handler) { for (var i = handlers.length - 1; i >= 0; --i) { if (handlers[i] === handler) { handlers.splice(i, 1); } } } /** * Remove all crash handlers. */ function unsubscribeAll() { uninstallGlobalHandler(); handlers = []; } /** * Dispatch stack information to all handlers. * @param {Object.<string, *>} stack */ function notifyHandlers(stack, isWindowError) { var exception = null; if (isWindowError && !TraceKit.collectWindowErrors) { return; } for (var i in handlers) { if (handlers.hasOwnProperty(i)) { try { handlers[i].apply(null, [stack].concat(_slice.call(arguments, 2))); } catch (inner) { exception = inner; } } } if (exception) { throw exception; } } var _oldOnerrorHandler, _onErrorHandlerInstalled; /** * Ensures all global unhandled exceptions are recorded. * Supported by Gecko and IE. * @param {string} message Error message. * @param {string} url URL of script that generated the exception. * @param {(number|string)} lineNo The line number at which the error * occurred. * @param {?(number|string)} colNo The column number at which the error * occurred. * @param {?Error} ex The actual Error object. */ function traceKitWindowOnError(message, url, lineNo, colNo, ex) { var stack = null; if (lastExceptionStack) { TraceKit.computeStackTrace.augmentStackTraceWithInitialElement(lastExceptionStack, url, lineNo, message); processLastException(); } else if (ex) { // New chrome and blink send along a real error object // Let's just report that like a normal error. // See: https://mikewest.org/2013/08/debugging-runtime-errors-with-window-onerror stack = TraceKit.computeStackTrace(ex); notifyHandlers(stack, true); } else { var location = { 'url': url, 'line': lineNo, 'column': colNo }; var name = undefined; var msg = message; // must be new var or will modify original `arguments` var groups; if ({}.toString.call(message) === '[object String]') { var groups = message.match(ERROR_TYPES_RE); if (groups) { name = groups[1]; msg = groups[2]; } } location.func = UNKNOWN_FUNCTION; stack = { 'name': name, 'message': msg, 'url': getLocationHref(), 'stack': [location] }; notifyHandlers(stack, true); } if (_oldOnerrorHandler) { return _oldOnerrorHandler.apply(this, arguments); } return false; } function installGlobalHandler() { if (_onErrorHandlerInstalled) { return; } _oldOnerrorHandler = _window.onerror; _window.onerror = traceKitWindowOnError; _onErrorHandlerInstalled = true; } function uninstallGlobalHandler() { if (!_onErrorHandlerInstalled) { return; } _window.onerror = _oldOnerrorHandler; _onErrorHandlerInstalled = false; _oldOnerrorHandler = undefined; } function processLastException() { var _lastExceptionStack = lastExceptionStack, _lastArgs = lastArgs; lastArgs = null; lastExceptionStack = null; lastException = null; notifyHandlers.apply(null, [_lastExceptionStack, false].concat(_lastArgs)); } /** * Reports an unhandled Error to TraceKit. * @param {Error} ex * @param {?boolean} rethrow If false, do not re-throw the exception. * Only used for window.onerror to not cause an infinite loop of * rethrowing. */ function report(ex, rethrow) { var args = _slice.call(arguments, 1); if (lastExceptionStack) { if (lastException === ex) { return; // already caught by an inner catch block, ignore } else { processLastException(); } } var stack = TraceKit.computeStackTrace(ex); lastExceptionStack = stack; lastException = ex; lastArgs = args; // If the stack trace is incomplete, wait for 2 seconds for // slow slow IE to see if onerror occurs or not before reporting // this exception; otherwise, we will end up with an incomplete // stack trace setTimeout(function () { if (lastException === ex) { processLastException(); } }, stack.incomplete ? 2000 : 0); if (rethrow !== false) { throw ex; // re-throw to propagate to the top level (and cause window.onerror) } } report.subscribe = subscribe; report.unsubscribe = unsubscribe; report.uninstall = unsubscribeAll; return report; }(); /** * TraceKit.computeStackTrace: cross-browser stack traces in JavaScript * * Syntax: * s = TraceKit.computeStackTrace(exception) // consider using TraceKit.report instead (see below) * Returns: * s.name - exception name * s.message - exception message * s.stack[i].url - JavaScript or HTML file URL * s.stack[i].func - function name, or empty for anonymous functions (if guessing did not work) * s.stack[i].args - arguments passed to the function, if known * s.stack[i].line - line number, if known * s.stack[i].column - column number, if known * * Supports: * - Firefox: full stack trace with line numbers and unreliable column * number on top frame * - Opera 10: full stack trace with line and column numbers * - Opera 9-: full stack trace with line numbers * - Chrome: full stack trace with line and column numbers * - Safari: line and column number for the topmost stacktrace element * only * - IE: no line numbers whatsoever * * Tries to guess names of anonymous functions by looking for assignments * in the source code. In IE and Safari, we have to guess source file names * by searching for function bodies inside all page scripts. This will not * work for scripts that are loaded cross-domain. * Here be dragons: some function names may be guessed incorrectly, and * duplicate functions may be mismatched. * * TraceKit.computeStackTrace should only be used for tracing purposes. * Logging of unhandled exceptions should be done with TraceKit.report, * which builds on top of TraceKit.computeStackTrace and provides better * IE support by utilizing the window.onerror event to retrieve information * about the top of the stack. * * Note: In IE and Safari, no stack trace is recorded on the Error object, * so computeStackTrace instead walks its *own* chain of callers. * This means that: * * in Safari, some methods may be missing from the stack trace; * * in IE, the topmost function in the stack trace will always be the * caller of computeStackTrace. * * This is okay for tracing (because you are likely to be calling * computeStackTrace from the function you want to be the topmost element * of the stack trace anyway), but not okay for logging unhandled * exceptions (because your catch block will likely be far away from the * inner function that actually caused the exception). * */ TraceKit.computeStackTrace = function computeStackTraceWrapper() { /** * Escapes special characters, except for whitespace, in a string to be * used inside a regular expression as a string literal. * @param {string} text The string. * @return {string} The escaped string literal. */ function escapeRegExp(text) { return text.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g, '\\$&'); } /** * Escapes special characters in a string to be used inside a regular * expression as a string literal. Also ensures that HTML entities will * be matched the same as their literal friends. * @param {string} body The string. * @return {string} The escaped string. */ function escapeCodeAsRegExpForMatchingInsideHTML(body) { return escapeRegExp(body).replace('<', '(?:<|&lt;)').replace('>', '(?:>|&gt;)').replace('&', '(?:&|&amp;)').replace('"', '(?:"|&quot;)').replace(/\s+/g, '\\s+'); } // Contents of Exception in various browsers. // // SAFARI: // ex.message = Can't find variable: qq // ex.line = 59 // ex.sourceId = 580238192 // ex.sourceURL = http://... // ex.expressionBeginOffset = 96 // ex.expressionCaretOffset = 98 // ex.expressionEndOffset = 98 // ex.name = ReferenceError // // FIREFOX: // ex.message = qq is not defined // ex.fileName = http://... // ex.lineNumber = 59 // ex.columnNumber = 69 // ex.stack = ...stack trace... (see the example below) // ex.name = ReferenceError // // CHROME: // ex.message = qq is not defined // ex.name = ReferenceError // ex.type = not_defined // ex.arguments = ['aa'] // ex.stack = ...stack trace... // // INTERNET EXPLORER: // ex.message = ... // ex.name = ReferenceError // // OPERA: // ex.message = ...message... (see the example below) // ex.name = ReferenceError // ex.opera#sourceloc = 11 (pretty much useless, duplicates the info in ex.message) // ex.stacktrace = n/a; see 'opera:config#UserPrefs|Exceptions Have Stacktrace' /** * Computes stack trace information from the stack property. * Chrome and Gecko use this property. * @param {Error} ex * @return {?Object.<string, *>} Stack trace information. */ function computeStackTraceFromStackProp(ex) { if (typeof ex.stack === 'undefined' || !ex.stack) return; var chrome = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|<anonymous>).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i, gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|resource|\[native).*?)(?::(\d+))?(?::(\d+))?\s*$/i, winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i, lines = ex.stack.split('\n'), stack = [], parts, element, reference = /^(.*) is undefined$/.exec(ex.message); for (var i = 0, j = lines.length; i < j; ++i) { if (parts = chrome.exec(lines[i])) { var isNative = parts[2] && parts[2].indexOf('native') !== -1; element = { 'url': !isNative ? parts[2] : null, 'func': parts[1] || UNKNOWN_FUNCTION, 'args': isNative ? [parts[2]] : [], 'line': parts[3] ? +parts[3] : null, 'column': parts[4] ? +parts[4] : null }; } else if (parts = winjs.exec(lines[i])) { element = { 'url': parts[2], 'func': parts[1] || UNKNOWN_FUNCTION, 'args': [], 'line': +parts[3], 'column': parts[4] ? +parts[4] : null }; } else if (parts = gecko.exec(lines[i])) { element = { 'url': parts[3], 'func': parts[1] || UNKNOWN_FUNCTION, 'args': parts[2] ? parts[2].split(',') : [], 'line': parts[4] ? +parts[4] : null, 'column': parts[5] ? +parts[5] : null }; } else { continue; } if (!element.func && element.line) { element.func = UNKNOWN_FUNCTION; } stack.push(element); } if (!stack.length) { return null; } if (!stack[0].column && typeof ex.columnNumber !== 'undefined') { // FireFox uses this awesome columnNumber property for its top frame // Also note, Firefox's column number is 0-based and everything else expects 1-based, // so adding 1 stack[0].column = ex.columnNumber + 1; } return { 'name': ex.name, 'message': ex.message, 'url': getLocationHref(), 'stack': stack }; } /** * Adds information about the first frame to incomplete stack traces. * Safari and IE require this to get complete data on the first frame. * @param {Object.<string, *>} stackInfo Stack trace information from * one of the compute* methods. * @param {string} url The URL of the script that caused an error. * @param {(number|string)} lineNo The line number of the script that * caused an error. * @param {string=} message The error generated by the browser, which * hopefully contains the name of the object that caused the error. * @return {boolean} Whether or not the stack information was * augmented. */ function augmentStackTraceWithInitialElement(stackInfo, url, lineNo, message) { var initial = { 'url': url, 'line': lineNo }; if (initial.url && initial.line) { stackInfo.incomplete = false; if (!initial.func) { initial.func = UNKNOWN_FUNCTION; } if (stackInfo.stack.length > 0) { if (stackInfo.stack[0].url === initial.url) { if (stackInfo.stack[0].line === initial.line) { return false; // already in stack trace } else if (!stackInfo.stack[0].line && stackInfo.stack[0].func === initial.func) { stackInfo.stack[0].line = initial.line; return false; } } } stackInfo.stack.unshift(initial); stackInfo.partial = true; return true; } else { stackInfo.incomplete = true; } return false; } /** * Computes stack trace information by walking the arguments.caller * chain at the time the exception occurred. This will cause earlier * frames to be missed but is the only way to get any stack trace in * Safari and IE. The top frame is restored by * {@link augmentStackTraceWithInitialElement}. * @param {Error} ex * @return {?Object.<string, *>} Stack trace information. */ function computeStackTraceByWalkingCallerChain(ex, depth) { var functionName = /function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i, stack = [], funcs = {}, recursion = false, parts, item, source; for (var curr = computeStackTraceByWalkingCallerChain.caller; curr && !recursion; curr = curr.caller) { if (curr === computeStackTrace || curr === TraceKit.report) { // console.log('skipping internal function'); continue; } item = { 'url': null, 'func': UNKNOWN_FUNCTION, 'line': null, 'column': null }; if (curr.name) { item.func = curr.name; } else if (parts = functionName.exec(curr.toString())) { item.func = parts[1]; } if (typeof item.func === 'undefined') { try { item.func = parts.input.substring(0, parts.input.indexOf('{')); } catch (e) {} } if (funcs['' + curr]) { recursion = true; } else { funcs['' + curr] = true; } stack.push(item); } if (depth) { // console.log('depth is ' + depth); // console.log('stack is ' + stack.length); stack.splice(0, depth); } var result = { 'name': ex.name, 'message': ex.message, 'url': getLocationHref(), 'stack': stack }; augmentStackTraceWithInitialElement(result, ex.sourceURL || ex.fileName, ex.line || ex.lineNumber, ex.message || ex.description); return result; } /** * Computes a stack trace for an exception. * @param {Error} ex * @param {(string|number)=} depth */ function computeStackTrace(ex, depth) { var stack = null; depth = depth == null ? 0 : +depth; try { stack = computeStackTraceFromStackProp(ex); if (stack) { return stack; } } catch (e) { if (TraceKit.debug) { throw e; } } try { stack = computeStackTraceByWalkingCallerChain(ex, depth + 1); if (stack) { return stack; } } catch (e) { if (TraceKit.debug) { throw e; } } return { 'name': ex.name, 'message': ex.message, 'url': getLocationHref() }; } computeStackTrace.augmentStackTraceWithInitialElement = augmentStackTraceWithInitialElement; computeStackTrace.computeStackTraceFromStackProp = computeStackTraceFromStackProp; return computeStackTrace; }(); module.exports = TraceKit; /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4))) /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /* eslint-disable no-param-reassign */ exports.captureMessage = captureMessage; exports.captureException = captureException; var _TraceKit = __webpack_require__(5); var _TraceKit2 = _interopRequireDefault(_TraceKit); var _stackTraceFromError = __webpack_require__(17); var _stackTraceFromError2 = _interopRequireDefault(_stackTraceFromError); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function isScalar(value) { return (/boolean|number|string/.test(typeof value === 'undefined' ? 'undefined' : _typeof(value)) ); } function scrub(data, options) { if (options) { var optionalScalars = [ // Valid values for 'level' are 'fatal', 'error', 'warning', 'info', // and 'debug'. Defaults to 'error'. 'level', 'logger']; var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = optionalScalars[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var field = _step.value; var value = options[field]; if (isScalar(value)) { data[field] = value.toString(); } } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } var optionalMaps = ['tags', 'extra']; var _iteratorNormalCompletion2 = true; var _didIteratorError2 = false; var _iteratorError2 = undefined; try { for (var _iterator2 = optionalMaps[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { var _field = _step2.value; var dirty = options[_field] || {}; var scrubbed = {}; var _iteratorNormalCompletion3 = true; var _didIteratorError3 = false; var _iteratorError3 = undefined; try { for (var _iterator3 = Object.keys(dirty)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { var key = _step3.value; var _value = dirty[key]; if (isScalar(_value)) { scrubbed[key.toString()] = _value.toString(); } } } catch (err) { _didIteratorError3 = true; _iteratorError3 = err; } finally { try { if (!_iteratorNormalCompletion3 && _iterator3.return) { _iterator3.return(); } } finally { if (_didIteratorError3) { throw _iteratorError3; } } } data[_field] = scrubbed; } } catch (err) { _didIteratorError2 = true; _iteratorError2 = err; } finally { try { if (!_iteratorNormalCompletion2 && _iterator2.return) { _iterator2.return(); } } finally { if (_didIteratorError2) { throw _iteratorError2; } } } } } function captureMessage(logger, message) { var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var isConsole = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; var data = { exceptionType: isConsole ? 'CONSOLE' : 'MESSAGE', message: message, browserHref: window.location.href }; scrub(data, options); logger.addEvent('lr.core.Exception', function () { return data; }); } function captureException(logger, exception) { var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var preppedTrace = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; var trace = preppedTrace || _TraceKit2.default.computeStackTrace(exception); var data = { exceptionType: 'WINDOW', errorType: trace.name, message: trace.message, browserHref: window.location.href }; scrub(data, options); var addEventOptions = { _stackTrace: (0, _stackTraceFromError2.default)(trace) }; logger.addEvent('lr.core.Exception', function () { return data; }, addEventOptions); } /***/ }), /* 7 */ /***/ (function(module, exports) { Object.defineProperty(exports,"__esModule",{value:true});var dateNow=Date.now.bind(Date);var loadTime=dateNow();exports.default=typeof performance!=='undefined'&&performance.now?performance.now.bind(performance):function(){return dateNow()-loadTime;};module.exports=exports['default']; /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(9); /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = setup; var _makeLogRocket = __webpack_require__(10); var _makeLogRocket2 = _interopRequireDefault(_makeLogRocket); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } var CDN_SERVER_MAP = { 'cdn.logrocket.io': 'https://r.logrocket.io', 'cdn.lr-ingest.io': 'https://r.lr-ingest.io', 'cdn-staging.logrocket.io': 'https://staging-i.logrocket.io', 'cdn-staging.lr-ingest.io': 'https://staging-i.lr-ingest.io' }; function setup() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var enterpriseServer = _ref.enterpriseServer, _ref$sdkVersion = _ref.sdkVersion, sdkVersion = _ref$sdkVersion === undefined ? "1.0.6" : _ref$sdkVersion, opts = _objectWithoutProperties(_ref, ['enterpriseServer', 'sdkVersion']); var scriptOrigin = undefined === 'staging' ? 'https://cdn-staging.logrocket.io' : 'https://cdn.logrocket.io'; var scriptIngest = void 0; if (sdkVersion === 'script') { try { var scriptTag = document.currentScript; var matches = scriptTag.src.match(/^(https?:\/\/([^\\]+))\/.+$/); var scriptHostname = matches && matches[2]; if (scriptHostname && CDN_SERVER_MAP[scriptHostname]) { scriptOrigin = matches && matches[1]; scriptIngest = CDN_SERVER_MAP[scriptHostname]; } } catch (_) { /* no-op */ } } else { // NPM scriptOrigin = undefined === 'staging' ? 'https://cdn-staging.lr-ingest.io' : 'https://cdn.lr-ingest.io'; scriptIngest = undefined === 'staging' ? 'https://staging-i.lr-ingest.io' : 'https://r.lr-ingest.io'; } var sdkServer = opts.sdkServer || enterpriseServer; var ingestServer = opts.ingestServer || enterpriseServer || scriptIngest; var instance = (0, _makeLogRocket2.default)(function () { var script = document.createElement('script'); if (ingestServer) { if (typeof window.__SDKCONFIG__ === 'undefined') { window.__SDKCONFIG__ = {}; } window.__SDKCONFIG__.serverURL = ingestServer + '/i'; window.__SDKCONFIG__.statsURL = ingestServer + '/s'; } if (sdkServer) { script.src = sdkServer + '/logger.min.js'; } else if (window.__SDKCONFIG__ && window.__SDKCONFIG__.loggerURL) { script.src = window.__SDKCONFIG__.loggerURL; } else if (window._lrAsyncScript) { script.src = window._lrAsyncScript; } else { script.src = scriptOrigin + '/logger.min.js'; } script.async = true; document.head.appendChild(script); script.onload = function () { // Brave browser: Advertises its user-agent as Chrome ##.##... then // loads logger.min.js, but blocks the execution of the script // causing _LRlogger to be undefined. Let's make sure its there first. if (typeof window._LRLogger === 'function') { instance.onLogger(new window._LRLogger({ sdkVersion: sdkVersion })); } else { console.warn('LogRocket: script execution has been blocked by a product or service.'); instance.uninstall(); } }; script.onerror = function () { console.warn('LogRocket: script could not load. Check that you have a valid network connection.'); instance.uninstall(); }; }); return instance; } module.exports = exports['default']; /***/ }), /* 10 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = makeLogRocket; var _LogRocket = __webpack_require__(11); var _LogRocket2 = _interopRequireDefault(_LogRocket); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var REACT_NATIVE_NOTICE = 'LogRocket does not yet support React Native.'; var makeNoopPolyfill = function makeNoopPolyfill() { return { init: function init() {}, uninstall: function uninstall() {}, log: function log() {}, info: function info() {}, warn: function warn() {}, error: function error() {}, debug: function debug() {}, addEvent: function addEvent() {}, identify: function identify() {}, start: function start() {}, get threadID() { return null; }, get recordingID() { return null; }, get recordingURL() { return null; }, reduxEnhancer: function reduxEnhancer() { return function (store) { return function () { return store.apply(undefined, arguments); }; }; }, reduxMiddleware: function reduxMiddleware() { return function () { return function (next) { return function (action) { return next(action); }; }; }; }, track: function track() {}, getSessionURL: function getSessionURL() {}, getVersion: function getVersion() {}, startNewSession: function startNewSession() {}, onLogger: function onLogger() {}, setClock: function setClock() {}, captureMessage: function captureMessage() {}, captureException: function captureException() {} }; }; function makeLogRocket() { var getLogger = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {}; if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { throw new Error(REACT_NATIVE_NOTICE); } if (typeof window !== 'undefined') { if (window._disableLogRocket) { return makeNoopPolyfill(); } if (window.MutationObserver && window.WeakMap) { // Save window globals that we rely on. window._lrMutationObserver = window.MutationObserver; var instance = new _LogRocket2.default(); getLogger(instance); return instance; } } return makeNoopPolyfill(); } module.exports = exports['default']; /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MAX_QUEUE_SIZE = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _logrocketNetwork = __webpack_require__(12); var _logrocketNetwork2 = _interopRequireDefault(_logrocketNetwork); var _logrocketExceptions = __webpack_require__(3); var _logrocketConsole = __webpack_require__(18); var _logrocketConsole2 = _interopRequireDefault(_logrocketConsole); var _logrocketRedux = __webpack_require__(20); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } var MAX_QUEUE_SIZE = exports.MAX_QUEUE_SIZE = 1000; var considerIngestServerOption = function considerIngestServerOption() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var ingestServer = _ref.ingestServer, options = _objectWithoutProperties(_ref, ['ingestServer']); if (ingestServer) { return _extends({ serverURL: ingestServer + '/i', statsURL: ingestServer + '/s' }, options); } return options; }; var LogRocket = function () { function LogRocket() { var _this = this; _classCallCheck(this, LogRocket); this._buffer = []; // TODO: tests for these exposed methods. ['log', 'info', 'warn', 'error', 'debug'].forEach(function (method) { _this[method] = function () { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this.addEvent('lr.core.LogEvent', function () { var consoleOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; if (method === 'error' && consoleOptions.shouldAggregateConsoleErrors) { _logrocketExceptions.Capture.captureMessage(_this, args[0], {}, true); } return { logLevel: method.toUpperCase(), args: args }; }, { shouldCaptureStackTrace: true }); }; }); this._isInitialized = false; this._installed = []; } _createClass(LogRocket, [{ key: 'addEvent', value: function addEvent(type, getMessage) { var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var time = Date.now(); this._run(function (logger) { logger.addEvent(type, getMessage, _extends({}, opts, { timeOverride: time })); }); } }, { key: 'onLogger', value: function onLogger(logger) { this._logger = logger; while (this._buffer.length > 0) { var f = this._buffer.shift(); f(this._logger); } } }, { key: '_run', value: function _run(f) { if (this._isDisabled) { return; } if (this._logger) { f(this._logger); } else { if (this._buffer.length >= MAX_QUEUE_SIZE) { this._isDisabled = true; console.warn('LogRocket: script did not load. Check that you have a valid network connection.'); this.uninstall(); return; } this._buffer.push(f.bind(this)); } } }, { key: 'init', value: function init(appID, opts) { if (!this._isInitialized) { this._installed.push((0, _logrocketExceptions.registerExceptions)(this)); this._installed.push((0, _logrocketNetwork2.default)(this)); this._installed.push((0, _logrocketConsole2.default)(this)); this._isInitialized = true; this._run(function (logger) { logger.init(appID, considerIngestServerOption(opts)); }); } } }, { key: 'start', value: function start() { this._run(function (logger) { logger.start(); }); } }, { ke