Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rip
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fanxuehui
rip
Commits
22bf6918
Commit
22bf6918
authored
Oct 09, 2019
by
aiduck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加黑名单
parent
62f0f78c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
59 deletions
+48
-59
package-lock.json
package-lock.json
+12
-31
package.json
package.json
+1
-1
monitor.js
src/lib/monitor.js
+35
-27
No files found.
package-lock.json
View file @
22bf6918
{
"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
}
}
},
...
...
package.json
View file @
22bf6918
{
"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"
:
{
...
...
src/lib/monitor.js
View file @
22bf6918
...
...
@@ -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,27 +61,26 @@ 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
)
{
this
.
tracksWorker
.
postMessage
({
type
:
"init"
,
payload
:
{
path
,
system
,
userIdentifier
,
env
,
log
,
protocol
,
},
});
if
(
this
.
isExistBlackList
(
path
))
{
this
.
stop
();
console
.
log
(
'改页面不支持用户行为监控'
);
this
.
stop
();
}
else
{
this
.
tracksWorker
.
postMessage
({
type
:
"init"
,
payload
:
{
path
,
system
,
userIdentifier
,
env
,
log
,
protocol
,
},
});
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
}
})
return
false
if
(
this
.
_blackList
&&
this
.
_blackList
.
length
===
0
)
{
return
false
}
else
{
let
flag
=
false
;
this
.
_blackList
.
map
(
item
=>
{
if
(
path
.
includes
(
item
))
{
flag
=
true
;
}
})
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,13 +155,13 @@ 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
(
'改页面不支持用户行为监控'
);
return
this
.
stop
();
return
}
// 忽略hash后的query
if
(
hash
===
preHash
)
return
console
.
log
(
"hash query 无变化,no reset"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment