Commit c6650f90 authored by aiduck's avatar aiduck

isExistBlackList

parent eaf7c61f
...@@ -54,7 +54,7 @@ class Monitor { ...@@ -54,7 +54,7 @@ class Monitor {
}, 5000); }, 5000);
} }
init({ system, userIdentifier, host = [], env = "prod", log = false, path = "/", blackList = [] }) { init({ system, userIdentifier, host = [], env = "prod", log = false, path = window.location.hash, blackList = [] }) {
let protocol = document.location.protocol; let protocol = document.location.protocol;
let realHost = window.location.host; let realHost = window.location.host;
_blackList = blackList; _blackList = blackList;
...@@ -75,7 +75,7 @@ class Monitor { ...@@ -75,7 +75,7 @@ class Monitor {
protocol, protocol,
}, },
}); });
if(_blackList && _blackList.includes(path)) { if(isExistBlackList(path)) {
this.stop(); this.stop();
console.log('改页面不支持用户行为监控'); console.log('改页面不支持用户行为监控');
} else { } else {
...@@ -99,6 +99,17 @@ class Monitor { ...@@ -99,6 +99,17 @@ class Monitor {
console.log("当前的系统并不是线上环境,不做特殊录制"); console.log("当前的系统并不是线上环境,不做特殊录制");
} }
} }
/**
* 是否存在黑名单中
**/
isExistBlackList(path) {
_blackList && _blackList.map(item => {
if(path.includes(item)){
return true
}
})
return false
}
/** /**
* 关闭rrweb * 关闭rrweb
*/ */
...@@ -136,12 +147,15 @@ class Monitor { ...@@ -136,12 +147,15 @@ class Monitor {
let preHash = ""; let preHash = "";
this.listenedRoute = true; this.listenedRoute = true;
window.addEventListener("hashchange", () => { window.addEventListener("hashchange", () => {
// 忽略hash后的query // 是否寻在和名单
let hash = getPureHash(location.hash); let hash = getPureHash(location.hash);
if(_blackList && _blackList.includes(hash)) { if(isExistBlackList(hash)) {
clearTimeout(timer);
this.stop(); this.stop();
console.log('改页面不支持用户行为监控'); console.log('改页面不支持用户行为监控');
return
} }
// 忽略hash后的query
if (hash === preHash) return console.log("hash query 无变化,no reset"); if (hash === preHash) return console.log("hash query 无变化,no reset");
preHash = hash; preHash = hash;
//防抖,防止无效的频繁触发 //防抖,防止无效的频繁触发
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment