This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-client-js.git


The following commit(s) were added to refs/heads/master by this push:
     new 239f4b2  fix: update stack and message in logs (#40)
239f4b2 is described below

commit 239f4b2020aaa8c0f582ea486c74e25dff4b66d9
Author: Qiuxia Fan <[email protected]>
AuthorDate: Fri Jan 15 10:00:12 2021 +0800

    fix: update stack and message in logs (#40)
---
 README.md               | 2 +-
 src/errors/ajax.ts      | 1 +
 src/errors/js.ts        | 1 +
 src/errors/promise.ts   | 5 +++--
 src/errors/resource.ts  | 3 ++-
 src/errors/vue.ts       | 3 ++-
 src/services/base.ts    | 6 ++----
 src/services/types.d.ts | 2 +-
 8 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index de84178..4a3afde 100644
--- a/README.md
+++ b/README.md
@@ -51,7 +51,7 @@ The register method supports the following parameters.
 |useFmp|Boolean|Collect FMP (first meaningful paint) data of the first 
screen|false|false|
 |enableSPA|Boolean|Monitor the page hashchange event and report PV, which is 
suitable for single page application scenarios|false|false|
 |autoTracePerf|Boolean|Support sending of performance data 
automatically.|false|true|
-|vue|Boolean|Support vue errors monitoring|false|undefined|
+|vue|Vue|Support vue errors monitoring|false|undefined|
 |traceSDKInternal|Boolean|Support tracing SDK internal RPC.|false|false|
 |detailMode|Boolean|Support tracing http method and url as tags in 
spans.|false|true|
 
diff --git a/src/errors/ajax.ts b/src/errors/ajax.ts
index d5b7f72..1a4879a 100644
--- a/src/errors/ajax.ts
+++ b/src/errors/ajax.ts
@@ -39,6 +39,7 @@ class AjaxErrors extends Base {
             errorUrl: event.target.responseURL,
             message: event.target.response,
             collector: options.collector,
+            stack: event.type + ':' + event.target.response,
           };
           this.traceInfo();
         }
diff --git a/src/errors/js.ts b/src/errors/js.ts
index 7adc112..dd8a726 100644
--- a/src/errors/js.ts
+++ b/src/errors/js.ts
@@ -33,6 +33,7 @@ class JSErrors extends Base {
         col,
         message,
         collector: options.collector,
+        stack: error.stack,
       };
       this.traceInfo();
     };
diff --git a/src/errors/promise.ts b/src/errors/promise.ts
index 7fa05be..fd46b70 100644
--- a/src/errors/promise.ts
+++ b/src/errors/promise.ts
@@ -37,8 +37,9 @@ class PromiseErrors extends Base {
           pagePath: options.pagePath,
           category: ErrorsCategory.PROMISE_ERROR,
           grade: GradeTypeEnum.ERROR,
-          errorUrl: url,
-          message: event.reason,
+          errorUrl: url || location.href,
+          message: event.reason.message,
+          stack: event.reason.stack,
           collector: options.collector,
         };
         this.traceInfo();
diff --git a/src/errors/resource.ts b/src/errors/resource.ts
index 2fcf651..0cfbe50 100644
--- a/src/errors/resource.ts
+++ b/src/errors/resource.ts
@@ -43,9 +43,10 @@ class ResourceErrors extends Base {
           pagePath: options.pagePath,
           category: ErrorsCategory.RESOURCE_ERROR,
           grade: target.tagName === 'IMG' ? GradeTypeEnum.WARNING : 
GradeTypeEnum.ERROR,
-          errorUrl: target.src || target.href,
+          errorUrl: target.src || target.href || location.href,
           message: `load ${target.tagName} resource error`,
           collector: options.collector,
+          stack: `load ${target.tagName} resource error`,
         };
         this.traceInfo();
       } catch (error) {
diff --git a/src/errors/vue.ts b/src/errors/vue.ts
index 04d16c3..a1de936 100644
--- a/src/errors/vue.ts
+++ b/src/errors/vue.ts
@@ -33,9 +33,10 @@ class VueErrors extends Base {
           pagePath: options.pagePath,
           category: ErrorsCategory.VUE_ERROR,
           grade: GradeTypeEnum.ERROR,
-          errorUrl: '',
+          errorUrl: location.href,
           message: info,
           collector: options.collector,
+          stack: error.stack,
         };
         this.traceInfo();
       } catch (error) {
diff --git a/src/services/base.ts b/src/services/base.ts
index b52737e..bd4a508 100644
--- a/src/services/base.ts
+++ b/src/services/base.ts
@@ -63,15 +63,13 @@ export default class Base {
   private handleErrorInfo() {
     let message = `error category:${this.logInfo.category}\r\n log 
info:${this.logInfo.message}\r\n
       error url: ${this.logInfo.errorUrl}\r\n `;
+
     switch (this.logInfo.category) {
       case ErrorsCategory.JS_ERROR:
         message += `error line number: ${this.logInfo.line}\r\n error col 
number:${this.logInfo.col}\r\n`;
-        if (this.logInfo.errorInfo && this.logInfo.errorInfo.stack) {
-          message += `error stack: ${this.logInfo.errorInfo.stack}\r\n`;
-        }
         break;
       default:
-        message += `other error: ${this.logInfo.errorInfo}\r\n`;
+        message;
         break;
     }
     const recordInfo = {
diff --git a/src/services/types.d.ts b/src/services/types.d.ts
index 0460489..1b214a8 100644
--- a/src/services/types.d.ts
+++ b/src/services/types.d.ts
@@ -23,7 +23,7 @@ export interface ErrorInfoFeilds {
   errorUrl: string;
   line?: number;
   col?: number;
-  errorInfo?: any;
+  stack?: string;
   firstReportedError?: boolean;
 }
 

Reply via email to