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