@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.
@@ -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
- observable.log('INFO', safeStringify({
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
- request_body: response.config.data,
216
- response: response.data
217
- }), {}, span);
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
- observable.log('ERROR', safeStringify({
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
- }), {}, span);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.2.1-alpha.14",
3
+ "version": "1.2.1-alpha.15",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [