fix(wechat): 文本消息与客服消息关键路径增加 WARN 级日志,便于定位全网发布检测失败原因
This commit is contained in:
parent
06a2126e2e
commit
c3896bc68a
@ -404,6 +404,11 @@ class WechatOpenController extends Controller {
|
|||||||
const msgType = String(data.MsgType || '');
|
const msgType = String(data.MsgType || '');
|
||||||
const event = String(data.Event || '');
|
const event = String(data.Event || '');
|
||||||
|
|
||||||
|
// 文本消息全量落盘(WARN 级):生产日志只落 WARN+,用于检测场景定位客服回复问题
|
||||||
|
if (msgType === 'text') {
|
||||||
|
ctx.logger.warn(`[wechatOpen.events] 收到文本消息 appid=${appid} openid=${data.FromUserName} content=${JSON.stringify(String(data.Content || ''))}`);
|
||||||
|
}
|
||||||
|
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case 'event':
|
case 'event':
|
||||||
await this.handlePushEvent(appid, event, data);
|
await this.handlePushEvent(appid, event, data);
|
||||||
@ -544,6 +549,7 @@ class WechatOpenController extends Controller {
|
|||||||
try {
|
try {
|
||||||
const authorizationInfo = await client.queryAuth(authCode);
|
const authorizationInfo = await client.queryAuth(authCode);
|
||||||
refreshToken = authorizationInfo.authorizer_refresh_token || null;
|
refreshToken = authorizationInfo.authorizer_refresh_token || null;
|
||||||
|
ctx.logger.warn(`[wechatOpen.events] QUERY_AUTH_CODE 换取令牌成功 appid=${appid} code=${authCode} has_refresh=${!!refreshToken}`);
|
||||||
if (refreshToken) {
|
if (refreshToken) {
|
||||||
await client.cacheSet(`App:${appid}:authorizer_refresh_token`, refreshToken, 30 * 24 * 3600);
|
await client.cacheSet(`App:${appid}:authorizer_refresh_token`, refreshToken, 30 * 24 * 3600);
|
||||||
if (authorizationInfo.authorizer_access_token) {
|
if (authorizationInfo.authorizer_access_token) {
|
||||||
@ -640,9 +646,9 @@ class WechatOpenController extends Controller {
|
|||||||
ctx.logger.warn(`[wechatOpen.events] 读取授权记录失败 appid=${appid}: ${e.message}`);
|
ctx.logger.warn(`[wechatOpen.events] 读取授权记录失败 appid=${appid}: ${e.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.logger.info(`[wechatOpen.events] 发送客服消息 appid=${appid} openid=${openid} content=${content}`);
|
ctx.logger.warn(`[wechatOpen.events] 发送客服消息 appid=${appid} openid=${openid} content=${JSON.stringify(content)} has_token=${!!token}`);
|
||||||
const result = await client.sendCustomMessage(appid, openid, content, token);
|
const result = await client.sendCustomMessage(appid, openid, content, token);
|
||||||
ctx.logger.info(`[wechatOpen.events] 客服消息发送结果: ${JSON.stringify(result)}`);
|
ctx.logger.warn(`[wechatOpen.events] 客服消息发送结果: ${JSON.stringify(result)}`);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user