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.
44 lines (39 loc) • 1.29 kB
JavaScript
function RollbarWrap(impl, options) {
this.impl = impl(options, this);
this.options = options;
_setupForwarding(RollbarWrap.prototype);
}
function _setupForwarding(prototype) {
var _forward = function (method) {
return function () {
var args = Array.prototype.slice.call(arguments, 0);
if (this.impl[method]) {
return this.impl[method].apply(this.impl, args);
}
};
};
var _methods =
'log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,_createItem,wrap,loadFull,shimId,captureEvent,captureDomContentLoaded,captureLoad'.split(
',',
);
for (const method of _methods) {
prototype[method] = _forward(method);
}
}
RollbarWrap.prototype._swapAndProcessMessages = function (impl, messages) {
this.impl = impl(this.options);
var msg, method, args;
while ((msg = messages.shift())) {
method = msg.method;
args = msg.args;
if (this[method] && typeof this[method] === 'function') {
if (method === 'captureDomContentLoaded' || method === 'captureLoad') {
this[method].apply(this, [args[0], msg.ts]);
} else {
this[method].apply(this, args);
}
}
}
return this;
};
export default RollbarWrap;