Commit eaf7c61f authored by aiduck's avatar aiduck

添加黑名单

parent 286001bd
{
"name": "@tuia/rip",
"version": "1.2.1",
"version": "1.2.2-beta",
"description": "Tools for user behavior recording and playback based on rrweb",
"main": "dist/index.js",
"scripts": {
......
......@@ -7,7 +7,9 @@ class Monitor {
rrwebHandler = null;
initialized = false;
listenedRoute = false;
isBlockingFlag = false;
tracksWorker = new TracksWorker();
_blackList = [];
constructor() {
(() => {
var lastTime = performance.now();
......@@ -44,16 +46,19 @@ class Monitor {
return false;
}
setInterval(() => {
if (isBlocking(fpsList, 30, 8)) {
if (isBlocking(fpsList, 20, 4)) {
// this.stop();
isBlockingFlag = true;
}
fpsList = [];
}, 10000);
}, 5000);
}
init({ system, userIdentifier, host = [], env = "prod", log = false, path = "/" }) {
init({ system, userIdentifier, host = [], env = "prod", log = false, path = "/", blackList = [] }) {
let protocol = document.location.protocol;
let realHost = window.location.host;
_blackList = blackList;
console.log('黑名单', _blackList);
if (!system || !userIdentifier || host.length > 0) {
console.log("system,userIdentifier,host是必传的");
}
......@@ -70,8 +75,13 @@ class Monitor {
protocol,
},
});
this.initialized = true;
this.record();
if(_blackList && _blackList.includes(path)) {
this.stop();
console.log('改页面不支持用户行为监控');
} else {
this.initialized = true;
this.record();
}
} else {
this.reset({ userIdentifier });
}
......@@ -104,7 +114,16 @@ class Monitor {
console.log("开始录制");
this.rrwebHandler = rrweb.record({
emit: event => {
this.tracksWorker.postMessage({ type: "record", payload: { ...event, fps: fpsList.length ? fpsList.slice(fpsList.length - 1)[0] : 0 } });
this.tracksWorker.postMessage(
{
type: "record",
payload: {
...event,
fps: fpsList.length ? fpsList.slice(fpsList.length - 1)[0] : 0,
isBlockingFlag
}
});
isBlockingFlag = 0;
},
});
}
......@@ -119,6 +138,10 @@ class Monitor {
window.addEventListener("hashchange", () => {
// 忽略hash后的query
let hash = getPureHash(location.hash);
if(_blackList && _blackList.includes(hash)) {
this.stop();
console.log('改页面不支持用户行为监控');
}
if (hash === preHash) return console.log("hash query 无变化,no reset");
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