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
eaf7c61f
Commit
eaf7c61f
authored
Sep 23, 2019
by
aiduck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加黑名单
parent
286001bd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
7 deletions
+30
-7
package.json
package.json
+1
-1
monitor.js
src/lib/monitor.js
+29
-6
No files found.
package.json
View file @
eaf7c61f
{
{
"name"
:
"@tuia/rip"
,
"name"
:
"@tuia/rip"
,
"version"
:
"1.2.
1
"
,
"version"
:
"1.2.
2-beta
"
,
"description"
:
"Tools for user behavior recording and playback based on rrweb"
,
"description"
:
"Tools for user behavior recording and playback based on rrweb"
,
"main"
:
"dist/index.js"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
src/lib/monitor.js
View file @
eaf7c61f
...
@@ -7,7 +7,9 @@ class Monitor {
...
@@ -7,7 +7,9 @@ class Monitor {
rrwebHandler
=
null
;
rrwebHandler
=
null
;
initialized
=
false
;
initialized
=
false
;
listenedRoute
=
false
;
listenedRoute
=
false
;
isBlockingFlag
=
false
;
tracksWorker
=
new
TracksWorker
();
tracksWorker
=
new
TracksWorker
();
_blackList
=
[];
constructor
()
{
constructor
()
{
(()
=>
{
(()
=>
{
var
lastTime
=
performance
.
now
();
var
lastTime
=
performance
.
now
();
...
@@ -44,16 +46,19 @@ class Monitor {
...
@@ -44,16 +46,19 @@ class Monitor {
return
false
;
return
false
;
}
}
setInterval
(()
=>
{
setInterval
(()
=>
{
if
(
isBlocking
(
fpsList
,
30
,
8
))
{
if
(
isBlocking
(
fpsList
,
20
,
4
))
{
// this.stop();
// this.stop();
isBlockingFlag
=
true
;
}
}
fpsList
=
[];
fpsList
=
[];
},
10
000
);
},
5
000
);
}
}
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
protocol
=
document
.
location
.
protocol
;
let
realHost
=
window
.
location
.
host
;
let
realHost
=
window
.
location
.
host
;
_blackList
=
blackList
;
console
.
log
(
'黑名单'
,
_blackList
);
if
(
!
system
||
!
userIdentifier
||
host
.
length
>
0
)
{
if
(
!
system
||
!
userIdentifier
||
host
.
length
>
0
)
{
console
.
log
(
"system,userIdentifier,host是必传的"
);
console
.
log
(
"system,userIdentifier,host是必传的"
);
}
}
...
@@ -70,8 +75,13 @@ class Monitor {
...
@@ -70,8 +75,13 @@ class Monitor {
protocol
,
protocol
,
},
},
});
});
if
(
_blackList
&&
_blackList
.
includes
(
path
))
{
this
.
stop
();
console
.
log
(
'改页面不支持用户行为监控'
);
}
else
{
this
.
initialized
=
true
;
this
.
initialized
=
true
;
this
.
record
();
this
.
record
();
}
}
else
{
}
else
{
this
.
reset
({
userIdentifier
});
this
.
reset
({
userIdentifier
});
}
}
...
@@ -104,7 +114,16 @@ class Monitor {
...
@@ -104,7 +114,16 @@ class Monitor {
console
.
log
(
"开始录制"
);
console
.
log
(
"开始录制"
);
this
.
rrwebHandler
=
rrweb
.
record
({
this
.
rrwebHandler
=
rrweb
.
record
({
emit
:
event
=>
{
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 {
...
@@ -119,6 +138,10 @@ class Monitor {
window
.
addEventListener
(
"hashchange"
,
()
=>
{
window
.
addEventListener
(
"hashchange"
,
()
=>
{
// 忽略hash后的query
// 忽略hash后的query
let
hash
=
getPureHash
(
location
.
hash
);
let
hash
=
getPureHash
(
location
.
hash
);
if
(
_blackList
&&
_blackList
.
includes
(
hash
))
{
this
.
stop
();
console
.
log
(
'改页面不支持用户行为监控'
);
}
if
(
hash
===
preHash
)
return
console
.
log
(
"hash query 无变化,no reset"
);
if
(
hash
===
preHash
)
return
console
.
log
(
"hash query 无变化,no reset"
);
preHash
=
hash
;
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