Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
64c2ad1e
Commit
64c2ad1e
authored
Apr 19, 2024
by
李嘉林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat: 加钉钉监控
parent
74f5d78a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
123 additions
and
2 deletions
+123
-2
src/App.vue
+24
-1
src/utils/dingdingLogMonitoring.js
+99
-0
src/utils/log.js
+0
-1
No files found.
src/App.vue
View file @
64c2ad1e
...
@@ -6,7 +6,7 @@ import spokesman from "@/api/spokesman";
...
@@ -6,7 +6,7 @@ import spokesman from "@/api/spokesman";
import
{
themeColor
,
checkShowConditionIds
,
getStoreInfo
,
setStoreInfo
}
from
"@/utils/mayi"
;
import
{
themeColor
,
checkShowConditionIds
,
getStoreInfo
,
setStoreInfo
}
from
"@/utils/mayi"
;
import
{
query_isEntry
}
from
"@/utils/mayi_fenxiao"
;
import
{
query_isEntry
}
from
"@/utils/mayi_fenxiao"
;
import
{
sendMsg
}
from
"@/utils/dingdingLogMonitoring"
;
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
...
@@ -351,6 +351,29 @@ export default {
...
@@ -351,6 +351,29 @@ export default {
},
},
onError
(
data
)
{
onError
(
data
)
{
console
.
log
(
data
,
"js异常捕获"
);
console
.
log
(
data
,
"js异常捕获"
);
// 钉钉监控
let
userId
=
wx
.
getStorageSync
(
"loginUserInfo"
)
?
wx
.
getStorageSync
(
"loginUserInfo"
).
userId
:
'-'
;
let
sendMsgQuery
=
{
type
:
'bug'
,
mixid
:
this
.
$store
.
state
.
mixid
,
errorType
:
'MINI'
,
errorText
:
data
,
monitorParams
:
{
userId
,
uid
:
wx
.
getStorageSync
(
"_ma_uid"
),
},
}
try
{
const
res
=
wx
.
getSystemInfoSync
();
sendMsgQuery
.
monitorParams
.
brand
=
res
.
brand
;
sendMsgQuery
.
monitorParams
.
SDKVersion
=
res
.
SDKVersion
;
sendMsgQuery
.
monitorParams
.
platform
=
res
.
platform
;
sendMsgQuery
.
monitorParams
.
system
=
res
.
system
;
sendMsgQuery
.
monitorParams
.
version
=
res
.
version
;
}
catch
(
e
)
{
console
.
error
(
'获取系统信息失败'
,
e
);
}
sendMsg
(
sendMsgQuery
);
this
.
$mpAnalytics
.
recordError
({
this
.
$mpAnalytics
.
recordError
({
data
,
data
,
keyword
:
data
,
keyword
:
data
,
...
...
src/utils/dingdingLogMonitoring.js
0 → 100644
View file @
64c2ad1e
/*
* 钉钉群消息推送机器人
* 文档
* https://open.dingtalk.com/document/orgapp/robot-message-type-staff-information-in-an-enterprise?spm=a2c6h.13066369.question.8.30c543fblTKVaW
*/
// 基础参数
const
AT_USER
=
{
"l"
:
"15838347133"
};
// 获取辅助参数
function
getMonitorParams
(
obj
)
{
console
.
log
(
'getMonitorParams-obj->'
,
obj
);
let
t
=
""
;
if
(
obj
&&
Object
.
keys
(
obj
).
length
>
0
)
{
Object
.
keys
(
obj
).
forEach
(
item
=>
{
t
+=
`- **
${
item
}
**: \`
${
obj
[
item
]}
\`\n`
})
}
return
t
||
`- **暂无**`
;
}
/**
* 获取模板
* @param {*} param0
* @returns
*/
function
md_template
({
type
=
'bug'
,
mixid
=
''
,
errorText
=
''
,
errorType
=
''
,
monitorParams
=
{}
})
{
let
bugT
=
[
'### ⚠️ **异常报警通知** ⚠️'
,
'#### **系统概览**'
,
`- **MIX_ID**: \`
${
mixid
}
\``
,
`- **环境**: \`
${
process
.
env
.
NODE_ENV
}
\``
,
`- **错误类型**: \`
${
errorType
}
\``
,
`- **抛出时间**: \`
${
new
Date
().
toLocaleString
()}
\``
,
'#### **错误描述**'
,
'
\
n'
,
`>
${
errorText
?
errorText
:
'-'
}
\n`
,
'#### **辅助参数**'
,
`
${
getMonitorParams
(
monitorParams
)}
`
,
'
\
n'
,
'#### **查看日志**'
,
`>[kibana](https://kibana.mayi888.com/app/kibana#/discover/9134c350-f707-11ee-8573-31e83e1bb75d?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now%2Fd,to:now%2Fd))&_a=(columns:!(log_message,log_host),filters:!(),index:'9c11dbd0-f704-11ee-8573-31e83e1bb75d',interval:auto,query:(language:lucene,query:''),sort:!()))\n`
,
`>[报表](https://bi.mayi888.com/)\n`
,
'
\
n'
,
`@
${[
AT_USER
[
"l"
]]}
`
]
let
temp
=
{
bug
:
bugT
.
join
(
"
\
n"
),
warning
:
`### warning`
,
}
return
temp
[
type
]
}
/**
* 初始化
* @param {*} data
* @returns
*/
function
initParams
(
data
)
{
// 钉钉请求参数
let
SEND_MSG_QUERY
=
{
at
:
{
atMobiles
:
[
AT_USER
[
"l"
]],
// atUserId: [],
// isAtAll: false,
},
msgtype
:
"markdown"
,
// text、markdown、actionCard
markdown
:
{
title
:
"异常报警"
,
text
:
md_template
({
...
data
}),
},
}
return
SEND_MSG_QUERY
}
/**
* 发送消息
* @param {*} data
* type = 'bug', mixid = '', errorText = '', errorType = '', monitorParams = {}
*/
export
function
sendMsg
(
data
)
{
console
.
log
(
'initParams->'
,
initParams
(
data
));
wx
.
request
({
url
:
"https://oapi.dingtalk.com/robot/send?access_token=1a29dd59d14953a831989e9ba19ad16dd5f06fcbed3256b3832752aee69b4d00"
,
method
:
"POST"
,
data
:
initParams
(
data
),
header
:
{
"Content-Type"
:
"application/json"
},
success
:
function
(
res
)
{
console
.
log
(
"发送成功"
,
res
);
},
fail
:
function
(
res
)
{
console
.
log
(
"发送失败"
,
res
);
}
})
}
\ No newline at end of file
src/utils/log.js
View file @
64c2ad1e
...
@@ -8,7 +8,6 @@ module.exports = {
...
@@ -8,7 +8,6 @@ module.exports = {
log
.
debug
.
apply
(
log
,
arguments
)
log
.
debug
.
apply
(
log
,
arguments
)
},
},
info
()
{
info
()
{
console
.
log
(
'日志log级别'
);
if
(
!
log
)
return
if
(
!
log
)
return
log
.
info
.
apply
(
log
,
arguments
)
log
.
info
.
apply
(
log
,
arguments
)
},
},
...
...
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