Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit cf18d8c

Browse files
committed
fix: fix xconsole-service
1 parent 91e7bcb commit cf18d8c

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

packages/console-utils/xconsole-service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@alicloud/xconsole-service",
3-
"version": "2.5.4",
3+
"version": "2.5.5",
44
"main": "lib/index.js",
55
"module": "es/index.js",
66
"types": "lib/index.d.ts",

packages/console-utils/xconsole-service/src/interceptors/armsInterceptor/response.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,13 @@ const logArmsForMultiApi = ({targetUrl, traceId, startTime, duration, success, c
3434
Object.keys(responseData).forEach((key) => {
3535
const respForSingleApi = responseData[key];
3636
const { Code } = respForSingleApi;
37-
if (Code && Code === '200' && Code !== 200) {
38-
const apiWithIdentifier = `${api}&identifier=${key}&requestId=${respForSingleApi.RequestId}`;
39-
console.log({
40-
api: apiWithIdentifier, success: false, duration, code: respForSingleApi.Code,
41-
msg: respForSingleApi?.Message, startTime, traceId
42-
})
43-
logger({
44-
api: apiWithIdentifier, success: false, duration, code: respForSingleApi.Code,
45-
msg: respForSingleApi?.Message, startTime, traceId
46-
});
47-
}
37+
const apiWithIdentifier = `${api}&identifier=${key}&requestId=${respForSingleApi.RequestId}`;
38+
const isSuccess = Code && (Code === '200' || Code === 200);
39+
40+
logger({
41+
api: apiWithIdentifier, success: isSuccess, duration, code: respForSingleApi.Code,
42+
msg: respForSingleApi?.Message, startTime, traceId
43+
});
4844
})
4945
}
5046
}

packages/console-utils/xconsole-service/src/utils/logger.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ declare global {
33
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
44
interface Window {
55
__bl: any;
6+
aplus_queue: any [];
7+
APLUS_CONFIG: Record<string, any>;
68
}
79
}
810

@@ -32,6 +34,28 @@ const apiLog = (info: any): void => {
3234
// window.__bl maybe is proxy
3335
if (window.__bl) window.__bl.pipe = [apiInfo];
3436
}
37+
38+
// 手动上报 aplus
39+
// eslint-disable-next-line @typescript-eslint/camelcase
40+
const q = (window.aplus_queue || (window.aplus_queue = []));
41+
window.APLUS_CONFIG && window.APLUS_CONFIG.apiTrack ==='off' && q.push({
42+
'action':'aplus.logApi',
43+
'arguments':[{
44+
api, // 必选 api地址
45+
url: window.location.href,
46+
success, // 必选 boolean 接口请求成功与否
47+
msg, // 可选,出错时接口返回信息
48+
// httpCode: number, // 可选 http状态码
49+
code, // 可选 业务code
50+
time: duration, // 可选 接口请求时长
51+
traceId, // 可选 traceId
52+
// params: string, // 可选 json格式 请求参数
53+
// header: string, // 可选 json格式 请求头
54+
requestType: 'xhr', // 可选 请求类型
55+
method: 'POST', // 可选 fetch,xhr的请求方法
56+
// sampling: 1 // 采样上报,不填为1,0-1之间的数字
57+
}]
58+
});
3559
};
3660

3761
export default apiLog;

0 commit comments

Comments
 (0)