web-monitor-ukl
v1.0.0
Published
web监控、js监控
Downloads
4
Readme
日志级别
日志信息分类
- 等级由低到高:debug、 info、notice、 warning、error、critical、alert、emergency
- 区别:
- debug 调试
- info 信息
- notice 通知,注意
- warning 警告
- error 错误
- critical 危险的
- alert 弹出警告
- emergency 紧急情况,突发事件
后三个,危险的、警告、紧急情况,这三者应该都在系统运行时检测到了一个不正常的状态。
- critical, 可修复,系统可继续运行下去;
- alert, 可修复性,但无法确定系统会正常的工作下去;
- emergency, 相当严重,可以肯定这种错误已经无法修复,并且如果系统继续运行下去的话后果严重。
使用
什么时候使用 debug,info,notice,warning,error
- debug 日志级别只是用来在开发阶段进行代码调试的时候打出的日志,对调试应用程序是非常有帮助,一般在上线的时候建议把这个日志给屏蔽或者删除。
- info 日志级别只是用来记录一些关键业务数据或者需要进行跟踪打点的信息,便于追踪定位;
- notice 不影响程序的主流程运行,只是部分出现一些不规范的写法,出现这种日志,风险级别是一般,可以查看日志信息,一般不需要处理。
- warning 表明系统出现轻微的不合理但不影响运行和使用,出现潜在错误的情形,出现这种日志,风险级别是一般;
- error 表明出现了系统错误和异常,但是不影响程序的主流程运行或者业务可以进行降级处理,出现这种日志,风险级别是中级。
错误类型
- 即时运行错误:代码错误
- 资源加载错误
- 图片加载错误
上报错误的方法
- 利用网络请求进行上报
- 利用图片方式上报
实现原理
- 利用 window.onerror 监控代码运行时发生的错误
- 利用 window.addEventListener('error',()=>{})监控资源加载的错误
疑问: 错误格式的统一问题(js 语法报错,资源加载类型的错误,资源载错误的严重程度)
开会的目的
- 只要把疑问的地方点提出来
- 我们看一看需不需要细节区分 3.埋点不够可以补充,日志格式能不能全流程唯一标识码这一块需要注意一下 问题 1 1.用户今天进入这个 app 或者使用这个公众号页面???? 通过 kibana 查询今天 ,然后通过什么手段 是 cookie? 那当前 cookie 有没有上传? 问题 2 如何区分当前事件流的链路? 通过 steamNumber 流水号? 那是不是需要全链路监控 TraceId
- http://10.1.75.12:8090/pages/viewpage.action?pageId=37162476------搜索 TraceId
- 监控 js 在底部引入
- 用户自定义(get||post)如果没传,则判断字符长度
- userId:"用户名",//读 cookie,如果不存在读 localstorage,不存在生成一个
- 检查所有代码的数据,监控代码要做容错处理,不能影响原本项目
- 主动上报,必填和非必填
- 日志级别,什么时候发邮件,什么时候发短信;监控代码错误上报自己定义一个级别(独立)
!function() {
var e = window;
function n(n) {
if (e.g_monitor && e.g_monitor.events) {
var t = e.g_monitor.events;
t.length < 20 && t.push(n)
}
}
e.g_monitor = e.g_monitor || {
listener: {},
events: []
};
var r = e.g_monitor.listener;
function t(t, n) {
try {
e.addEventListener ? e.addEventListener(t, n, !0) : e.attachEvent ? e.attachEvent("on" + t, n) : e[t] = n,
r[t] = n
} catch(n) {
console.warn("Tracert 监控事件注册失败:" + t, n)
}
}
r.error || t("error", n),
r.unhandledrejection || t("unhandledrejection", n)
} ();
!
function(t, e) {
"object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = t || self).YuyanMonitor = e()
} (this, (function() {
"use strict";
function _typeof(t) {
return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
function(t) {
return typeof t
}: function(t) {
return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol": typeof t
})(t)
}
function asyncGeneratorStep(t, e, r, n, o, i, a) {
try {
var c = t[i](a),
s = c.value
} catch(t) {
return void r(t)
}
c.done ? e(s) : Promise.resolve(s).then(n, o)
}
function _asyncToGenerator(t) {
return function() {
var e = this,
r = arguments;
return new Promise((function(n, o) {
var i = t.apply(e, r);
function a(t) {
asyncGeneratorStep(i, n, o, a, c, "next", t)
}
function c(t) {
asyncGeneratorStep(i, n, o, a, c, "throw", t)
}
a(void 0)
}))
}
}
function _classCallCheck(t, e) {
if (! (t instanceof e)) throw new TypeError("Cannot call a class as a function")
}
function _defineProperties(t, e) {
for (var r = 0; e.length > r; r++) {
var n = e[r];
n.enumerable = n.enumerable || !1,
n.configurable = !0,
"value" in n && (n.writable = !0),
Object.defineProperty(t, n.key, n)
}
}
function _createClass(t, e, r) {
return e && _defineProperties(t.prototype, e),
r && _defineProperties(t, r),
t
}
function _defineProperty(t, e, r) {
return e in t ? Object.defineProperty(t, e, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0
}) : t[e] = r,
t
}
function ownKeys(t, e) {
var r = Object.keys(t);
if (Object.getOwnPropertySymbols) {
var n = Object.getOwnPropertySymbols(t);
e && (n = n.filter((function(e) {
return Object.getOwnPropertyDescriptor(t, e).enumerable
}))),
r.push.apply(r, n)
}
return r
}
function _objectSpread2(t) {
for (var e = 1; arguments.length > e; e++) {
var r = null != arguments[e] ? arguments[e] : {};
e % 2 ? ownKeys(Object(r), !0).forEach((function(e) {
_defineProperty(t, e, r[e])
})) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : ownKeys(Object(r)).forEach((function(e) {
Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(r, e))
}))
}
return t
}
function _inherits(t, e) {
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
t.prototype = Object.create(e && e.prototype, {
constructor: {
value: t,
writable: !0,
configurable: !0
}
}),
e && _setPrototypeOf(t, e)
}
function _getPrototypeOf(t) {
return (_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf: function(t) {
return t.__proto__ || Object.getPrototypeOf(t)
})(t)
}
function _setPrototypeOf(t, e) {
return (_setPrototypeOf = Object.setPrototypeOf ||
function(t, e) {
return t.__proto__ = e,
t
})(t, e)
}
function _isNativeReflectConstruct() {
if ("undefined" == typeof Reflect || !Reflect.construct) return ! 1;
if (Reflect.construct.sham) return ! 1;
if ("function" == typeof Proxy) return ! 0;
try {
return Date.prototype.toString.call(Reflect.construct(Date, [], (function() {}))),
!0
} catch(t) {
return ! 1
}
}
function _assertThisInitialized(t) {
if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return t
}
function _possibleConstructorReturn(t, e) {
return ! e || "object" != typeof e && "function" != typeof e ? _assertThisInitialized(t) : e
}
function _createSuper(t) {
var e = _isNativeReflectConstruct();
return function() {
var r, n = _getPrototypeOf(t);
if (e) {
var o = _getPrototypeOf(this).constructor;
r = Reflect.construct(n, arguments, o)
} else r = n.apply(this, arguments);
return _possibleConstructorReturn(this, r)
}
}
function _toArray(t) {
return _arrayWithHoles(t) || _iterableToArray(t) || _unsupportedIterableToArray(t) || _nonIterableRest()
}
function _arrayWithHoles(t) {
if (Array.isArray(t)) return t
}
function _iterableToArray(t) {
if ("undefined" != typeof Symbol && Symbol.iterator in Object(t)) return Array.from(t)
}
function _unsupportedIterableToArray(t, e) {
if (t) {
if ("string" == typeof t) return _arrayLikeToArray(t, e);
var r = Object.prototype.toString.call(t).slice(8, -1);
return "Object" === r && t.constructor && (r = t.constructor.name),
"Map" === r || "Set" === r ? Array.from(t) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? _arrayLikeToArray(t, e) : void 0
}
}
function _arrayLikeToArray(t, e) { (null == e || e > t.length) && (e = t.length);
for (var r = 0,
n = Array(e); e > r; r++) n[r] = t[r];
return n
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
}
var commonjsGlobal = "undefined" != typeof globalThis ? globalThis: "undefined" != typeof window ? window: "undefined" != typeof global ? global: "undefined" != typeof self ? self: {};
function createCommonjsModule(t, e) {
return t(e = {
exports: {}
},
e.exports),
e.exports
}
var runtime_1 = createCommonjsModule((function(t) {
var e = function(t) {
var e = Object.prototype,
r = e.hasOwnProperty,
n = "function" == typeof Symbol ? Symbol: {},
o = n.iterator || "@@iterator",
i = n.asyncIterator || "@@asyncIterator",
a = n.toStringTag || "@@toStringTag";
function c(t, e, r) {
return Object.defineProperty(t, e, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0
}),
t[e]
}
try {
c({},
"")
} catch(t) {
c = function(t, e, r) {
return t[e] = r
}
}
function s(t, e, r, n) {
var o = Object.create((e && e.prototype instanceof l ? e: l).prototype),
i = new C(n || []);
return o._invoke = function(t, e, r) {
var n = "suspendedStart";
return function(o, i) {
if ("executing" === n) throw Error("Generator is already running");
if ("completed" === n) {
if ("throw" === o) throw i;
return A()
}
for (r.method = o, r.arg = i;;) {
var a = r.delegate;
if (a) {
var c = _(a, r);
if (c) {
if (c === f) continue;
return c
}
}
if ("next" === r.method) r.sent = r._sent = r.arg;
else if ("throw" === r.method) {
if ("suspendedStart" === n) throw n = "completed",
r.arg;
r.dispatchException(r.arg)
} else "return" === r.method && r.abrupt("return", r.arg);
n = "executing";
var s = u(t, e, r);
if ("normal" === s.type) {
if (n = r.done ? "completed": "suspendedYield", s.arg === f) continue;
return {
value: s.arg,
done: r.done
}
}
"throw" === s.type && (n = "completed", r.method = "throw", r.arg = s.arg)
}
}
} (t, r, i),
o
}
function u(t, e, r) {
try {
return {
type: "normal",
arg: t.call(e, r)
}
} catch(t) {
return {
type: "throw",
arg: t
}
}
}
t.wrap = s;
var f = {};
function l() {}
function d() {}
function p() {}
var h = {};
h[o] = function() {
return this
};
var y = Object.getPrototypeOf,
m = y && y(y(S([])));
m && m !== e && r.call(m, o) && (h = m);
var g = p.prototype = l.prototype = Object.create(h);
function v(t) { ["next", "throw", "return"].forEach((function(e) {
c(t, e, (function(t) {
return this._invoke(e, t)
}))
}))
}
function b(t, e) {
var n;
this._invoke = function(o, i) {
function a() {
return new e((function(n, a) { !
function n(o, i, a, c) {
var s = u(t[o], t, i);
if ("throw" !== s.type) {
var f = s.arg,
l = f.value;
return l && "object" == typeof l && r.call(l, "__await") ? e.resolve(l.__await).then((function(t) {
n("next", t, a, c)
}), (function(t) {
n("throw", t, a, c)
})) : e.resolve(l).then((function(t) {
f.value = t,
a(f)
}), (function(t) {
return n("throw", t, a, c)
}))
}
c(s.arg)
} (o, i, n, a)
}))
}
return n = n ? n.then(a, a) : a()
}
}
function _(t, e) {
var r = t.iterator[e.method];
if (void 0 === r) {
if (e.delegate = null, "throw" === e.method) {
if (t.iterator.
return && (e.method = "return", e.arg = void 0, _(t, e), "throw" === e.method)) return f;
e.method = "throw",
e.arg = new TypeError("The iterator does not provide a 'throw' method")
}
return f
}
var n = u(r, t.iterator, e.arg);
if ("throw" === n.type) return e.method = "throw",
e.arg = n.arg,
e.delegate = null,
f;
var o = n.arg;
return o ? o.done ? (e[t.resultName] = o.value, e.next = t.nextLoc, "return" !== e.method && (e.method = "next", e.arg = void 0), e.delegate = null, f) : o: (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f)
}
function w(t) {
var e = {
tryLoc: t[0]
};
1 in t && (e.catchLoc = t[1]),
2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]),
this.tryEntries.push(e)
}
function E(t) {
var e = t.completion || {};
e.type = "normal",
delete e.arg,
t.completion = e
}
function C(t) {
this.tryEntries = [{
tryLoc: "root"
}],
t.forEach(w, this),
this.reset(!0)
}
function S(t) {
if (t) {
var e = t[o];
if (e) return e.call(t);
if ("function" == typeof t.next) return t;
if (!isNaN(t.length)) {
var n = -1,
i = function e() {
for (; ++n < t.length;) if (r.call(t, n)) return e.value = t[n],
e.done = !1,
e;
return e.value = void 0,
e.done = !0,
e
};
return i.next = i
}
}
return {
next: A
}
}
function A() {
return {
value: void 0,
done: !0
}
}
return d.prototype = g.constructor = p,
p.constructor = d,
d.displayName = c(p, a, "GeneratorFunction"),
t.isGeneratorFunction = function(t) {
var e = "function" == typeof t && t.constructor;
return !! e && (e === d || "GeneratorFunction" === (e.displayName || e.name))
},
t.mark = function(t) {
return Object.setPrototypeOf ? Object.setPrototypeOf(t, p) : (t.__proto__ = p, c(t, a, "GeneratorFunction")),
t.prototype = Object.create(g),
t
},
t.awrap = function(t) {
return {
__await: t
}
},
v(b.prototype),
b.prototype[i] = function() {
return this
},
t.AsyncIterator = b,
t.async = function(e, r, n, o, i) {
void 0 === i && (i = Promise);
var a = new b(s(e, r, n, o), i);
return t.isGeneratorFunction(r) ? a: a.next().then((function(t) {
return t.done ? t.value: a.next()
}))
},
v(g),
c(g, a, "Generator"),
g[o] = function() {
return this
},
g.toString = function() {
return "[object Generator]"
},
t.keys = function(t) {
var e = [];
for (var r in t) e.push(r);
return e.reverse(),
function r() {
for (; e.length;) {
var n = e.pop();
if (n in t) return r.value = n,
r.done = !1,
r
}
return r.done = !0,
r
}
},
t.values = S,
C.prototype = {
constructor: C,
reset: function(t) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = !1, this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(E), !t) for (var e in this)"t" === e.charAt(0) && r.call(this, e) && !isNaN( + e.slice(1)) && (this[e] = void 0)
},
stop: function() {
this.done = !0;
var t = this.tryEntries[0].completion;
if ("throw" === t.type) throw t.arg;
return this.rval
},
dispatchException: function(t) {
if (this.done) throw t;
var e = this;
function n(r, n) {
return a.type = "throw",
a.arg = t,
e.next = r,
n && (e.method = "next", e.arg = void 0),
!!n
}
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
var i = this.tryEntries[o],
a = i.completion;
if ("root" === i.tryLoc) return n("end");
if (this.prev >= i.tryLoc) {
var c = r.call(i, "catchLoc"),
s = r.call(i, "finallyLoc");
if (c && s) {
if (i.catchLoc > this.prev) return n(i.catchLoc, !0);
if (i.finallyLoc > this.prev) return n(i.finallyLoc)
} else if (c) {
if (i.catchLoc > this.prev) return n(i.catchLoc, !0)
} else {
if (!s) throw Error("try statement without catch or finally");
if (i.finallyLoc > this.prev) return n(i.finallyLoc)
}
}
}
},
abrupt: function(t, e) {
for (var n = this.tryEntries.length - 1; n >= 0; --n) {
var o = this.tryEntries[n];
if (this.prev >= o.tryLoc && r.call(o, "finallyLoc") && o.finallyLoc > this.prev) {
var i = o;
break
}
} ! i || "break" !== t && "continue" !== t || i.tryLoc > e || e > i.finallyLoc || (i = null);
var a = i ? i.completion: {};
return a.type = t,
a.arg = e,
i ? (this.method = "next", this.next = i.finallyLoc, f) : this.complete(a)
},
complete: function(t, e) {
if ("throw" === t.type) throw t.arg;
return "break" === t.type || "continue" === t.type ? this.next = t.arg: "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e),
f
},
finish: function(t) {
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
var r = this.tryEntries[e];
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc),
E(r),
f
}
},
catch: function(t) {
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
var r = this.tryEntries[e];
if (r.tryLoc === t) {
var n = r.completion;
if ("throw" === n.type) {
var o = n.arg;
E(r)
}
return o
}
}
throw Error("illegal catch attempt")
},
delegateYield: function(t, e, r) {
return this.delegate = {
iterator: S(t),
resultName: e,
nextLoc: r
},
"next" === this.method && (this.arg = void 0),
f
}
},
t
} (t.exports);
try {
regeneratorRuntime = e
} catch(t) {
Function("r", "regeneratorRuntime = r")(e)
}
}));
function _typeof$1(t) {
return (_typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
function(t) {
return typeof t
}: function(t) {
return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol": typeof t
})(t)
}
function _classCallCheck$1(t, e) {
if (! (t instanceof e)) throw new TypeError("Cannot call a class as a function")
}
function _defineProperties$1(t, e) {
for (var r = 0; e.length > r; r++) {
var n = e[r];
n.enumerable = n.enumerable || !1,
n.configurable = !0,
"value" in n && (n.writable = !0),
Object.defineProperty(t, n.key, n)
}
}
function _createClass$1(t, e, r) {
return e && _defineProperties$1(t.prototype, e),
r && _defineProperties$1(t, r),
t
}
function _slicedToArray(t, e) {
return _arrayWithHoles$1(t) || _iterableToArrayLimit(t, e) || _unsupportedIterableToArray$1(t, e) || _nonIterableRest$1()
}
function _toConsumableArray(t) {
return _arrayWithoutHoles(t) || _iterableToArray$1(t) || _unsupportedIterableToArray$1(t) || _nonIterableSpread()
}
function _arrayWithoutHoles(t) {
if (Array.isArray(t)) return _arrayLikeToArray$1(t)
}
function _arrayWithHoles$1(t) {
if (Array.isArray(t)) return t
}
function _iterableToArray$1(t) {
if ("undefined" != typeof Symbol && Symbol.iterator in Object(t)) return Array.from(t)
}
function _iterableToArrayLimit(t, e) {
if ("undefined" != typeof Symbol && Symbol.iterator in Object(t)) {
var r = [],
n = !0,
o = !1,
i = void 0;
try {
for (var a, c = t[Symbol.iterator](); ! (n = (a = c.next()).done) && (r.push(a.value), !e || r.length !== e); n = !0);
} catch(t) {
o = !0,
i = t
} finally {
try {
n || null == c.
return || c.
return ()
} finally {
if (o) throw i
}
}
return r
}
}
function _unsupportedIterableToArray$1(t, e) {
if (t) {
if ("string" == typeof t) return _arrayLikeToArray$1(t, e);
var r = Object.prototype.toString.call(t).slice(8, -1);
return "Object" === r && t.constructor && (r = t.constructor.name),
"Map" === r || "Set" === r ? Array.from(t) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? _arrayLikeToArray$1(t, e) : void 0
}
}
function _arrayLikeToArray$1(t, e) { (null == e || e > t.length) && (e = t.length);
for (var r = 0,
n = Array(e); e > r; r++) n[r] = t[r];
return n
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
}
function _nonIterableRest$1() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
}
var checkEnv = function(t) {
return function() {
if (!t || !t.navigator || !t.navigator.userAgent) return "";
var e = t.navigator.userAgent,
r = "";
return !! e.match(/iphone|ipad|iPod/gi) && (r = "iOS"),
!!e.match(/android/gi) && (r = "Android"),
!!e.match(/Firefox/gi) && (r = "Firefox"),
!!e.match(/Chrome/gi) && (r = "Chrome"),
!e.match(/Chrome/gi) && !!e.match(/Safari/gi) && (r = "Safari"),
!!e.match(/Opera/gi) && (r = "Opera"),
!!e.match(/MSIE/gi) && (r = "IE"),
r
}
} (void 0);
function checkAndriodSpecial() {
return ! 0
}
var generateHandler = function(t) {
switch (t) {
case "iOS":
return {
filter:
function(t) {
return 0 > t.indexOf("[native code]") && t.indexOf("@") >= 0
}
};
case "Android":
return {
filter:
function(t, e) {
return e && 0 > t.indexOf("nonymous") && checkAndriodSpecial()
}
};
default:
return {
filter:
function() {
return ! 0
}
}
}
};
function safeAdd(t, e) {
var r = (65535 & t) + (65535 & e);
return (t >> 16) + (e >> 16) + (r >> 16) << 16 | 65535 & r
}
function bitRotateLeft(t, e) {
return t << e | t >>> 32 - e
}
function md5cmn(t, e, r, n, o, i) {
return safeAdd(bitRotateLeft(safeAdd(safeAdd(e, t), safeAdd(n, i)), o), r)
}
function md5ff(t, e, r, n, o, i, a) {
return md5cmn(e & r | ~e & n, t, e, o, i, a)
}
function md5gg(t, e, r, n, o, i, a) {
return md5cmn(e & n | r & ~n, t, e, o, i, a)
}
function md5hh(t, e, r, n, o, i, a) {
return md5cmn(e ^ r ^ n, t, e, o, i, a)
}
function md5ii(t, e, r, n, o, i, a) {
return md5cmn(r ^ (e | ~n), t, e, o, i, a)
}
function binlMD5(t, e) {
var r, n, o, i, a;
t[e >> 5] |= 128 << e % 32,
t[14 + (e + 64 >>> 9 << 4)] = e;
var c = 1732584193,
s = -271733879,
u = -1732584194,
f = 271733878;
for (r = 0; t.length > r; r += 16) n = c,
o = s,
i = u,
a = f,
c = md5ff(c, s, u, f, t[r], 7, -680876936),
f = md5ff(f, c, s, u, t[r + 1], 12, -389564586),
u = md5ff(u, f, c, s, t[r + 2], 17, 606105819),
s = md5ff(s, u, f, c, t[r + 3], 22, -1044525330),
c = md5ff(c, s, u, f, t[r + 4], 7, -176418897),
f = md5ff(f, c, s, u, t[r + 5], 12, 1200080426),
u = md5ff(u, f, c, s, t[r + 6], 17, -1473231341),
s = md5ff(s, u, f, c, t[r + 7], 22, -45705983),
c = md5ff(c, s, u, f, t[r + 8], 7, 1770035416),
f = md5ff(f, c, s, u, t[r + 9], 12, -1958414417),
u = md5ff(u, f, c, s, t[r + 10], 17, -42063),
s = md5ff(s, u, f, c, t[r + 11], 22, -1990404162),
c = md5ff(c, s, u, f, t[r + 12], 7, 1804603682),
f = md5ff(f, c, s, u, t[r + 13], 12, -40341101),
u = md5ff(u, f, c, s, t[r + 14], 17, -1502002290),
c = md5gg(c, s = md5ff(s, u, f, c, t[r + 15], 22, 1236535329), u, f, t[r + 1], 5, -165796510),
f = md5gg(f, c, s, u, t[r + 6], 9, -1069501632),
u = md5gg(u, f, c, s, t[r + 11], 14, 643717713),
s = md5gg(s, u, f, c, t[r], 20, -373897302),
c = md5gg(c, s, u, f, t[r + 5], 5, -701558691),
f = md5gg(f, c, s, u, t[r + 10], 9, 38016083),
u = md5gg(u, f, c, s, t[r + 15], 14, -660478335),
s = md5gg(s, u, f, c, t[r + 4], 20, -405537848),
c = md5gg(c, s, u, f, t[r + 9], 5, 568446438),
f = md5gg(f, c, s, u, t[r + 14], 9, -1019803690),
u = md5gg(u, f, c, s, t[r + 3], 14, -187363961),
s = md5gg(s, u, f, c, t[r + 8], 20, 1163531501),
c = md5gg(c, s, u, f, t[r + 13], 5, -1444681467),
f = md5gg(f, c, s, u, t[r + 2], 9, -51403784),
u = md5gg(u, f, c, s, t[r + 7], 14, 1735328473),
c = md5hh(c, s = md5gg(s, u, f, c, t[r + 12], 20, -1926607734), u, f, t[r + 5], 4, -378558),
f = md5hh(f, c, s, u, t[r + 8], 11, -2022574463),
u = md5hh(u, f, c, s, t[r + 11], 16, 1839030562),
s = md5hh(s, u, f, c, t[r + 14], 23, -35309556),
c = md5hh(c, s, u, f, t[r + 1], 4, -1530992060),
f = md5hh(f, c, s, u, t[r + 4], 11, 1272893353),
u = md5hh(u, f, c, s, t[r + 7], 16, -155497632),
s = md5hh(s, u, f, c, t[r + 10], 23, -1094730640),
c = md5hh(c, s, u, f, t[r + 13], 4, 681279174),
f = md5hh(f, c, s, u, t[r], 11, -358537222),
u = md5hh(u, f, c, s, t[r + 3], 16, -722521979),
s = md5hh(s, u, f, c, t[r + 6], 23, 76029189),
c = md5hh(c, s, u, f, t[r + 9], 4, -640364487),
f = md5hh(f, c, s, u, t[r + 12], 11, -421815835),
u = md5hh(u, f, c, s, t[r + 15], 16, 530742520),
c = md5ii(c, s = md5hh(s, u, f, c, t[r + 2], 23, -995338651), u, f, t[r], 6, -198630844),
f = md5ii(f, c, s, u, t[r + 7], 10, 1126891415),
u = md5ii(u, f, c, s, t[r + 14], 15, -1416354905),
s = md5ii(s, u, f, c, t[r + 5], 21, -57434055),
c = md5ii(c, s, u, f, t[r + 12], 6, 1700485571),
f = md5ii(f, c, s, u, t[r + 3], 10, -1894986606),
u = md5ii(u, f, c, s, t[r + 10], 15, -1051523),
s = md5ii(s, u, f, c, t[r + 1], 21, -2054922799),
c = md5ii(c, s, u, f, t[r + 8], 6, 1873313359),
f = md5ii(f, c, s, u, t[r + 15], 10, -30611744),
u = md5ii(u, f, c, s, t[r + 6], 15, -1560198380),
s = md5ii(s, u, f, c, t[r + 13], 21, 1309151649),
c = md5ii(c, s, u, f, t[r + 4], 6, -145523070),
f = md5ii(f, c, s, u, t[r + 11], 10, -1120210379),
u = md5ii(u, f, c, s, t[r + 2], 15, 718787259),
s = md5ii(s, u, f, c, t[r + 9], 21, -343485551),
c = safeAdd(c, n),
s = safeAdd(s, o),
u = safeAdd(u, i),
f = safeAdd(f, a);
return [c, s, u, f]
}
function binl2rstr(t) {
var e, r = "",
n = 32 * t.length;
for (e = 0; n > e; e += 8) r += String.fromCharCode(t[e >> 5] >>> e % 32 & 255);
return r
}
function rstr2binl(t) {
var e, r = [];
for (r[(t.length >> 2) - 1] = void 0, e = 0; r.length > e; e += 1) r[e] = 0;
var n = 8 * t.length;
for (e = 0; n > e; e += 8) r[e >> 5] |= (255 & t.charCodeAt(e / 8)) << e % 32;
return r
}
function rstrMD5(t) {
return binl2rstr(binlMD5(rstr2binl(t), 8 * t.length))
}
function rstrHMACMD5(t, e) {
var r, n, o = rstr2binl(t),
i = [],
a = [];
for (i[15] = a[15] = void 0, o.length > 16 && (o = binlMD5(o, 8 * t.length)), r = 0; 16 > r; r += 1) i[r] = 909522486 ^ o[r],
a[r] = 1549556828 ^ o[r];
return n = binlMD5(i.concat(rstr2binl(e)), 512 + 8 * e.length),
binl2rstr(binlMD5(a.concat(n), 640))
}
function rstr2hex(t) {
var e, r, n = "";
for (r = 0; t.length > r; r += 1) e = t.charCodeAt(r),
n += "0123456789abcdef".charAt(e >>> 4 & 15) + "0123456789abcdef".charAt(15 & e);
return n
}
function str2rstrUTF8(t) {
return unescape(encodeURIComponent(t))
}
function rawMD5(t) {
return rstrMD5(str2rstrUTF8(t))
}
function hexMD5(t) {
return rstr2hex(rawMD5(t))
}
function rawHMACMD5(t, e) {
return rstrHMACMD5(str2rstrUTF8(t), str2rstrUTF8(e))
}
function hexHMACMD5(t, e) {
return rstr2hex(rawHMACMD5(t, e))
}
function md5(t, e, r) {
return e ? r ? rawHMACMD5(e, t) : hexHMACMD5(e, t) : r ? rawMD5(t) : hexMD5(t)
}
var ErrorStack = function() {
function t(e) {
_classCallCheck$1(this, t),
this.env = e || checkEnv(),
this.stackFilter = generateHandler(this.env).filter
}
return _createClass$1(t, [{
key: "makeReg",
value: function() {
switch (this.env) {
case "iOS":
return /(?:\s*)\w+(?=@)|(?:@).*?(?=:\d*:)|(?::)\d*(?=:)|(?::)\d*$/g;
default:
return null
}
}
},
{
key: "stackFormatter",
value: function(t) {
var e = t.message,
r = [],
n = "Android" === this.env,
o = "iOS" === this.env,
i = t.stack.split("\n").filter(this.stackFilter);
i.shift();
var a = i.join("\n"),
c = this.makeReg();
return c ? i.map((function(t) {
var e = t.match(c);
if (e) {
var i = _slicedToArray(e, 4),
a = i[0],
s = void 0 === a ? "": a,
u = i[1],
f = void 0 === u ? "": u,
l = i[2],
d = void 0 === l ? "": l,
p = i[3],
h = void 0 === p ? "": p,
y = n ? s.split(".").reverse()[0] : s,
m = o ? 1 : 0;
r.push("at ".concat(y, " (").concat(f.substr(m), ":").concat(d.substr(m), ":").concat(h.substr(m), ")"))
} else r.push(t);
return null
})) : r = i,
{
hash: this.encryptStack(e, r),
message: e,
stackList: r,
stackStr: a
}
}
},
{
key: "encryptStack",
value: function(t, e) {
var r = [].concat(_toConsumableArray(e.slice(0, 6)), _toConsumableArray(e.slice(7, 8)), _toConsumableArray(e.slice(9, 10)), _toConsumableArray(e.slice(11, 12)), _toConsumableArray(e.slice(13, 14))).join(";");
return md5("".concat(t, ":").concat(r))
}
}]),
t
} (),
STACK_LENGTH_LIMIT = 20,
ChromeREGEX = /^\s*at .*? ?\(((?:file|https?|blob|chrome-extension|native|eval|<anonymous>).*?)(?::\d+)?(?::\d+)?\)?\s*$/i,
GeckoREGEX = /^\s*.*?(?:\(.*?\))?(?:^|@)((?:file|https?|blob|chrome|resource|\[native).*?)(?::\d+)?(?::\d+)?\s*$/i,
WinJSREGEX = /^\s*at (?:(?:\[object object\])?.+ )?\(?((?:file|ms-appx|https?|blob):.*?):\d+(?::\d+)?\)?\s*$/i;
function parseStack(t) {
for (var e = t.slice(0, STACK_LENGTH_LIMIT), r = ["", ""], n = {},
o = 1, i = 0; e.length > i; i += 1) {
var a = ChromeREGEX,
c = (e[i] || "").match(a);
if (null === c && (c = (e[i] || "").match(a = GeckoREGEX)), null === c && (c = (e[i] || "").match(a = WinJSREGEX)), null !== c) {
var s = c[1],
u = n[s];
void 0 === u && (n[s] = "#".concat(o, "#"), o += 1, u = n[s]),
e[i] = e[i].replace(s, u)
}
}
e.length > 0 && (r[1] = e.map((function(t) {
return t.trim()
})).join(""));
var f = "";
for (var l in n) n.hasOwnProperty(l) && (f += "".concat(l, "@").concat(n[l], ";"));
return f = f.replace(/;$/, ""),
r[0] = f,
r.join("").replace(/\^/g, "").replace(/=/g, "").replace(/,/g, "")
}
function unParseStack(t) {
var e = t && t.split("") || [];
if (!e[0] || !e[1]) return t;
for (var r = {},
n = e[0].split(";"), o = 0; n.length > o; o += 1) {
var i = n[o] && n[o].split("@#");
r["#".concat(i[1])] = i[0]
}
return e[1].replace(/#[0-9]+#/g, (function(t) {
return r[t] || ""
})).replace(/\u0004/g, "^").replace(/\u0005/g, "=").replace(/\u0006/g, ",").split("")
}
"undefined" == typeof process || _typeof$1(process);
var helper = {
compressStack: function(t) {
return parseStack(t)
},
uncompressStack: function(t) {
return unParseStack(t)
}
},
compressStack = helper.compressStack;
function _typeof$2(t) {
return (_typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
function(t) {
return typeof t
}: function(t) {
return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol": typeof t
})(t)
}
function _classCallCheck$2(t, e) {
if (! (t instanceof e)) throw new TypeError("Cannot call a class as a function")
}
function _defineProperties$2(t, e) {
for (var r = 0; e.length > r; r++) {
var n = e[r];
n.enumerable = n.enumerable || !1,
n.configurable = !0,
"value" in n && (n.writable = !0),
Object.defineProperty(t, n.key, n)
}
}
function _createClass$2(t, e, r) {
return e && _defineProperties$2(t.prototype, e),
r && _defineProperties$2(t, r),
t
}
function _defineProperty$1(t, e, r) {
return e in t ? Object.defineProperty(t, e, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0
}) : t[e] = r,
t
}
function ownKeys$1(t, e) {
var r = Object.keys(t);
if (Object.getOwnPropertySymbols) {
var n = Object.getOwnPropertySymbols(t);
e && (n = n.filter((function(e) {
return Object.getOwnPropertyDescriptor(t, e).enumerable
}))),
r.push.apply(r, n)
}
return r
}
function _objectSpread2$1(t) {
for (var e = 1; arguments.length > e; e++) {
var r = null != arguments[e] ? arguments[e] : {};
e % 2 ? ownKeys$1(Object(r), !0).forEach((function(e) {
_defineProperty$1(t, e, r[e])
})) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : ownKeys$1(Object(r)).forEach((function(e) {
Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(r, e))
}))
}
return t
}
function _toConsumableArray$1(t) {
return _arrayWithoutHoles$1(t) || _iterableToArray$2(t) || _unsupportedIterableToArray$2(t) || _nonIterableSpread$1()
}
function _arrayWithoutHoles$1(t) {
if (Array.isArray(t)) return _arrayLikeToArray$2(t)
}
function _iterableToArray$2(t) {
if ("undefined" != typeof Symbol && Symbol.iterator in Object(t)) return Array.from(t)
}
function _unsupportedIterableToArray$2(t, e) {
if (t) {
if ("string" == typeof t) return _arrayLikeToArray$2(t, e);
var r = Object.prototype.toString.call(t).slice(8, -1);
return "Object" === r && t.constructor && (r = t.constructor.name),
"Map" === r || "Set" === r ? Array.from(t) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? _arrayLikeToArray$2(t, e) : void 0
}
}
function _arrayLikeToArray$2(t, e) { (null == e || e > t.length) && (e = t.length);
for (var r = 0,
n = Array(e); e > r; r++) n[r] = t[r];
return n
}
function _nonIterableSpread$1() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
}
function _createForOfIteratorHelper(t, e) {
var r;
if ("undefined" == typeof Symbol || null == t[Symbol.iterator]) {
if (Array.isArray(t) || (r = _unsupportedIterableToArray$2(t)) || e && t && "number" == typeof t.length) {
r && (t = r);
var n = 0,
o = function() {};
return {
s: o,
n: function() {
return t.length > n ? {
done: !1,
value: t[n++]
}: {
done: !0
}
},
e: function(t) {
throw t
},
f: o
}
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
}
var i, a = !0,
c = !1;
return {
s: function() {
r = t[Symbol.iterator]()
},
n: function() {
var t = r.next();
return a = t.done,
t
},
e: function(t) {
c = !0,
i = t
},
f: function() {
try {
a || null == r.
return || r.
return ()
} finally {
if (c) throw i
}
}
}
}
function allFieldsReady(t) {
var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [],
r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : function() {};
if (!e.length) return ! 0;
var n, o = _createForOfIteratorHelper(e);
try {
for (o.s(); ! (n = o.n()).done;) {
var i = n.value;
if (null == t[i]) return r && r('Field "'.concat(i, '" is required. Log cached.')),
!1
}
} catch(t) {
o.e(t)
} finally {
o.f()
}
return ! 0
}
function shallowMerge(t, e) {
for (var r in e) e.hasOwnProperty(r) && (t[r] = e[r])
}
function objectAssign(t, e) {
if (!e || "object" !== _typeof$2(e)) return t;
var r = t || {};
for (var n in e) e.hasOwnProperty(n) && void 0 !== e[n] && (r[n] = e[n]);
return r
}
function getProperty(t, e) {
for (var r = e.split("."), n = 0; r.length - 1 > n; n++) if ("object" !== _typeof$2(t = t[r[n]]) || !t || Array.isArray(t)) return "";
return t[r.pop()]
}
function setProperty(t, e, r) {
for (var n = e.split("."), o = 0; n.length - 1 > o; o++) {
if ("object" !== _typeof$2(t[n[o]]) && void 0 !== t[n[o]]) return;
if (Array.isArray(t[n[o]])) return;
t[n[o]] || (t[n[o]] = {}),
t = t[n[o]]
}
t[n.pop()] = r
}
var OptionsDefaulter = function() {
function t() {
_classCallCheck$2(this, t),
this.defaults = {},
this.configs = {}
}
return _createClass$2(t, [{
key: "set",
value: function(t, e, r) {
void 0 !== r ? (this.defaults[t] = r, this.configs[t] = e) : (this.defaults[t] = e, delete this.configs[t])
}
},
{
key: "process",
value: function(t) {
var e;
for (var r in t = objectAssign({},
t), this.defaults) if (this.defaults.hasOwnProperty(r)) switch (this.configs[r]) {
case "call":
setProperty(t, r, this.defaults[r].call(this, getProperty(t, r), t));
break;
case "make":
void 0 === getProperty(t, r) && setProperty(t, r, this.defaults[r].call(this, t));
break;
case "append":
var n = getProperty(t, r);
Array.isArray(n) || (n = []),
(e = n).push.apply(e, _toConsumableArray$1(this.defaults[r])),
setProperty(t, r, n);
break;
default:
void 0 === getProperty(t, r) && setProperty(t, r, this.defaults[r])
}
return t
}
}]),
t
} ();
function nodeListToArray(t) {
var e, r;
try {
return e = [].slice.call(t)
} catch(o) {
e = [],
r = t.length;
for (var n = 0; r > n; n++) e.push(t[n]);
return e
}
}
function getAttr(t, e) {
return t && t.getAttribute && t.getAttribute(e) || ""
}
var warnCache = {},
defaulterSingleton;
function warnDeprecated(t, e) {
console && console.warn && !warnCache[t] && (warnCache[t] = 1, console.warn("閰嶇疆椤� [".concat(t, "] 宸蹭笉鎺ㄨ崘浣跨敤銆傝浣跨敤 [").concat(e, "]銆�")))
}
function getGlobal() {
return eval ? (0, eval)("this") : global || window
}
function getOptionsDefaulter() {
return defaulterSingleton || (defaulterSingleton = createOptionsDefaulter()),
defaulterSingleton
}
var getMetaInfo = function(t) {
return function(e) {
var r;
if (! (null == t || null === (r = t.document) || void 0 === r ? void 0 : r.querySelectorAll)) return "";
for (var n = nodeListToArray(t.document.querySelectorAll("meta")), o = 0; n.length > o; o++) {
var i = n[o];
if (getAttr(i, "name") === e) return getAttr(i, "content")
}
return null
}
} (getGlobal()),
metaMap = {
_appId: "bm_app_id",
yuyanId: "yuyan_id",
sprintId: "bm_sprint_id"
};
function getMetaOptions() {
var t = {};
for (var e in metaMap) if (metaMap.hasOwnProperty(e)) {
var r = getMetaInfo(metaMap[e]);
r && (t[e] = r)
}
return t
}
function createOptionsDefaulter() {
var t = new OptionsDefaulter,
e = getMetaOptions();
return t.set("bmAppid", "call", (function(t, r) {
return t ? (warnDeprecated("bmAppid", "_appId"), t) : r.appid ? (warnDeprecated("appid", "_appId"), r.appid) : r._appId || e._appId
})),
t.set("yuyanId", "call", (function(t) {
return t || e.yuyanId
})),
t.set("userId", "call", (function(t, e) {
return e.roleId ? (warnDeprecated("roleId", "userId"), e.roleId) : t
})),
t.set("disableInterface", "call", (function(t) {
return t || !1
})),
t.set("oncePerSession", "call", (function(t) {
return t || !1
})),
t.set("autoCapture", "call", (function(t, e) {
return ! e.hasOwnProperty("autoCapture") || !!e.autoCapture
})),
t.set("defaults", "call", (function(t) {
return objectAssign({},
t)
})),
t.set("sprintId", "call", (function(t) {
return t || e.sprintId
})),
t.set("requiredFields", "call", (function(t) {
return Array.isArray(t) ? t: "string" == typeof t ? [t] : []
})),
t.set("eventId", "call", (function(t, e) {
return "PC" === e.appType ? "102022": "102023"
})),
t.set("beforeLog", "call", (function(t) {
if ("function" == typeof t) return t
})),
t.set("callBridge", "call", (function(t) {
if ("function" == typeof t) return t
})),
t.set("plugins", "call", (function(t) {
return Array.isArray(t) ? t: ["performance", "buc"]
})),
t
}
var ErrorCodeEnums = {
JS: 1,
REQUEST: 2,
PROMISEREJECTION: 3,
ASSETS: 4
},
enums = Object.freeze({
__proto__: null,
ErrorCodeEnums: ErrorCodeEnums
}),
es = new ErrorStack;
function logError(t, e, r) {
var n = r.log,
o = r._warn,
i = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {};
try {
var a = (null == i ? void 0 : i.code) || ErrorCodeEnums.JS,
c = "";
if (t) if (t.stack) {
var s = es.stackFormatter(t),
u = s.hash,
f = s.stackList;
c = u,
u && f && f.length && e(u).then((function(t) {
t || n(_objectSpread2$1(_objectSpread2$1({},
i), {},
{
code: ErrorCodeEnums.JS,
s1: u,
s2: compressStack(f),
s3: 1
}))
})).
catch((function(t) {
o("hash妫€娴嬪け璐�", t)
})),
n(_objectSpread2$1({
code: a,
msg: t.message,
s10: c
},
i))
} else n(_objectSpread2$1({
code: a,
msg: t.message || t
},
i))
} catch(t) {
o("寮傚父涓婃姤澶辫触:", t)
}
}
var checkApp = function(t) {
var e = {},
r = t.match(/AliApp\S+\b\)/gi);
return e.is = !!/(T-UA)|(TBIOS)|(WindVane)|(AliApp)/i.test(t),
e.name = r ? r[0].match(/\(\w+\-*\w*/)[0].split("(")[1] : "",
e.version = r ? r[0].match(/(\d+\.*)+/gi)[0] : "",
e
},
checkApp_1 = checkApp,
encodeValue = function(t) {
return encodeURIComponent(t).replace(/'/g, "%27")
};
function objToStr(t) {
var e, r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "^",
n = arguments.length > 2 && void 0 !== arguments[2] && arguments[2],
o = [];
if (t instanceof Array) o = t;
else if (t instanceof Object) {
var i = n ? encodeValue: function(t) {
return t
};
for (e in t) if (t.hasOwnProperty(e)) {
var a = i(t[e]);
o.push("".concat(e, "=").concat(a))
}
}
return o.join(r)
}
function getTime() {
var t = new Date,
e = function(t) {
return 10 > t ? "0".concat(t) : "".concat(t)
};
return "".concat(t.getFullYear(), "-").concat(e(t.getMonth() + 1), "-").concat(e(t.getDate()), " ").concat(e(t.getHours()), ":").concat(e(t.getMinutes()), ":").concat(e(t.getSeconds()), ":").concat(t.getMilliseconds())
}
function parseItem(t) {
if (!t || "object" !== _typeof(t)) return [];
var e = t.eventId,
r = t.userId,
n = t.ua,
o = t.param4,
i = ["D-AE", getTime(), "", "", "2", "", "", r, "1000", e, "H5behavior", "2", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", n, "", "", "", "", "", ""];
return i.push(objToStr(o, "^", !0)),
i
}
function objectAssign$1(t, e) {
var r = t || {};
if (!e || "object" !== _typeof(e)) return r;
for (var n in e) e.hasOwnProperty(n) && void 0 !== e[n] && (r[n] = e[n]);
return r
}
function checkIsAlipay(t) {
var e = t && t.userAgent;
if (!e) return ! 1;
var r = checkApp_1(e);
return ["AP", "AF", "AFW", "BK", "AM", "APHK", "KB"].indexOf(r.name) >= 0
}
function applyMixins(t, e) {
e.forEach((function(e) {
Object.getOwnPropertyNames(e.prototype).forEach((function(r) {
"constructor" !== r && (t.prototype[r] = e.prototype[r])
}))
}))
}
function addEvent(t, e, r) {
var n = e || window.document;
n.addEventListener ? n.addEventListener(t, r, !0) : n.attachEvent ? n.attachEvent("on".concat(t), r) : n[t] = r
}
function removeEvent(t, e, r) {
var n = e || window.document;
n.removeEventListener ? n.removeEventListener(t, r, !0) : n.detachEvent ? n.detachEvent("on".concat(t), r) : n[t] = r
}
function generateIdentifier(t) {
return [t.code, t.uid, t.page, t.msg || ""].join("_")
}
function load(t) {
"interactive" === document.readyState || "complete" === document.readyState ? t() : addEvent("DOMContentLoaded", document, t)
}
function getAttr$1(t, e) {
return t && t.getAttribute && t.getAttribute(e) || ""
}
function nodeListToArray$1(t) {
var e, r;
try {
return e = [].slice.call(t)
} catch(o) {
e = [],
r = t.length;
for (var n = 0; r > n; n++) e.push(t[n]);
return e
}
}
function getXPath(t, e) {
var r = t.id ? "".concat(t.id) : "",
n = t.className ? "".concat(t.className) : "",
o = t.tagName.toLowerCase(),
i = r || n,
a = [];
r && a.push('[@id="'.concat(r, '"]')),
n && a.push('[@class="'.concat(n, '"]'));
var c = "".concat(o).concat(i ? a.join("") : "");
return t.parentNode && t.parentNode.tagName && e - 1 != 0 ? "".concat(getXPath(t.parentNode, e - 1), ">").concat(c) : c
}
function getResourceErrorSrc() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.src || t.href;
return "img" === t.tagName.toLowerCase() && 0 === e.indexOf("data:") && (e = e.split(",")[0]),
e
}
var spmDataKey = "data-aspm";
function getMetaSpm(t) {
for (var e, r, n, o, i = nodeListToArray$1(t || document.getElementsByTagName("meta")), a = i.length, c = 0; a > c; c++) if (r = getAttr$1(e = i[c], "name"), n = getAttr$1(e, "content"), r === spmDataKey && n) {
o = n;
break
}
var s = {};
return o && (s.spmAPos = o),
s
}
function getSpmBPos() {
return getAttr$1(document.body, spmDataKey)
}
var win = window;
function interfaceRegister(t) {
var e = !1;
if ("XMLHttpRequest" in win) {
var r = win.XMLHttpRequest.prototype,
n = r.open;
r.open = function(t, e) {
this.__interfaceMonitor__ = {
method: t,
url: e || "",
status_code: null
};
for (var r = Array(arguments.length), o = 0; r.length > o; ++o) r[o] = arguments[o];
n.apply(this, r)
};
var o = r.send;
r.send = function(r) {
var n = this;
function i() {
if (n.__interfaceMonitor__ && 4 === n.readyState) try {
var o = n.__interfaceMonitor__.url;
if (0 === n.status) return;
var i = o.split("?")[0],
a = o.split("?")[1] || "",
c = "string" == typeof r ? r: JSON.stringify(r),
s = n.response + "";
s.length > 2048 && (s = "[too large]");
if (200 > n.status || n.status > 299 || e) {
if (i === t.server) return void t._warn("涓婃姤寮傚父", c);
t.logRequestError({
type: "http",
status: n.status,
url: i,
method: n.__interfaceMonitor__.method,
query: a,
data: c,
response: s,
traceId: t.traceId || ""
})
}
} catch(e) {
t._warn("鎺ュ彛寮傚父涓婃姤澶辫触:", e)
}
}
if ("onreadystatechange" in n && "function" == typeof n.onreadystatechange) {
var a = n.onreadystatechange;
n.onreadystatechange = function() {
for (var t = Array(arguments.length), e = 0; t.length > e; ++e) t[e] = arguments[e];
i.apply(this, t),
a.apply(this, t)
}
} else n.onreadystatechange = i;
for (var c = Array(arguments.length), s = 0; c.length > s; ++s) c[s] = arguments[s];
return o.apply(this, arguments)
}
}
if ("fetch" in win) {
var i = win.fetch;
win.fetch = function() {
for (var r = Array(arguments.length), n = 0; r.length > n; ++n) r[n] = arguments[n];
var o = "GET";
return r[1] && r[1].method && (o = r[1].method.toUpperCase()),
i.apply(this, r).then((function(n) {
return new Promise((function(i) {
try {
var a = r[0],
c = a.split("?")[0],
s = a.split("?")[1] || "",
u = r[1] && r[1].body || "",
f = "string" == typeof u ? u: JSON.stringify(u);
n.clone().text().then((function(r) {
n.ok && !e || t.logRequestError({
type: "http",
status: n.status,
url: c,
method: o,
query: s,
data: f,
response: (r || "").length > 2048 ? "[too large]": r,
traceId: t.traceId || ""
})
})).then((function() {
i(n)
}), (function() {
i(n)
}))
} catch(t) {
i(n)
}
}))
}))
}
}
}
var version = "2.0.29",
spliter = "",
doc = document,
docEl = doc.documentElement,
LastAction = function() {
function t() {
var e = this;
_classCallCheck(this, t),
this.lastAction = "0".concat(getTime(), ""),
this.setLastActionTimer = !1,
addEvent("scroll", document, (function(t) {
e.setLastActionTimer || (e.setLastActionTimer = !0, setTimeout((function() {
e.setLastActionTimer = !1
}), 300), e.setLastAction(t))
})),
addEvent("click", document, (function(t) {
e.setLastAction(t)
}))
}
return _createClass(t, [{
key: "setLastAction",
value: function(t) {
try {
var e = [],
r = "click" === t.type;
e.push(r ? 1 : 2);
var n = r ? "".concat(getXPath(t.target, 5)) : "";
e.push(n),
e.push(getTime());
var o = r ? "".concat(t.x, "x").concat(t.y) : "".concat(docEl.scrollLeft + doc.body.scrollLeft, "x").concat(docEl.scrollTop + doc.body.scrollTop);
e.push(o);
var i = t.target && t.target.innerText,
a = i ? "".concat(i.slice(0, 8)) : "";
e.push(a),
this.lastAction = e.join(spliter)
} catch(t) {}
}
},
{
key: "get",
value: function() {
return this.lastAction
}
}]),
t
} (),
serverUrl = "https://mdap.alipay.com/loggw/dwcookieLogGet.do",
NAVIGATION_KEYS = ["connectEnd", "connectStart", "decodedBodySize", "domComplete", "domContentLoadedEventEnd", "domContentLoadedEventStart", "domInteractive", "domainLookupEnd", "domainLookupStart", "duration", "encodedBodySize", "fetchStart", "loadEventEnd", "loadEventStart", "redirectCount", "redirectEnd", "redirectStart", "requestStart", "responseEnd", "responseStart", "secureConnectionStart", "transferSize", "type", "unloadEventEnd", "unloadEventStart", "workerStart", "firstPaint", "firstContentfulPaint", "firstMeaningfulPaint"],
ErrorCodeEnums$1 = enums.ErrorCodeEnums,
doc$1 = document,
docEl$1 = doc$1.documentElement,
startTime = (new Date).getTime(),
Base = function() {
function t(e) {
_classCallCheck(this, t),
this.server = serverUrl,
this.userConfig = {},
this.defaults = {},
this.cOfflineVer = "",
this.cAppId = "",
this.cUserId = "",
this.trackedLogs = [],
this.requiredFields = [],
this.isErrorHandler = !1,
this.enabledPlugins = [];
var r = getOptionsDefaulter().process(e);
this.userConfig = r,
this.eventId = "102022",
this.bmAppid = r.bmAppid,
this.debug = r.debug || !1,
this.autoCapture = r.autoCapture,
this.disableInterface = r.disableInterface,
this.lastActionComp = new LastAction,
this.oncePerSession = r.oncePerSession,
this.beforeLog = r.beforeLog,
this.defaults = r.defaults || {},
this.requiredFields = r.requiredFields || [],
this.enabledPlugins = r.plugins
}
return _createClass(t, [{
key: "handleErrorEvent",
value: function(t, e) {
try {
var r = t.target || t.srcElement;
if (!r) return;
if ("unhandledrejection" === t.type) {
var n = t.reason || {};
if (n.message && n.stack) this.logError(n, {
code: ErrorCodeEnums$1.PROMISEREJECTION
});
else {
var o = n.message || ("string" == typeof n ? n: JSON.stringify(n));
e({
code: ErrorCodeEnums$1.PROMISEREJECTION,
msg: o
})
}
return
}
if (r instanceof HTMLElement) {
var i = getResourceErrorSrc(r),
a = r.tagName.toLowerCase(),
c = r.alt,
s = void 0 === c ? "": c;
return void e({
code: ErrorCodeEnums$1.ASSETS,
msg: i || "",
s1: a,
s2: getXPath(r, 5),
s3: s
})
}
if (t.error && t.error.stack) return void this.logError(t.error);
e({
code: ErrorCodeEnums$1.JS,
msg: t.message,
s3: 0
})
} catch(t) {
this._warn("handleErrorOptions failed", t)
}
}
},
{
key: "handlePreCapture",
value: function() {
var t = this,
e = window.g_monitor;
if (e) {
var r = e.listener,
n = void 0 === r ? {}: r,
o = e.events,
i = void 0 === o ? [] : o;
for (var a in n) n.hasOwnProperty(a) && (removeEvent(a, window, n[a]), delete n[a]);
for (var c = 0; i.length > c; c++) this.handleErrorEvent(i[c], (function(e) {
t.log(e)
}));
e.events = []
}
}
},
{
key: "register",
value: function() {
var t = this;
if (this.autoCapture) try {
if (!doc$1) return this._warn("褰撳墠涓洪潪 web 鐜锛屼笉鏀寔鎶ラ敊鐩戝惉涓庢彃浠朵娇鐢�"),
this;
if (this.isErrorHandler) return void this._warn("閿欒浜嬩欢宸茬洃鍚�");
var e = function(e) {
t.handleErrorEvent(e, (function(e) {
t.log(e)
}))
};
addEvent("error", window, e),
addEvent("unhandledrejection", window, e),
this.isErrorHandler = !0
} catch(t) {
this._warn("寮傚父鐩戝惉浜嬩欢娉ㄥ唽澶辫触", t)
} else this._warn("宸查€氳繃 autoCapture 绂佺敤寮傚父鎹曡幏")
}
},
{
key: "isBridgeReport",
value: function(t) {
return window.AlipayJSBridge && (Number(t) > 10 || 1 > Number(t))
}
},
{
key: "getNetwork",
value: function() {
var t = navigator;
return t && t.connection && t.connection.effectiveType ? t.connection.effectiveType: ""
}
},
{
key: "_warn",
value: function() {
var t = window;
if ("object" === _typeof(t) && t.console && "function" == typeof t.console.warn && this.debug) {
for (var e = arguments.length,
r = Array(e), n = 0; e > n; n++) r[n] = arguments[n];
var o = Array.prototype.slice.call(r);
t.console.warn.call(null, "[Monitor Debug]".concat(o[0]), o.slice(1))
}
}
},
{
key: "parseParam4",
value: function(t) {
if (!t || "object" !== _typeof(t)) return null;
var e = _objectSpread2(_objectSpread2({},
this.defaults), t); (t.bmAppid || this.bmAppid) && (e.bm_appid = t.bmAppid || this.bmAppid),
this.userConfig.sprintId && (e.bm_sid = this.userConfig.sprintId),
this.userConfig.env && (e.env = this.userConfig.env),
this.userConfig.yuyanId && (e.yuyan_id = this.userConfig.yuyanId),
e.monitor_ver = "websdk:".concat(version),
e.title = e.title || document.title,
e.dom_cnt = document.getElementsByTagName("*").length,
e.delay = (new Date).getTime() - startTime,
e.scroll_top = docEl$1.scrollTop + doc$1.body.scrollTop,
e.content_height = Math.max(docEl$1.clientHeight, docEl$1.offsetHeight, docEl$1.scrollHeight),
e.last_action = this.lastActionComp.get(),
e.network = this.getNetwork();
var r = this.userConfig.spmAPos && this.userConfig.spmBPos ? "".concat(this.userConfig.spmAPos, ".").concat(this.userConfig.spmBPos) : "";
if (r && (e.spmId = r), e.fullURL = e.fullURL || location.href, this.cOfflineVer && (e.c_offline_ver = this.cOfflineVer), this.cAppId && (e.c_app_id = this.cAppId), "object" === _typeof(e)) {
var n = e;
for (var o in n) if (n.hasOwnProperty(o) && "string" == typeof n[o]) {
var i = n[o].replace(/\s+/g, " ");
n[o] = "fullURL" === o && i.length > 300 ? i.slice(0, 300) : i
}
}
return e
}
},
{
key: "sendData",
value: function(t) {
var e = encodeURIComponent;
this.debug && console.log("send", t);
try {
var r = new XMLHttpRequest;
r.open("POST", this.server, !0),
r.setRequestHeader("Content-type", "application/x-www-form-urlencoded"),
r.send("data=".concat(e(t.join()), "&time=").concat((new Date).getTime()))
} catch(r) {
try { (new Image).src = "".concat(this.server, "?data=").concat(e(t.join()), "&time=").concat((new Date).getTime())
} catch(t) {
this._warn("閫氳繃 IMG 涓婃姤澶辫触.", t)
}
}
}
},
{
key: "bridgeLog",
value: function(t) {
window.AlipayJSBridge ? window.AlipayJSBridge.call("handleLoggingAction", {
actionType: "reportEvent",
params: {
eventId: this.eventId,
bizType: "bmmonitor",
extData: t || {}
}
}) : this._warn("闈炲鍣ㄧ幆澧冿紝涓嶈兘璋冪敤 handleLoggingAction")
}
}]),
t
} (),
monitorConfigCacheKey = "_YUYAN_COOKIE_monitor_config",
expireDelta = 9e5,
ConfigStorage = function() {
function t() {
_classCallCheck(this, t)
}
return _createClass(t, [{
key: "getStorageInfoMap",
value: function() {
try {
var t = window.localStorage;
if (!t) return {};
var e = t.getItem(monitorConfigCacheKey) || "{}";
return JSON.parse(e)
} catch(t) {
console && console.warn && console.warn("[MonitorSDK]浠嶴torage涓幏鍙栭厤缃け璐�", t)
}
return {}
}
},
{
key: "getMonitorConfig",
value: function(t) {
var e = this.getStorageInfoMap()[t];
return ! e || (new Date).valueOf() > e.expire ? null: e.config
}
},
{
key: "saveMonitorConfig",
value: function(t, e) {
var r = window.localStorage;
if (!r) return null;
var n = this.getStorageInfoMap();
n[t] = {
config: e,
expire: (new Date).valueOf() + expireDelta
},
r.setItem(monitorConfigCacheKey, JSON.stringify(n))
}
}]),
t
} (),
configStorage = new ConfigStorage;
function execScript(Monitor, configScript) {
var window = {
Tracert: Monitor
};
return eval(configScript),
window
}
var ServerConfig = function() {
function t() {
_classCallCheck(this, t),
this.monitorConfigInited = !1,
this.monitorConfigFailed = !1,
this.monitorOptions = []
}
return _createClass(t, [{
key: "fetchConfig",
value: function() {
var t = this;
if (this.bmAppid) {
var e = configStorage.getMonitorConfig(this.bmAppid);
if (e) this.setMonitorConfigs(e);
else {
var r = "https://render.alipay.com/p/alertserver".concat("pre" === this.userConfig.env ? "_pre": "", "/").concat(this.bmAppid, "_config/index.js");
window.AlipayJSBridge ? this.fetchConfigByJSBridge(r) : this.fetchConfigByRequest(r)
}
} else setTimeout((function() {
t.onFetchConfigError("娌℃湁 bmAppid")
}))
}
},
{
key: "fetchConfigByRequest",
value: function(t) {
var e = this;
window.XMLHttpRequest || this.onFetchConfigError("娌℃湁 XHR锛屾棤娉曡姹傞厤缃�");
try {
var r = new XMLHttpRequest;
r.open("GET", t, !0),
r.send(),
r.onreadystatechange = function() {
if (4 === r.readyState) if (200 === r.status || 304 === r.status) try {
execScript(e, r.responseText)
} catch(t) {
e.onFetchConfigError(t)
} else e.onFetchConfigError("鑾峰彇閰嶇疆澶辫触: ".concat(t))
}
} catch(t) {
this.onFetchConfigError(t)
}
}
},
{
key: "initMonitorConfigs",
value: function(t) {
this.setMonitorConfigs(t),
configStorage.saveMonitorConfig(this.bmAppid, t)
}
},
{
key: "setMonitorConfigs",
value: function(t) {
this.monitorOptions = t.monitors,
this.monitorConfigInited = !0,
this.onMonitorConfigInited()
}
},
{
key: "fetchConf