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
900aa80d
Commit
900aa80d
authored
Jul 22, 2019
by
fanxuehui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(postmessage):
parent
319ad83b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
package.json
package.json
+1
-1
monitor.js
src/lib/monitor.js
+8
-1
tracks.worker.js
src/lib/tracks.worker.js
+3
-4
No files found.
package.json
View file @
900aa80d
{
"name"
:
"hunter-rrweb"
,
"version"
:
"0.0.1"
,
"description"
:
"Tools for
recording and replaying user behavior built using
rrweb"
,
"description"
:
"Tools for
user behavior recording and playback based on
rrweb"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
"dev"
:
"cross-env NODE_ENV=dev node build.js"
,
...
...
src/lib/monitor.js
View file @
900aa80d
...
...
@@ -3,11 +3,18 @@ import TracksWorker from "./tracks.worker";
export
default
class
Monitor
{
rrwebHandler
=
null
;
tracksWorker
=
new
TracksWorker
();
constructor
()
{
this
.
tracksWorker
.
onmessage
=
({
data
})
=>
{
console
.
log
(
data
);
window
.
localStorage
.
setItem
(
"rrevents"
,
JSON
.
stringify
(
data
));
console
.
log
(
"local"
);
};
}
record
()
{
this
.
rrwebHandler
&&
this
.
rrwebHandler
();
this
.
rrwebHandler
=
rrweb
.
record
({
emit
:
event
=>
{
this
.
tracksWorker
.
postMessage
({
type
:
"record"
,
event
});
this
.
tracksWorker
.
postMessage
({
type
:
"record"
,
payload
:
event
});
},
});
}
...
...
src/lib/tracks.worker.js
View file @
900aa80d
let
events
=
[];
onmessage
=
({
data
:
{
type
,
event
}
})
=>
{
onmessage
=
({
data
:
{
type
,
payload
}
})
=>
{
switch
(
type
)
{
case
"record"
:
// todo : 根据事件类型优先级触发上传策略
// todo : 全量快照上传cdn
// todo : 数据压缩
events
.
push
(
event
);
events
.
push
(
payload
);
console
.
log
(
events
);
if
(
events
.
length
>
100
)
{
window
.
localStorage
.
setItem
(
"rrevents"
,
JSON
.
stringify
(
events
)
);
postMessage
(
events
);
events
=
[];
console
.
log
(
"local"
);
}
break
;
case
"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