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
c6650f90
Commit
c6650f90
authored
Sep 23, 2019
by
aiduck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
isExistBlackList
parent
eaf7c61f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
monitor.js
src/lib/monitor.js
+18
-4
No files found.
src/lib/monitor.js
View file @
c6650f90
...
...
@@ -54,7 +54,7 @@ class Monitor {
},
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
realHost
=
window
.
location
.
host
;
_blackList
=
blackList
;
...
...
@@ -75,7 +75,7 @@ class Monitor {
protocol
,
},
});
if
(
_blackList
&&
_blackList
.
includes
(
path
))
{
if
(
isExistBlackList
(
path
))
{
this
.
stop
();
console
.
log
(
'改页面不支持用户行为监控'
);
}
else
{
...
...
@@ -99,6 +99,17 @@ class Monitor {
console
.
log
(
"当前的系统并不是线上环境,不做特殊录制"
);
}
}
/**
* 是否存在黑名单中
**/
isExistBlackList
(
path
)
{
_blackList
&&
_blackList
.
map
(
item
=>
{
if
(
path
.
includes
(
item
)){
return
true
}
})
return
false
}
/**
* 关闭rrweb
*/
...
...
@@ -136,12 +147,15 @@ class Monitor {
let
preHash
=
""
;
this
.
listenedRoute
=
true
;
window
.
addEventListener
(
"hashchange"
,
()
=>
{
//
忽略hash后的query
//
是否寻在和名单
let
hash
=
getPureHash
(
location
.
hash
);
if
(
_blackList
&&
_blackList
.
includes
(
hash
))
{
if
(
isExistBlackList
(
hash
))
{
clearTimeout
(
timer
);
this
.
stop
();
console
.
log
(
'改页面不支持用户行为监控'
);
return
}
// 忽略hash后的query
if
(
hash
===
preHash
)
return
console
.
log
(
"hash query 无变化,no reset"
);
preHash
=
hash
;
//防抖,防止无效的频繁触发
...
...
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