@lark-apaas/client-toolkit 1.2.1-alpha.14 → 1.2.1-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/utils/axiosConfig.js +15 -13
- package/package.json +1 -1
package/lib/utils/axiosConfig.js
CHANGED
|
@@ -205,16 +205,17 @@ function initAxiosConfig(axiosInstance) {
|
|
|
205
205
|
const method = (response.config.method || 'GET').toUpperCase();
|
|
206
206
|
const cleanedPath = url.split('?')[0].replace(/^\/spark\/p\/app_\w+/, '') || '/';
|
|
207
207
|
if (span) {
|
|
208
|
-
|
|
208
|
+
const logData = {
|
|
209
209
|
method,
|
|
210
210
|
path: cleanedPath,
|
|
211
|
-
url,
|
|
212
|
-
user_agent: response.config.headers["user-agent"],
|
|
211
|
+
url: response.request?.responseURL || url || "",
|
|
213
212
|
duration_ms: startTime ? Date.now() - startTime : void 0,
|
|
214
|
-
status: response.status
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
213
|
+
status: response.status
|
|
214
|
+
};
|
|
215
|
+
if ('undefined' != typeof navigator) logData.user_agent = navigator.userAgent;
|
|
216
|
+
if (response.config.data) logData.request_body = response.config.data;
|
|
217
|
+
if (response.data) logData.response = response.data || {};
|
|
218
|
+
observable.log('INFO', safeStringify(logData), {}, span);
|
|
218
219
|
'function' == typeof span.end && span.end();
|
|
219
220
|
}
|
|
220
221
|
return response;
|
|
@@ -224,17 +225,18 @@ function initAxiosConfig(axiosInstance) {
|
|
|
224
225
|
const method = (errorConfig.method || 'GET').toUpperCase();
|
|
225
226
|
const cleanedPath = url.split('?')[0].replace(/^\/spark\/p\/app_\w+/, '') || '/';
|
|
226
227
|
if (span) {
|
|
227
|
-
|
|
228
|
+
const logData = {
|
|
228
229
|
method,
|
|
229
230
|
path: cleanedPath,
|
|
230
|
-
url,
|
|
231
|
-
user_agent: errorConfig.headers?.["user-agent"],
|
|
231
|
+
url: errorResponse.request?.responseURL || errorConfig.url || "",
|
|
232
232
|
duration_ms: startTime ? Date.now() - startTime : void 0,
|
|
233
233
|
status: errorResponse.status || 200,
|
|
234
|
-
request_body: errorConfig.data,
|
|
235
|
-
response: errorResponse.data || {},
|
|
236
234
|
error_message: errorMessage
|
|
237
|
-
}
|
|
235
|
+
};
|
|
236
|
+
if ('undefined' != typeof navigator) logData.user_agent = navigator.userAgent;
|
|
237
|
+
if (errorConfig.data) logData.request_body = errorConfig.data;
|
|
238
|
+
if (errorResponse.data) logData.response = errorResponse.data || {};
|
|
239
|
+
observable.log('ERROR', safeStringify(logData), {}, span);
|
|
238
240
|
'function' == typeof span.end && span.end();
|
|
239
241
|
}
|
|
240
242
|
return Promise.reject(error);
|