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