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
717ef537
Commit
717ef537
authored
Aug 05, 2019
by
fanxuehui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(types):
parent
feb99f13
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
21 deletions
+28
-21
index.d.ts
src/index.d.ts
+9
-0
monitor.js
src/lib/monitor.js
+9
-7
utils.js
src/lib/utils.js
+10
-14
No files found.
src/index.d.ts
0 → 100644
View file @
717ef537
export
interface
MProps
{
system
:
string
;
userIdentifier
:
string
;
env
:
"dev"
|
"prod"
;
log
:
boolean
;
}
export
declare
class
Monitor
{
constructor
(
props
:
MProps
);
}
\ No newline at end of file
src/lib/monitor.js
View file @
717ef537
import
*
as
rrweb
from
"rrweb"
;
import
TracksWorker
from
"./tracks.worker"
;
import
utils
from
'./utils'
;
import
utils
from
"./utils"
;
export
default
class
Monitor
{
rrwebHandler
=
null
;
tracksWorker
=
new
TracksWorker
();
constructor
(
props
)
{
console
.
log
(
'初始化'
);
constructor
(
{
system
=
"unknow"
,
userIdentifier
=
"unknow"
,
env
=
"prod"
,
log
=
false
}
)
{
console
.
log
(
"初始化"
);
this
.
tracksWorker
.
postMessage
({
type
:
"init"
,
payload
:
{
system
:
props
.
system
,
config
:
props
.
config
}
system
,
userIdentifier
,
env
,
log
,
},
});
}
resetRrwebHandler
()
{
...
...
@@ -44,7 +46,7 @@ export default class Monitor {
}
/**
* 重置
* @param {*} event
* @param {*} event
*/
reset
(
event
)
{
this
.
resetRrwebHandler
();
...
...
src/lib/utils.js
View file @
717ef537
/**
* 包装event
* @param {*} extraData
* @param {*} event
* @param {*} extraData
* @param {*} event
*/
export
const
dataWrapper
=
(
extraData
,
event
)
=>
{
return
{
...
extraData
,
track
:
event
}
return
{
...
extraData
,
track
:
event
,
};
};
/**
* 是否打印日志
* @param {
*} logMes
* @param {
boolean} log
*/
export
const
log
=
(
log
,
logMes
,
logContent
)
=>
{
if
(
log
)
{
return
console
.
log
(
logMes
,
logContent
);
}
else
{
return
;
}
};
\ No newline at end of file
export
const
log
=
(
log
,
...
rest
)
=>
{
console
.
log
(
rest
);
};
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