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
c174b672
Commit
c174b672
authored
Aug 05, 2019
by
aiduck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setData
parent
717ef537
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
25 deletions
+26
-25
monitor.js
src/lib/monitor.js
+9
-0
reporter.js
src/lib/reporter.js
+13
-17
tracks.worker.js
src/lib/tracks.worker.js
+4
-8
No files found.
src/lib/monitor.js
View file @
c174b672
...
...
@@ -17,6 +17,9 @@ export default class Monitor {
},
});
}
/**
* 关闭rrweb
*/
resetRrwebHandler
()
{
this
.
rrwebHandler
&&
this
.
rrwebHandler
();
}
...
...
@@ -33,6 +36,12 @@ export default class Monitor {
},
});
}
/**
* 路由监听
*/
listenOnHash
()
{
// console.log(window.onhashchange());
}
/**
* 停止录制
* @memberof Monitor
...
...
src/lib/reporter.js
View file @
c174b672
...
...
@@ -18,15 +18,20 @@ class Reporter {
constructor
(
recordKey
)
{
this
.
recordKey
=
recordKey
;
}
// 设置系统名
setSystem
(
system
)
{
this
.
system
=
system
;
}
// 设置配置内容
setConfig
(
config
)
{
this
.
config
=
config
;
this
.
setEnvironment
(
config
.
env
);
// 设置参数内容
setData
(
dataObj
)
{
console
.
log
(
dataObj
);
// 设置系统名
this
.
system
=
dataObj
.
system
||
this
.
system
;
// 设置配置内容
this
.
config
=
dataObj
.
config
||
this
.
config
;
this
.
setEnvironment
(
this
.
config
.
env
);
// 设置用户标示
this
.
userIdentifier
=
dataObj
.
userInfo
||
this
.
userIdentifier
;
// 设置当前访问路径
this
.
path
=
dataObj
.
url
||
this
.
path
;
}
// 设置系统环境变量
setEnvironment
(
env
)
{
if
(
env
===
'dev'
)
{
...
...
@@ -35,15 +40,6 @@ class Reporter {
this
.
environmentUrl
=
'http://hunter.dui88.com.cn'
;
}
}
// 设置用户标示
setUserIdentifier
(
userIdentifier
)
{
this
.
userIdentifier
=
userIdentifier
;
}
// 设置当前访问路径
setPath
(
url
)
{
this
.
path
=
url
}
// 上传CDN
toCDN
(
payload
)
{
this
.
isUploading
=
true
;
...
...
src/lib/tracks.worker.js
View file @
c174b672
...
...
@@ -6,10 +6,9 @@ const reporter = new Reporter("recordKey");
onmessage
=
({
data
:
{
type
,
payload
}
})
=>
{
switch
(
type
)
{
case
"init"
:
reporter
.
setSystem
(
payload
.
system
);
reporter
.
setConfig
(
payload
.
config
);
case
"init"
:
log
(
reporter
.
config
.
log
,
'init参数'
,
payload
);
reporter
.
setData
(
payload
);
break
;
case
"record"
:
// todo : 数据本地存储
...
...
@@ -21,25 +20,22 @@ onmessage = ({ data: { type, payload } }) => {
reporter
.
toCDN
(
payload
);
}
// todo : 数据压缩
// todo : 根据事件类型优先级触发上传策略(click)
if
(
payload
.
data
.
source
===
2
&&
!
reporter
.
isUploading
)
{
postMessage
({
type
:
"localData"
,
payload
:
reporter
.
bus
})
reporter
.
report
(
reporter
.
bus
);
}
// todo : 数据超出100条上线,自动上传
if
(
reporter
.
bus
.
length
>
100
&&
!
reporter
.
isUploading
)
{
postMessage
({
type
:
"localData"
,
payload
:
reporter
.
bus
})
reporter
.
report
(
reporter
.
bus
);
}
break
;
case
"reset"
:
// todo : 重置参数,重新生成recordKey
const
{
url
,
email
,
userInfo
}
=
payload
;
reporter
.
setUserIdentifier
(
userInfo
);
reporter
.
setPath
(
url
);
reporter
.
setData
(
payload
);
let
recordKey
=
md5
(
url
+
email
+
Date
.
parse
(
new
Date
()));
reporter
.
reset
(
recordKey
);
log
(
reporter
.
config
.
log
,
'用户信息'
,
userInfo
);
log
(
reporter
.
config
.
log
,
'分片id'
,
reporter
.
recordKey
);
break
;
default
:
...
...
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