Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
foreign
/
customer-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
142ecbe7
authored
Jan 12, 2022
by
杨铁龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
日志支持小程序
parent
51763f55
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
34 deletions
service/monitor.ts
service/monitor.ts
View file @
142ecbe7
import
Axios
,
{
AxiosResponse
}
from
"axios"
;
import
Axios
,
{
AxiosResponse
,
AxiosAdapter
}
from
"axios"
;
import
{
UniplatSdk
}
from
"uniplat-sdk"
;
import
{
ImEnvironment
}
from
"../model"
;
export
const
enum
Product
{
Default
=
'default'
,
QqxbWeixin
=
'qqxb-weixin'
,
QqxbApp
=
'qqxb-app'
,
Fulibao
=
'fulibao'
,
HrManager
=
'hr-manager'
,
Hrs100
=
'hrs100'
,
HrsApp
=
'hrs-app'
,
BiJie
=
'bi-jie'
,
Cashier
=
'cashier'
,
Default
=
"default"
,
QqxbWeixin
=
"qqxb-weixin"
,
QqxbApp
=
"qqxb-app"
,
Fulibao
=
"fulibao"
,
HrManager
=
"hr-manager"
,
Hrs100
=
"hrs100"
,
HrsApp
=
"hrs-app"
,
BiJie
=
"bi-jie"
,
Cashier
=
"cashier"
,
Uniplat
=
"uniplat"
,
DeShengJiuYeBao
=
'de-sheng-jiu-ye-bao'
DeShengJiuYeBao
=
"de-sheng-jiu-ye-bao"
,
}
const
enum
ProductTable
{
...
...
@@ -26,6 +26,7 @@ export interface SdkMonitorOption {
userAgent
?:
boolean
;
envir
:
ImEnvironment
;
product
:
Product
;
call
?:
(
r
:
any
)
=>
void
;
}
class
WebMonitor
{
...
...
@@ -33,6 +34,7 @@ class WebMonitor {
private
envir
=
ImEnvironment
.
Dev
;
private
product
=
Product
.
Default
;
private
readonly
url
=
"https://pre-hrs-monitor.hrs100.com"
;
private
adapter
:
AxiosAdapter
|
undefined
;
public
updateKey
(
key
:
string
)
{
this
.
key
=
key
;
...
...
@@ -42,6 +44,7 @@ class WebMonitor {
private
buildHeaders
()
{
return
{
headers
:
{
authorization
:
"cdd0a34e-f537-4e5b-808e-2ba06af21845"
},
adapter
:
this
.
adapter
,
};
}
...
...
@@ -85,35 +88,46 @@ class WebMonitor {
);
}
public
useSdk
(
sdk
:
UniplatSdk
,
options
:
SdkMonitorOption
)
{
public
useSdk
(
sdk
:
UniplatSdk
,
options
:
SdkMonitorOption
,
adapter
?:
AxiosAdapter
)
{
this
.
envir
=
options
.
envir
;
this
.
product
=
options
.
product
;
sdk
.
events
.
addUniversalErrorResponseCallback
((
r
:
AxiosResponse
<
any
>
)
=>
{
if
(
this
.
enable
())
{
const
msg
:
string
[]
=
[];
msg
.
push
(
`URL:
${
decodeURIComponent
(
r
.
config
.
url
as
string
)}
`
);
msg
.
push
(
`Token:
${
sdk
.
global
.
jwtToken
}
`
);
const
header
=
r
.
config
.
headers
;
if
(
header
)
{
msg
.
push
(
`CurrentOrg:
${
header
.
CurrentOrg
}
`
);
msg
.
push
(
`Scenes:
${
header
.
Scenes
}
`
);
}
this
.
adapter
=
adapter
;
sdk
.
events
.
addUniversalErrorResponseCallback
(
(
r
:
AxiosResponse
<
any
>
)
=>
{
options
.
call
&&
options
.
call
(
r
);
if
(
this
.
enable
())
{
const
msg
:
string
[]
=
[];
msg
.
push
(
`URL:
${
decodeURIComponent
(
r
.
config
.
url
as
string
)}
`
);
msg
.
push
(
`Token:
${
sdk
.
global
.
jwtToken
}
`
);
const
header
=
r
.
config
.
headers
;
if
(
header
)
{
msg
.
push
(
`CurrentOrg:
${
header
.
CurrentOrg
}
`
);
msg
.
push
(
`Scenes:
${
header
.
Scenes
}
`
);
}
options
&&
options
.
userAgent
&&
msg
.
push
(
`UserAgent:
${
window
.
navigator
.
userAgent
}
`
);
r
.
config
&&
r
.
config
.
data
&&
msg
.
push
(
`Payload:
${
JSON
.
stringify
(
r
.
config
.
data
)}
`
);
options
&&
options
.
userAgent
&&
msg
.
push
(
`UserAgent:
${
window
.
navigator
.
userAgent
}
`
);
r
.
config
&&
r
.
config
.
data
&&
msg
.
push
(
`Payload:
${
JSON
.
stringify
(
r
.
config
.
data
)}
`
);
msg
.
push
(
`Exception:
${((
r
.
data
.
error
as
string
)
||
""
).
substring
(
0
,
500
)}
`
);
msg
.
push
(
`Exception:
${(
(
r
.
data
.
error
as
string
)
||
""
).
substring
(
0
,
500
)}
`
);
r
&&
r
.
config
&&
this
.
error
(
msg
.
join
(
"\n"
));
r
&&
r
.
config
&&
this
.
error
(
msg
.
join
(
"\n"
));
}
}
}
);
);
}
}
...
...
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