-
Notifications
You must be signed in to change notification settings - Fork 213
/
rollbarWrapper.js
43 lines (39 loc) · 1.28 KB
/
rollbarWrapper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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 (var i = 0; i < _methods.length; i++) {
prototype[_methods[i]] = _forward(_methods[i]);
}
}
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;
};
module.exports = RollbarWrap;