alife-logger
Advanced tools
Comparing version 1.5.7 to 1.5.9
# Changelog | ||
* [[a41d3b2](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/a41d3b2c74084da57cb9573ee810de6beb690dfb)] - `chore` 注释优化 | ||
* [[9b67b5c](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/9b67b5c84aaa45cb4920d3daf09754366ceea15f)] - `test` ignore配置项单测 | ||
* [[327b164](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/327b1641349d67c04d8e6f5dd1642c445e2e1f61)] - `test` ignore配置正则单测 | ||
* [[54bf1ca](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/54bf1ca76e95d52921a6359bc7c805779255030e)] - `test` ignoreUrls & ignoreApis & ignoreErrors 字符串模式单测 | ||
* [[107829a](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/107829a44f6f38a7011b7370da04ff9b73ef8baf)] - `test` base logger | ||
* [[29335b8](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/29335b83a553b37a91f18da0951b2fa936f4f149)] - `test` 基础log方法单测 | ||
* [[bd4f1bf](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/bd4f1bf48dc9b50deab45392a22800e4d7228a4b)] - `test` base logger 单测 | ||
* [[7b106a9](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/7b106a972b6cf130891e178c05ec18a709d4dd6a)] - `fix` ignore为空的bug | ||
* [[803cd73](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/803cd73f5f226cb0d9b28e429cd1650b58281f33)] - `feat` 过滤规则支持string/RegExp/Function及其混搭 | ||
* [[fd9ce96](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/fd9ce967da573360a67bc685085b04ac846738d1)] - `chore` 调整ignore配置项格式 | ||
* [[3bcc0cb](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/3bcc0cbceb1cb4f4095c88f6db1e592d9fbd164d)] - `feat` ignoreApis, ignoreErrors, ignoreUrls | ||
* [[b6c9d85](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/b6c9d85e09d3a5351c8f5690702ea7056e16afb6)] - `feat` url & api过滤规则 | ||
* [[d5f0514](http://gitlab.alibaba-inc.com/retcode/cloud-sdk/commit/d5f051495b62489d693de3cd76aace73fa45f44a)] - `feat` 增加ignoreErrors等配置项 | ||
@@ -4,0 +17,0 @@ ## 1.5.3 / 2019-05-05 |
var util = require("./util"), pushToQueue = function(e, t) { | ||
var i; | ||
{ | ||
if ("error" !== t.t || !(i = e.requestQueue[0]) || "error" !== i.t || t.msg !== i.msg) return e.requestQueue.unshift(t), | ||
e.onReady(function() { | ||
e.requestTimmer = util.delay(function() { | ||
e.clear(); | ||
}, "error" === t.t ? 3e3 : -1); | ||
}), !0; | ||
if ("error" !== t.t || !(i = e.requestQueue[0]) || "error" !== i.t || t.msg !== i.msg) { | ||
if ("behavior" === t.t) { | ||
var r = e.requestQueue && e.requestQueue.length; | ||
if (r > 0 && "behavior" === e.requestQueue[r - 1].t) { | ||
var s = t.behavior || []; | ||
e.requestQueue[r - 1].behavior.concat(s); | ||
} else e.requestQueue.push(t); | ||
} else e.requestQueue.unshift(t); | ||
return e.onReady(function() { | ||
e.requestTimmer = util.delay(function() { | ||
e.clear(); | ||
}, e.requestQueue[0] && "error" === e.requestQueue[0].t ? 3e3 : -1); | ||
}), !0; | ||
} | ||
i.times++; | ||
} | ||
}, Base = function(e) { | ||
return this.ver = "1.5.7", this._conf = util.ext({}, Base.dftCon), this.sampleCache = {}, | ||
return this.ver = "1.5.9", this._conf = util.ext({}, Base.dftCon), this.sampleCache = {}, | ||
this.requestQueue = [], this.hash = util.seq(), this.resetSession(), this.setConfig(e), | ||
@@ -92,11 +100,11 @@ this.rip = util.getRandIP(), this.record = 999, this["EagleEye-TraceID"] = this.getTraceId()["EagleEye-TraceID"], | ||
var e; | ||
for (clearTimeout(this.requestTimmer), this.requestTimmer = null; e = this.requestQueue.pop(); ) "res" === e.t ? this.postData(e, "res") : "error" === e.t ? this.postData(e, "err") : this.sendRequest(e); | ||
for (clearTimeout(this.requestTimmer), this.requestTimmer = null; e = this.requestQueue.pop(); ) "res" === e.t ? this.postData(e, "res") : "error" === e.t ? this.postData(e, "err") : "behavior" === e.t ? this.postData(e, "behavior") : this.sendRequest(e); | ||
return this; | ||
}, | ||
_lg: function(e, t, i) { | ||
var r = this._conf, n = this.getPage(), s = r.ignore || {}, o = s.ignoreErrors, u = s.ignoreUrls, a = s.ignoreApis; | ||
return util.ignoreByRule(n, u) ? this : "error" === e && util.ignoreByRule(t.msg, o) ? this : "api" === e && util.ignoreByRule(t.api, a) ? this : this.checkImgUrl(r.imgUrl) && t && !r.disabled && r.pid ? i && !this.sampling(i) ? this : (t = util.ext({ | ||
var r = this._conf, s = this.getPage(), n = r.ignore || {}, o = n.ignoreErrors, u = n.ignoreUrls, a = n.ignoreApis; | ||
return util.ignoreByRule(s, u) ? this : "error" === e && util.ignoreByRule(t.msg, o) ? this : "api" === e && util.ignoreByRule(t.api, a) ? this : this.checkImgUrl(r.imgUrl) && t && !r.disabled && r.pid ? i && !this.sampling(i) ? this : (t = util.ext({ | ||
t: e, | ||
times: 1, | ||
page: n, | ||
page: s, | ||
tag: r.tag || "", | ||
@@ -111,3 +119,6 @@ release: r.release || "", | ||
sampling: i || 1, | ||
z: util.seq() | ||
z: util.seq(), | ||
custom_1: r.custom_1, | ||
custom_2: r.custom_2, | ||
custom_3: r.custom_3 | ||
}), pushToQueue(this, t)) : this; | ||
@@ -114,0 +125,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
var util = require("../util"), Reporter = require("../reporter"), webSender = require("../common/sender"), webPost = require("../common/post"), win = util.win, doc = win.document, validFn = /^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig)$/, Browser = function(e) { | ||
var util = require("../util"), Reporter = require("../reporter"), webSender = require("../common/sender"), webPost = require("../common/post"), win = util.win, doc = win.document, validFn = /^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig|behavior)$/, Browser = function(e) { | ||
var r = this; | ||
@@ -10,3 +10,4 @@ return Reporter.call(r, e), r._initialPage = e.page && util.safetyCall(e.page, [], e.page + "") || null, | ||
"error" === e ? r._health.errcount++ : "api" === e && r._health[t.success ? "apisucc" : "apifail"]++; | ||
}, r.initHandler(), r.initHook(), r.initFmpObserver(1e4), Object.defineProperty && win.addEventListener && Object.defineProperty(r, "pipe", { | ||
}, r.initHandler(), r.initHook(), r.initFmpObserver(1e4), r._conf && r._conf.behavior && r.initBehavior(), | ||
Object.defineProperty && win.addEventListener && Object.defineProperty(r, "pipe", { | ||
set: r.sendPipe | ||
@@ -18,10 +19,4 @@ }), r; | ||
uid: null, | ||
ignoreUrlPath: [ { | ||
rule: /\/([a-z\-_]+)?\d{2,20}/g, | ||
target: "/$1**" | ||
}, /\/$/ ], | ||
ignoreApiPath: { | ||
rule: /(\w+)\/\d{2,}/g, | ||
target: "$1" | ||
}, | ||
ignoreUrlPath: null, | ||
ignoreApiPath: null, | ||
urlHelper: [ { | ||
@@ -42,2 +37,3 @@ rule: /\/([a-z\-_]+)?\d{2,20}/g, | ||
sendResource: !0, | ||
behavior: !0, | ||
parseHash: function(e) { | ||
@@ -68,3 +64,3 @@ return (e ? util.cutUrlSearch(e.replace(/^#\/?/, "")) : "") || "[index]"; | ||
var r = this._conf, t = r.page, i = location, o = i.host + i.pathname; | ||
return t && !e ? util.safetyCall(t, [], t + "") : this._initialPage || util.filterByRule(r.ignoreUrlCase ? o.toLowerCase() : o, r.ignoreUrlPath); | ||
return t && !e ? util.safetyCall(t, [], t + "") : this._initialPage || util.filterByRule(r.ignoreUrlCase ? o.toLowerCase() : o, r.ignoreUrlPath ? r.ignoreUrlPath : r.urlHelper); | ||
}, | ||
@@ -133,4 +129,5 @@ setPage: function(e, r) { | ||
} | ||
}), require("./handler")(Browser, win, doc), require("./fmp")(Browser, win, doc), | ||
require("./hook")(Browser, win), require("./hack")(Browser, win), Browser._super = Reporter, | ||
Browser._root = Reporter._root, Reporter.Browser = Browser, module.exports = Browser; | ||
}), require("./behavior")(Browser, win), require("./handler")(Browser, win, doc), | ||
require("./fmp")(Browser, win, doc), require("./hook")(Browser, win), require("./hack")(Browser, win), | ||
Browser._super = Reporter, Browser._root = Reporter._root, Reporter.Browser = Browser, | ||
module.exports = Browser; |
module.exports = function(e, n, r) { | ||
var t = require("../util"), a = require("../common/perf"), o = require("../common/res"), i = null, h = r.documentElement, s = n.innerWidth || h.clientWidth || r.body.clientWidth, c = n.innerHeight || h.clientHeight || r.body.clientHeight, d = n.navigator.connection, l = { | ||
var t = require("../util"), a = require("../common/perf"), i = require("../common/res"), o = null, h = r.documentElement, s = n.innerWidth || h.clientWidth || r.body.clientWidth, c = n.innerHeight || h.clientHeight || r.body.clientHeight, d = n.navigator.connection, l = { | ||
sr: screen.width + "x" + screen.height, | ||
vp: s + "x" + c, | ||
ct: d ? d.effectiveType || d.type : "" | ||
}, u = {}, f = function(e, n, a, o, i) { | ||
}, u = {}, f = function(e, n, a, i, o) { | ||
if (n === undefined) { | ||
@@ -21,3 +21,3 @@ var h, s; | ||
var c = e + "=" + n; | ||
o && (c += "; domain=" + o), c += "; path=" + (i || "/"), a && (c += "; max-age=" + a); | ||
i && (c += "; domain=" + i), c += "; path=" + (o || "/"), a && (c += "; max-age=" + a); | ||
try { | ||
@@ -38,3 +38,3 @@ return r.cookie = c, !!r.cookie; | ||
activeErrHandler: function(e) { | ||
return i && !e ? this : (i = this, this); | ||
return o && !e ? this : (o = this, this); | ||
}, | ||
@@ -44,6 +44,9 @@ errorHandler: function(e) { | ||
var n = e.type; | ||
return "error" === n ? this.error(e.error || { | ||
"error" === n ? this.error(e.error || { | ||
message: e.message | ||
}, e) : "unhandledrejection" === n && t.T(e.reason, "Error") && t.checkAutoError(e.reason) && this.error(e.reason), | ||
this; | ||
}, e) : "unhandledrejection" === n && t.T(e.reason, "Error") && t.checkAutoError(e.reason) && this.error(e.reason); | ||
try { | ||
this.getConfig("behavior") && this.reportBehavior && this.reportBehavior(); | ||
} catch (e) {} | ||
return this; | ||
}, | ||
@@ -60,3 +63,3 @@ sendPerformance: function(e) { | ||
n.onReady(function() { | ||
var r = o(); | ||
var r = i(); | ||
r && (r.load && r.load <= 2e3 || r.load && r.load <= 8e3 && Math.random() > .05 || (r.page = n.getPage(!0), | ||
@@ -117,6 +120,6 @@ r.dl = location.href, e && (r = t.ext(r, e)), n._lg("res", r, n.getConfig("sample")))); | ||
}), t.on(n, "error", function(e) { | ||
i && i.errorHandler(e); | ||
o && o.errorHandler(e); | ||
}).on(n, "unhandledrejection", function(e) { | ||
i && i.errorHandler(e); | ||
o && o.errorHandler(e); | ||
}), e; | ||
}; |
module.exports = function(e, t) { | ||
var a = require("../util"), n = null, r = function(e, t, n, r, o, i, s, p, c, l) { | ||
var a = require("../util"), n = null, r = function(e, t, n, r, o, i, s, p, l, c) { | ||
var g = a.J(o) || null, u = a.safetyCall(t, [ g, r ], null); | ||
if (!u) return !1; | ||
var f = u.code || i, h = !("success" in u) || u.success; | ||
e.api(n, h, s, f, u.msg, p, c, l); | ||
e.api(n, h, s, f, u.msg, p, l, c); | ||
}, o = "fetch", i = "__oFetch_", s = "__oXMLHttpRequest_", p = "XMLHttpRequest"; | ||
@@ -21,6 +21,6 @@ return a.ext(e.prototype, { | ||
if (i && ("HEAD" === i.method || "no-cors" === i.mode)) return e.apply(t, s); | ||
var c = Date.now(), l = p._conf, g = (o && "string" != typeof o ? o.url : o) || "", u = g; | ||
var l = Date.now(), c = p._conf, g = (o && "string" != typeof o ? o.url : o) || "", u = g; | ||
if (g = a.cutUrlSearch(g), !a.checkAPI(g, !0)) return e.apply(t, s); | ||
g = a.filterByRule(g, l.ignoreApiPath); | ||
var f = l.enableLinkTrace, h = "", y = "", d = p.getConfig("pid"); | ||
g = a.filterByRule(g, c.ignoreApiPath ? c.ignoreApiPath : c.apiHelper); | ||
var f = c.enableLinkTrace, h = "", y = "", d = p.getConfig("pid"); | ||
if (f) { | ||
@@ -56,10 +56,10 @@ var E = ""; | ||
} | ||
var o = Date.now() - c; | ||
var o = Date.now() - l; | ||
return t.ok ? t.text().then(function(e) { | ||
r(p, l.parseResponse, g, u, e, t.status || 200, o, c, h, y); | ||
}) : p.api(g, !1, o, t.status || 404, t.statusText, c, h, y), e; | ||
r(p, c.parseResponse, g, u, e, t.status || 200, o, l, h, y); | ||
}) : p.api(g, !1, o, t.status || 404, t.statusText, l, h, y), e; | ||
})["catch"](function(e) { | ||
if (!p || !p.api) throw e; | ||
var t = Date.now() - c; | ||
throw p.api(g, !1, t, e.name || "Error", e.message, c, h, y), e; | ||
var t = Date.now() - l; | ||
throw p.api(g, !1, t, e.name || "Error", e.message, l, h, y), e; | ||
}); | ||
@@ -74,6 +74,6 @@ }, t[o].toString = a.createFakeToString(o); | ||
if (!i || !i.api || !o.addEventListener) return o; | ||
var s, p, c, l = o.send, g = o.open, u = o.setRequestHeader, f = i._conf, h = i.getConfig("enableLinkTrace"), y = "", d = "", E = ""; | ||
var s, p, l, c = o.send, g = o.open, u = o.setRequestHeader, f = i._conf, h = i.getConfig("enableLinkTrace"), y = "", d = "", E = ""; | ||
return o.open = function(e, t) { | ||
var n = 1 === arguments.length ? [ arguments[0] ] : Array.apply(null, arguments); | ||
if (g.apply(o, n), c = t || "", p = a.cutUrlSearch(c), p = p ? a.filterByRule(p, f.ignoreApiPath) : "", | ||
if (g.apply(o, n), l = t || "", p = a.cutUrlSearch(l), p = p ? a.filterByRule(p, f.ignoreApiPath ? f.ignoreApiPath : f.apiHelper) : "", | ||
h) { | ||
@@ -86,3 +86,3 @@ var r = ""; | ||
} | ||
a.checkSameOrigin(c, r) && u && "function" == typeof u && (y = i.getTraceId()["EagleEye-TraceID"], | ||
a.checkSameOrigin(l, r) && u && "function" == typeof u && (y = i.getTraceId()["EagleEye-TraceID"], | ||
u.apply(o, [ "EagleEye-TraceID", y ]), d = i.getSessionId()["EagleEye-SessionID"], | ||
@@ -94,3 +94,3 @@ u.apply(o, [ "EagleEye-SessionID", d ]), E = i.getConfig("pid"), u.apply(o, [ "EagleEye-pAppName", E ])); | ||
var e = 1 === arguments.length ? [ arguments[0] ] : Array.apply(null, arguments); | ||
l.apply(o, e); | ||
c.apply(o, e); | ||
}, a.on(o, "readystatechange", function() { | ||
@@ -105,3 +105,3 @@ if (p && 4 === o.readyState) { | ||
} | ||
o.responseType && "text" !== o.responseType ? i.api(p, !0, e, t, "", s, y, d) : r(i, f.parseResponse, p, c, o.responseText, t, e, s, y, d); | ||
o.responseType && "text" !== o.responseType ? i.api(p, !0, e, t, "", s, y, d) : r(i, f.parseResponse, p, l, o.responseText, t, e, s, y, d); | ||
} else i.api(p, !1, e, o.status || "FAILED", o.statusText, s, y, d); | ||
@@ -108,0 +108,0 @@ } |
@@ -5,11 +5,11 @@ var util = require("../util"), Reporter = require("../reporter"), webSender = require("../common/sender"), perfModel = require("../common/perf"), env = require("./env"), commonInfo = { | ||
}, WeexLogger = function(e) { | ||
var n = this; | ||
return Reporter.call(n, e), n._health = { | ||
var r = this; | ||
return Reporter.call(r, e), r._health = { | ||
errcount: 0, | ||
apisucc: 0, | ||
apifail: 0 | ||
}, n._initialPage = e.page && util.safetyCall(e.page, [], "" + e.page) || null, | ||
n.beforeSend = function(e, r) { | ||
"error" === e ? n._health.errcount++ : "api" === e && n._health[r.success ? "apisucc" : "apifail"]++; | ||
}, n.init(), n; | ||
}, r._initialPage = e.page && util.safetyCall(e.page, [], "" + e.page) || null, | ||
r.beforeSend = function(e, n) { | ||
"error" === e ? r._health.errcount++ : "api" === e && r._health[n.success ? "apisucc" : "apifail"]++; | ||
}, r.init(), r; | ||
}; | ||
@@ -20,6 +20,12 @@ | ||
page: null, | ||
ignoreUrlPath: [ { | ||
ignoreUrlPath: null, | ||
ignoreApiPath: null, | ||
urlHelper: [ { | ||
rule: /\/([a-z\-_]+)?\d{2,20}/g, | ||
target: "/$1**" | ||
}, /\/$/ ], | ||
apiHelper: { | ||
rule: /(\w+)\/\d{2,}/g, | ||
target: "$1" | ||
}, | ||
ignoreUrlCase: !0, | ||
@@ -31,27 +37,27 @@ imgUrl: "https://arms-retcode.aliyuncs.com/r.png?" | ||
onReady: function(e) { | ||
var n = this; | ||
return n.hasReady ? e() : env.isH5 && "complete" !== document.readyState ? void util.on(env.win, "load", function() { | ||
n.hasReady = !0, e(); | ||
}, !0) : (n.hasReady = !0, e()); | ||
var r = this; | ||
return r.hasReady ? e() : env.isH5 && "complete" !== document.readyState ? void util.on(env.win, "load", function() { | ||
r.hasReady = !0, e(); | ||
}, !0) : (r.hasReady = !0, e()); | ||
}, | ||
setPage: function(e, n) { | ||
var r = this, t = r.prevPage; | ||
if (!1 !== n) { | ||
if (!e || e === t) return r; | ||
r.prevPage = e, clearTimeout(r.sendPVTimmer), r.handleUnload(), r.resetSession(), | ||
r.sendPVTimmer = setTimeout(function() { | ||
r.sendPV(); | ||
setPage: function(e, r) { | ||
var n = this, t = n.prevPage; | ||
if (!1 !== r) { | ||
if (!e || e === t) return n; | ||
n.prevPage = e, clearTimeout(n.sendPVTimmer), n.handleUnload(), n.resetSession(), | ||
n.sendPVTimmer = setTimeout(function() { | ||
n.sendPV(); | ||
}, 10); | ||
} | ||
r._conf.page = e; | ||
n._conf.page = e; | ||
}, | ||
sendRequest: function(e) { | ||
var n = this._conf.sendRequest, r = this.getConfig("imgUrl"); | ||
return "function" == typeof n ? n(e, r) : webSender(e, r); | ||
var r = this._conf.sendRequest, n = this.getConfig("imgUrl"); | ||
return "function" == typeof r ? r(e, n) : webSender(e, n); | ||
}, | ||
postData: function(e, n) { | ||
var r = {}, t = ""; | ||
r[n] = e[n], delete e[n], "object" == typeof e && (t = util.serialize(e)); | ||
postData: function(e, r) { | ||
var n = {}, t = ""; | ||
n[r] = e[r], delete e[r], "object" == typeof e && (t = util.serialize(e)); | ||
var i = this._conf.postRequest, o = this.getConfig("imgUrl"); | ||
return "function" == typeof i ? i(r, o + t + "&post_res=") : this.sendRequest(e); | ||
return "function" == typeof i ? i(n, o + t + "&post_res=") : this.sendRequest(e); | ||
}, | ||
@@ -61,4 +67,4 @@ sendPV: function() { | ||
e.onReady(function() { | ||
var n = env.getPvInfo(); | ||
e._lg("pv", n); | ||
var r = env.getPvInfo(); | ||
e._lg("pv", r); | ||
}); | ||
@@ -70,7 +76,7 @@ }, | ||
e.onReady(function() { | ||
var n = perfModel(); | ||
if (n) { | ||
var r = e._conf; | ||
commonInfo.ct = n.ct, n.page = e._initialPage || env.getH5Page(r.ignoreUrlPath, r.ignoreUrlCase), | ||
e._lg("perf", n, e.getConfig("sample")); | ||
var r = perfModel(); | ||
if (r) { | ||
var n = e._conf; | ||
commonInfo.ct = r.ct, r.page = e._initialPage || env.getH5Page(n.ignoreUrlPath ? n.ignoreUrlPath : n.urlHelper, n.ignoreUrlCase), | ||
e._lg("perf", r, e.getConfig("sample")); | ||
} | ||
@@ -82,4 +88,4 @@ }); | ||
e.healthy = e.errcount > 0 ? 0 : 1, e.begin = Date.now(); | ||
var n = e.begin - this.sBegin; | ||
e.stay = n, this._lg("health", e, 1), this._health = { | ||
var r = e.begin - this.sBegin; | ||
e.stay = r, this._lg("health", e, 1), this._health = { | ||
errcount: 0, | ||
@@ -98,6 +104,6 @@ apisucc: 0, | ||
if (e) { | ||
var n = e.type; | ||
"error" === n ? this.error(e.error || { | ||
var r = e.type; | ||
"error" === r ? this.error(e.error || { | ||
message: e.message | ||
}, e) : "unhandledrejection" === n && util.T(e.reason, "Error") && this.error(e.reason); | ||
}, e) : "unhandledrejection" === r && util.T(e.reason, "Error") && this.error(e.reason); | ||
} | ||
@@ -107,8 +113,8 @@ }, | ||
var e = this; | ||
util.on(env.win, "error", function(n) { | ||
n && e.error(n.error || { | ||
message: n.message | ||
}, n); | ||
}).on(env.win, "unhandledrejection", function(n) { | ||
n && util.T(n.reason, "Error") && util.checkAutoError(n.reason) && e.error(n.reason); | ||
util.on(env.win, "error", function(r) { | ||
r && e.error(r.error || { | ||
message: r.message | ||
}, r); | ||
}).on(env.win, "unhandledrejection", function(r) { | ||
r && util.T(r.reason, "Error") && util.checkAutoError(r.reason) && e.error(r.reason); | ||
}); | ||
@@ -130,6 +136,6 @@ }, | ||
WeexLogger.singleton = function(e) { | ||
var n = util.key; | ||
return singleton || (util.win && util.win[n] && util.win.__hasInitBlSdk ? singleton = util.win[n] : (singleton = new WeexLogger(e), | ||
util.win && (util.win[n] = singleton))), singleton; | ||
var r = util.key; | ||
return singleton || (util.win && util.win[r] && util.win.__hasInitBlSdk ? singleton = util.win[r] : (singleton = new WeexLogger(e), | ||
util.win && (util.win[r] = singleton))), singleton; | ||
}, WeexLogger._super = Reporter, WeexLogger._root = Reporter._root, Reporter.WeexLogger = WeexLogger, | ||
module.exports = WeexLogger; |
@@ -1,1 +0,1 @@ | ||
/** retcode cloud sdk | @version 1.5.7 | @copyright Alibaba Group Holding Limited. */ !function(){function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var c="function"==typeof require&&require;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){return i(t[o][1][e]||e)},f,f.exports,e,t,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}return e}()({1:[function(e,t,n){var r=e("./util"),i=function(e){return this.ver="1.5.7",this._conf=r.ext({},i.dftCon),this.$a5={},this.$a1=[],this.hash=r.seq(),this.$a6(),this.setConfig(e),this.rip=r.getRandIP(),this.record=999,this["EagleEye-TraceID"]=this.getTraceId()["EagleEye-TraceID"],this._common={},this};i.dftCon={sample:1,tag:"",imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",region:null,ignore:{ignoreUrls:[],ignoreApis:[],ignoreErrors:[]},release:undefined,environment:"production"},i.prototype={constructor:i,$a2:function(e){return e()},$a7:function(){var e=this._conf.page;return r.$a8(e,[],e+"")},setPage:function(){},setConfig:function(e){e&&"object"==typeof e&&(r.$a9(e),e=this.$aa(e),this._conf=r.ext({},this._conf,e))},$aa:function(e){var t=e.region,n=e.imgUrl;if(t){var i=r.regionMap[t];return e.imgUrl=i||r.defaultImgUrl,e}return n&&(e.imgUrl=n),e},$ab:function(e){if(this.getConfig("debug"))return!0;var t=r.regionMap,n=!1;for(var i in t)if(t[i]===e){n=!0;break}return!n&&r.warn("[retcode] invalid url: "+e),n},$ac:function(){},$ad:function(){},$ae:function(){return{}},setCommonInfo:function(e){e&&"object"==typeof e&&(this._common=r.ext({},this._common,e))},$a6:function(){this.session=r.uu(),this.sBegin=Date.now()},getTraceId:function(){var e=this.rip,t=Date.now(),n=r.getSortNum(this.record),i=e+t+n+r.getRandNum(this._conf.pid);return this["EagleEye-TraceID"]=i,this.record=n,{"EagleEye-TraceID":i}},getSessionId:function(){return{"EagleEye-SessionID":this.session}},getConfig:function(e){return e?this._conf[e]:r.ext({},this._conf)},$af:function(e){return 1===e||("boolean"==typeof this.$a5[e]?this.$a5[e]:(this.$a5[e]=r.pick(e),this.$a5[e]))},$a4:function(){var e;for(clearTimeout(this.$a3),this.$a3=null;e=this.$a1.pop();)"res"===e.t?this.$ad(e,"res"):"error"===e.t?this.$ad(e,"err"):this.$ac(e);return this},_lg:function(e,t,n){var i=this._conf,a=this.$a7(),o=i.ignore||{},s=o.ignoreErrors,c=o.ignoreUrls,u=o.ignoreApis;return r.$ag(a,c)?this:"error"===e&&r.$ag(t.msg,s)?this:"api"===e&&r.$ag(t.api,u)?this:this.$ab(i.imgUrl)&&t&&!i.disabled&&i.pid?n&&!this.$af(n)?this:(t=r.ext({t:e,times:1,page:a,tag:i.tag||"",release:i.release||"",environment:i.environment,begin:Date.now()},t,this.$ae(),this._common,{pid:i.pid,_v:this.ver,sid:this.session,sampling:n||1,z:r.seq()}),function(e,t){var n;{if("error"!==t.t||!(n=e.$a1[0])||"error"!==n.t||t.msg!==n.msg)return e.$a1.unshift(t),e.$a2(function(){e.$a3=r.delay(function(){e.$a4()},"error"===t.t?3e3:-1)}),!0;n.times++}}(this,t)):this},custom:function(e,t){if(!e||"object"!=typeof e)return this;var n=!1,i={begin:Date.now()};return r.each(e,function(e,t){return!(n=t&&t.length<=20)&&r.warn("[retcode] invalid key: "+t),i["x-"+t]=e,n}),n?this._lg("custom",i,t||1):this}},t.exports=i},{"./util":14}],2:[function(e,t,n){var r=e("../util"),i=e("../reporter"),a=e("../common/sender"),o=e("../common/post"),s=r.win,c=s.document,u=/^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig)$/,f=function(e){var t=this;return i.call(t,e),t._initialPage=e.page&&r.$a8(e.page,[],e.page+"")||null,t._health={errcount:0,apisucc:0,apifail:0},t.$ah=function(e,n){"error"===e?t._health.errcount++:"api"===e&&t._health[n.success?"apisucc":"apifail"]++},t.$ai(),t.$aj(),t.$ak(1e4),Object.defineProperty&&s.addEventListener&&Object.defineProperty(t,"pipe",{set:t.$al}),t};f.prototype=r.$am(i.prototype),r.ext(i._root.dftCon,{uid:null,ignoreUrlPath:[{rule:/\/([a-z\-_]+)?\d{2,20}/g,target:"/$1**"},/\/$/],ignoreApiPath:{rule:/(\w+)\/\d{2,}/g,target:"$1"},urlHelper:[{rule:/\/([a-z\-_]+)?\d{2,20}/g,target:"/$1**"},/\/$/],apiHelper:{rule:/(\w+)\/\d{2,}/g,target:"$1"},ignoreUrlCase:!0,imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",disableHook:!1,autoSendPv:!0,enableSPA:!1,enableLinkTrace:!1,sendResource:!0,parseHash:function(e){return(e?r.$ao(e.replace(/^#\/?/,"")):"")||"[index]"},parseResponse:function(e){if(!e||"object"!=typeof e)return{};var t=e.code,n=e.msg||e.message||e.subMsg||e.errorMsg||e.ret||e.errorResponse||"";return"object"==typeof n&&(t=t||n.code,n=n.msg||n.message||n.info||n.ret||JSON.stringify(n)),{msg:n,code:t,success:!0}}}),r.ext(f.prototype,{constructor:f,_super:i,$a2:function(e){var t=this;if(t.hasReady)return e();"complete"===c.readyState?(t.hasReady=!0,e()):r.on(s,"load",function(){t.hasReady=!0,e()},!0)},$a7:function(e){var t=this._conf,n=t.page,i=location,a=i.host+i.pathname;return n&&!e?r.$a8(n,[],n+""):this._initialPage||r.$an(t.ignoreUrlCase?a.toLowerCase():a,t.ignoreUrlPath)},setPage:function(e,t){var n=this,r=n.$ap;if(!1!==t){if(!e||e===r)return n;n.$ap=e,clearTimeout(n.$aq),n.$ar(1),n.$a6(),n.$aq=setTimeout(function(){n.$as()},10)}else n.$ap=e;return n._conf.page=e,n},setConfig:function(e,t){if(e&&"object"==typeof e){r.$a9(e),e=this.$aa(e);var n=this._conf;if(this._conf=r.ext({},n,e),!t){var i="disableHook";i in e&&n[i]!==e[i]&&(e[i]?this.removeHook():this.addHook()),(i="enableSPA")in e&&n[i]!==e[i]&&this.$at(e[i])}}},$ac:function(e){a(e,this.getConfig("imgUrl"))},$ad:function(e,t){var n={};n[t]=e[t],delete e[t];var i="";"object"==typeof e&&(i=r.serialize(e)),o(n,this.getConfig("imgUrl")+i+"&post_res=")},$al:function(e){var t=this;if(!e||!e.length)return t;try{if("Array"===r.T(e[0]))return r.each(e,function(e){return t.$al(e)});if("Array"!==r.T(e))return t;var n=e.shift();if(!u.test(n))return t;t[n].apply(t,e)}catch(i){return r.warn("[retcode] error in sendPipe",i),t}},$au:function(){var e=r.ext({},this._health);e.healthy=e.errcount>0?0:1,e.begin=Date.now();var t=e.begin-this.sBegin;e.stay=t,this._lg("health",e,1),this._health={errcount:0,apisucc:0,apifail:0}},createInstance:function(e){e=r.ext({pid:this._conf.pid},e);var t=this.__proto__.constructor(e);return e.page&&t.$as(),t}}),e("./handler")(f,s,c),e("./fmp")(f,s,c),e("./hook")(f,s),e("./hack")(f,s),f._super=i,f._root=i._root,i.Browser=f,t.exports=f},{"../common/post":9,"../common/sender":11,"../reporter":13,"../util":14,"./fmp":3,"./hack":4,"./handler":5,"./hook":6}],3:[function(e,t,n){var r=e("../util"),i=500;t.exports=function(e,t,n){function a(e,t,n){var r=0,i=e.tagName;if("SCRIPT"!==i&&"STYLE"!==i&&"META"!==i&&"HEAD"!==i){var o=e.children?e.children.length:0;if(o>0)for(var c=e.children,u=o-1;u>=0;u--)r+=a(c[u],t+1,r>0);if(r<=0&&!n){if(!(e.getBoundingClientRect&&e.getBoundingClientRect().top<s))return 0}r+=1+.5*t}return r}function o(e){for(var t=1;t<e.length;t++)if(e[t].score<e[t-1].score)return e.splice(t,1),o(e);return e}var s=t.innerHeight||0,c=[],u=null,f=0;r.ext(e.prototype,{$ak:function(e){var i=this;if(!i._conf||!i._conf.useFmp)return null;if(!t.MutationObserver)return r.warn("[retcode] first meaningful paint can not be retrieved"),i.$av(),null;r.on(t,"beforeunload",function(){i.$aw(0,!0)});var o=t.MutationObserver;return(u=new o(function(){!function(e){var t=Date.now()-e,r=n.querySelector("body");if(r){var i=0;i+=a(r,1,!1),c.push({score:i,t:t})}else c.push({score:0,t:t})}(i._startTime)})).observe(document,{childList:!0,subtree:!0}),f=1,i.$a2(function(){i.$aw(e)}),u},$aw:function(e,t){var n=this;if(u&&f)if(t||!function(e,t){var n=Date.now()-e;return!(n>t||n-(c&&c.length&&c[c.length-1].t||0)>2*i)}(n._startTime,e)){u.disconnect(),f=0,c=o(c);for(var a=null,s=1;s<c.length;s++)if(c[s].t>=c[s-1].t){var l=c[s].score-c[s-1].score;(!a||a.rate<=l)&&(a={t:c[s].t,rate:l})}a&&a.t>0&&a.t<36e5?n.$av({fmp:a.t}):n.$av()}else r.delay(function(){n.$aw(e)},i)}})}},{"../util":14}],4:[function(e,t,n){t.exports=function(t,n){var r=e("../util"),i=n.history||{},a=n.document,o=function(e,t){var r;n.CustomEvent?r=new CustomEvent(e,{detail:t}):((r=a.createEvent("HTMLEvents")).initEvent(e,!1,!0),r.detail=t),n.dispatchEvent(r)},s=function(e){var t=i[e];"function"==typeof t&&(i[e]=function(n,a,s){var c=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),u=location.href,f=t.apply(i,c);if(!s||"string"!=typeof s)return f;if(s===u)return f;try{var l=u.split("#"),p=s.split("#"),h=r.$ao(l[0]),g=r.$ao(p[0]),d=l[1]&&l[1].replace(/^\/?(.*)/,"$1"),v=p[1]&&p[1].replace(/^\/?(.*)/,"$1");h!==g?o("historystatechange",g):d!==v&&o("historystatechange",v)}catch(m){r.warn("[retcode] error in "+e+": "+m)}return f},i[e].toString=r.$ax(e))};r.ext(t.prototype,{$ay:function(){return this.$az?this:(s("pushState"),s("replaceState"),this.$az=!0,this)}})}},{"../util":14}],5:[function(e,t,n){t.exports=function(t,n,r){var i=e("../util"),a=e("../common/perf"),o=e("../common/res"),s=null,c=r.documentElement,u=n.innerWidth||c.clientWidth||r.body.clientWidth,f=n.innerHeight||c.clientHeight||r.body.clientHeight,l=n.navigator.connection,p={sr:screen.width+"x"+screen.height,vp:u+"x"+f,ct:l?l.effectiveType||l.type:""},h={},g=function(e,t,n,a,o){if(t===undefined){var s,c;if(!h[e]){s=new RegExp(e+"=([^;]+)");try{c=s.exec(r.cookie)}catch(f){return i.warn("[retcode] can not get cookie:",f),null}c&&(h[e]=c[1])}return h[e]}var u=e+"="+t;a&&(u+="; domain="+a),u+="; path="+(o||"/"),n&&(u+="; max-age="+n);try{return r.cookie=u,!!r.cookie}catch(f){return i.warn("[retcode] can not set cookie: ",f),!1}},d=function(e){var t=e._conf.uid||g("_nk_")||g("_bl_uid");if(!t){t=i.uu();if(!g("_bl_uid",t,15552e3))return null}return t};return i.ext(t.prototype,{activeErrHandler:function(e){return s&&!e?this:(s=this,this)},errorHandler:function(e){if(!e)return this;var t=e.type;return"error"===t?this.error(e.error||{message:e.message},e):"unhandledrejection"===t&&i.T(e.reason,"Error")&&i.$b0(e.reason)&&this.error(e.reason),this},$av:function(e){var t=this;t.$a2(function(){var n=a();n&&(n.page=t.$a7(!0),e&&(n=i.ext(n,e)),t._lg("perf",n,t.getConfig("sample")))})},$b1:function(e){var t=this;t.$a2(function(){var n=o();n&&(n.load&&n.load<=2e3||n.load&&n.load<=8e3&&Math.random()>.05||(n.page=t.$a7(!0),n.dl=location.href,e&&(n=i.ext(n,e)),t._lg("res",n,t.getConfig("sample"))))})},$as:function(){var e=this;e.$a2(function(){var t=function(e){var t=d(e),i=n.devicePixelRatio||1;return{uid:t,dt:r.title,dl:location.href,dr:r.referrer,dpr:i.toFixed(2),de:(r.characterSet||r.defaultCharset||"").toLowerCase(),ul:c.lang,begin:Date.now()}}(e);t&&t.uid&&e._lg("pv",t)})},$ae:function(){return p.uid=d(this),p},$ar:function(e){var t=Date.now();if(t-this._lastUnload<200)return this;this._lastUnload=t,this.$au(e),this.$b2&&(this._lg("speed",this.$b2),this.$b2=null,clearTimeout(this.$b3)),this.$a4()},$at:function(e){var t=this;if(!e^t.$b4)return t;e?(t.$ay(),t.$b4=function(e){var n=t._conf.parseHash(location.hash);n&&t.setPage(n,!1!==e)},t.$b5=function(e){var n=t._conf.parseHash(e.detail);n&&t.setPage(n)},i.on(n,"hashchange",t.$b4),i.on(n,"historystatechange",t.$b5),t.$b4(!1)):(i.off(n,"hashchange",t.$b4),i.off(n,"historystatechange",t.$b5),t.$b4=null,t.$b5=null)},$ai:function(){var e=this;if(e.$b6)return e;var t=e._conf;return i.on(n,"beforeunload",function(){e.$ar(0)}),e.$at(t.enableSPA),e.activeErrHandler(!1),e.$b6=!0,e}}),i.on(n,"error",function(e){s&&s.errorHandler(e)}).on(n,"unhandledrejection",function(e){s&&s.errorHandler(e)}),t}},{"../common/perf":8,"../common/res":10,"../util":14}],6:[function(e,t,n){t.exports=function(t,n){var r=e("../util"),i=null,a=function(e,t,n,i,a,o,s,c,u,f){var l=r.J(a)||null,p=r.$a8(t,[l,i],null);if(!p)return!1;var h=p.code||o,g=!("success"in p)||p.success;e.api(n,g,s,h,p.msg,c,u,f)},o="fetch",s="__oFetch_",c="__oXMLHttpRequest_",u="XMLHttpRequest";return r.ext(t.prototype,{removeHook:function(e,t){return i&&(t||this===i)?(n[s]&&(n[o]=n[s],delete n[s]),n[c]&&(n[u]=n[c],delete n[c]),i=null,this):this},addHook:function(e){return!e&&i?this:(i||(function(){if("function"==typeof n[o]){var e=n[o];n[s]=e,n[o]=function(t,o){var s=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),c=i;if(!c||!c.api)return e.apply(n,s);if(o&&("HEAD"===o.method||"no-cors"===o.mode))return e.apply(n,s);var u=Date.now(),f=c._conf,l=(t&&"string"!=typeof t?t.url:t)||"",p=l;if(l=r.$ao(l),!r.$b7(l,!0))return e.apply(n,s);l=r.$an(l,f.ignoreApiPath);var h=f.enableLinkTrace,g="",d="",v=c.getConfig("pid");if(h){var m="";try{m=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(w){m=""}if(r.checkSameOrigin(p,m)){if(t&&"string"!=typeof t)try{if(s[0].headers&&"function"==typeof s[0].headers.get&&"function"==typeof s[0].headers.append){var y=s[0].headers.get("EagleEye-TraceID"),$=s[0].headers.get("EagleEye-SessionID"),b=s[0].headers.get("EagleEye-pAppName");y?g=y:(g=c.getTraceId()["EagleEye-TraceID"],s[0].headers.append("EagleEye-TraceID",g)),$?d=$:(d=c.getSessionId()["EagleEye-SessionID"],s[0].headers.append("EagleEye-SessionID",d)),b||s[0].headers.append("EagleEye-pAppName",v)}}catch(E){r.warn("[retcode] fetch failed to set header, exception is :\n"+E)}o&&(o.headers=o.headers?o.headers:{},o.headers["EagleEye-TraceID"]?g=o.headers["EagleEye-TraceID"]:(g=c.getTraceId()["EagleEye-TraceID"],o.headers["EagleEye-TraceID"]=g),o.headers["EagleEye-SessionID"]?d=o.headers["EagleEye-SessionID"]:(d=c.getSessionId()["EagleEye-SessionID"],o.headers["EagleEye-SessionID"]=d),o.headers["EagleEye-pAppName"]||(o.headers["EagleEye-pAppName"]=v))}}return e.apply(n,s).then(function(e){if(!c||!c.api)return e;var t=e.clone(),n=t.headers;if(n&&"function"==typeof n.get){var r=n.get("content-type");if(r&&!/(text)|(json)/.test(r))return e}var i=Date.now()-u;return t.ok?t.text().then(function(e){a(c,f.parseResponse,l,p,e,t.status||200,i,u,g,d)}):c.api(l,!1,i,t.status||404,t.statusText,u,g,d),e})["catch"](function(e){if(!c||!c.api)throw e;var t=Date.now()-u;throw c.api(l,!1,t,e.name||"Error",e.message,u,g,d),e})},n[o].toString=r.$ax(o)}}(),function(){if("function"==typeof n[u]){var e=n[u];n[c]=e,n[u]=function(t){var n=new e(t),o=i;if(!o||!o.api||!n.addEventListener)return n;var s,c,u,f=n.send,l=n.open,p=n.setRequestHeader,h=o._conf,g=o.getConfig("enableLinkTrace"),d="",v="",m="";return n.open=function(e,t){var i=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);if(l.apply(n,i),u=t||"",c=r.$ao(u),c=c?r.$an(c,h.ignoreApiPath):"",g){var a="";try{a=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(s){a=""}r.checkSameOrigin(u,a)&&p&&"function"==typeof p&&(d=o.getTraceId()["EagleEye-TraceID"],p.apply(n,["EagleEye-TraceID",d]),v=o.getSessionId()["EagleEye-SessionID"],p.apply(n,["EagleEye-SessionID",v]),m=o.getConfig("pid"),p.apply(n,["EagleEye-pAppName",m]))}},n.send=function(){s=Date.now();var e=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);f.apply(n,e)},r.on(n,"readystatechange",function(){if(c&&4===n.readyState){var e=Date.now()-s;if(n.status>=200&&n.status<=299){var t=n.status||200;if("function"==typeof n.getResponseHeader){var r=n.getResponseHeader("Content-Type");if(r&&!/(text)|(json)/.test(r))return}n.responseType&&"text"!==n.responseType?o.api(c,!0,e,t,"",s,d,v):a(o,h.parseResponse,c,u,n.responseText,t,e,s,d,v)}else o.api(c,!1,e,n.status||"FAILED",n.statusText,s,d,v)}}),n},n[u].toString=r.$ax(u)}}()),i=this,this)},$aj:function(){return this.$b8?this:(this.getConfig("disableHook")||this.addHook(),this.$b8=!0,this)}}),t}},{"../util":14}],7:[function(e,t,n){n.TIMING_KEYS=["","fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","requestStart","responseStart","responseEnd","","domInteractive","","domContentLoadedEventEnd","","loadEventStart","","msFirstPaint","secureConnectionStart"]},{}],8:[function(e,t,n){var r=e("../util"),i=e("./constants").TIMING_KEYS;t.exports=function(){var e=r.win||{},t=e.performance;if(!t||"object"!=typeof t)return null;var n={},a=t.timing||{},o=Date.now(),s=1;if("function"==typeof e.PerformanceNavigationTiming){var c=t.getEntriesByType("navigation")[0];c&&(a=c,s=2)}r.each({dns:[3,2],tcp:[5,4],ssl:[5,17],ttfb:[7,6],trans:[8,7],dom:[10,8],res:[14,12],firstbyte:[7,2],fpt:[8,1],tti:[10,1],ready:[12,1],load:[14,1]},function(e,t){var r=a[i[e[1]]],o=a[i[e[0]]];if(2===s||r>0&&o>0){var c=Math.round(o-r);c>=0&&c<36e5&&(n[t]=c)}});var u=e.navigator.connection,f=t.navigation||{};n.ct=u?u.effectiveType||u.type:"";var l=u?u.downlinkMax||u.bandwidth||-1:-1;if(l=l>999?999:l,n.bandwidth=l,n.navtype=1===f.type?"Reload":"Other",1===s&&a[i[16]]>0&&a[i[1]]>0){var p=a[i[16]]-a[i[1]];p>=0&&p<36e5&&(n.fpt=p)}return 1===s&&a[i[1]]>0?n.begin=a[i[1]]:2===s&&n.load>0?n.begin=o-n.load:n.begin=o,n}},{"../util":14,"./constants":7}],9:[function(e,t,n){var r=e("../util"),i="object"==typeof window?window:{},a=i.__oXMLHttpRequest_||i.XMLHttpRequest;a="function"==typeof a?a:undefined,t.exports=function(e,t){try{var n=new a;n.open("POST",t,!0),n.setRequestHeader("Content-Type","text/plain"),n.send(JSON.stringify(e))}catch(i){r.warn("[retcode] Failed to log, exception is :\n"+i)}}},{"../util":14}],10:[function(e,t,n){var r=e("../util"),i=e("./constants").TIMING_KEYS;t.exports=function(){var e=r.win||{},t=e.performance;if(!t||"object"!=typeof t||"function"!=typeof t.getEntriesByType)return null;var n={},a=t.timing||{},o=t.getEntriesByType("resource")||[];if(n.begin=a[i[1]]||Date.now(),"function"==typeof e.PerformanceNavigationTiming){var s=t.getEntriesByType("navigation")[0];s&&(a=s)}return r.each({dom:[10,8],load:[14,1]},function(e,t){var r=a[i[e[1]]],o=a[i[e[0]]];if(r>0&&o>0){var s=Math.round(o-r);s>=0&&s<36e5&&(n[t]=s)}}),n.res=JSON.stringify(o),n}},{"../util":14,"./constants":7}],11:[function(e,t,n){var r=e("../util"),i="object"==typeof window?window:{},a=i.__oFetch_||i.fetch;a="function"==typeof a?a:undefined,t.exports=function(e,t){var n=-1;"object"==typeof e&&(n=e.z,e=r.serialize(e));var o=t+e;if(a)return a(o,{method:"HEAD",mode:"no-cors"})["catch"](r.noop);if(i.document&&i.document.createElement){var s="__request_hold_"+n,c=i[s]=new Image;c.onload=c.onerror=function(){i[s]=undefined},c.src=o,c=null}}},{"../util":14}],12:[function(e,t,n){"use strict";function r(e,t){var n=i[o]=new a(e);n.$al(t);var r=n._conf;return!1!==r.autoSendPv&&n.$as(),r&&r.useFmp||n.$av(),r&&r.sendResource&&n.$b1(),i[s]=!0,n}var i=window,a=i.BrowserLogger=e("./biz.browser/clazz"),o=e("./util").key,s="__hasInitBlSdk";a.singleton=function(e,t){return i[s]?i[o]:r(e,t)};"object"==typeof window&&!!window.navigator&&i[o]&&(a.bl=function(){if(i[s])return i[o];var e={},t=[];return o in i&&(e=i[o].config||{},t=i[o].pipe||[]),r(e,t)}(i.__hasInitBlSdk)),t.exports=a},{"./biz.browser/clazz":2,"./util":14}],13:[function(e,t,n){var r=e("./util"),i=e("./base"),a=["api","success","time","code","msg","trace","traceId","begin","sid","seq"],o=function(e,t){var n=e.split("::");return n.length>1?r.ext({group:n[0],key:n[1]},t):r.ext({group:"default_group",key:n[0]},t)},s=function(e){i.call(this,e);var t;try{t="object"==typeof performance?performance.timing.fetchStart:Date.now()}catch(n){t=Date.now()}return this._startTime=t,this};s.prototype=r.$am(i.prototype),r.ext(i.dftCon,{startTime:null}),r.ext(s.prototype,{constructor:s,_super:i,sum:function(e,t,n){try{return this._lg("sum",o(e,{val:t||1,begin:Date.now()}),n)}catch(i){r.warn("[retcode] can not get parseStatData: "+i)}},avg:function(e,t,n){try{return this._lg("avg",o(e,{val:t||0,begin:Date.now()}),n)}catch(i){r.warn("[retcode] can not get parseStatData: "+i)}},percent:function(e,t,n,i){try{return this._lg("percent",o(e,{subkey:t,val:n||0,begin:Date.now()}),i)}catch(a){r.warn("[retcode] can not get parseStatData: "+a)}},msg:function(e,t){if(e&&!(e.length>180))return this.custom({msg:e},t)},error:function(e,t){if(!e)return r.warn("[retcode] invalid param e: "+e),this;1===arguments.length?("string"==typeof e&&(e={message:e},t={}),"object"==typeof e&&(t=e=e.error||e)):("string"==typeof e&&(e={message:e}),"object"!=typeof t&&(t={}));var n=e.name||"CustomError",i=e.message,a=e.stack||"";t=t||{};var o={begin:Date.now(),cate:n,msg:i.substring(0,1e3),stack:a&&a.substring(0,1e3),file:t.filename||"",line:t.lineno||"",col:t.colno||"",err:{msg_raw:i,stack_raw:a}},s=(this.getConfig("ignore")||{}).ignoreErrors;return r.$ag(o.msg,s)?this:(this.$ah&&this.$ah("error",o),this._lg("error",o,1))},api:function(e,t,n,i,o,s,c,u){if(!e)return r.warn("[retcode] api is null"),this;if(e="string"==typeof e?{api:e,success:t,time:n,code:i,msg:o,begin:s,traceId:c,sid:u}:r.sub(e,a),!r.$b7(e.api))return this;if(e.code=e.code||"",e.msg=e.msg||"",e.success=e.success?1:0,e.time=+e.time,e.begin=e.begin,e.traceId=e.traceId||"",e.sid=e.sid||"",!e.api||isNaN(e.time))return r.warn("[retcode] invalid time or api"),this;var f=(this.getConfig("ignore")||{}).ignoreApis;return r.$ag(e.api,f)?this:(this.$ah&&this.$ah("api",e),this._lg("api",e,e.success&&this.getConfig("sample")))},speed:function(e,t,n){var i=this,a=this.getConfig("startTime")||this._startTime;return/^s(\d|1[0])$/.test(e)?(t="number"!=typeof t?Date.now()-a:t>=a?t-a:t,i.$b2=i.$b2||{},i.$b2[e]=t,i.$b2.begin=a,clearTimeout(i.$b3),i.$b3=setTimeout(function(){n||(i.$b2.page=i.$a7(!0)),i._lg("speed",i.$b2),i.$b2=null},5e3),i):(r.warn("[retcode] invalid point: "+e),i)},resource:function(e,t){if(!e||!r.isPlainObject(e))return r.warn("[arms] invalid param data: "+e),this;var n=Object.keys(e),i=["begin","dom","load","res","dl"],a=!1;for(var o in i){if(n.indexOf(i[o])<0){a=!0;break}}if(a)return r.warn("[arms] lack param data: "+e),this;var s={begin:e.begin||Date.now(),dom:e.dom||"",load:e.load||"",res:r.isArray(e.res)?JSON.stringify(e.res):JSON.stringify([]),dl:e.dl||""};return this._lg("res",s,t)}}),s._super=i,s._root=i,i.Reporter=s,t.exports=s},{"./base":1,"./util":14}],14:[function(e,t,n){Date.now=Date.now||function(){return(new Date).getTime()};var r=Date.now(),i=function(){},a={noop:i,warn:function(){var e="object"==typeof console?console.warn:i;try{var t={warn:e};t.warn.call(t)}catch(n){return i}return e}(),key:"__bl",win:"object"==typeof window&&window.document?window:undefined,regionMap:{cn:"https://arms-retcode.aliyuncs.com/r.png?",sg:"https://arms-retcode-sg.aliyuncs.com/r.png?",sg_2:"https://retcode-sg-lazada.arms.aliyuncs.com/r.png?",daily:"http://arms-retcode-daily.alibaba.net/r.png?",daily_2:"https://arms-retcode-daily.alibaba.net/r.png?",us:"https://retcode-us-west-1.arms.aliyuncs.com/r.png?"},defaultImgUrl:"https://arms-retcode.aliyuncs.com/r.png?",$am:function(e){if(Object.create)return Object.create(e);var t=function(){};return t.prototype=e,new t},each:function(e,t){var n=0,r=e.length;if(this.T(e,"Array"))for(;n<r&&!1!==t.call(e[n],e[n],n);n++);else for(n in e)if(!1===t.call(e[n],e[n],n))break;return e},$a8:function(e,t,n){if("function"!=typeof e)return n;try{return e.apply(this,t)}catch(r){return n}},T:function(e,t){var n=Object.prototype.toString.call(e).substring(8).replace("]","");return t?n===t:n},$an:function(e,t){if(!e)return"";if(!t)return e;var n=this,r=n.T(t);return"Function"===r?n.$a8(t,[e],e):"Array"===r?(this.each(t,function(t){e=n.$an(e,t)}),e):"Object"===r?e.replace(t.rule,t.target||""):e.replace(t,"")},$ag:function(e,t){if(!e||!t)return!1;if((this.isString(t)||t.source||"Function"===this.T(t))&&(t=[t]),!this.isArray(t))return a.warn("[arms] invalid rules of ignore config, (list of) String/RegExp/Funcitons are available"),!1;for(var n,r=[],i=0,o=t.length;i<o;i++)if(n=t[i],this.isString(n))r.push(n.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"));else if(n&&n.source)r.push(n.source);else if(n&&"Function"===this.T(n)&&!0===this.$a8(n,[e],!1))return!0;var s=new RegExp(r.join("|"),"i");return!!(r.length&&s.test&&s.test(e))},J:function(e){if(!e||"string"!=typeof e)return e;var t=null;try{t=JSON.parse(e)}catch(n){}return t},pick:function(e){return 1===e||1===Math.ceil(Math.random()*e)},$a9:function(e){if("sample"in e){var t=e.sample,n=t;t&&/^\d+(\.\d+)?%$/.test(t)&&(n=parseInt(100/parseFloat(t))),0<n&&1>n&&(n=parseInt(1/n)),n>=1&&n<=100?e.sample=n:delete e.sample}return e},on:function(e,t,n,r){return e.addEventListener?e.addEventListener(t,function i(a){r&&e.removeEventListener(t,i,!1),n.call(this,a)},!1):e.attachEvent&&e.attachEvent("on"+t,function a(i){r&&e.detachEvent("on"+t,a),n.call(this,i)}),this},off:function(e,t,n){return n?(e.removeEventListener?e.removeEventListener(t,n):e.detachEvent&&e.detachEvent(t,n),this):this},delay:function(e,t){return-1===t?(e(),null):setTimeout(e,t||0)},ext:function(e){for(var t=1,n=arguments.length;t<n;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},sub:function(e,t){var n={};return this.each(e,function(e,r){-1!==t.indexOf(r)&&(n[r]=e)}),n},uu:function(){for(var e,t,n=20,r=new Array(n),i=Date.now().toString(36).split("");n-- >0;)t=(e=36*Math.random()|0).toString(36),r[n]=e%3?t:t.toUpperCase();for(var a=0;a<8;a++)r.splice(3*a+2,0,i[a]);return r.join("")},seq:function(){return(r++).toString(36)},encode:function(e,t){try{e=t?encodeURIComponent(e).replace(/\(/g,"%28").replace(/\)/g,"%29"):encodeURIComponent(e)}catch(n){}return e},serialize:function(e){e=e||{};var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==undefined&&t.push(n+"="+this.encode(e[n],"msg"===n));return t.join("&")},$b7:function(e,t){if(!e||"string"!=typeof e)return!1;var n=/arms-retcode[\w-]*\.aliyuncs/.test(e);return!n&&t&&(n=/(\.png)|(\.gif)|(alicdn\.com)/.test(e)),!n},$b0:function(e){return!(!e||!e.message)&&!/failed[\w\s]+fetch/i.test(e.message)},$ao:function(e){return e&&"string"==typeof e?e.replace(/^(https?:)?\/\//,"").replace(/\?.*$/,""):""},$ax:function(e){return function(){return e+"() { [native code] }"}},checkSameOrigin:function(e,t){if(!t||!e)return!1;var n="//"+t.split("/")[2];return e===t||e.slice(0,t.length+1)===t+"/"||e===n||e.slice(0,n.length+1)===n+"/"||!/^(\/\/|http:|https:).*/.test(e)},getRandIP:function(){for(var e=[],t=0;t<4;t++){var n=Math.floor(256*Math.random());e[t]=(n>15?"":"0")+n.toString(16)}return e.join("")},getSortNum:function(e){return e?(e+=1)>=1e3&&e<=9999?e:e<1e3?e+1e3:e%1e4+1e3:1e3},getRandNum:function(e){return e&&"string"==typeof e?e.length<5?this.getNum(5):e.substring(e.length-5):this.getNum(5)},getNum:function(e){for(var t=[],n=0;n<e;n++){var r=Math.floor(16*Math.random());t[n]=r.toString(16)}return t.join("")},isFunction:function(e){return"function"==typeof e},isPlainObject:function(e){return"[object Object]"===Object.prototype.toString.call(e)},isString:function(e){return"[object String]"===Object.prototype.toString.call(e)},isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},joinRegExp:function(e){for(var t,n=[],r=0,i=e.length;r<i;r++)t=e[r],this.isString(t)?n.push(t.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):t&&t.source&&n.push(t.source);return new RegExp(n.join("|"),"i")}};t.exports=a},{}]},{},[12]); | ||
/** retcode cloud sdk | @version 1.5.9 | @copyright Alibaba Group Holding Limited. */ !function(){function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var c="function"==typeof require&&require;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){return i(t[o][1][e]||e)},f,f.exports,e,t,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}return e}()({1:[function(e,t,n){var r=e("./util"),i=function(e){return this.ver="1.5.9",this._conf=r.ext({},i.dftCon),this.$a5={},this.$a1=[],this.hash=r.seq(),this.$a6(),this.setConfig(e),this.rip=r.getRandIP(),this.record=999,this["EagleEye-TraceID"]=this.getTraceId()["EagleEye-TraceID"],this._common={},this};i.dftCon={sample:1,tag:"",imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",region:null,ignore:{ignoreUrls:[],ignoreApis:[],ignoreErrors:[]},release:undefined,environment:"production"},i.prototype={constructor:i,$a2:function(e){return e()},$a7:function(){var e=this._conf.page;return r.$a8(e,[],e+"")},setPage:function(){},setConfig:function(e){e&&"object"==typeof e&&(r.$a9(e),e=this.$aa(e),this._conf=r.ext({},this._conf,e))},$aa:function(e){var t=e.region,n=e.imgUrl;if(t){var i=r.regionMap[t];return e.imgUrl=i||r.defaultImgUrl,e}return n&&(e.imgUrl=n),e},$ab:function(e){if(this.getConfig("debug"))return!0;var t=r.regionMap,n=!1;for(var i in t)if(t[i]===e){n=!0;break}return!n&&r.warn("[retcode] invalid url: "+e),n},$ac:function(){},$ad:function(){},$ae:function(){return{}},setCommonInfo:function(e){e&&"object"==typeof e&&(this._common=r.ext({},this._common,e))},$a6:function(){this.session=r.uu(),this.sBegin=Date.now()},getTraceId:function(){var e=this.rip,t=Date.now(),n=r.getSortNum(this.record),i=e+t+n+r.getRandNum(this._conf.pid);return this["EagleEye-TraceID"]=i,this.record=n,{"EagleEye-TraceID":i}},getSessionId:function(){return{"EagleEye-SessionID":this.session}},getConfig:function(e){return e?this._conf[e]:r.ext({},this._conf)},$af:function(e){return 1===e||("boolean"==typeof this.$a5[e]?this.$a5[e]:(this.$a5[e]=r.pick(e),this.$a5[e]))},$a4:function(){var e;for(clearTimeout(this.$a3),this.$a3=null;e=this.$a1.pop();)"res"===e.t?this.$ad(e,"res"):"error"===e.t?this.$ad(e,"err"):"behavior"===e.t?this.$ad(e,"behavior"):this.$ac(e);return this},_lg:function(e,t,n){var i=this._conf,a=this.$a7(),o=i.ignore||{},s=o.ignoreErrors,c=o.ignoreUrls,u=o.ignoreApis;return r.$ag(a,c)?this:"error"===e&&r.$ag(t.msg,s)?this:"api"===e&&r.$ag(t.api,u)?this:this.$ab(i.imgUrl)&&t&&!i.disabled&&i.pid?n&&!this.$af(n)?this:(t=r.ext({t:e,times:1,page:a,tag:i.tag||"",release:i.release||"",environment:i.environment,begin:Date.now()},t,this.$ae(),this._common,{pid:i.pid,_v:this.ver,sid:this.session,sampling:n||1,z:r.seq(),custom_1:i.custom_1,custom_2:i.custom_2,custom_3:i.custom_3}),function(e,t){var n;{if("error"!==t.t||!(n=e.$a1[0])||"error"!==n.t||t.msg!==n.msg){if("behavior"===t.t){var i=e.$a1&&e.$a1.length;if(i>0&&"behavior"===e.$a1[i-1].t){var a=t.behavior||[];e.$a1[i-1].behavior.concat(a)}else e.$a1.push(t)}else e.$a1.unshift(t);return e.$a2(function(){e.$a3=r.delay(function(){e.$a4()},e.$a1[0]&&"error"===e.$a1[0].t?3e3:-1)}),!0}n.times++}}(this,t)):this},custom:function(e,t){if(!e||"object"!=typeof e)return this;var n=!1,i={begin:Date.now()};return r.each(e,function(e,t){return!(n=t&&t.length<=20)&&r.warn("[retcode] invalid key: "+t),i["x-"+t]=e,n}),n?this._lg("custom",i,t||1):this}},t.exports=i},{"./util":15}],2:[function(e,t,n){var r=e("../util");t.exports=function(e,t){var n=[],i=null,a=t&&t.location&&t.location.href,o=0,s=undefined,c=null,u=function(e,t,n){if(null!==e){var r=e[t];e[t]=n(r)}},f=function(e){var t,n,r,i,a,o=[];if(!e||!e.tagName)return"";if(o.push(e.tagName.toLowerCase()),e.id&&o.push("#".concat(e.id)),(t=e.className)&&"[object String]"===Object.prototype.toString.call(t))for(n=t.split(/\s+/),a=0;a<n.length;a++)o.push(".".concat(n[a]));var s=["type","name","title","alt"];for(a=0;a<s.length;a++)r=s[a],(i=e.getAttribute(r))&&o.push("[".concat(r,'="').concat(i,'"]'));return o.join("")},l=function(e,t){return function(n){if(n&&n!==c){c=n;var r;try{r=n.target}catch(u){r="<unknown>"}if(0!==r.length){var a={type:"ui.".concat(e),data:{message:function(e){if(!e||1!==e.nodeType)return"";for(var t=e||null,n=[],r=0,i=0,a=" > ".length,o="";t&&r++<5&&!("html"===(o=f(t))||r>1&&i+n.length*a+o.length>=80);)n.push(o),i+=o.length,t=t.parentNode;return n.reverse().join(" > ")}(r)},timestamp:Date.now()};"click"===e?(o&&clearTimeout(o),t?o=setTimeout(function(){i&&i.addBehavior(a)},0):i&&i.addBehavior(a)):"keypress"===e&&(s||i&&i.addBehavior(a),clearTimeout(s),s=setTimeout(function(){s=undefined},100))}}}},h=function(){if(function(){var e=t&&t.chrome,n=e&&e.app&&e.app.runtime,r="history"in t&&!!t.history.pushState&&!!t.history.replaceState;return!n&&r}()){var e=function(e,t){var n={type:"navigation",data:{from:e,to:t}};i&&i.addBehavior(n),a=t},n=t.onpopstate;t.onpopstate=function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];var s=t.location.href;if(e(a,s),n)return n.apply(this,i)};var r=function(t){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o=r.length>2?r[2]:undefined;return o&&e(a,String(o)),t.apply(this,r)}};u(t.history,"pushState",r),u(t.history,"replaceState",r)}};r.ext(e.prototype,{addBehavior:function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},i=arguments.length>1?arguments[1]:undefined;if(this.getConfig("behavior")){var a=i&&i>0?min(i,100):100;return(e=r.ext({},{type:"default",data:{},timestamp:Date.now(),page:t&&t.location&&t.location.pathname},e)).data&&e.data.message&&(e.data.message=r.encode(e.data.message)),n.push(e),n=n.slice(-a)}},getBehavior:function(){return n||[]},setBehavior:function(e){return e&&(n=e),n},reportBehavior:function(e){var t=this;t.getConfig("behavior")&&(t.$ah=setTimeout(function(){n&&n.length>0&&(t.behavior(n),n=[],t.$ah=undefined,e&&e())},0))},$ai:function(){return i||(!function(){if(document&&document.referrer&&document.location){var e=document.referrer,t=document.location.href;if(""!==e){var n={type:"navigation",data:{from:e,to:t}};a=t,i&&i.addBehavior(n)}}}(),function(){if(t&&t.console)for(var e=["debug","info","warn","log","error","assert"],n=0;e.length;n++){var r=e[n];if(!t.console[r])return;u(t.console,r,function(e){var n=r;return function(){for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];var s={type:"console",data:{level:n,message:a}};if(i&&i.addBehavior(s),"error"===n)for(var c=0;c<a.length;c++){var u=a[c];u.message&&u.stack&&i&&i.errorHandler(new ErrorEvent("error",{error:u,message:u.message}))}e&&Function.prototype.apply.call(e,t.console,a)}})}}(),function(){if(t&&t.document){t.document.addEventListener("click",l("click"),!1),t.document.addEventListener("keypress",l("keypress"),!1);for(var e=["EventTarget","Node"],n=0;n<e.length;n++){var r=e[n],i=t[r]&&t[r].prototype;if(!i||!i.hasOwnProperty||!i.hasOwnProperty("addEventListener"))return;u(i,"addEventListener",function(e){return function(t,n,r){return n&&n.handleEvent?"click"!==t&&"keypress"!==t||u(n,"handleEvent",function(e){return function(n){return l(t,!1)(n),e.call(this,n)}}):"click"!==t&&"keypress"!==t||e.call(this,t,l(t,!1),r),e.call(this,t,n,r)}})}}}(),h()),i=this,this}})}},{"../util":15}],3:[function(e,t,n){var r=e("../util"),i=e("../reporter"),a=e("../common/sender"),o=e("../common/post"),s=r.win,c=s.document,u=/^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig|behavior)$/,f=function(e){var t=this;return i.call(t,e),t._initialPage=e.page&&r.$a8(e.page,[],e.page+"")||null,t._health={errcount:0,apisucc:0,apifail:0},t.$aj=function(e,n){"error"===e?t._health.errcount++:"api"===e&&t._health[n.success?"apisucc":"apifail"]++},t.$ak(),t.$al(),t.$am(1e4),t._conf&&t._conf.behavior&&t.$ai(),Object.defineProperty&&s.addEventListener&&Object.defineProperty(t,"pipe",{set:t.$an}),t};f.prototype=r.$ao(i.prototype),r.ext(i._root.dftCon,{uid:null,ignoreUrlPath:null,ignoreApiPath:null,urlHelper:[{rule:/\/([a-z\-_]+)?\d{2,20}/g,target:"/$1**"},/\/$/],apiHelper:{rule:/(\w+)\/\d{2,}/g,target:"$1"},ignoreUrlCase:!0,imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",disableHook:!1,autoSendPv:!0,enableSPA:!1,enableLinkTrace:!1,sendResource:!0,behavior:!0,parseHash:function(e){return(e?r.$aq(e.replace(/^#\/?/,"")):"")||"[index]"},parseResponse:function(e){if(!e||"object"!=typeof e)return{};var t=e.code,n=e.msg||e.message||e.subMsg||e.errorMsg||e.ret||e.errorResponse||"";return"object"==typeof n&&(t=t||n.code,n=n.msg||n.message||n.info||n.ret||JSON.stringify(n)),{msg:n,code:t,success:!0}}}),r.ext(f.prototype,{constructor:f,_super:i,$a2:function(e){var t=this;if(t.hasReady)return e();"complete"===c.readyState?(t.hasReady=!0,e()):r.on(s,"load",function(){t.hasReady=!0,e()},!0)},$a7:function(e){var t=this._conf,n=t.page,i=location,a=i.host+i.pathname;return n&&!e?r.$a8(n,[],n+""):this._initialPage||r.$ap(t.ignoreUrlCase?a.toLowerCase():a,t.ignoreUrlPath?t.ignoreUrlPath:t.urlHelper)},setPage:function(e,t){var n=this,r=n.$ar;if(!1!==t){if(!e||e===r)return n;n.$ar=e,clearTimeout(n.$as),n.$at(1),n.$a6(),n.$as=setTimeout(function(){n.$au()},10)}else n.$ar=e;return n._conf.page=e,n},setConfig:function(e,t){if(e&&"object"==typeof e){r.$a9(e),e=this.$aa(e);var n=this._conf;if(this._conf=r.ext({},n,e),!t){var i="disableHook";i in e&&n[i]!==e[i]&&(e[i]?this.removeHook():this.addHook()),(i="enableSPA")in e&&n[i]!==e[i]&&this.$av(e[i])}}},$ac:function(e){a(e,this.getConfig("imgUrl"))},$ad:function(e,t){var n={};n[t]=e[t],delete e[t];var i="";"object"==typeof e&&(i=r.serialize(e)),o(n,this.getConfig("imgUrl")+i+"&post_res=")},$an:function(e){var t=this;if(!e||!e.length)return t;try{if("Array"===r.T(e[0]))return r.each(e,function(e){return t.$an(e)});if("Array"!==r.T(e))return t;var n=e.shift();if(!u.test(n))return t;t[n].apply(t,e)}catch(i){return r.warn("[retcode] error in sendPipe",i),t}},$aw:function(){var e=r.ext({},this._health);e.healthy=e.errcount>0?0:1,e.begin=Date.now();var t=e.begin-this.sBegin;e.stay=t,this._lg("health",e,1),this._health={errcount:0,apisucc:0,apifail:0}},createInstance:function(e){e=r.ext({pid:this._conf.pid},e);var t=this.__proto__.constructor(e);return e.page&&t.$au(),t}}),e("./behavior")(f,s),e("./handler")(f,s,c),e("./fmp")(f,s,c),e("./hook")(f,s),e("./hack")(f,s),f._super=i,f._root=i._root,i.Browser=f,t.exports=f},{"../common/post":10,"../common/sender":12,"../reporter":14,"../util":15,"./behavior":2,"./fmp":4,"./hack":5,"./handler":6,"./hook":7}],4:[function(e,t,n){var r=e("../util"),i=500;t.exports=function(e,t,n){function a(e,t,n){var r=0,i=e.tagName;if("SCRIPT"!==i&&"STYLE"!==i&&"META"!==i&&"HEAD"!==i){var o=e.children?e.children.length:0;if(o>0)for(var c=e.children,u=o-1;u>=0;u--)r+=a(c[u],t+1,r>0);if(r<=0&&!n){if(!(e.getBoundingClientRect&&e.getBoundingClientRect().top<s))return 0}r+=1+.5*t}return r}function o(e){for(var t=1;t<e.length;t++)if(e[t].score<e[t-1].score)return e.splice(t,1),o(e);return e}var s=t.innerHeight||0,c=[],u=null,f=0;r.ext(e.prototype,{$am:function(e){var i=this;if(!i._conf||!i._conf.useFmp)return null;if(!t.MutationObserver)return r.warn("[retcode] first meaningful paint can not be retrieved"),i.$ax(),null;r.on(t,"beforeunload",function(){i.$ay(0,!0)});var o=t.MutationObserver;return(u=new o(function(){!function(e){var t=Date.now()-e,r=n.querySelector("body");if(r){var i=0;i+=a(r,1,!1),c.push({score:i,t:t})}else c.push({score:0,t:t})}(i._startTime)})).observe(document,{childList:!0,subtree:!0}),f=1,i.$a2(function(){i.$ay(e)}),u},$ay:function(e,t){var n=this;if(u&&f)if(t||!function(e,t){var n=Date.now()-e;return!(n>t||n-(c&&c.length&&c[c.length-1].t||0)>2*i)}(n._startTime,e)){u.disconnect(),f=0,c=o(c);for(var a=null,s=1;s<c.length;s++)if(c[s].t>=c[s-1].t){var l=c[s].score-c[s-1].score;(!a||a.rate<=l)&&(a={t:c[s].t,rate:l})}a&&a.t>0&&a.t<36e5?n.$ax({fmp:a.t}):n.$ax()}else r.delay(function(){n.$ay(e)},i)}})}},{"../util":15}],5:[function(e,t,n){t.exports=function(t,n){var r=e("../util"),i=n.history||{},a=n.document,o=function(e,t){var r;n.CustomEvent?r=new CustomEvent(e,{detail:t}):((r=a.createEvent("HTMLEvents")).initEvent(e,!1,!0),r.detail=t),n.dispatchEvent(r)},s=function(e){var t=i[e];"function"==typeof t&&(i[e]=function(n,a,s){var c=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),u=location.href,f=t.apply(i,c);if(!s||"string"!=typeof s)return f;if(s===u)return f;try{var l=u.split("#"),h=s.split("#"),p=r.$aq(l[0]),g=r.$aq(h[0]),d=l[1]&&l[1].replace(/^\/?(.*)/,"$1"),v=h[1]&&h[1].replace(/^\/?(.*)/,"$1");p!==g?o("historystatechange",g):d!==v&&o("historystatechange",v)}catch(m){r.warn("[retcode] error in "+e+": "+m)}return f},i[e].toString=r.$az(e))};r.ext(t.prototype,{$b0:function(){return this.$b1?this:(s("pushState"),s("replaceState"),this.$b1=!0,this)}})}},{"../util":15}],6:[function(e,t,n){t.exports=function(t,n,r){var i=e("../util"),a=e("../common/perf"),o=e("../common/res"),s=null,c=r.documentElement,u=n.innerWidth||c.clientWidth||r.body.clientWidth,f=n.innerHeight||c.clientHeight||r.body.clientHeight,l=n.navigator.connection,h={sr:screen.width+"x"+screen.height,vp:u+"x"+f,ct:l?l.effectiveType||l.type:""},p={},g=function(e,t,n,a,o){if(t===undefined){var s,c;if(!p[e]){s=new RegExp(e+"=([^;]+)");try{c=s.exec(r.cookie)}catch(f){return i.warn("[retcode] can not get cookie:",f),null}c&&(p[e]=c[1])}return p[e]}var u=e+"="+t;a&&(u+="; domain="+a),u+="; path="+(o||"/"),n&&(u+="; max-age="+n);try{return r.cookie=u,!!r.cookie}catch(f){return i.warn("[retcode] can not set cookie: ",f),!1}},d=function(e){var t=e._conf.uid||g("_nk_")||g("_bl_uid");if(!t){t=i.uu();if(!g("_bl_uid",t,15552e3))return null}return t};return i.ext(t.prototype,{activeErrHandler:function(e){return s&&!e?this:(s=this,this)},errorHandler:function(e){if(!e)return this;var t=e.type;"error"===t?this.error(e.error||{message:e.message},e):"unhandledrejection"===t&&i.T(e.reason,"Error")&&i.$b2(e.reason)&&this.error(e.reason);try{this.getConfig("behavior")&&this.reportBehavior&&this.reportBehavior()}catch(e){}return this},$ax:function(e){var t=this;t.$a2(function(){var n=a();n&&(n.page=t.$a7(!0),e&&(n=i.ext(n,e)),t._lg("perf",n,t.getConfig("sample")))})},$b3:function(e){var t=this;t.$a2(function(){var n=o();n&&(n.load&&n.load<=2e3||n.load&&n.load<=8e3&&Math.random()>.05||(n.page=t.$a7(!0),n.dl=location.href,e&&(n=i.ext(n,e)),t._lg("res",n,t.getConfig("sample"))))})},$au:function(){var e=this;e.$a2(function(){var t=function(e){var t=d(e),i=n.devicePixelRatio||1;return{uid:t,dt:r.title,dl:location.href,dr:r.referrer,dpr:i.toFixed(2),de:(r.characterSet||r.defaultCharset||"").toLowerCase(),ul:c.lang,begin:Date.now()}}(e);t&&t.uid&&e._lg("pv",t)})},$ae:function(){return h.uid=d(this),h},$at:function(e){var t=Date.now();if(t-this._lastUnload<200)return this;this._lastUnload=t,this.$aw(e),this.$b4&&(this._lg("speed",this.$b4),this.$b4=null,clearTimeout(this.$b5)),this.$a4()},$av:function(e){var t=this;if(!e^t.$b6)return t;e?(t.$b0(),t.$b6=function(e){var n=t._conf.parseHash(location.hash);n&&t.setPage(n,!1!==e)},t.$b7=function(e){var n=t._conf.parseHash(e.detail);n&&t.setPage(n)},i.on(n,"hashchange",t.$b6),i.on(n,"historystatechange",t.$b7),t.$b6(!1)):(i.off(n,"hashchange",t.$b6),i.off(n,"historystatechange",t.$b7),t.$b6=null,t.$b7=null)},$ak:function(){var e=this;if(e.$b8)return e;var t=e._conf;return i.on(n,"beforeunload",function(){e.$at(0)}),e.$av(t.enableSPA),e.activeErrHandler(!1),e.$b8=!0,e}}),i.on(n,"error",function(e){s&&s.errorHandler(e)}).on(n,"unhandledrejection",function(e){s&&s.errorHandler(e)}),t}},{"../common/perf":9,"../common/res":11,"../util":15}],7:[function(e,t,n){t.exports=function(t,n){var r=e("../util"),i=null,a=function(e,t,n,i,a,o,s,c,u,f){var l=r.J(a)||null,h=r.$a8(t,[l,i],null);if(!h)return!1;var p=h.code||o,g=!("success"in h)||h.success;e.api(n,g,s,p,h.msg,c,u,f)},o="fetch",s="__oFetch_",c="__oXMLHttpRequest_",u="XMLHttpRequest";return r.ext(t.prototype,{removeHook:function(e,t){return i&&(t||this===i)?(n[s]&&(n[o]=n[s],delete n[s]),n[c]&&(n[u]=n[c],delete n[c]),i=null,this):this},addHook:function(e){return!e&&i?this:(i||(function(){if("function"==typeof n[o]){var e=n[o];n[s]=e,n[o]=function(t,o){var s=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),c=i;if(!c||!c.api)return e.apply(n,s);if(o&&("HEAD"===o.method||"no-cors"===o.mode))return e.apply(n,s);var u=Date.now(),f=c._conf,l=(t&&"string"!=typeof t?t.url:t)||"",h=l;if(l=r.$aq(l),!r.$b9(l,!0))return e.apply(n,s);l=r.$ap(l,f.ignoreApiPath?f.ignoreApiPath:f.apiHelper);var p=f.enableLinkTrace,g="",d="",v=c.getConfig("pid");if(p){var m="";try{m=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(w){m=""}if(r.checkSameOrigin(h,m)){if(t&&"string"!=typeof t)try{if(s[0].headers&&"function"==typeof s[0].headers.get&&"function"==typeof s[0].headers.append){var y=s[0].headers.get("EagleEye-TraceID"),$=s[0].headers.get("EagleEye-SessionID"),b=s[0].headers.get("EagleEye-pAppName");y?g=y:(g=c.getTraceId()["EagleEye-TraceID"],s[0].headers.append("EagleEye-TraceID",g)),$?d=$:(d=c.getSessionId()["EagleEye-SessionID"],s[0].headers.append("EagleEye-SessionID",d)),b||s[0].headers.append("EagleEye-pAppName",v)}}catch(E){r.warn("[retcode] fetch failed to set header, exception is :\n"+E)}o&&(o.headers=o.headers?o.headers:{},o.headers["EagleEye-TraceID"]?g=o.headers["EagleEye-TraceID"]:(g=c.getTraceId()["EagleEye-TraceID"],o.headers["EagleEye-TraceID"]=g),o.headers["EagleEye-SessionID"]?d=o.headers["EagleEye-SessionID"]:(d=c.getSessionId()["EagleEye-SessionID"],o.headers["EagleEye-SessionID"]=d),o.headers["EagleEye-pAppName"]||(o.headers["EagleEye-pAppName"]=v))}}return e.apply(n,s).then(function(e){if(!c||!c.api)return e;var t=e.clone(),n=t.headers;if(n&&"function"==typeof n.get){var r=n.get("content-type");if(r&&!/(text)|(json)/.test(r))return e}var i=Date.now()-u;return t.ok?t.text().then(function(e){a(c,f.parseResponse,l,h,e,t.status||200,i,u,g,d)}):c.api(l,!1,i,t.status||404,t.statusText,u,g,d),e})["catch"](function(e){if(!c||!c.api)throw e;var t=Date.now()-u;throw c.api(l,!1,t,e.name||"Error",e.message,u,g,d),e})},n[o].toString=r.$az(o)}}(),function(){if("function"==typeof n[u]){var e=n[u];n[c]=e,n[u]=function(t){var n=new e(t),o=i;if(!o||!o.api||!n.addEventListener)return n;var s,c,u,f=n.send,l=n.open,h=n.setRequestHeader,p=o._conf,g=o.getConfig("enableLinkTrace"),d="",v="",m="";return n.open=function(e,t){var i=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);if(l.apply(n,i),u=t||"",c=r.$aq(u),c=c?r.$ap(c,p.ignoreApiPath?p.ignoreApiPath:p.apiHelper):"",g){var a="";try{a=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(s){a=""}r.checkSameOrigin(u,a)&&h&&"function"==typeof h&&(d=o.getTraceId()["EagleEye-TraceID"],h.apply(n,["EagleEye-TraceID",d]),v=o.getSessionId()["EagleEye-SessionID"],h.apply(n,["EagleEye-SessionID",v]),m=o.getConfig("pid"),h.apply(n,["EagleEye-pAppName",m]))}},n.send=function(){s=Date.now();var e=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);f.apply(n,e)},r.on(n,"readystatechange",function(){if(c&&4===n.readyState){var e=Date.now()-s;if(n.status>=200&&n.status<=299){var t=n.status||200;if("function"==typeof n.getResponseHeader){var r=n.getResponseHeader("Content-Type");if(r&&!/(text)|(json)/.test(r))return}n.responseType&&"text"!==n.responseType?o.api(c,!0,e,t,"",s,d,v):a(o,p.parseResponse,c,u,n.responseText,t,e,s,d,v)}else o.api(c,!1,e,n.status||"FAILED",n.statusText,s,d,v)}}),n},n[u].toString=r.$az(u)}}()),i=this,this)},$al:function(){return this.$ba?this:(this.getConfig("disableHook")||this.addHook(),this.$ba=!0,this)}}),t}},{"../util":15}],8:[function(e,t,n){n.TIMING_KEYS=["","fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","requestStart","responseStart","responseEnd","","domInteractive","","domContentLoadedEventEnd","","loadEventStart","","msFirstPaint","secureConnectionStart"]},{}],9:[function(e,t,n){var r=e("../util"),i=e("./constants").TIMING_KEYS;t.exports=function(){var e=r.win||{},t=e.performance;if(!t||"object"!=typeof t)return null;var n={},a=t.timing||{},o=Date.now(),s=1;if("function"==typeof e.PerformanceNavigationTiming){var c=t.getEntriesByType("navigation")[0];c&&(a=c,s=2)}r.each({dns:[3,2],tcp:[5,4],ssl:[5,17],ttfb:[7,6],trans:[8,7],dom:[10,8],res:[14,12],firstbyte:[7,2],fpt:[8,1],tti:[10,1],ready:[12,1],load:[14,1]},function(e,t){var r=a[i[e[1]]],o=a[i[e[0]]];if(2===s||r>0&&o>0){var c=Math.round(o-r);c>=0&&c<36e5&&(n[t]=c)}});var u=e.navigator.connection,f=t.navigation||{};n.ct=u?u.effectiveType||u.type:"";var l=u?u.downlinkMax||u.bandwidth||-1:-1;if(l=l>999?999:l,n.bandwidth=l,n.navtype=1===f.type?"Reload":"Other",1===s&&a[i[16]]>0&&a[i[1]]>0){var h=a[i[16]]-a[i[1]];h>=0&&h<36e5&&(n.fpt=h)}return 1===s&&a[i[1]]>0?n.begin=a[i[1]]:2===s&&n.load>0?n.begin=o-n.load:n.begin=o,n}},{"../util":15,"./constants":8}],10:[function(e,t,n){var r=e("../util"),i="object"==typeof window?window:{},a=i.__oXMLHttpRequest_||i.XMLHttpRequest;a="function"==typeof a?a:undefined,t.exports=function(e,t){try{var n=new a;n.open("POST",t,!0),n.setRequestHeader("Content-Type","text/plain"),n.send(JSON.stringify(e))}catch(i){r.warn("[retcode] Failed to log, exception is :\n"+i)}}},{"../util":15}],11:[function(e,t,n){var r=e("../util"),i=e("./constants").TIMING_KEYS;t.exports=function(){var e=r.win||{},t=e.performance;if(!t||"object"!=typeof t||"function"!=typeof t.getEntriesByType)return null;var n={},a=t.timing||{},o=t.getEntriesByType("resource")||[];if(n.begin=a[i[1]]||Date.now(),"function"==typeof e.PerformanceNavigationTiming){var s=t.getEntriesByType("navigation")[0];s&&(a=s)}return r.each({dom:[10,8],load:[14,1]},function(e,t){var r=a[i[e[1]]],o=a[i[e[0]]];if(r>0&&o>0){var s=Math.round(o-r);s>=0&&s<36e5&&(n[t]=s)}}),n.res=JSON.stringify(o),n}},{"../util":15,"./constants":8}],12:[function(e,t,n){var r=e("../util"),i="object"==typeof window?window:{},a=i.__oFetch_||i.fetch;a="function"==typeof a?a:undefined,t.exports=function(e,t){var n=-1;"object"==typeof e&&(n=e.z,e=r.serialize(e));var o=t+e;if(a)return a(o,{method:"HEAD",mode:"no-cors"})["catch"](r.noop);if(i.document&&i.document.createElement){var s="__request_hold_"+n,c=i[s]=new Image;c.onload=c.onerror=function(){i[s]=undefined},c.src=o,c=null}}},{"../util":15}],13:[function(e,t,n){"use strict";function r(e,t){var n=i[o]=new a(e);n.$an(t);var r=n._conf;return!1!==r.autoSendPv&&n.$au(),r&&r.useFmp||n.$ax(),r&&r.sendResource&&n.$b3(),i[s]=!0,n}var i=window,a=i.BrowserLogger=e("./biz.browser/clazz"),o=e("./util").key,s="__hasInitBlSdk";a.singleton=function(e,t){return i[s]?i[o]:r(e,t)};"object"==typeof window&&!!window.navigator&&i[o]&&(a.bl=function(){if(i[s])return i[o];var e={},t=[];return o in i&&(e=i[o].config||{},t=i[o].pipe||[]),r(e,t)}(i.__hasInitBlSdk)),t.exports=a},{"./biz.browser/clazz":3,"./util":15}],14:[function(e,t,n){var r=e("./util"),i=e("./base"),a=["api","success","time","code","msg","trace","traceId","begin","sid","seq"],o=function(e,t){var n=e.split("::");return n.length>1?r.ext({group:n[0],key:n[1]},t):r.ext({group:"default_group",key:n[0]},t)},s=function(e){i.call(this,e);var t;try{t="object"==typeof performance?performance.timing.fetchStart:Date.now()}catch(n){t=Date.now()}return this._startTime=t,this};s.prototype=r.$ao(i.prototype),r.ext(i.dftCon,{startTime:null}),r.ext(s.prototype,{constructor:s,_super:i,sum:function(e,t,n){try{return this._lg("sum",o(e,{val:t||1,begin:Date.now()}),n)}catch(i){r.warn("[retcode] can not get parseStatData: "+i)}},avg:function(e,t,n){try{return this._lg("avg",o(e,{val:t||0,begin:Date.now()}),n)}catch(i){r.warn("[retcode] can not get parseStatData: "+i)}},percent:function(e,t,n,i){try{return this._lg("percent",o(e,{subkey:t,val:n||0,begin:Date.now()}),i)}catch(a){r.warn("[retcode] can not get parseStatData: "+a)}},msg:function(e,t){if(e&&!(e.length>180))return this.custom({msg:e},t)},error:function(e,t){if(!e)return r.warn("[retcode] invalid param e: "+e),this;1===arguments.length?("string"==typeof e&&(e={message:e},t={}),"object"==typeof e&&(t=e=e.error||e)):("string"==typeof e&&(e={message:e}),"object"!=typeof t&&(t={}));var n=e.name||"CustomError",i=r.encode(e.message),a=r.encode(e.stack||"");t=t||{};var o={begin:Date.now(),cate:n,msg:i.substring(0,1e3),stack:a&&a.substring(0,1e3),file:t.filename||"",line:t.lineno||"",col:t.colno||"",err:{msg_raw:i,stack_raw:a}},s=(this.getConfig("ignore")||{}).ignoreErrors;return r.$ag(o.msg,s)?this:(this.$aj&&this.$aj("error",o),this._lg("error",o,1))},behavior:function(e){if(e){var t="object"==typeof e&&e.behavior?e:{behavior:e};return this.$aj&&this.$aj("behavior",t),this._lg("behavior",t,1)}},api:function(e,t,n,i,o,s,c,u){if(!e)return r.warn("[retcode] api is null"),this;if(e="string"==typeof e?{api:e,success:t,time:n,code:i,msg:o,begin:s,traceId:c,sid:u}:r.sub(e,a),!r.$b9(e.api))return this;if(e.code=e.code||"",e.msg=e.msg||"",e.success=e.success?1:0,e.time=+e.time,e.begin=e.begin,e.traceId=e.traceId||"",e.sid=e.sid||"",!e.api||isNaN(e.time))return r.warn("[retcode] invalid time or api"),this;var f=(this.getConfig("ignore")||{}).ignoreApis;if(r.$ag(e.api,f))return this;this.$aj&&this.$aj("api",e);var l={type:"api",data:{message:o,url:e.api,status:i||""},timestamp:s};try{this.getConfig("behavior")&&this.addBehavior&&this.addBehavior(l)}catch(h){}return this._lg("api",e,e.success&&this.getConfig("sample"))},speed:function(e,t,n){var i=this,a=this.getConfig("startTime")||this._startTime;return/^s(\d|1[0])$/.test(e)?(t="number"!=typeof t?Date.now()-a:t>=a?t-a:t,i.$b4=i.$b4||{},i.$b4[e]=t,i.$b4.begin=a,clearTimeout(i.$b5),i.$b5=setTimeout(function(){n||(i.$b4.page=i.$a7(!0)),i._lg("speed",i.$b4),i.$b4=null},5e3),i):(r.warn("[retcode] invalid point: "+e),i)},resource:function(e,t){if(!e||!r.isPlainObject(e))return r.warn("[arms] invalid param data: "+e),this;var n=Object.keys(e),i=["begin","dom","load","res","dl"],a=!1;for(var o in i){if(n.indexOf(i[o])<0){a=!0;break}}if(a)return r.warn("[arms] lack param data: "+e),this;var s={begin:e.begin||Date.now(),dom:e.dom||"",load:e.load||"",res:r.isArray(e.res)?JSON.stringify(e.res):JSON.stringify([]),dl:e.dl||""};return this._lg("res",s,t)}}),s._super=i,s._root=i,i.Reporter=s,t.exports=s},{"./base":1,"./util":15}],15:[function(e,t,n){Date.now=Date.now||function(){return(new Date).getTime()};var r=Date.now(),i=function(){},a={noop:i,warn:function(){var e="object"==typeof console?console.warn:i;try{var t={warn:e};t.warn.call(t)}catch(n){return i}return e}(),key:"__bl",win:"object"==typeof window&&window.document?window:undefined,regionMap:{cn:"https://arms-retcode.aliyuncs.com/r.png?",sg:"https://arms-retcode-sg.aliyuncs.com/r.png?",sg_2:"https://retcode-sg-lazada.arms.aliyuncs.com/r.png?",daily:"http://arms-retcode-daily.alibaba.net/r.png?",daily_2:"https://arms-retcode-daily.alibaba.net/r.png?",us:"https://retcode-us-west-1.arms.aliyuncs.com/r.png?"},defaultImgUrl:"https://arms-retcode.aliyuncs.com/r.png?",$ao:function(e){if(Object.create)return Object.create(e);var t=function(){};return t.prototype=e,new t},each:function(e,t){var n=0,r=e.length;if(this.T(e,"Array"))for(;n<r&&!1!==t.call(e[n],e[n],n);n++);else for(n in e)if(!1===t.call(e[n],e[n],n))break;return e},$a8:function(e,t,n){if("function"!=typeof e)return n;try{return e.apply(this,t)}catch(r){return n}},T:function(e,t){var n=Object.prototype.toString.call(e).substring(8).replace("]","");return t?n===t:n},$ap:function(e,t){if(!e)return"";if(!t)return e;var n=this,r=n.T(t);return"Function"===r?n.$a8(t,[e],e):"Array"===r?(this.each(t,function(t){e=n.$ap(e,t)}),e):"Object"===r?e.replace(t.rule,t.target||""):e.replace(t,"")},$ag:function(e,t){if(!e||!t)return!1;if((this.isString(t)||t.source||"Function"===this.T(t))&&(t=[t]),!this.isArray(t))return a.warn("[arms] invalid rules of ignore config, (list of) String/RegExp/Funcitons are available"),!1;for(var n,r=[],i=0,o=t.length;i<o;i++)if(n=t[i],this.isString(n))r.push(n.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"));else if(n&&n.source)r.push(n.source);else if(n&&"Function"===this.T(n)&&!0===this.$a8(n,[e],!1))return!0;var s=new RegExp(r.join("|"),"i");return!!(r.length&&s.test&&s.test(e))},J:function(e){if(!e||"string"!=typeof e)return e;var t=null;try{t=JSON.parse(e)}catch(n){}return t},pick:function(e){return 1===e||1===Math.ceil(Math.random()*e)},$a9:function(e){if("sample"in e){var t=e.sample,n=t;t&&/^\d+(\.\d+)?%$/.test(t)&&(n=parseInt(100/parseFloat(t))),0<n&&1>n&&(n=parseInt(1/n)),n>=1&&n<=100?e.sample=n:delete e.sample}return e},on:function(e,t,n,r){return e.addEventListener?e.addEventListener(t,function i(a){r&&e.removeEventListener(t,i,!1),n.call(this,a)},!1):e.attachEvent&&e.attachEvent("on"+t,function a(i){r&&e.detachEvent("on"+t,a),n.call(this,i)}),this},off:function(e,t,n){return n?(e.removeEventListener?e.removeEventListener(t,n):e.detachEvent&&e.detachEvent(t,n),this):this},delay:function(e,t){return-1===t?(e(),null):setTimeout(e,t||0)},ext:function(e){for(var t=1,n=arguments.length;t<n;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},sub:function(e,t){var n={};return this.each(e,function(e,r){-1!==t.indexOf(r)&&(n[r]=e)}),n},uu:function(){for(var e,t,n=20,r=new Array(n),i=Date.now().toString(36).split("");n-- >0;)t=(e=36*Math.random()|0).toString(36),r[n]=e%3?t:t.toUpperCase();for(var a=0;a<8;a++)r.splice(3*a+2,0,i[a]);return r.join("")},seq:function(){return(r++).toString(36)},encode:function(e,t){try{e=t?encodeURIComponent(e).replace(/\(/g,"%28").replace(/\)/g,"%29"):encodeURIComponent(e)}catch(n){}return e},serialize:function(e){e=e||{};var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==undefined&&t.push(n+"="+this.encode(e[n],"msg"===n));return t.join("&")},$b9:function(e,t){if(!e||"string"!=typeof e)return!1;var n=/arms-retcode[\w-]*\.aliyuncs/.test(e);return!n&&t&&(n=/(\.png)|(\.gif)|(alicdn\.com)/.test(e)),!n},$b2:function(e){return!(!e||!e.message)&&!/failed[\w\s]+fetch/i.test(e.message)},$aq:function(e){return e&&"string"==typeof e?e.replace(/^(https?:)?\/\//,"").replace(/\?.*$/,""):""},$az:function(e){return function(){return e+"() { [native code] }"}},checkSameOrigin:function(e,t){if(!t||!e)return!1;var n="//"+t.split("/")[2];return e===t||e.slice(0,t.length+1)===t+"/"||e===n||e.slice(0,n.length+1)===n+"/"||!/^(\/\/|http:|https:).*/.test(e)},getRandIP:function(){for(var e=[],t=0;t<4;t++){var n=Math.floor(256*Math.random());e[t]=(n>15?"":"0")+n.toString(16)}return e.join("")},getSortNum:function(e){return e?(e+=1)>=1e3&&e<=9999?e:e<1e3?e+1e3:e%1e4+1e3:1e3},getRandNum:function(e){return e&&"string"==typeof e?e.length<5?this.getNum(5):e.substring(e.length-5):this.getNum(5)},getNum:function(e){for(var t=[],n=0;n<e;n++){var r=Math.floor(16*Math.random());t[n]=r.toString(16)}return t.join("")},isFunction:function(e){return"function"==typeof e},isPlainObject:function(e){return"[object Object]"===Object.prototype.toString.call(e)},isString:function(e){return"[object String]"===Object.prototype.toString.call(e)},isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},joinRegExp:function(e){for(var t,n=[],r=0,i=e.length;r<i;r++)t=e[r],this.isString(t)?n.push(t.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):t&&t.source&&n.push(t.source);return new RegExp(n.join("|"),"i")}};t.exports=a},{}]},{},[13]); |
@@ -69,3 +69,3 @@ var util = require("./util"), Base = require("./base"), validApiKeys = [ "api", "success", "time", "code", "msg", "trace", "traceId", "begin", "sid", "seq" ], parseStatData = function(e, t) { | ||
}), "object" != typeof t && (t = {})); | ||
var r = e.name || "CustomError", i = e.message, a = e.stack || ""; | ||
var r = e.name || "CustomError", i = util.encode(e.message), a = util.encode(e.stack || ""); | ||
t = t || {}; | ||
@@ -88,2 +88,10 @@ var s = { | ||
}, | ||
behavior: function(e) { | ||
if (e) { | ||
var t = "object" == typeof e && e.behavior ? e : { | ||
behavior: e | ||
}; | ||
return this.beforeSend && this.beforeSend("behavior", t), this._lg("behavior", t, 1); | ||
} | ||
}, | ||
api: function(e, t, r, i, a, s, n, o) { | ||
@@ -105,4 +113,17 @@ if (!e) return util.warn("[retcode] api is null"), this; | ||
var c = (this.getConfig("ignore") || {}).ignoreApis; | ||
return util.ignoreByRule(e.api, c) ? this : (this.beforeSend && this.beforeSend("api", e), | ||
this._lg("api", e, e.success && this.getConfig("sample"))); | ||
if (util.ignoreByRule(e.api, c)) return this; | ||
this.beforeSend && this.beforeSend("api", e); | ||
var u = { | ||
type: "api", | ||
data: { | ||
message: a, | ||
url: e.api, | ||
status: i || "" | ||
}, | ||
timestamp: s | ||
}; | ||
try { | ||
this.getConfig("behavior") && this.addBehavior && this.addBehavior(u); | ||
} catch (p) {} | ||
return this._lg("api", e, e.success && this.getConfig("sample")); | ||
}, | ||
@@ -109,0 +130,0 @@ speed: function(e, t, r) { |
@@ -1,1 +0,1 @@ | ||
/** retcode cloud sdk | @version 1.5.7 | @copyright Alibaba Group Holding Limited. */ "use strict";Date.now=Date.now||function(){return(new Date).getTime()};var SEQUENCE=Date.now(),noop=function(){},$a1=function(){var t="object"==typeof console?console.warn:noop;try{var e={warn:t};e.warn.call(e)}catch(r){return noop}return t},util={noop:noop,warn:$a1(),key:"__bl",win:"object"==typeof window&&window.document?window:undefined,regionMap:{cn:"https://arms-retcode.aliyuncs.com/r.png?",sg:"https://arms-retcode-sg.aliyuncs.com/r.png?",sg_2:"https://retcode-sg-lazada.arms.aliyuncs.com/r.png?",daily:"http://arms-retcode-daily.alibaba.net/r.png?",daily_2:"https://arms-retcode-daily.alibaba.net/r.png?",us:"https://retcode-us-west-1.arms.aliyuncs.com/r.png?"},defaultImgUrl:"https://arms-retcode.aliyuncs.com/r.png?",$a2:function(t){if(Object.create)return Object.create(t);var e=function(){};return e.prototype=t,new e},each:function(t,e){var r=0,n=t.length;if(this.T(t,"Array"))for(;r<n&&!1!==e.call(t[r],t[r],r);r++);else for(r in t)if(!1===e.call(t[r],t[r],r))break;return t},$a3:function(t,e,r){if("function"!=typeof t)return r;try{return t.apply(this,e)}catch(n){return r}},T:function(t,e){var r=Object.prototype.toString.call(t).substring(8).replace("]","");return e?r===e:r},$a4:function(t,e){if(!t)return"";if(!e)return t;var r=this,n=r.T(e);return"Function"===n?r.$a3(e,[t],t):"Array"===n?(this.each(e,function(e){t=r.$a4(t,e)}),t):"Object"===n?t.replace(e.rule,e.target||""):t.replace(e,"")},$a5:function(t,e){if(!t||!e)return!1;if((this.isString(e)||e.source||"Function"===this.T(e))&&(e=[e]),!this.isArray(e))return util.warn("[arms] invalid rules of ignore config, (list of) String/RegExp/Funcitons are available"),!1;for(var r,n=[],i=0,o=e.length;i<o;i++)if(r=e[i],this.isString(r))n.push(r.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"));else if(r&&r.source)n.push(r.source);else if(r&&"Function"===this.T(r)&&!0===this.$a3(r,[t],!1))return!0;var a=new RegExp(n.join("|"),"i");return!!(n.length&&a.test&&a.test(t))},J:function(t){if(!t||"string"!=typeof t)return t;var e=null;try{e=JSON.parse(t)}catch(r){}return e},pick:function(t){return 1===t||1===Math.ceil(Math.random()*t)},$a6:function(t){if("sample"in t){var e=t.sample,r=e;e&&/^\d+(\.\d+)?%$/.test(e)&&(r=parseInt(100/parseFloat(e))),0<r&&1>r&&(r=parseInt(1/r)),r>=1&&r<=100?t.sample=r:delete t.sample}return t},on:function(t,e,r,n){return t.addEventListener?t.addEventListener(e,function i(o){n&&t.removeEventListener(e,i,!1),r.call(this,o)},!1):t.attachEvent&&t.attachEvent("on"+e,function o(i){n&&t.detachEvent("on"+e,o),r.call(this,i)}),this},off:function(t,e,r){return r?(t.removeEventListener?t.removeEventListener(e,r):t.detachEvent&&t.detachEvent(e,r),this):this},delay:function(t,e){return-1===e?(t(),null):setTimeout(t,e||0)},ext:function(t){for(var e=1,r=arguments.length;e<r;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},sub:function(t,e){var r={};return this.each(t,function(t,n){-1!==e.indexOf(n)&&(r[n]=t)}),r},uu:function(){for(var t,e,r=20,n=new Array(r),i=Date.now().toString(36).split("");r-- >0;)e=(t=36*Math.random()|0).toString(36),n[r]=t%3?e:e.toUpperCase();for(var o=0;o<8;o++)n.splice(3*o+2,0,i[o]);return n.join("")},seq:function(){return(SEQUENCE++).toString(36)},encode:function(t,e){try{t=e?encodeURIComponent(t).replace(/\(/g,"%28").replace(/\)/g,"%29"):encodeURIComponent(t)}catch(r){}return t},serialize:function(t){t=t||{};var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&t[r]!==undefined&&e.push(r+"="+this.encode(t[r],"msg"===r));return e.join("&")},$a7:function(t,e){if(!t||"string"!=typeof t)return!1;var r=/arms-retcode[\w-]*\.aliyuncs/.test(t);return!r&&e&&(r=/(\.png)|(\.gif)|(alicdn\.com)/.test(t)),!r},$a8:function(t){return!(!t||!t.message)&&!/failed[\w\s]+fetch/i.test(t.message)},$a9:function(t){return t&&"string"==typeof t?t.replace(/^(https?:)?\/\//,"").replace(/\?.*$/,""):""},$aa:function(t){return function(){return t+"() { [native code] }"}},checkSameOrigin:function(t,e){if(!e||!t)return!1;var r="//"+e.split("/")[2];return t===e||t.slice(0,e.length+1)===e+"/"||t===r||t.slice(0,r.length+1)===r+"/"||!/^(\/\/|http:|https:).*/.test(t)},getRandIP:function(){for(var t=[],e=0;e<4;e++){var r=Math.floor(256*Math.random());t[e]=(r>15?"":"0")+r.toString(16)}return t.join("")},getSortNum:function(t){return t?(t+=1)>=1e3&&t<=9999?t:t<1e3?t+1e3:t%1e4+1e3:1e3},getRandNum:function(t){return t&&"string"==typeof t?t.length<5?this.getNum(5):t.substring(t.length-5):this.getNum(5)},getNum:function(t){for(var e=[],r=0;r<t;r++){var n=Math.floor(16*Math.random());e[r]=n.toString(16)}return e.join("")},isFunction:function(t){return"function"==typeof t},isPlainObject:function(t){return"[object Object]"===Object.prototype.toString.call(t)},isString:function(t){return"[object String]"===Object.prototype.toString.call(t)},isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},joinRegExp:function(t){for(var e,r=[],n=0,i=t.length;n<i;n++)e=t[n],this.isString(e)?r.push(e.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):e&&e.source&&r.push(e.source);return new RegExp(r.join("|"),"i")}},util_1=util,pushToQueue=function(t,e){var r;{if("error"!==e.t||!(r=t.$ab[0])||"error"!==r.t||e.msg!==r.msg)return t.$ab.unshift(e),t.$ac(function(){t.$ad=util_1.delay(function(){t.$ae()},"error"===e.t?3e3:-1)}),!0;r.times++}},Base=function(t){return this.ver="1.5.7",this._conf=util_1.ext({},Base.dftCon),this.$af={},this.$ab=[],this.hash=util_1.seq(),this.$ag(),this.setConfig(t),this.rip=util_1.getRandIP(),this.record=999,this["EagleEye-TraceID"]=this.getTraceId()["EagleEye-TraceID"],this._common={},this};Base.dftCon={sample:1,tag:"",imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",region:null,ignore:{ignoreUrls:[],ignoreApis:[],ignoreErrors:[]},release:undefined,environment:"production"},Base.prototype={constructor:Base,$ac:function(t){return t()},$ah:function(){var t=this._conf.page;return util_1.$a3(t,[],t+"")},setPage:function(){},setConfig:function(t){t&&"object"==typeof t&&(util_1.$a6(t),t=this.$ai(t),this._conf=util_1.ext({},this._conf,t))},$ai:function(t){var e=t.region,r=t.imgUrl;if(e){var n=util_1.regionMap[e];return t.imgUrl=n||util_1.defaultImgUrl,t}return r&&(t.imgUrl=r),t},$aj:function(t){if(this.getConfig("debug"))return!0;var e=util_1.regionMap,r=!1;for(var n in e)if(e[n]===t){r=!0;break}return!r&&util_1.warn("[retcode] invalid url: "+t),r},$ak:function(){},$al:function(){},$am:function(){return{}},setCommonInfo:function(t){t&&"object"==typeof t&&(this._common=util_1.ext({},this._common,t))},$ag:function(){this.session=util_1.uu(),this.sBegin=Date.now()},getTraceId:function(){var t=this.rip,e=Date.now(),r=util_1.getSortNum(this.record),n=t+e+r+util_1.getRandNum(this._conf.pid);return this["EagleEye-TraceID"]=n,this.record=r,{"EagleEye-TraceID":n}},getSessionId:function(){return{"EagleEye-SessionID":this.session}},getConfig:function(t){return t?this._conf[t]:util_1.ext({},this._conf)},$an:function(t){return 1===t||("boolean"==typeof this.$af[t]?this.$af[t]:(this.$af[t]=util_1.pick(t),this.$af[t]))},$ae:function(){var t;for(clearTimeout(this.$ad),this.$ad=null;t=this.$ab.pop();)"res"===t.t?this.$al(t,"res"):"error"===t.t?this.$al(t,"err"):this.$ak(t);return this},_lg:function(t,e,r){var n=this._conf,i=this.$ah(),o=n.ignore||{},a=o.ignoreErrors,s=o.ignoreUrls,u=o.ignoreApis;return util_1.$a5(i,s)?this:"error"===t&&util_1.$a5(e.msg,a)?this:"api"===t&&util_1.$a5(e.api,u)?this:this.$aj(n.imgUrl)&&e&&!n.disabled&&n.pid?r&&!this.$an(r)?this:(e=util_1.ext({t:t,times:1,page:i,tag:n.tag||"",release:n.release||"",environment:n.environment,begin:Date.now()},e,this.$am(),this._common,{pid:n.pid,_v:this.ver,sid:this.session,sampling:r||1,z:util_1.seq()}),pushToQueue(this,e)):this},custom:function(t,e){if(!t||"object"!=typeof t)return this;var r=!1,n={begin:Date.now()};return util_1.each(t,function(t,e){return!(r=e&&e.length<=20)&&util_1.warn("[retcode] invalid key: "+e),n["x-"+e]=t,r}),r?this._lg("custom",n,e||1):this}};var base=Base,validApiKeys=["api","success","time","code","msg","trace","traceId","begin","sid","seq"],parseStatData=function(t,e){var r=t.split("::");return r.length>1?util_1.ext({group:r[0],key:r[1]},e):util_1.ext({group:"default_group",key:r[0]},e)},Reporter=function(t){base.call(this,t);var e;try{e="object"==typeof performance?performance.timing.fetchStart:Date.now()}catch(r){e=Date.now()}return this._startTime=e,this};Reporter.prototype=util_1.$a2(base.prototype),util_1.ext(base.dftCon,{startTime:null}),util_1.ext(Reporter.prototype,{constructor:Reporter,_super:base,sum:function(t,e,r){try{return this._lg("sum",parseStatData(t,{val:e||1,begin:Date.now()}),r)}catch(n){util_1.warn("[retcode] can not get parseStatData: "+n)}},avg:function(t,e,r){try{return this._lg("avg",parseStatData(t,{val:e||0,begin:Date.now()}),r)}catch(n){util_1.warn("[retcode] can not get parseStatData: "+n)}},percent:function(t,e,r,n){try{return this._lg("percent",parseStatData(t,{subkey:e,val:r||0,begin:Date.now()}),n)}catch(i){util_1.warn("[retcode] can not get parseStatData: "+i)}},msg:function(t,e){if(t&&!(t.length>180))return this.custom({msg:t},e)},error:function(t,e){if(!t)return util_1.warn("[retcode] invalid param e: "+t),this;1===arguments.length?("string"==typeof t&&(t={message:t},e={}),"object"==typeof t&&(e=t=t.error||t)):("string"==typeof t&&(t={message:t}),"object"!=typeof e&&(e={}));var r=t.name||"CustomError",n=t.message,i=t.stack||"";e=e||{};var o={begin:Date.now(),cate:r,msg:n.substring(0,1e3),stack:i&&i.substring(0,1e3),file:e.filename||"",line:e.lineno||"",col:e.colno||"",err:{msg_raw:n,stack_raw:i}},a=(this.getConfig("ignore")||{}).ignoreErrors;return util_1.$a5(o.msg,a)?this:(this.$aq&&this.$aq("error",o),this._lg("error",o,1))},api:function(t,e,r,n,i,o,a,s){if(!t)return util_1.warn("[retcode] api is null"),this;if(t="string"==typeof t?{api:t,success:e,time:r,code:n,msg:i,begin:o,traceId:a,sid:s}:util_1.sub(t,validApiKeys),!util_1.$a7(t.api))return this;if(t.code=t.code||"",t.msg=t.msg||"",t.success=t.success?1:0,t.time=+t.time,t.begin=t.begin,t.traceId=t.traceId||"",t.sid=t.sid||"",!t.api||isNaN(t.time))return util_1.warn("[retcode] invalid time or api"),this;var u=(this.getConfig("ignore")||{}).ignoreApis;return util_1.$a5(t.api,u)?this:(this.$aq&&this.$aq("api",t),this._lg("api",t,t.success&&this.getConfig("sample")))},speed:function(t,e,r){var n=this,i=this.getConfig("startTime")||this._startTime;return/^s(\d|1[0])$/.test(t)?(e="number"!=typeof e?Date.now()-i:e>=i?e-i:e,n.$ao=n.$ao||{},n.$ao[t]=e,n.$ao.begin=i,clearTimeout(n.$ap),n.$ap=setTimeout(function(){r||(n.$ao.page=n.$ah(!0)),n._lg("speed",n.$ao),n.$ao=null},5e3),n):(util_1.warn("[retcode] invalid point: "+t),n)},resource:function(t,e){if(!t||!util_1.isPlainObject(t))return util_1.warn("[arms] invalid param data: "+t),this;var r=Object.keys(t),n=["begin","dom","load","res","dl"],i=!1;for(var o in n){if(r.indexOf(n[o])<0){i=!0;break}}if(i)return util_1.warn("[arms] lack param data: "+t),this;var a={begin:t.begin||Date.now(),dom:t.dom||"",load:t.load||"",res:util_1.isArray(t.res)?JSON.stringify(t.res):JSON.stringify([]),dl:t.dl||""};return this._lg("res",a,e)}}),Reporter._super=base,Reporter._root=base,base.Reporter=Reporter;var reporter=Reporter,MiniProgramLogger=function(t){t&&t.pid||util_1.warn("[arms] pid is a required prop to instatiate MiniProgramLogger");var e=this;return reporter.call(e,t),e._health={errcount:0,apisucc:0,apifail:0},e.DEFAUT_PAGE_PATH="[app]",e.isSendPerf=!1,e.$aq=function(t,r){"error"===t?e._health.errcount++:"api"===t&&e._health[r.success?"apisucc":"apifail"]++},"function"==typeof e.$ar&&e.$ar(),"function"==typeof e.$as&&e.$as(),this};MiniProgramLogger.prototype=util_1.$a2(reporter.prototype),util_1.ext(reporter._root.dftCon,{uid:null,disableHook:!1,enableLinkTrace:!1,sendRequest:function(){},getCurrentPage:function(){}}),util_1.ext(MiniProgramLogger.prototype,{constructor:MiniProgramLogger,_super:reporter,$ac:function(t){t()},$ak:function(t,e){if(this.getConfig("debug"))"undefined"!=typeof console&&console&&"function"==typeof console.log&&console.log("[arms] [DEBUG MODE] log data",t);else{var r=this.getConfig("imgUrl");"object"==typeof t&&(t=util_1.serialize(t));var n=r+t;e&&(n+="&post_res=");var i=this._conf.sendRequest;if("function"==typeof i)try{i(n,e)}catch(o){util_1.warn("[arms] error in $ak",o)}}},$al:function(t,e){var r={};r[e]=t[e],delete t[e],this.$ak(t,r)},$ah:function(){var t=this._conf.getCurrentPage;if("function"==typeof t)try{var e=t();if(e&&"string"==typeof e)return e}catch(r){util_1.warn("[arms] error in $ah",r)}return"string"==typeof t&&t?t:this.DEFAUT_PAGE_PATH},setConfig:function(t){if(t&&"object"==typeof t){util_1.$a6(t),t=this.$ai(t);var e=this._conf;this._conf=util_1.ext({},this._conf,t);var r="disableHook";r in t&&e[r]!==t[r]&&(t[r]?"function"==typeof this.removeHook&&this.removeHook():"function"==typeof this.addHook&&this.addHook())}},pageShow:function(){var t=this;t.$ag(),t.$at(),clearTimeout(t.$au),t.$av(),t.$au=setTimeout(function(){t.$aw()},10),t.sessionPage=t.$ah()},pageHide:function(){this.$av()},addHook:function(){return this},removeHook:function(){return this},hookApp:function(t){var e=this,r={onError:function(r){var n=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),i=t.onError;try{e.error(r)}catch(r){util_1.warn("[arms] error in hookApp:onError",r)}if("function"==typeof i)return i.apply(this,n)}};return util_1.ext({},t,r)},hookPage:function(t){var e=this,r={onShow:function(){var r=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),n=t.onShow;try{e.pageShow()}catch(i){util_1.warn("[arms] error in hookPage:pageShow",i)}if("function"==typeof n)return n.apply(this,r)},onHide:function(){var r=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),n=t.onHide;try{e.pageHide()}catch(i){util_1.warn("[arms] error in hookPage:onHide",i)}if("function"==typeof n)return n.apply(this,r)},onUnload:function(){var r=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),n=t.onUnload;try{e.pageHide()}catch(i){util_1.warn("[arms] error in hookPage:onUnload",i)}if("function"==typeof n)return n.apply(this,r)}};return util_1.ext({},t,r)},$ar:function(){},$as:function(){this.setCommonInfo({app:"mini_common",uid:this._conf.uid})},$aw:function(){var t=this;t.$ac(function(){t._lg("pv",{})})},$at:function(){var t=this;t.isSendPerf||(t.$ac(function(){var e={fpt:Date.now()-t.sBegin};t._lg("perf",e)}),t.isSendPerf=!0)},$av:function(){this.$ax(),this.$ao&&(this._lg("speed",this.$ao),this.$ao=null,clearTimeout(this.$ap)),this.$ae()},$ax:function(){if(this.sessionPage){var t=util_1.ext({},this._health);t.healthy=t.errcount>0?0:1,t.begin=Date.now();var e=t.begin-this.sBegin;t.page=this.sessionPage,t.stay=e,this._lg("health",t,1),this._health={errcount:0,apisucc:0,apifail:0},this.sessionPage=null}}});var singleton=null,generator=function(t){return singleton||(singleton=new MiniProgramLogger(t||{})),singleton};MiniProgramLogger.init=generator,MiniProgramLogger.singleton=generator,MiniProgramLogger._super=reporter,MiniProgramLogger._root=reporter._root,reporter.MiniProgramLogger=MiniProgramLogger;var miniProgramLogger=MiniProgramLogger,hook=function(t){var e=util_1,r=null,n={};return e.ext(t.prototype,{addHook:function(){return this.isHookInstantiated?this:(function(){var t=this;if("undefined"!=typeof wx&&wx&&"function"==typeof wx.request){r=wx;var i={request:function(r){var n=(new Date).getTime();if(r&&"object"==typeof r&&r[0]){var i,o,a=r[0],s=e.$a9(a.url),u=a.success,c=a.fail,g=a&&a.header;g&&"object"==typeof g||(g={});var l={};if(t.getConfig("enableLinkTrace")){var f=g["EagleEye-pAppName"];if(i=g["EagleEye-TraceID"],o=g["EagleEye-SessionID"],i||(i=t.getTraceId()["EagleEye-TraceID"],l["EagleEye-TraceID"]=i),o||(o=t.getSessionId()["EagleEye-SessionID"],l["EagleEye-SessionID"]=o),!f){var p=t.getConfig("pid");l["EagleEye-pAppName"]=p}}a.success=function(){var a=(new Date).getTime();if(e.$a7(s,!0)){var c=arguments&&arguments[0]&&arguments[0].statusCode||200;t.api({api:r[0].url,success:!0,time:a-n,code:c,begin:n,traceId:i,sid:o})}u&&u.apply(t,[].slice.call(arguments))},a.fail=function(){var a=(new Date).getTime();if(e.$a7(s,!0)){var u="";arguments&&arguments[0]&&"object"==typeof arguments[0]&&(u=(u=JSON.stringify(arguments[0])).substring(0,1e3));var g=arguments&&arguments[0]&&arguments[0].statusCode||"FAILED";t.api({api:r[0].url,success:!1,time:a-n,code:g,msg:u,begin:n,traceId:i,sid:o})}c&&c.apply(t,[].slice.call(arguments))},a.header=e.ext({},g,l)}}};for(var o in wx)if(i[o]){var a=o.toString();n[a]=function(){return i[a](arguments),r[a].apply(r,[].slice.call(arguments))}}else n[o]=r[o];wx=n}}.call(this),this.isHookInstantiated=!0,this)},removeHook:function(){return this.isHookInstantiated?(function(){"undefined"!=typeof wx&&wx&&r&&(wx=r,r=null)}.call(this),this.isHookInstantiated=!1,this):this},$ar:function(){return this.$ay?this:(this.getConfig("disableHook")||this.addHook(),this.$ay=!0,this)}}),t},ARMS_STORAGE_MINIPROGRAM_WX_UID_KEY="ARMS_STORAGE_MINIPROGRAM_WX_UID_KEY",WXLogger=function(t){return miniProgramLogger.call(this,t),this};WXLogger.prototype=util_1.$a2(miniProgramLogger.prototype),util_1.ext(miniProgramLogger._root.dftCon,{sendRequest:function(t,e){if("undefined"!=typeof wx&&wx&&"function"==typeof wx.request)try{var r,n="GET";e&&(n="POST",r=JSON.stringify(e)),wx.request({url:t,method:n,data:r,fail:function(t){util_1.warn("[arms] sendRequest fail",t)}})}catch(i){util_1.warn("[arms] error in conf sendRequest",i)}},getCurrentPage:function(){if("function"==typeof getCurrentPages)try{var t=getCurrentPages()||[],e=t[t.length-1];return e&&e.route||null}catch(r){util_1.warn("[arms] error in conf getCurrentPage",r)}}}),util_1.ext(WXLogger.prototype,{constructor:WXLogger,_super:miniProgramLogger,$as:function(){this.setCommonInfo({app:"mini_wx"}),this.$az(),this.$b0(),this.$b1()},$b1:function(){if(this._conf&&this._conf.uid)this.setCommonInfo({uid:this._conf.uid});else if("undefined"!=typeof wx&&wx&&"function"==typeof wx.getStorageSync)try{var t=wx.getStorageSync(ARMS_STORAGE_MINIPROGRAM_WX_UID_KEY);if(t&&"string"==typeof t)this.setCommonInfo({uid:t});else if("function"==typeof wx.setStorageSync){var e=util_1.uu();wx.setStorageSync(ARMS_STORAGE_MINIPROGRAM_WX_UID_KEY,e),this.setCommonInfo({uid:e})}}catch(r){util_1.warn("[arms] error in $b1",r)}},$az:function(){if("undefined"!=typeof wx&&wx&&"function"==typeof wx.getSystemInfoSync)try{var t=wx.getSystemInfoSync();"object"==typeof t&&this.setCommonInfo({sr:(t.screenWidth||0)+"x"+(t.screenHeight||0),vp:(t.windowWidth||0)+"x"+(t.windowHeight||0),dpr:t.pixelRatio,ul:t.language})}catch(e){util_1.warn("[arms] error in $az",e)}},$b0:function(){var t=this;if("undefined"!=typeof wx&&wx&&"function"==typeof wx.getNetworkType)try{wx.getNetworkType({success:function(e){e&&"string"==typeof e.networkType&&t.setCommonInfo({ct:e.networkType})},fail:function(t){util_1.warn("[arms] $b0 getNetworkType fail",t)}})}catch(e){util_1.warn("[arms] error in $b0",e)}},hookApp:function(t){var e=this,r={onError:function(r){var n=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),i=t.onError;try{if(r&&"object"==typeof r&&e.error(r),r&&"string"==typeof r){var o=r.split("\n"),a="",s="";o.length>1&&(a=o[0]&&o[0].length<100?o[0]:o[0].substring(0,100),s=o[1]),e.error({name:a,message:s||r,stack:r})}}catch(r){util_1.warn("[arms] error in hookApp:onError",r)}if("function"==typeof i)return i.apply(this,n)}};return util_1.ext({},t,r)}}),hook(WXLogger);var singleton$1=null,generator$1=function(t){return singleton$1||(singleton$1=new WXLogger(t||{})),singleton$1};WXLogger.init=generator$1,WXLogger.singleton=generator$1,WXLogger._super=miniProgramLogger,WXLogger._root=miniProgramLogger._root,miniProgramLogger.WXLogger=WXLogger;var clazz=WXLogger;module.exports=clazz; | ||
/** retcode cloud sdk | @version 1.5.9 | @copyright Alibaba Group Holding Limited. */ "use strict";Date.now=Date.now||function(){return(new Date).getTime()};var SEQUENCE=Date.now(),noop=function(){},$a1=function(){var t="object"==typeof console?console.warn:noop;try{var e={warn:t};e.warn.call(e)}catch(r){return noop}return t},util={noop:noop,warn:$a1(),key:"__bl",win:"object"==typeof window&&window.document?window:undefined,regionMap:{cn:"https://arms-retcode.aliyuncs.com/r.png?",sg:"https://arms-retcode-sg.aliyuncs.com/r.png?",sg_2:"https://retcode-sg-lazada.arms.aliyuncs.com/r.png?",daily:"http://arms-retcode-daily.alibaba.net/r.png?",daily_2:"https://arms-retcode-daily.alibaba.net/r.png?",us:"https://retcode-us-west-1.arms.aliyuncs.com/r.png?"},defaultImgUrl:"https://arms-retcode.aliyuncs.com/r.png?",$a2:function(t){if(Object.create)return Object.create(t);var e=function(){};return e.prototype=t,new e},each:function(t,e){var r=0,n=t.length;if(this.T(t,"Array"))for(;r<n&&!1!==e.call(t[r],t[r],r);r++);else for(r in t)if(!1===e.call(t[r],t[r],r))break;return t},$a3:function(t,e,r){if("function"!=typeof t)return r;try{return t.apply(this,e)}catch(n){return r}},T:function(t,e){var r=Object.prototype.toString.call(t).substring(8).replace("]","");return e?r===e:r},$a4:function(t,e){if(!t)return"";if(!e)return t;var r=this,n=r.T(e);return"Function"===n?r.$a3(e,[t],t):"Array"===n?(this.each(e,function(e){t=r.$a4(t,e)}),t):"Object"===n?t.replace(e.rule,e.target||""):t.replace(e,"")},$a5:function(t,e){if(!t||!e)return!1;if((this.isString(e)||e.source||"Function"===this.T(e))&&(e=[e]),!this.isArray(e))return util.warn("[arms] invalid rules of ignore config, (list of) String/RegExp/Funcitons are available"),!1;for(var r,n=[],i=0,o=e.length;i<o;i++)if(r=e[i],this.isString(r))n.push(r.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"));else if(r&&r.source)n.push(r.source);else if(r&&"Function"===this.T(r)&&!0===this.$a3(r,[t],!1))return!0;var a=new RegExp(n.join("|"),"i");return!!(n.length&&a.test&&a.test(t))},J:function(t){if(!t||"string"!=typeof t)return t;var e=null;try{e=JSON.parse(t)}catch(r){}return e},pick:function(t){return 1===t||1===Math.ceil(Math.random()*t)},$a6:function(t){if("sample"in t){var e=t.sample,r=e;e&&/^\d+(\.\d+)?%$/.test(e)&&(r=parseInt(100/parseFloat(e))),0<r&&1>r&&(r=parseInt(1/r)),r>=1&&r<=100?t.sample=r:delete t.sample}return t},on:function(t,e,r,n){return t.addEventListener?t.addEventListener(e,function i(o){n&&t.removeEventListener(e,i,!1),r.call(this,o)},!1):t.attachEvent&&t.attachEvent("on"+e,function o(i){n&&t.detachEvent("on"+e,o),r.call(this,i)}),this},off:function(t,e,r){return r?(t.removeEventListener?t.removeEventListener(e,r):t.detachEvent&&t.detachEvent(e,r),this):this},delay:function(t,e){return-1===e?(t(),null):setTimeout(t,e||0)},ext:function(t){for(var e=1,r=arguments.length;e<r;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},sub:function(t,e){var r={};return this.each(t,function(t,n){-1!==e.indexOf(n)&&(r[n]=t)}),r},uu:function(){for(var t,e,r=20,n=new Array(r),i=Date.now().toString(36).split("");r-- >0;)e=(t=36*Math.random()|0).toString(36),n[r]=t%3?e:e.toUpperCase();for(var o=0;o<8;o++)n.splice(3*o+2,0,i[o]);return n.join("")},seq:function(){return(SEQUENCE++).toString(36)},encode:function(t,e){try{t=e?encodeURIComponent(t).replace(/\(/g,"%28").replace(/\)/g,"%29"):encodeURIComponent(t)}catch(r){}return t},serialize:function(t){t=t||{};var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&t[r]!==undefined&&e.push(r+"="+this.encode(t[r],"msg"===r));return e.join("&")},$a7:function(t,e){if(!t||"string"!=typeof t)return!1;var r=/arms-retcode[\w-]*\.aliyuncs/.test(t);return!r&&e&&(r=/(\.png)|(\.gif)|(alicdn\.com)/.test(t)),!r},$a8:function(t){return!(!t||!t.message)&&!/failed[\w\s]+fetch/i.test(t.message)},$a9:function(t){return t&&"string"==typeof t?t.replace(/^(https?:)?\/\//,"").replace(/\?.*$/,""):""},$aa:function(t){return function(){return t+"() { [native code] }"}},checkSameOrigin:function(t,e){if(!e||!t)return!1;var r="//"+e.split("/")[2];return t===e||t.slice(0,e.length+1)===e+"/"||t===r||t.slice(0,r.length+1)===r+"/"||!/^(\/\/|http:|https:).*/.test(t)},getRandIP:function(){for(var t=[],e=0;e<4;e++){var r=Math.floor(256*Math.random());t[e]=(r>15?"":"0")+r.toString(16)}return t.join("")},getSortNum:function(t){return t?(t+=1)>=1e3&&t<=9999?t:t<1e3?t+1e3:t%1e4+1e3:1e3},getRandNum:function(t){return t&&"string"==typeof t?t.length<5?this.getNum(5):t.substring(t.length-5):this.getNum(5)},getNum:function(t){for(var e=[],r=0;r<t;r++){var n=Math.floor(16*Math.random());e[r]=n.toString(16)}return e.join("")},isFunction:function(t){return"function"==typeof t},isPlainObject:function(t){return"[object Object]"===Object.prototype.toString.call(t)},isString:function(t){return"[object String]"===Object.prototype.toString.call(t)},isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},joinRegExp:function(t){for(var e,r=[],n=0,i=t.length;n<i;n++)e=t[n],this.isString(e)?r.push(e.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):e&&e.source&&r.push(e.source);return new RegExp(r.join("|"),"i")}},util_1=util,pushToQueue=function(t,e){var r;{if("error"!==e.t||!(r=t.$ab[0])||"error"!==r.t||e.msg!==r.msg){if("behavior"===e.t){var n=t.$ab&&t.$ab.length;if(n>0&&"behavior"===t.$ab[n-1].t){var i=e.behavior||[];t.$ab[n-1].behavior.concat(i)}else t.$ab.push(e)}else t.$ab.unshift(e);return t.$ac(function(){t.$ad=util_1.delay(function(){t.$ae()},t.$ab[0]&&"error"===t.$ab[0].t?3e3:-1)}),!0}r.times++}},Base=function(t){return this.ver="1.5.9",this._conf=util_1.ext({},Base.dftCon),this.$af={},this.$ab=[],this.hash=util_1.seq(),this.$ag(),this.setConfig(t),this.rip=util_1.getRandIP(),this.record=999,this["EagleEye-TraceID"]=this.getTraceId()["EagleEye-TraceID"],this._common={},this};Base.dftCon={sample:1,tag:"",imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",region:null,ignore:{ignoreUrls:[],ignoreApis:[],ignoreErrors:[]},release:undefined,environment:"production"},Base.prototype={constructor:Base,$ac:function(t){return t()},$ah:function(){var t=this._conf.page;return util_1.$a3(t,[],t+"")},setPage:function(){},setConfig:function(t){t&&"object"==typeof t&&(util_1.$a6(t),t=this.$ai(t),this._conf=util_1.ext({},this._conf,t))},$ai:function(t){var e=t.region,r=t.imgUrl;if(e){var n=util_1.regionMap[e];return t.imgUrl=n||util_1.defaultImgUrl,t}return r&&(t.imgUrl=r),t},$aj:function(t){if(this.getConfig("debug"))return!0;var e=util_1.regionMap,r=!1;for(var n in e)if(e[n]===t){r=!0;break}return!r&&util_1.warn("[retcode] invalid url: "+t),r},$ak:function(){},$al:function(){},$am:function(){return{}},setCommonInfo:function(t){t&&"object"==typeof t&&(this._common=util_1.ext({},this._common,t))},$ag:function(){this.session=util_1.uu(),this.sBegin=Date.now()},getTraceId:function(){var t=this.rip,e=Date.now(),r=util_1.getSortNum(this.record),n=t+e+r+util_1.getRandNum(this._conf.pid);return this["EagleEye-TraceID"]=n,this.record=r,{"EagleEye-TraceID":n}},getSessionId:function(){return{"EagleEye-SessionID":this.session}},getConfig:function(t){return t?this._conf[t]:util_1.ext({},this._conf)},$an:function(t){return 1===t||("boolean"==typeof this.$af[t]?this.$af[t]:(this.$af[t]=util_1.pick(t),this.$af[t]))},$ae:function(){var t;for(clearTimeout(this.$ad),this.$ad=null;t=this.$ab.pop();)"res"===t.t?this.$al(t,"res"):"error"===t.t?this.$al(t,"err"):"behavior"===t.t?this.$al(t,"behavior"):this.$ak(t);return this},_lg:function(t,e,r){var n=this._conf,i=this.$ah(),o=n.ignore||{},a=o.ignoreErrors,s=o.ignoreUrls,u=o.ignoreApis;return util_1.$a5(i,s)?this:"error"===t&&util_1.$a5(e.msg,a)?this:"api"===t&&util_1.$a5(e.api,u)?this:this.$aj(n.imgUrl)&&e&&!n.disabled&&n.pid?r&&!this.$an(r)?this:(e=util_1.ext({t:t,times:1,page:i,tag:n.tag||"",release:n.release||"",environment:n.environment,begin:Date.now()},e,this.$am(),this._common,{pid:n.pid,_v:this.ver,sid:this.session,sampling:r||1,z:util_1.seq(),custom_1:n.custom_1,custom_2:n.custom_2,custom_3:n.custom_3}),pushToQueue(this,e)):this},custom:function(t,e){if(!t||"object"!=typeof t)return this;var r=!1,n={begin:Date.now()};return util_1.each(t,function(t,e){return!(r=e&&e.length<=20)&&util_1.warn("[retcode] invalid key: "+e),n["x-"+e]=t,r}),r?this._lg("custom",n,e||1):this}};var base=Base,validApiKeys=["api","success","time","code","msg","trace","traceId","begin","sid","seq"],parseStatData=function(t,e){var r=t.split("::");return r.length>1?util_1.ext({group:r[0],key:r[1]},e):util_1.ext({group:"default_group",key:r[0]},e)},Reporter=function(t){base.call(this,t);var e;try{e="object"==typeof performance?performance.timing.fetchStart:Date.now()}catch(r){e=Date.now()}return this._startTime=e,this};Reporter.prototype=util_1.$a2(base.prototype),util_1.ext(base.dftCon,{startTime:null}),util_1.ext(Reporter.prototype,{constructor:Reporter,_super:base,sum:function(t,e,r){try{return this._lg("sum",parseStatData(t,{val:e||1,begin:Date.now()}),r)}catch(n){util_1.warn("[retcode] can not get parseStatData: "+n)}},avg:function(t,e,r){try{return this._lg("avg",parseStatData(t,{val:e||0,begin:Date.now()}),r)}catch(n){util_1.warn("[retcode] can not get parseStatData: "+n)}},percent:function(t,e,r,n){try{return this._lg("percent",parseStatData(t,{subkey:e,val:r||0,begin:Date.now()}),n)}catch(i){util_1.warn("[retcode] can not get parseStatData: "+i)}},msg:function(t,e){if(t&&!(t.length>180))return this.custom({msg:t},e)},error:function(t,e){if(!t)return util_1.warn("[retcode] invalid param e: "+t),this;1===arguments.length?("string"==typeof t&&(t={message:t},e={}),"object"==typeof t&&(e=t=t.error||t)):("string"==typeof t&&(t={message:t}),"object"!=typeof e&&(e={}));var r=t.name||"CustomError",n=util_1.encode(t.message),i=util_1.encode(t.stack||"");e=e||{};var o={begin:Date.now(),cate:r,msg:n.substring(0,1e3),stack:i&&i.substring(0,1e3),file:e.filename||"",line:e.lineno||"",col:e.colno||"",err:{msg_raw:n,stack_raw:i}},a=(this.getConfig("ignore")||{}).ignoreErrors;return util_1.$a5(o.msg,a)?this:(this.$aq&&this.$aq("error",o),this._lg("error",o,1))},behavior:function(t){if(t){var e="object"==typeof t&&t.behavior?t:{behavior:t};return this.$aq&&this.$aq("behavior",e),this._lg("behavior",e,1)}},api:function(t,e,r,n,i,o,a,s){if(!t)return util_1.warn("[retcode] api is null"),this;if(t="string"==typeof t?{api:t,success:e,time:r,code:n,msg:i,begin:o,traceId:a,sid:s}:util_1.sub(t,validApiKeys),!util_1.$a7(t.api))return this;if(t.code=t.code||"",t.msg=t.msg||"",t.success=t.success?1:0,t.time=+t.time,t.begin=t.begin,t.traceId=t.traceId||"",t.sid=t.sid||"",!t.api||isNaN(t.time))return util_1.warn("[retcode] invalid time or api"),this;var u=(this.getConfig("ignore")||{}).ignoreApis;if(util_1.$a5(t.api,u))return this;this.$aq&&this.$aq("api",t);var c={type:"api",data:{message:i,url:t.api,status:n||""},timestamp:o};try{this.getConfig("behavior")&&this.addBehavior&&this.addBehavior(c)}catch(g){}return this._lg("api",t,t.success&&this.getConfig("sample"))},speed:function(t,e,r){var n=this,i=this.getConfig("startTime")||this._startTime;return/^s(\d|1[0])$/.test(t)?(e="number"!=typeof e?Date.now()-i:e>=i?e-i:e,n.$ao=n.$ao||{},n.$ao[t]=e,n.$ao.begin=i,clearTimeout(n.$ap),n.$ap=setTimeout(function(){r||(n.$ao.page=n.$ah(!0)),n._lg("speed",n.$ao),n.$ao=null},5e3),n):(util_1.warn("[retcode] invalid point: "+t),n)},resource:function(t,e){if(!t||!util_1.isPlainObject(t))return util_1.warn("[arms] invalid param data: "+t),this;var r=Object.keys(t),n=["begin","dom","load","res","dl"],i=!1;for(var o in n){if(r.indexOf(n[o])<0){i=!0;break}}if(i)return util_1.warn("[arms] lack param data: "+t),this;var a={begin:t.begin||Date.now(),dom:t.dom||"",load:t.load||"",res:util_1.isArray(t.res)?JSON.stringify(t.res):JSON.stringify([]),dl:t.dl||""};return this._lg("res",a,e)}}),Reporter._super=base,Reporter._root=base,base.Reporter=Reporter;var reporter=Reporter,MiniProgramLogger=function(t){t&&t.pid||util_1.warn("[arms] pid is a required prop to instatiate MiniProgramLogger");var e=this;return reporter.call(e,t),e._health={errcount:0,apisucc:0,apifail:0},e.DEFAUT_PAGE_PATH="[app]",e.isSendPerf=!1,e.$aq=function(t,r){"error"===t?e._health.errcount++:"api"===t&&e._health[r.success?"apisucc":"apifail"]++},"function"==typeof e.$ar&&e.$ar(),"function"==typeof e.$as&&e.$as(),this};MiniProgramLogger.prototype=util_1.$a2(reporter.prototype),util_1.ext(reporter._root.dftCon,{uid:null,disableHook:!1,enableLinkTrace:!1,sendRequest:function(){},getCurrentPage:function(){}}),util_1.ext(MiniProgramLogger.prototype,{constructor:MiniProgramLogger,_super:reporter,$ac:function(t){t()},$ak:function(t,e){if(this.getConfig("debug"))"undefined"!=typeof console&&console&&"function"==typeof console.log&&console.log("[arms] [DEBUG MODE] log data",t);else{var r=this.getConfig("imgUrl");"object"==typeof t&&(t=util_1.serialize(t));var n=r+t;e&&(n+="&post_res=");var i=this._conf.sendRequest;if("function"==typeof i)try{i(n,e)}catch(o){util_1.warn("[arms] error in $ak",o)}}},$al:function(t,e){var r={};r[e]=t[e],delete t[e],this.$ak(t,r)},$ah:function(){var t=this._conf.getCurrentPage;if("function"==typeof t)try{var e=t();if(e&&"string"==typeof e)return e}catch(r){util_1.warn("[arms] error in $ah",r)}return"string"==typeof t&&t?t:this.DEFAUT_PAGE_PATH},setConfig:function(t){if(t&&"object"==typeof t){util_1.$a6(t),t=this.$ai(t);var e=this._conf;this._conf=util_1.ext({},this._conf,t);var r="disableHook";r in t&&e[r]!==t[r]&&(t[r]?"function"==typeof this.removeHook&&this.removeHook():"function"==typeof this.addHook&&this.addHook())}},pageShow:function(){var t=this;t.$ag(),t.$at(),clearTimeout(t.$au),t.$av(),t.$au=setTimeout(function(){t.$aw()},10),t.sessionPage=t.$ah()},pageHide:function(){this.$av()},addHook:function(){return this},removeHook:function(){return this},hookApp:function(t){var e=this,r={onError:function(r){var n=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),i=t.onError;try{e.error(r)}catch(r){util_1.warn("[arms] error in hookApp:onError",r)}if("function"==typeof i)return i.apply(this,n)}};return util_1.ext({},t,r)},hookPage:function(t){var e=this,r={onShow:function(){var r=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),n=t.onShow;try{e.pageShow()}catch(i){util_1.warn("[arms] error in hookPage:pageShow",i)}if("function"==typeof n)return n.apply(this,r)},onHide:function(){var r=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),n=t.onHide;try{e.pageHide()}catch(i){util_1.warn("[arms] error in hookPage:onHide",i)}if("function"==typeof n)return n.apply(this,r)},onUnload:function(){var r=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),n=t.onUnload;try{e.pageHide()}catch(i){util_1.warn("[arms] error in hookPage:onUnload",i)}if("function"==typeof n)return n.apply(this,r)}};return util_1.ext({},t,r)},$ar:function(){},$as:function(){this.setCommonInfo({app:"mini_common",uid:this._conf.uid})},$aw:function(){var t=this;t.$ac(function(){t._lg("pv",{})})},$at:function(){var t=this;t.isSendPerf||(t.$ac(function(){var e={fpt:Date.now()-t.sBegin};t._lg("perf",e)}),t.isSendPerf=!0)},$av:function(){this.$ax(),this.$ao&&(this._lg("speed",this.$ao),this.$ao=null,clearTimeout(this.$ap)),this.$ae()},$ax:function(){if(this.sessionPage){var t=util_1.ext({},this._health);t.healthy=t.errcount>0?0:1,t.begin=Date.now();var e=t.begin-this.sBegin;t.page=this.sessionPage,t.stay=e,this._lg("health",t,1),this._health={errcount:0,apisucc:0,apifail:0},this.sessionPage=null}}});var singleton=null,generator=function(t){return singleton||(singleton=new MiniProgramLogger(t||{})),singleton};MiniProgramLogger.init=generator,MiniProgramLogger.singleton=generator,MiniProgramLogger._super=reporter,MiniProgramLogger._root=reporter._root,reporter.MiniProgramLogger=MiniProgramLogger;var miniProgramLogger=MiniProgramLogger,hook=function(t){var e=util_1,r=null,n={};return e.ext(t.prototype,{addHook:function(){return this.isHookInstantiated?this:(function(){var t=this;if("undefined"!=typeof wx&&wx&&"function"==typeof wx.request){r=wx;var i={request:function(r){var n=(new Date).getTime();if(r&&"object"==typeof r&&r[0]){var i,o,a=r[0],s=e.$a9(a.url),u=a.success,c=a.fail,g=a&&a.header;g&&"object"==typeof g||(g={});var l={};if(t.getConfig("enableLinkTrace")){var f=g["EagleEye-pAppName"];if(i=g["EagleEye-TraceID"],o=g["EagleEye-SessionID"],i||(i=t.getTraceId()["EagleEye-TraceID"],l["EagleEye-TraceID"]=i),o||(o=t.getSessionId()["EagleEye-SessionID"],l["EagleEye-SessionID"]=o),!f){var h=t.getConfig("pid");l["EagleEye-pAppName"]=h}}a.success=function(){var a=(new Date).getTime();if(e.$a7(s,!0)){var c=arguments&&arguments[0]&&arguments[0].statusCode||200;t.api({api:r[0].url,success:!0,time:a-n,code:c,begin:n,traceId:i,sid:o})}u&&u.apply(t,[].slice.call(arguments))},a.fail=function(){var a=(new Date).getTime();if(e.$a7(s,!0)){var u="";arguments&&arguments[0]&&"object"==typeof arguments[0]&&(u=(u=JSON.stringify(arguments[0])).substring(0,1e3));var g=arguments&&arguments[0]&&arguments[0].statusCode||"FAILED";t.api({api:r[0].url,success:!1,time:a-n,code:g,msg:u,begin:n,traceId:i,sid:o})}c&&c.apply(t,[].slice.call(arguments))},a.header=e.ext({},g,l)}}};for(var o in wx)if(i[o]){var a=o.toString();n[a]=function(){return i[a](arguments),r[a].apply(r,[].slice.call(arguments))}}else n[o]=r[o];wx=n}}.call(this),this.isHookInstantiated=!0,this)},removeHook:function(){return this.isHookInstantiated?(function(){"undefined"!=typeof wx&&wx&&r&&(wx=r,r=null)}.call(this),this.isHookInstantiated=!1,this):this},$ar:function(){return this.$ay?this:(this.getConfig("disableHook")||this.addHook(),this.$ay=!0,this)}}),t},ARMS_STORAGE_MINIPROGRAM_WX_UID_KEY="ARMS_STORAGE_MINIPROGRAM_WX_UID_KEY",WXLogger=function(t){return miniProgramLogger.call(this,t),this};WXLogger.prototype=util_1.$a2(miniProgramLogger.prototype),util_1.ext(miniProgramLogger._root.dftCon,{sendRequest:function(t,e){if("undefined"!=typeof wx&&wx&&"function"==typeof wx.request)try{var r,n="GET";e&&(n="POST",r=JSON.stringify(e)),wx.request({url:t,method:n,data:r,fail:function(t){util_1.warn("[arms] sendRequest fail",t)}})}catch(i){util_1.warn("[arms] error in conf sendRequest",i)}},getCurrentPage:function(){if("function"==typeof getCurrentPages)try{var t=getCurrentPages()||[],e=t[t.length-1];return e&&e.route||null}catch(r){util_1.warn("[arms] error in conf getCurrentPage",r)}}}),util_1.ext(WXLogger.prototype,{constructor:WXLogger,_super:miniProgramLogger,$as:function(){this.setCommonInfo({app:"mini_wx"}),this.$az(),this.$b0(),this.$b1()},$b1:function(){if(this._conf&&this._conf.uid)this.setCommonInfo({uid:this._conf.uid});else if("undefined"!=typeof wx&&wx&&"function"==typeof wx.getStorageSync)try{var t=wx.getStorageSync(ARMS_STORAGE_MINIPROGRAM_WX_UID_KEY);if(t&&"string"==typeof t)this.setCommonInfo({uid:t});else if("function"==typeof wx.setStorageSync){var e=util_1.uu();wx.setStorageSync(ARMS_STORAGE_MINIPROGRAM_WX_UID_KEY,e),this.setCommonInfo({uid:e})}}catch(r){util_1.warn("[arms] error in $b1",r)}},$az:function(){if("undefined"!=typeof wx&&wx&&"function"==typeof wx.getSystemInfoSync)try{var t=wx.getSystemInfoSync();"object"==typeof t&&this.setCommonInfo({sr:(t.screenWidth||0)+"x"+(t.screenHeight||0),vp:(t.windowWidth||0)+"x"+(t.windowHeight||0),dpr:t.pixelRatio,ul:t.language})}catch(e){util_1.warn("[arms] error in $az",e)}},$b0:function(){var t=this;if("undefined"!=typeof wx&&wx&&"function"==typeof wx.getNetworkType)try{wx.getNetworkType({success:function(e){e&&"string"==typeof e.networkType&&t.setCommonInfo({ct:e.networkType})},fail:function(t){util_1.warn("[arms] $b0 getNetworkType fail",t)}})}catch(e){util_1.warn("[arms] error in $b0",e)}},hookApp:function(t){var e=this,r={onError:function(r){var n=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),i=t.onError;try{if(r&&"object"==typeof r&&e.error(r),r&&"string"==typeof r){var o=r.split("\n"),a="",s="";o.length>1&&(a=o[0]&&o[0].length<100?o[0]:o[0].substring(0,100),s=o[1]),e.error({name:a,message:s||r,stack:r})}}catch(r){util_1.warn("[arms] error in hookApp:onError",r)}if("function"==typeof i)return i.apply(this,n)}};return util_1.ext({},t,r)}}),hook(WXLogger);var singleton$1=null,generator$1=function(t){return singleton$1||(singleton$1=new WXLogger(t||{})),singleton$1};WXLogger.init=generator$1,WXLogger.singleton=generator$1,WXLogger._super=miniProgramLogger,WXLogger._root=miniProgramLogger._root,miniProgramLogger.WXLogger=WXLogger;var clazz=WXLogger;module.exports=clazz; |
{ | ||
"name": "alife-logger", | ||
"version": "1.5.7", | ||
"version": "1.5.9", | ||
"description": "retcode cloud sdk", | ||
@@ -16,3 +16,3 @@ "exports": "__bl", | ||
"his": "fie commit out", | ||
"proxy2local": "npx f2etest-local start --port 1080 --server http://f2etest.alibaba-inc.com/ --name yufeng.wjj --apikey 1e61b90a0b3c4450a689b267ff30f012", | ||
"proxy2local": "npx f2etest-local start --port 1080 --server http://f2etest.alibaba-inc.com/ --name maixi.fl --apikey 1c0ca34a085e4c69af399c0ba699b543", | ||
"f2etest": "npm run proxy2local && mocha --no-timeouts test/f2etest/** && npm run stop_proxy", | ||
@@ -19,0 +19,0 @@ "stop_proxy": "npx f2etest-local stop", |
@@ -65,4 +65,4 @@ # ARMS BROSWER LOGGER | ||
| ignoreUrlCase | `Boolean` | 是否忽略page url大小写,默认忽略 | 否 | `true` | | ||
| ignoreUrlPath | * | URL 过滤规则,详情见下文 | 否 | 见下文 | | ||
| ignoreApiPath | * | API过滤规则,详情见下文 | 否 | 见下文 | | ||
| urlHelper | * | URL 规整规则,详情见下文 | 否 | 见下文 | | ||
| apiHelper | * | API 规整规则,详情见下文 | 否 | 见下文 | | ||
@@ -109,3 +109,3 @@ **部分设置项详细说明** | ||
#### 2. `ignoreUrlPath` URL 过滤规则 | ||
#### 2. `urlHelper` URL规整规则,代替原`ignoreUrlPath` | ||
@@ -130,3 +130,3 @@ 在页面 URL 类似于 `http://xxx.com/projects/123456` 这样的场景中(projects 后面紧跟的是项目 id), | ||
`ignoreUrlPath` 的值可以是多种类型,用法分别为: | ||
`urlHelper` 的值可以是多种类型,用法分别为: | ||
@@ -138,5 +138,5 @@ - `String` 或 `RegExp`: 将匹配到的字符串去掉; | ||
#### 3. `config.ignoreApiPath` API 过滤规则 | ||
#### 3. `apiHelper` api规整规则,代替原`ignoreApiPath` | ||
用于在自动上报 API 的时候过滤掉接口 URL 中的非关键字符,用法及含义同 `ignoreUrlPath` | ||
用于在自动上报 API 的时候过滤掉接口 URL 中的非关键字符,用法及含义同 `urlHelper` | ||
@@ -143,0 +143,0 @@ 默认值是一个对象,**一般情况下不需要修改**: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
446904
45
2214
1