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
b30763b3
Commit
b30763b3
authored
Aug 05, 2019
by
aiduck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
opt
parent
086f64f7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
20 deletions
+25
-20
package-lock.json
package-lock.json
+1
-1
monitor.js
src/lib/monitor.js
+4
-2
reporter.js
src/lib/reporter.js
+15
-12
tracks.worker.js
src/lib/tracks.worker.js
+5
-5
No files found.
package-lock.json
View file @
b30763b3
{
{
"name"
:
"
hunter-rrweb
"
,
"name"
:
"
@tuia/rip
"
,
"version"
:
"0.0.1"
,
"version"
:
"0.0.1"
,
"lockfileVersion"
:
1
,
"lockfileVersion"
:
1
,
"requires"
:
true
,
"requires"
:
true
,
...
...
src/lib/monitor.js
View file @
b30763b3
...
@@ -12,8 +12,10 @@ export default class Monitor {
...
@@ -12,8 +12,10 @@ export default class Monitor {
payload
:
{
payload
:
{
system
,
system
,
userIdentifier
,
userIdentifier
,
config
:
{
env
,
env
,
log
,
log
,
}
},
},
});
});
}
}
...
...
src/lib/reporter.js
View file @
b30763b3
...
@@ -3,14 +3,18 @@ import Counter from "./counter";
...
@@ -3,14 +3,18 @@ import Counter from "./counter";
import
{
dataWrapper
,
log
}
from
'./utils'
;
import
{
dataWrapper
,
log
}
from
'./utils'
;
class
Reporter
{
class
Reporter
{
system
=
''
;
// 系统名
// 基础配置
baseInfo
=
{
system
:
''
,
userIdentifier
:
''
,
path
:
''
,
};
// 系统配置
config
=
{
config
=
{
env
:
'prod'
,
env
:
'prod'
,
log
:
false
log
:
false
};
// 系统配置
};
environmentUrl
=
''
;
// 环境
environmentUrl
=
''
;
// 环境配置
userIdentifier
=
''
;
//用户标示
path
=
''
;
// 当前路径
isUploading
=
false
;
// 是否在上传cdn
isUploading
=
false
;
// 是否在上传cdn
bus
=
[];
// 上传分片数据
bus
=
[];
// 上传分片数据
counter
=
new
Counter
();
// 计数器和recordKey一起重置
counter
=
new
Counter
();
// 计数器和recordKey一起重置
...
@@ -20,16 +24,15 @@ class Reporter {
...
@@ -20,16 +24,15 @@ class Reporter {
}
}
// 设置参数内容
// 设置参数内容
setData
(
dataObj
)
{
setData
(
dataObj
)
{
console
.
log
(
dataObj
);
// 设置系统名
this
.
system
=
dataObj
.
system
||
this
.
system
;
// 设置配置内容
// 设置配置内容
this
.
config
=
dataObj
.
config
||
this
.
config
;
this
.
config
=
dataObj
.
config
||
this
.
config
;
this
.
setEnvironment
(
this
.
config
.
env
);
this
.
setEnvironment
(
this
.
config
.
env
);
// 设置用户标示
// 设置基础信息 系统名 + 用户标示 + 当前访问路径
this
.
userIdentifier
=
dataObj
.
userInfo
||
this
.
userIdentifier
;
dataObj
.
config
&&
delete
dataObj
.
config
// 设置当前访问路径
this
.
baseInfo
=
{
this
.
path
=
dataObj
.
url
||
this
.
path
;
...
this
.
baseInfo
,
...
dataObj
}
}
}
// 设置系统环境变量
// 设置系统环境变量
...
...
src/lib/tracks.worker.js
View file @
b30763b3
...
@@ -7,8 +7,8 @@ const reporter = new Reporter("recordKey");
...
@@ -7,8 +7,8 @@ const reporter = new Reporter("recordKey");
onmessage
=
({
data
:
{
type
,
payload
}
})
=>
{
onmessage
=
({
data
:
{
type
,
payload
}
})
=>
{
switch
(
type
)
{
switch
(
type
)
{
case
"init"
:
case
"init"
:
log
(
reporter
.
config
.
log
,
'init参数'
,
payload
);
reporter
.
setData
(
payload
);
reporter
.
setData
(
payload
);
log
(
reporter
.
config
.
log
,
'init参数'
,
payload
);
break
;
break
;
case
"record"
:
case
"record"
:
// todo : 数据本地存储
// todo : 数据本地存储
...
@@ -31,11 +31,11 @@ onmessage = ({ data: { type, payload } }) => {
...
@@ -31,11 +31,11 @@ onmessage = ({ data: { type, payload } }) => {
break
;
break
;
case
"reset"
:
case
"reset"
:
// todo : 重置参数,重新生成recordKey
// todo : 重置参数,重新生成recordKey
const
{
url
,
email
,
userInfo
}
=
payload
;
const
{
path
,
email
}
=
payload
;
reporter
.
setData
(
payload
);
reporter
.
setData
(
{
path
}
);
let
recordKey
=
md5
(
url
+
email
+
Date
.
parse
(
new
Date
()));
let
recordKey
=
md5
(
path
+
email
+
Date
.
parse
(
new
Date
()));
reporter
.
reset
(
recordKey
);
reporter
.
reset
(
recordKey
);
log
(
reporter
.
config
.
log
,
'
用户信息'
,
userInfo
);
log
(
reporter
.
config
.
log
,
'
path'
,
reporter
.
baseInfo
.
path
);
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