Commit 22bf6918 authored by aiduck's avatar aiduck

添加黑名单

parent 62f0f78c
{
"name": "@tuia/rip",
"version": "1.2.1-beta",
"version": "1.2.3-beta2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -2393,8 +2393,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
......@@ -2415,14 +2414,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
......@@ -2437,20 +2434,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
......@@ -2567,8 +2561,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
......@@ -2580,7 +2573,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
......@@ -2595,7 +2587,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
......@@ -2603,14 +2594,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
......@@ -2629,7 +2618,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
......@@ -2710,8 +2698,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
......@@ -2723,7 +2710,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
......@@ -2809,8 +2795,7 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
......@@ -2846,7 +2831,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
......@@ -2866,7 +2850,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
......@@ -2910,14 +2893,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
}
}
},
......
{
"name": "@tuia/rip",
"version": "1.2.3-beta2",
"version": "1.2.3",
"description": "Tools for user behavior recording and playback based on rrweb",
"main": "dist/index.js",
"scripts": {
......
......@@ -11,6 +11,7 @@ class Monitor {
tracksWorker = new TracksWorker();
_blackList = [];
constructor() {
(() => {
var lastTime = performance.now();
var frame = 0;
......@@ -31,6 +32,7 @@ class Monitor {
};
loop();
})();
function isBlocking(fpsList, below, last) {
var count = 0;
for (var i = 0; i < fpsList.length; i++) {
......@@ -45,10 +47,11 @@ class Monitor {
}
return false;
}
setInterval(() => {
if (isBlocking(fpsList, 20, 4)) {
// this.stop();
isBlockingFlag = true;
this.isBlockingFlag = true;
this.stop();
}
fpsList = [];
}, 5000);
......@@ -58,12 +61,15 @@ class Monitor {
let protocol = document.location.protocol;
let realHost = window.location.host;
this._blackList = blackList;
console.log('黑名单', this._blackList);
if (!system || !userIdentifier || host.length > 0) {
console.log("system,userIdentifier,host是必传的");
}
if (host.includes(realHost)) {
if (!this.initialized) {
if(this.isExistBlackList(path)) {
console.log('改页面不支持用户行为监控');
this.stop();
} else {
this.tracksWorker.postMessage({
type: "init",
payload: {
......@@ -75,10 +81,6 @@ class Monitor {
protocol,
},
});
if(this.isExistBlackList(path)) {
this.stop();
console.log('改页面不支持用户行为监控');
} else {
this.initialized = true;
this.record();
}
......@@ -103,12 +105,17 @@ class Monitor {
* 是否存在黑名单中
**/
isExistBlackList(path) {
this._blackList && this._blackList.map(item => {
if(path.includes(item)){
return true
if(this._blackList && this._blackList.length === 0) {
return false
} else {
let flag = false;
this._blackList.map(item => {
if(path.includes(item)) {
flag = true;
}
})
return false
return flag;
}
}
/**
* 关闭rrweb
......@@ -131,10 +138,11 @@ class Monitor {
payload: {
...event,
fps: fpsList.length ? fpsList.slice(fpsList.length - 1)[0] : 0,
isBlockingFlag
isBlockingFlag: this.isBlockingFlag
}
});
isBlockingFlag = false;
}
);
this.isBlockingFlag = false;
},
});
}
......@@ -147,12 +155,12 @@ class Monitor {
let preHash = "";
this.listenedRoute = true;
window.addEventListener("hashchange", () => {
// 是否寻在名单
// 是否寻在名单
let hash = getPureHash(location.hash);
if(this.isExistBlackList(hash)) {
clearTimeout(timer);
this.stop();
console.log('改页面不支持用户行为监控');
this.stop();
return
}
// 忽略hash后的query
......
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