rollbar
Version:
Effortlessly track and debug errors in your JavaScript applications with Rollbar. This package includes advanced error tracking features and an intuitive interface to help you identify and fix issues more quickly.
1,795 lines (1,553 loc) • 204 kB
JavaScript
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 12:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var _ = __webpack_require__(539);
function traverse(obj, func, seen) {
var k, v, i;
var isObj = _.isType(obj, 'object');
var isArray = _.isType(obj, 'array');
var keys = [];
var seenIndex;
// Best might be to use Map here with `obj` as the keys, but we want to support IE < 11.
seen = seen || { obj: [], mapped: [] };
if (isObj) {
seenIndex = seen.obj.indexOf(obj);
if (isObj && seenIndex !== -1) {
// Prefer the mapped object if there is one.
return seen.mapped[seenIndex] || seen.obj[seenIndex];
}
seen.obj.push(obj);
seenIndex = seen.obj.length - 1;
}
if (isObj) {
for (k in obj) {
if (Object.prototype.hasOwnProperty.call(obj, k)) {
keys.push(k);
}
}
} else if (isArray) {
for (i = 0; i < obj.length; ++i) {
keys.push(i);
}
}
var result = isObj ? {} : [];
var same = true;
for (i = 0; i < keys.length; ++i) {
k = keys[i];
v = obj[k];
result[k] = func(k, v, seen);
same = same && result[k] === obj[k];
}
if (isObj && !same) {
seen.mapped[seenIndex] = result;
}
return !same ? result : obj;
}
module.exports = traverse;
/***/ }),
/***/ 61:
/***/ ((module) => {
"use strict";
// See https://nodejs.org/docs/latest/api/url.html
function parse(url) {
var result = {
protocol: null,
auth: null,
host: null,
path: null,
hash: null,
href: url,
hostname: null,
port: null,
pathname: null,
search: null,
query: null,
};
var i, last;
i = url.indexOf('//');
if (i !== -1) {
result.protocol = url.substring(0, i);
last = i + 2;
} else {
last = 0;
}
i = url.indexOf('@', last);
if (i !== -1) {
result.auth = url.substring(last, i);
last = i + 1;
}
i = url.indexOf('/', last);
if (i === -1) {
i = url.indexOf('?', last);
if (i === -1) {
i = url.indexOf('#', last);
if (i === -1) {
result.host = url.substring(last);
} else {
result.host = url.substring(last, i);
result.hash = url.substring(i);
}
result.hostname = result.host.split(':')[0];
result.port = result.host.split(':')[1];
if (result.port) {
result.port = parseInt(result.port, 10);
}
return result;
} else {
result.host = url.substring(last, i);
result.hostname = result.host.split(':')[0];
result.port = result.host.split(':')[1];
if (result.port) {
result.port = parseInt(result.port, 10);
}
last = i;
}
} else {
result.host = url.substring(last, i);
result.hostname = result.host.split(':')[0];
result.port = result.host.split(':')[1];
if (result.port) {
result.port = parseInt(result.port, 10);
}
last = i;
}
i = url.indexOf('#', last);
if (i === -1) {
result.path = url.substring(last);
} else {
result.path = url.substring(last, i);
result.hash = url.substring(i);
}
if (result.path) {
var pathParts = result.path.split('?');
result.pathname = pathParts[0];
result.query = pathParts[1];
result.search = result.query ? '?' + result.query : null;
}
return result;
}
module.exports = {
parse: parse,
};
/***/ }),
/***/ 67:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var _ = __webpack_require__(539);
var helpers = __webpack_require__(91);
var defaultOptions = {
hostname: 'api.rollbar.com',
path: '/api/1/item/',
search: null,
version: '1',
protocol: 'https:',
port: 443,
};
/**
* Api is an object that encapsulates methods of communicating with
* the Rollbar API. It is a standard interface with some parts implemented
* differently for server or browser contexts. It is an object that should
* be instantiated when used so it can contain non-global options that may
* be different for another instance of RollbarApi.
*
* @param options {
* accessToken: the accessToken to use for posting items to rollbar
* endpoint: an alternative endpoint to send errors to
* must be a valid, fully qualified URL.
* The default is: https://api.rollbar.com/api/1/item
* proxy: if you wish to proxy requests provide an object
* with the following keys:
* host or hostname (required): foo.example.com
* port (optional): 123
* protocol (optional): https
* }
*/
function Api(options, transport, urllib, truncation, jsonBackup) {
this.options = options;
this.transport = transport;
this.url = urllib;
this.truncation = truncation;
this.jsonBackup = jsonBackup;
this.accessToken = options.accessToken;
this.transportOptions = _getTransport(options, urllib);
}
/**
*
* @param data
* @param callback
*/
Api.prototype.postItem = function (data, callback) {
var transportOptions = helpers.transportOptions(
this.transportOptions,
'POST',
);
var payload = helpers.buildPayload(this.accessToken, data, this.jsonBackup);
var self = this;
// ensure the network request is scheduled after the current tick.
setTimeout(function () {
self.transport.post(self.accessToken, transportOptions, payload, callback);
}, 0);
};
/**
*
* @param data
* @param callback
*/
Api.prototype.buildJsonPayload = function (data, callback) {
var payload = helpers.buildPayload(this.accessToken, data, this.jsonBackup);
var stringifyResult;
if (this.truncation) {
stringifyResult = this.truncation.truncate(payload);
} else {
stringifyResult = _.stringify(payload);
}
if (stringifyResult.error) {
if (callback) {
callback(stringifyResult.error);
}
return null;
}
return stringifyResult.value;
};
/**
*
* @param jsonPayload
* @param callback
*/
Api.prototype.postJsonPayload = function (jsonPayload, callback) {
var transportOptions = helpers.transportOptions(
this.transportOptions,
'POST',
);
this.transport.postJsonPayload(
this.accessToken,
transportOptions,
jsonPayload,
callback,
);
};
Api.prototype.configure = function (options) {
var oldOptions = this.oldOptions;
this.options = _.merge(oldOptions, options);
this.transportOptions = _getTransport(this.options, this.url);
if (this.options.accessToken !== undefined) {
this.accessToken = this.options.accessToken;
}
return this;
};
function _getTransport(options, url) {
return helpers.getTransportFromOptions(options, defaultOptions, url);
}
module.exports = Api;
/***/ }),
/***/ 91:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var _ = __webpack_require__(539);
function buildPayload(accessToken, data, jsonBackup) {
if (!_.isType(data.context, 'string')) {
var contextResult = _.stringify(data.context, jsonBackup);
if (contextResult.error) {
data.context = "Error: could not serialize 'context'";
} else {
data.context = contextResult.value || '';
}
if (data.context.length > 255) {
data.context = data.context.substr(0, 255);
}
}
return {
access_token: accessToken,
data: data,
};
}
function getTransportFromOptions(options, defaults, url) {
var hostname = defaults.hostname;
var protocol = defaults.protocol;
var port = defaults.port;
var path = defaults.path;
var search = defaults.search;
var timeout = options.timeout;
var transport = detectTransport(options);
var proxy = options.proxy;
if (options.endpoint) {
var opts = url.parse(options.endpoint);
hostname = opts.hostname;
protocol = opts.protocol;
port = opts.port;
path = opts.pathname;
search = opts.search;
}
return {
timeout: timeout,
hostname: hostname,
protocol: protocol,
port: port,
path: path,
search: search,
proxy: proxy,
transport: transport,
};
}
function detectTransport(options) {
var gWindow =
(typeof window != 'undefined' && window) ||
(typeof self != 'undefined' && self);
var transport = options.defaultTransport || 'xhr';
if (typeof gWindow.fetch === 'undefined') transport = 'xhr';
if (typeof gWindow.XMLHttpRequest === 'undefined') transport = 'fetch';
return transport;
}
function transportOptions(transport, method) {
var protocol = transport.protocol || 'https:';
var port =
transport.port ||
(protocol === 'http:' ? 80 : protocol === 'https:' ? 443 : undefined);
var hostname = transport.hostname;
var path = transport.path;
var timeout = transport.timeout;
var transportAPI = transport.transport;
if (transport.search) {
path = path + transport.search;
}
if (transport.proxy) {
path = protocol + '//' + hostname + path;
hostname = transport.proxy.host || transport.proxy.hostname;
port = transport.proxy.port;
protocol = transport.proxy.protocol || protocol;
}
return {
timeout: timeout,
protocol: protocol,
hostname: hostname,
path: path,
port: port,
method: method,
transport: transportAPI,
};
}
function appendPathToPath(base, path) {
var baseTrailingSlash = /\/$/.test(base);
var pathBeginningSlash = /^\//.test(path);
if (baseTrailingSlash && pathBeginningSlash) {
path = path.substring(1);
} else if (!baseTrailingSlash && !pathBeginningSlash) {
path = '/' + path;
}
return base + path;
}
module.exports = {
buildPayload: buildPayload,
getTransportFromOptions: getTransportFromOptions,
transportOptions: transportOptions,
appendPathToPath: appendPathToPath,
};
/***/ }),
/***/ 108:
/***/ (function(module, exports) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) {
'use strict';
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
/* istanbul ignore next */
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}(this, function() {
'use strict';
function _isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function _capitalize(str) {
return str.charAt(0).toUpperCase() + str.substring(1);
}
function _getter(p) {
return function() {
return this[p];
};
}
var booleanProps = ['isConstructor', 'isEval', 'isNative', 'isToplevel'];
var numericProps = ['columnNumber', 'lineNumber'];
var stringProps = ['fileName', 'functionName', 'source'];
var arrayProps = ['args'];
var objectProps = ['evalOrigin'];
var props = booleanProps.concat(numericProps, stringProps, arrayProps, objectProps);
function StackFrame(obj) {
if (!obj) return;
for (var i = 0; i < props.length; i++) {
if (obj[props[i]] !== undefined) {
this['set' + _capitalize(props[i])](obj[props[i]]);
}
}
}
StackFrame.prototype = {
getArgs: function() {
return this.args;
},
setArgs: function(v) {
if (Object.prototype.toString.call(v) !== '[object Array]') {
throw new TypeError('Args must be an Array');
}
this.args = v;
},
getEvalOrigin: function() {
return this.evalOrigin;
},
setEvalOrigin: function(v) {
if (v instanceof StackFrame) {
this.evalOrigin = v;
} else if (v instanceof Object) {
this.evalOrigin = new StackFrame(v);
} else {
throw new TypeError('Eval Origin must be an Object or StackFrame');
}
},
toString: function() {
var fileName = this.getFileName() || '';
var lineNumber = this.getLineNumber() || '';
var columnNumber = this.getColumnNumber() || '';
var functionName = this.getFunctionName() || '';
if (this.getIsEval()) {
if (fileName) {
return '[eval] (' + fileName + ':' + lineNumber + ':' + columnNumber + ')';
}
return '[eval]:' + lineNumber + ':' + columnNumber;
}
if (functionName) {
return functionName + ' (' + fileName + ':' + lineNumber + ':' + columnNumber + ')';
}
return fileName + ':' + lineNumber + ':' + columnNumber;
}
};
StackFrame.fromString = function StackFrame$$fromString(str) {
var argsStartIndex = str.indexOf('(');
var argsEndIndex = str.lastIndexOf(')');
var functionName = str.substring(0, argsStartIndex);
var args = str.substring(argsStartIndex + 1, argsEndIndex).split(',');
var locationString = str.substring(argsEndIndex + 1);
if (locationString.indexOf('@') === 0) {
var parts = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(locationString, '');
var fileName = parts[1];
var lineNumber = parts[2];
var columnNumber = parts[3];
}
return new StackFrame({
functionName: functionName,
args: args || undefined,
fileName: fileName,
lineNumber: lineNumber || undefined,
columnNumber: columnNumber || undefined
});
};
for (var i = 0; i < booleanProps.length; i++) {
StackFrame.prototype['get' + _capitalize(booleanProps[i])] = _getter(booleanProps[i]);
StackFrame.prototype['set' + _capitalize(booleanProps[i])] = (function(p) {
return function(v) {
this[p] = Boolean(v);
};
})(booleanProps[i]);
}
for (var j = 0; j < numericProps.length; j++) {
StackFrame.prototype['get' + _capitalize(numericProps[j])] = _getter(numericProps[j]);
StackFrame.prototype['set' + _capitalize(numericProps[j])] = (function(p) {
return function(v) {
if (!_isNumber(v)) {
throw new TypeError(p + ' must be a Number');
}
this[p] = Number(v);
};
})(numericProps[j]);
}
for (var k = 0; k < stringProps.length; k++) {
StackFrame.prototype['get' + _capitalize(stringProps[k])] = _getter(stringProps[k]);
StackFrame.prototype['set' + _capitalize(stringProps[k])] = (function(p) {
return function(v) {
this[p] = String(v);
};
})(stringProps[k]);
}
return StackFrame;
}));
/***/ }),
/***/ 175:
/***/ ((module) => {
"use strict";
// This detection.js module is used to encapsulate any ugly browser/feature
// detection we may need to do.
// Figure out which version of IE we're using, if any.
// This is gleaned from http://stackoverflow.com/questions/5574842/best-way-to-check-for-ie-less-than-9-in-javascript-without-library
// Will return an integer on IE (i.e. 8)
// Will return undefined otherwise
function getIEVersion() {
var undef;
if (typeof document === 'undefined') {
return undef;
}
var v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
while (
((div.innerHTML = '<!--[if gt IE ' + ++v + ']><i></i><![endif]-->'), all[0])
);
return v > 4 ? v : undef;
}
var Detection = {
ieVersion: getIEVersion,
};
module.exports = Detection;
/***/ }),
/***/ 197:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var Client = __webpack_require__(335);
var _ = __webpack_require__(539);
var API = __webpack_require__(67);
var logger = __webpack_require__(306);
var globals = __webpack_require__(796);
var Transport = __webpack_require__(497);
var urllib = __webpack_require__(61);
var transforms = __webpack_require__(203);
var sharedTransforms = __webpack_require__(962);
var predicates = __webpack_require__(584);
var sharedPredicates = __webpack_require__(581);
var errorParser = __webpack_require__(342);
function Rollbar(options, client) {
this.options = _.handleOptions(defaultOptions, options, null, logger);
this.options._configuredOptions = options;
var Telemeter = this.components.telemeter;
var Instrumenter = this.components.instrumenter;
var polyfillJSON = this.components.polyfillJSON;
this.wrapGlobals = this.components.wrapGlobals;
this.scrub = this.components.scrub;
var truncation = this.components.truncation;
var transport = new Transport(truncation);
var api = new API(this.options, transport, urllib, truncation);
if (Telemeter) {
this.telemeter = new Telemeter(this.options);
}
this.client =
client || new Client(this.options, api, logger, this.telemeter, 'browser');
var gWindow = _gWindow();
var gDocument = typeof document != 'undefined' && document;
this.isChrome = gWindow.chrome && gWindow.chrome.runtime; // check .runtime to avoid Edge browsers
this.anonymousErrorsPending = 0;
addTransformsToNotifier(this.client.notifier, this, gWindow);
addPredicatesToQueue(this.client.queue);
this.setupUnhandledCapture();
if (Instrumenter) {
this.instrumenter = new Instrumenter(
this.options,
this.client.telemeter,
this,
gWindow,
gDocument,
);
this.instrumenter.instrument();
}
_.setupJSON(polyfillJSON);
// Used with rollbar-react for rollbar-react-native compatibility.
this.rollbar = this;
}
var _instance = null;
Rollbar.init = function (options, client) {
if (_instance) {
return _instance.global(options).configure(options);
}
_instance = new Rollbar(options, client);
return _instance;
};
Rollbar.prototype.components = {};
Rollbar.setComponents = function (components) {
Rollbar.prototype.components = components;
};
function handleUninitialized(maybeCallback) {
var message = 'Rollbar is not initialized';
logger.error(message);
if (maybeCallback) {
maybeCallback(new Error(message));
}
}
Rollbar.prototype.global = function (options) {
this.client.global(options);
return this;
};
Rollbar.global = function (options) {
if (_instance) {
return _instance.global(options);
} else {
handleUninitialized();
}
};
Rollbar.prototype.configure = function (options, payloadData) {
var oldOptions = this.options;
var payload = {};
if (payloadData) {
payload = { payload: payloadData };
}
this.options = _.handleOptions(oldOptions, options, payload, logger);
this.options._configuredOptions = _.handleOptions(
oldOptions._configuredOptions,
options,
payload,
);
this.client.configure(this.options, payloadData);
this.instrumenter && this.instrumenter.configure(this.options);
this.setupUnhandledCapture();
return this;
};
Rollbar.configure = function (options, payloadData) {
if (_instance) {
return _instance.configure(options, payloadData);
} else {
handleUninitialized();
}
};
Rollbar.prototype.lastError = function () {
return this.client.lastError;
};
Rollbar.lastError = function () {
if (_instance) {
return _instance.lastError();
} else {
handleUninitialized();
}
};
Rollbar.prototype.log = function () {
var item = this._createItem(arguments);
var uuid = item.uuid;
this.client.log(item);
return { uuid: uuid };
};
Rollbar.log = function () {
if (_instance) {
return _instance.log.apply(_instance, arguments);
} else {
var maybeCallback = _getFirstFunction(arguments);
handleUninitialized(maybeCallback);
}
};
Rollbar.prototype.debug = function () {
var item = this._createItem(arguments);
var uuid = item.uuid;
this.client.debug(item);
return { uuid: uuid };
};
Rollbar.debug = function () {
if (_instance) {
return _instance.debug.apply(_instance, arguments);
} else {
var maybeCallback = _getFirstFunction(arguments);
handleUninitialized(maybeCallback);
}
};
Rollbar.prototype.info = function () {
var item = this._createItem(arguments);
var uuid = item.uuid;
this.client.info(item);
return { uuid: uuid };
};
Rollbar.info = function () {
if (_instance) {
return _instance.info.apply(_instance, arguments);
} else {
var maybeCallback = _getFirstFunction(arguments);
handleUninitialized(maybeCallback);
}
};
Rollbar.prototype.warn = function () {
var item = this._createItem(arguments);
var uuid = item.uuid;
this.client.warn(item);
return { uuid: uuid };
};
Rollbar.warn = function () {
if (_instance) {
return _instance.warn.apply(_instance, arguments);
} else {
var maybeCallback = _getFirstFunction(arguments);
handleUninitialized(maybeCallback);
}
};
Rollbar.prototype.warning = function () {
var item = this._createItem(arguments);
var uuid = item.uuid;
this.client.warning(item);
return { uuid: uuid };
};
Rollbar.warning = function () {
if (_instance) {
return _instance.warning.apply(_instance, arguments);
} else {
var maybeCallback = _getFirstFunction(arguments);
handleUninitialized(maybeCallback);
}
};
Rollbar.prototype.error = function () {
var item = this._createItem(arguments);
var uuid = item.uuid;
this.client.error(item);
return { uuid: uuid };
};
Rollbar.error = function () {
if (_instance) {
return _instance.error.apply(_instance, arguments);
} else {
var maybeCallback = _getFirstFunction(arguments);
handleUninitialized(maybeCallback);
}
};
Rollbar.prototype.critical = function () {
var item = this._createItem(arguments);
var uuid = item.uuid;
this.client.critical(item);
return { uuid: uuid };
};
Rollbar.critical = function () {
if (_instance) {
return _instance.critical.apply(_instance, arguments);
} else {
var maybeCallback = _getFirstFunction(arguments);
handleUninitialized(maybeCallback);
}
};
Rollbar.prototype.buildJsonPayload = function (item) {
return this.client.buildJsonPayload(item);
};
Rollbar.buildJsonPayload = function () {
if (_instance) {
return _instance.buildJsonPayload.apply(_instance, arguments);
} else {
handleUninitialized();
}
};
Rollbar.prototype.sendJsonPayload = function (jsonPayload) {
return this.client.sendJsonPayload(jsonPayload);
};
Rollbar.sendJsonPayload = function () {
if (_instance) {
return _instance.sendJsonPayload.apply(_instance, arguments);
} else {
handleUninitialized();
}
};
Rollbar.prototype.setupUnhandledCapture = function () {
var gWindow = _gWindow();
if (!this.unhandledExceptionsInitialized) {
if (this.options.captureUncaught || this.options.handleUncaughtExceptions) {
globals.captureUncaughtExceptions(gWindow, this);
if (this.wrapGlobals && this.options.wrapGlobalEventHandlers) {
this.wrapGlobals(gWindow, this);
}
this.unhandledExceptionsInitialized = true;
}
}
if (!this.unhandledRejectionsInitialized) {
if (
this.options.captureUnhandledRejections ||
this.options.handleUnhandledRejections
) {
globals.captureUnhandledRejections(gWindow, this);
this.unhandledRejectionsInitialized = true;
}
}
};
Rollbar.prototype.handleUncaughtException = function (
message,
url,
lineno,
colno,
error,
context,
) {
if (!this.options.captureUncaught && !this.options.handleUncaughtExceptions) {
return;
}
// Chrome will always send 5+ arguments and error will be valid or null, not undefined.
// If error is undefined, we have a different caller.
// Chrome also sends errors from web workers with null error, but does not invoke
// prepareStackTrace() for these. Test for empty url to skip them.
if (
this.options.inspectAnonymousErrors &&
this.isChrome &&
error === null &&
url === ''
) {
return 'anonymous';
}
var item;
var stackInfo = _.makeUnhandledStackInfo(
message,
url,
lineno,
colno,
error,
'onerror',
'uncaught exception',
errorParser,
);
if (_.isError(error)) {
item = this._createItem([message, error, context]);
item._unhandledStackInfo = stackInfo;
} else if (_.isError(url)) {
item = this._createItem([message, url, context]);
item._unhandledStackInfo = stackInfo;
} else {
item = this._createItem([message, context]);
item.stackInfo = stackInfo;
}
item.level = this.options.uncaughtErrorLevel;
item._isUncaught = true;
this.client.log(item);
};
/**
* Chrome only. Other browsers will ignore.
*
* Use Error.prepareStackTrace to extract information about errors that
* do not have a valid error object in onerror().
*
* In tested version of Chrome, onerror is called first but has no way
* to communicate with prepareStackTrace. Use a counter to let this
* handler know which errors to send to Rollbar.
*
* In config options, set inspectAnonymousErrors to enable.
*/
Rollbar.prototype.handleAnonymousErrors = function () {
if (!this.options.inspectAnonymousErrors || !this.isChrome) {
return;
}
var r = this;
function prepareStackTrace(error, _stack) {
// eslint-disable-line no-unused-vars
if (r.options.inspectAnonymousErrors) {
if (r.anonymousErrorsPending) {
// This is the only known way to detect that onerror saw an anonymous error.
// It depends on onerror reliably being called before Error.prepareStackTrace,
// which so far holds true on tested versions of Chrome. If versions of Chrome
// are tested that behave differently, this logic will need to be updated
// accordingly.
r.anonymousErrorsPending -= 1;
if (!error) {
// Not likely to get here, but calling handleUncaughtException from here
// without an error object would throw off the anonymousErrorsPending counter,
// so return now.
return;
}
// Allow this to be tracked later.
error._isAnonymous = true;
// url, lineno, colno shouldn't be needed for these errors.
// If that changes, update this accordingly, using the unused
// _stack param as needed (rather than parse error.toString()).
r.handleUncaughtException(error.message, null, null, null, error);
}
}
// Workaround to ensure stack is preserved for normal errors.
return error.stack;
}
// https://v8.dev/docs/stack-trace-api
try {
Error.prepareStackTrace = prepareStackTrace;
} catch (e) {
this.options.inspectAnonymousErrors = false;
this.error('anonymous error handler failed', e);
}
};
Rollbar.prototype.handleUnhandledRejection = function (reason, promise) {
if (
!this.options.captureUnhandledRejections &&
!this.options.handleUnhandledRejections
) {
return;
}
var message = 'unhandled rejection was null or undefined!';
if (reason) {
if (reason.message) {
message = reason.message;
} else {
var reasonResult = _.stringify(reason);
if (reasonResult.value) {
message = reasonResult.value;
}
}
}
var context =
(reason && reason._rollbarContext) || (promise && promise._rollbarContext);
var item;
if (_.isError(reason)) {
item = this._createItem([message, reason, context]);
} else {
item = this._createItem([message, reason, context]);
item.stackInfo = _.makeUnhandledStackInfo(
message,
'',
0,
0,
null,
'unhandledrejection',
'',
errorParser,
);
}
item.level = this.options.uncaughtErrorLevel;
item._isUncaught = true;
item._originalArgs = item._originalArgs || [];
item._originalArgs.push(promise);
this.client.log(item);
};
Rollbar.prototype.wrap = function (f, context, _before) {
try {
var ctxFn;
if (_.isFunction(context)) {
ctxFn = context;
} else {
ctxFn = function () {
return context || {};
};
}
if (!_.isFunction(f)) {
return f;
}
if (f._isWrap) {
return f;
}
if (!f._rollbar_wrapped) {
f._rollbar_wrapped = function () {
if (_before && _.isFunction(_before)) {
_before.apply(this, arguments);
}
try {
return f.apply(this, arguments);
} catch (exc) {
var e = exc;
if (e && window._rollbarWrappedError !== e) {
if (_.isType(e, 'string')) {
e = new String(e);
}
e._rollbarContext = ctxFn() || {};
e._rollbarContext._wrappedSource = f.toString();
window._rollbarWrappedError = e;
}
throw e;
}
};
f._rollbar_wrapped._isWrap = true;
if (f.hasOwnProperty) {
for (var prop in f) {
if (f.hasOwnProperty(prop) && prop !== '_rollbar_wrapped') {
f._rollbar_wrapped[prop] = f[prop];
}
}
}
}
return f._rollbar_wrapped;
} catch (e) {
// Return the original function if the wrap fails.
return f;
}
};
Rollbar.wrap = function (f, context) {
if (_instance) {
return _instance.wrap(f, context);
} else {
handleUninitialized();
}
};
Rollbar.prototype.captureEvent = function () {
var event = _.createTelemetryEvent(arguments);
return this.client.captureEvent(event.type, event.metadata, event.level);
};
Rollbar.captureEvent = function () {
if (_instance) {
return _instance.captureEvent.apply(_instance, arguments);
} else {
handleUninitialized();
}
};
// The following two methods are used internally and are not meant for public use
Rollbar.prototype.captureDomContentLoaded = function (e, ts) {
if (!ts) {
ts = new Date();
}
return this.client.captureDomContentLoaded(ts);
};
Rollbar.prototype.captureLoad = function (e, ts) {
if (!ts) {
ts = new Date();
}
return this.client.captureLoad(ts);
};
/* Internal */
function addTransformsToNotifier(notifier, rollbar, gWindow) {
notifier
.addTransform(transforms.handleDomException)
.addTransform(transforms.handleItemWithError)
.addTransform(transforms.ensureItemHasSomethingToSay)
.addTransform(transforms.addBaseInfo)
.addTransform(transforms.addRequestInfo(gWindow))
.addTransform(transforms.addClientInfo(gWindow))
.addTransform(transforms.addPluginInfo(gWindow))
.addTransform(transforms.addBody)
.addTransform(sharedTransforms.addMessageWithError)
.addTransform(sharedTransforms.addTelemetryData)
.addTransform(sharedTransforms.addConfigToPayload)
.addTransform(transforms.addScrubber(rollbar.scrub))
.addTransform(sharedTransforms.addPayloadOptions)
.addTransform(sharedTransforms.userTransform(logger))
.addTransform(sharedTransforms.addConfiguredOptions)
.addTransform(sharedTransforms.addDiagnosticKeys)
.addTransform(sharedTransforms.itemToPayload);
}
function addPredicatesToQueue(queue) {
queue
.addPredicate(sharedPredicates.checkLevel)
.addPredicate(predicates.checkIgnore)
.addPredicate(sharedPredicates.userCheckIgnore(logger))
.addPredicate(sharedPredicates.urlIsNotBlockListed(logger))
.addPredicate(sharedPredicates.urlIsSafeListed(logger))
.addPredicate(sharedPredicates.messageIsIgnored(logger));
}
Rollbar.prototype.loadFull = function () {
logger.info(
'Unexpected Rollbar.loadFull() called on a Notifier instance. This can happen when Rollbar is loaded multiple times.',
);
};
Rollbar.prototype._createItem = function (args) {
return _.createItem(args, logger, this);
};
function _getFirstFunction(args) {
for (var i = 0, len = args.length; i < len; ++i) {
if (_.isFunction(args[i])) {
return args[i];
}
}
return undefined;
}
function _gWindow() {
return (
(typeof window != 'undefined' && window) ||
(typeof self != 'undefined' && self)
);
}
var defaults = __webpack_require__(441);
var scrubFields = __webpack_require__(537);
var defaultOptions = {
version: defaults.version,
scrubFields: scrubFields.scrubFields,
logLevel: defaults.logLevel,
reportLevel: defaults.reportLevel,
uncaughtErrorLevel: defaults.uncaughtErrorLevel,
endpoint: defaults.endpoint,
verbose: false,
enabled: true,
transmit: true,
sendConfig: false,
includeItemsInTelemetry: true,
captureIp: true,
inspectAnonymousErrors: true,
ignoreDuplicateErrors: true,
wrapGlobalEventHandlers: false,
};
module.exports = Rollbar;
/***/ }),
/***/ 203:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var _ = __webpack_require__(539);
var errorParser = __webpack_require__(342);
var logger = __webpack_require__(306);
function handleDomException(item, options, callback) {
if (item.err && errorParser.Stack(item.err).name === 'DOMException') {
var originalError = new Error();
originalError.name = item.err.name;
originalError.message = item.err.message;
originalError.stack = item.err.stack;
originalError.nested = item.err;
item.err = originalError;
}
callback(null, item);
}
function handleItemWithError(item, options, callback) {
item.data = item.data || {};
if (item.err) {
try {
item.stackInfo =
item.err._savedStackTrace ||
errorParser.parse(item.err, item.skipFrames);
if (options.addErrorContext) {
addErrorContext(item);
}
} catch (e) {
logger.error('Error while parsing the error object.', e);
try {
item.message =
item.err.message ||
item.err.description ||
item.message ||
String(item.err);
} catch (e2) {
item.message = String(item.err) || String(e2);
}
delete item.err;
}
}
callback(null, item);
}
function addErrorContext(item) {
var chain = [];
var err = item.err;
chain.push(err);
while (err.nested || err.cause) {
err = err.nested || err.cause;
chain.push(err);
}
_.addErrorContext(item, chain);
}
function ensureItemHasSomethingToSay(item, options, callback) {
if (!item.message && !item.stackInfo && !item.custom) {
callback(new Error('No message, stack info, or custom data'), null);
}
callback(null, item);
}
function addBaseInfo(item, options, callback) {
var environment =
(options.payload && options.payload.environment) || options.environment;
item.data = _.merge(item.data, {
environment: environment,
level: item.level,
endpoint: options.endpoint,
platform: 'browser',
framework: 'browser-js',
language: 'javascript',
server: {},
uuid: item.uuid,
notifier: {
name: 'rollbar-browser-js',
version: options.version,
},
custom: item.custom,
});
callback(null, item);
}
function addRequestInfo(window) {
return function (item, options, callback) {
var requestInfo = {};
if (window && window.location) {
requestInfo.url = window.location.href;
requestInfo.query_string = window.location.search;
}
var remoteString = '$remote_ip';
if (!options.captureIp) {
remoteString = null;
} else if (options.captureIp !== true) {
remoteString += '_anonymize';
}
if (remoteString) requestInfo.user_ip = remoteString;
if (Object.keys(requestInfo).length > 0) {
_.set(item, 'data.request', requestInfo);
}
callback(null, item);
};
}
function addClientInfo(window) {
return function (item, options, callback) {
if (!window) {
return callback(null, item);
}
var nav = window.navigator || {};
var scr = window.screen || {};
_.set(item, 'data.client', {
runtime_ms: item.timestamp - window._rollbarStartTime,
timestamp: Math.round(item.timestamp / 1000),
javascript: {
browser: nav.userAgent,
language: nav.language,
cookie_enabled: nav.cookieEnabled,
screen: {
width: scr.width,
height: scr.height,
},
},
});
callback(null, item);
};
}
function addPluginInfo(window) {
return function (item, options, callback) {
if (!window || !window.navigator) {
return callback(null, item);
}
var plugins = [];
var navPlugins = window.navigator.plugins || [];
var cur;
for (var i = 0, l = navPlugins.length; i < l; ++i) {
cur = navPlugins[i];
plugins.push({ name: cur.name, description: cur.description });
}
_.set(item, 'data.client.javascript.plugins', plugins);
callback(null, item);
};
}
function addBody(item, options, callback) {
if (item.stackInfo) {
if (item.stackInfo.traceChain) {
addBodyTraceChain(item, options, callback);
} else {
addBodyTrace(item, options, callback);
}
} else {
addBodyMessage(item, options, callback);
}
}
function addBodyMessage(item, options, callback) {
var message = item.message;
var custom = item.custom;
if (!message) {
message = 'Item sent with null or missing arguments.';
}
var result = {
body: message,
};
if (custom) {
result.extra = _.merge(custom);
}
_.set(item, 'data.body', { message: result });
callback(null, item);
}
function stackFromItem(item) {
// Transform a TraceKit stackInfo object into a Rollbar trace
var stack = item.stackInfo.stack;
if (
stack &&
stack.length === 0 &&
item._unhandledStackInfo &&
item._unhandledStackInfo.stack
) {
stack = item._unhandledStackInfo.stack;
}
return stack;
}
function addBodyTraceChain(item, options, callback) {
var traceChain = item.stackInfo.traceChain;
var traces = [];
var traceChainLength = traceChain.length;
for (var i = 0; i < traceChainLength; i++) {
var trace = buildTrace(item, traceChain[i], options);
traces.push(trace);
}
_.set(item, 'data.body', { trace_chain: traces });
callback(null, item);
}
function addBodyTrace(item, options, callback) {
var stack = stackFromItem(item);
if (stack) {
var trace = buildTrace(item, item.stackInfo, options);
_.set(item, 'data.body', { trace: trace });
callback(null, item);
} else {
var stackInfo = item.stackInfo;
var guess = errorParser.guessErrorClass(stackInfo.message);
var className = errorClass(stackInfo, guess[0], options);
var message = guess[1];
item.message = className + ': ' + message;
addBodyMessage(item, options, callback);
}
}
function buildTrace(item, stackInfo, options) {
var description = item && item.data.description;
var custom = item && item.custom;
var stack = stackFromItem(item);
var guess = errorParser.guessErrorClass(stackInfo.message);
var className = errorClass(stackInfo, guess[0], options);
var message = guess[1];
var trace = {
exception: {
class: className,
message: message,
},
};
if (description) {
trace.exception.description = description;
}
if (stack) {
if (stack.length === 0) {
trace.exception.stack = stackInfo.rawStack;
trace.exception.raw = String(stackInfo.rawException);
}
var stackFrame;
var frame;
var code;
var pre;
var post;
var contextLength;
var i, mid;
trace.frames = [];
for (i = 0; i < stack.length; ++i) {
stackFrame = stack[i];
frame = {
filename: stackFrame.url ? _.sanitizeUrl(stackFrame.url) : '(unknown)',
lineno: stackFrame.line || null,
method:
!stackFrame.func || stackFrame.func === '?'
? '[anonymous]'
: stackFrame.func,
colno: stackFrame.column,
};
if (options.sendFrameUrl) {
frame.url = stackFrame.url;
}
if (
frame.method &&
frame.method.endsWith &&
frame.method.endsWith('_rollbar_wrapped')
) {
continue;
}
code = pre = post = null;
contextLength = stackFrame.context ? stackFrame.context.length : 0;
if (contextLength) {
mid = Math.floor(contextLength / 2);
pre = stackFrame.context.slice(0, mid);
code = stackFrame.context[mid];
post = stackFrame.context.slice(mid);
}
if (code) {
frame.code = code;
}
if (pre || post) {
frame.context = {};
if (pre && pre.length) {
frame.context.pre = pre;
}
if (post && post.length) {
frame.context.post = post;
}
}
if (stackFrame.args) {
frame.args = stackFrame.args;
}
trace.frames.push(frame);
}
// NOTE(cory): reverse the frames since rollbar.com expects the most recent call last
trace.frames.reverse();
if (custom) {
trace.extra = _.merge(custom);
}
}
return trace;
}
function errorClass(stackInfo, guess, options) {
if (stackInfo.name) {
return stackInfo.name;
} else if (options.guessErrorClass) {
return guess;
} else {
return '(unknown)';
}
}
function addScrubber(scrubFn) {
return function (item, options, callback) {
if (scrubFn) {
var scrubFields = options.scrubFields || [];
var scrubPaths = options.scrubPaths || [];
item.data = scrubFn(item.data, scrubFields, scrubPaths);
}
callback(null, item);
};
}
module.exports = {
handleDomException: handleDomException,
handleItemWithError: handleItemWithError,
ensureItemHasSomethingToSay: ensureItemHasSomethingToSay,
addBaseInfo: addBaseInfo,
addRequestInfo: addRequestInfo,
addClientInfo: addClientInfo,
addPluginInfo: addPluginInfo,
addBody: addBody,
addScrubber: addScrubber,
};
/***/ }),
/***/ 215:
/***/ ((module) => {
"use strict";
'use strict';
var hasOwn = Object.prototype.hasOwnProperty;
var toStr = Object.prototype.toString;
var isPlainObject = function isPlainObject(obj) {
if (!obj || toStr.call(obj) !== '[object Object]') {
return false;
}
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
var hasIsPrototypeOf =
obj.constructor &&
obj.constructor.prototype &&
hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
// Not own constructor property must be Object
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
return false;
}
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
var key;
for (key in obj) {
/**/
}
return typeof key === 'undefined' || hasOwn.call(obj, key);
};
function merge() {
var i,
src,
copy,
clone,
name,
result = Object.create(null), // no prototype pollution on Object
current = null,
length = arguments.length;
for (i = 0; i < length; i++) {
current = arguments[i];
if (current == null) {
continue;
}
for (name in current) {
src = result[name];
copy = current[name];
if (result !== copy) {
if (copy && isPlainObject(copy)) {
clone = src && isPlainObject(src) ? src : {};
result[name] = merge(clone, copy);
} else if (typeof copy !== 'undefined') {
result[name] = copy;
}
}
}
}
return result;
}
module.exports = merge;
/***/ }),
/***/ 263:
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) {
'use strict';
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
/* istanbul ignore next */
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(108)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}(this, function ErrorStackParser(StackFrame) {
'use strict';
var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
return {
/**
* Given an Error object, extract the most information from it.
*
* @param {Error} error object
* @return {Array} of StackFrames
*/
parse: function ErrorStackParser$$parse(error) {
if (typeof error.stacktrace !== 'undefined' || typeof error['opera#sourceloc'] !== 'undefined') {
return this.parseOpera(error);
} else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
return this.parseV8OrIE(error);
} else if (error.stack) {
return this.parseFFOrSafari(error);
} else {
throw new Error('Cannot parse given Error object');
}
},
// Separate line and column numbers from a string of the form: (URI:Line:Column)
extractLocation: function ErrorStackParser$$extractLocation(urlLike) {
// Fail-fast but return locations like "(native)"
if (urlLike.indexOf(':') === -1) {
return [urlLike];
}
var regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
var parts = regExp.exec(urlLike.replace(/[()]/g, ''));
return [parts[1], parts[2] || undefined, parts[3] || undefined];
},
parseV8OrIE: function ErrorStackParser$$parseV8OrIE(error) {
var filtered = error.stack.split('\n').filter(function(line) {
return !!line.match(CHROME_IE_STACK_REGEXP);
}, this);
return filtered.map(function(line) {
if (line.indexOf('(eval ') > -1) {
// Throw away eval information until we implement stacktrace.js/stackframe#8
line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^()]*)|(\),.*$)/g, '');
}
var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(');
// capture and preseve the parenthesized location "(/foo/my bar.js:12:87)" in
// case it has spaces in it, as the string is split on \s+ later on
var location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
// remove the parenthesized location from the line, if it was matched
sanitizedLine = location ? sanitizedLine.replace(location[0], '') : sanitizedLine;
var tokens = sanitizedLine.split(/\s+/).slice(1);
// if a location was matched, pass it to extractLocation() otherwise pop the last token
var locationParts = this.extractLocation(location ? location[1] : tokens.pop());
var functionName = tokens.join(' ') || undefined;
var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1 ? undefined : locationParts[0];
return new StackFrame({
functionName: functionName,
fileName: fileName,
lineNumber: locationParts[1],
columnNumber: locationParts[2],
source: line
});
}, this);
},
parseFFOrSafari: function ErrorStackParser$$parseFFOrSafari(error) {
var filtered = error.stack.split('\n').filter(function(line) {
return !line.match(SAFARI_NATIVE_CODE_REGEXP);
}, this);
return filtered.map(function(line) {
// Throw away eval information until we implement stacktrace.js/stackframe#8
if (line.indexOf(' > eval') > -1) {
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ':$1');
}
if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {
// Safari eval frames only have function names and nothing else
return new StackFrame({
functionName: line
});
} else {
var functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
var matches = line.match(functionNameRegex);
var functionName = matches && matches[1] ? matches[1] : undefined;
var locationParts = this.extractLocation(line.replace(functionNameRegex, ''));
return new StackFrame({
functionName: functionName,
fileName: locationParts[0],
lineNumber: locationParts[1],
columnNumber: locationParts[2],
source: line
});
}
}, this);
},
parseOpera: function ErrorStackParser$$parseOpera(e) {
if (!e.stacktrace || (e.message.indexOf('\n') > -1 &&
e.message.split('\n').length > e.stacktrace.split('\n').length)) {
return this.parseOpera9(e);
} else if (!e.stack) {
return this.parseOpera10(e);
} else {
return this.parseOpera11(e);
}
},
parseOpera9: function ErrorStackParser$$parseOpera9(e) {
var lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
var lines = e.message.split('\n');
var result = [];
for (var i = 2, len = lines.length; i < len; i += 2) {
var match = lineRE.exec(lines[i]);
if (match) {
result.push(new StackFrame({
fileName: match[2],
lineNumber: match[1],
source: lin