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
0eb7f34f
Commit
0eb7f34f
authored
Jul 22, 2019
by
aiduck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并代码
parent
ee77a5c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
18 deletions
+20
-18
monitor.js
src/lib/monitor.js
+2
-2
tracks.worker.js
src/lib/tracks.worker.js
+18
-16
No files found.
src/lib/monitor.js
View file @
0eb7f34f
...
...
@@ -16,7 +16,7 @@ export default class Monitor {
console
.
log
(
'开始录制'
)
this
.
rrwebHandler
=
rrweb
.
record
({
emit
:
event
=>
{
this
.
tracksWorker
.
postMessage
({
type
:
"record"
,
event
});
this
.
tracksWorker
.
postMessage
({
type
:
"record"
,
payload
:
event
});
},
});
}
...
...
@@ -32,7 +32,7 @@ export default class Monitor {
reset
(
event
)
{
this
.
rrwebHandler
&&
this
.
rrwebHandler
();
console
.
log
(
'重置数据'
)
this
.
tracksWorker
.
postMessage
({
type
:
"reset"
,
event
});
this
.
tracksWorker
.
postMessage
({
type
:
"reset"
,
payload
:
event
});
}
// 发送信息
postMessage
(
action
)
{
...
...
src/lib/tracks.worker.js
View file @
0eb7f34f
...
...
@@ -4,52 +4,54 @@ import _ from 'lodash';
// 原始数据数组
let
events
=
[];
// 包装后的数据对象
let
wrap
Events
=
[];
let
wrap
Data
=
[];
// 分条视频id
let
recordKey
=
''
;
// 全量快照是否已经返回
let
isCdnReturn
=
false
;
onmessage
=
({
data
:
{
type
,
event
}
})
=>
{
onmessage
=
({
data
:
{
type
,
payload
}
})
=>
{
switch
(
type
)
{
case
"record"
:
// todo : 数据本地存储
wrap
Events
.
push
(
utils
.
dataWrapper
({
wrap
Data
.
push
(
utils
.
dataWrapper
({
recordKey
,
isCdn
:
false
},
event
));
events
.
push
(
event
);
},
payload
));
events
.
push
(
payload
);
// todo : 全量快照上传cdn
if
(
event
.
type
===
2
)
{
if
(
payload
.
type
===
2
)
{
const
cdnIndex
=
_
.
findIndex
(
events
,
{
'type'
:
2
});
setTimeout
(()
=>
{
wrap
Events
.
splice
(
cdnIndex
,
1
,
utils
.
dataWrapper
({
wrap
Data
.
splice
(
cdnIndex
,
1
,
utils
.
dataWrapper
({
recordKey
,
isCdn
:
true
},
event
));
},
payload
));
isCdnReturn
=
true
;
},
1000
);
}
// todo : 数据压缩
// todo : 根据事件类型优先级触发上传策略(click)
if
(
event
.
data
.
source
===
2
&&
isCdnReturn
)
{
console
.
log
(
'点击上上传events'
,
wrapEvents
);
if
(
payload
.
data
.
source
===
2
&&
isCdnReturn
)
{
console
.
log
(
'点击上上传events'
,
wrapData
);
postMessage
(
wrapData
);
events
=
[];
wrap
Events
=
[];
wrap
Data
=
[];
}
// todo : 数据超出100条上线,自动上传
if
(
wrapEvents
.
length
>
100
&&
isCdnReturn
)
{
console
.
log
(
'超出线上100条上传events'
,
wrapEvents
)
if
(
wrapData
.
length
>
100
&&
isCdnReturn
)
{
console
.
log
(
'超出线上100条上传events'
,
wrapData
)
postMessage
(
wrapData
);
events
=
[];
wrap
Events
=
[];
wrap
Data
=
[];
}
break
;
case
"reset"
:
// todo : 重置参数,重新生成recordKey
events
=
[];
wrap
Events
=
[];
wrap
Data
=
[];
recordKey
=
''
;
isCdnReture
=
false
;
const
{
url
,
email
}
=
events
;
const
{
url
,
email
}
=
payload
;
recordKey
=
md5
(
url
+
email
+
Date
.
parse
(
new
Date
()));
console
.
log
(
url
,
'分片id'
,
recordKey
);
break
;
...
...
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