Explorar o código

后台统计语句出错

Michael Wang %!s(int64=4) %!d(string=hai) anos
pai
achega
6ac1cc373e
Modificáronse 1 ficheiros con 8 adicións e 3 borrados
  1. 8 3
      src/utils/monitors.js

+ 8 - 3
src/utils/monitors.js

@@ -98,7 +98,12 @@ window.addEventListener("unhandledrejection", function (event) {
   // } catch (error) {
   //   return;
   // }
-  console.log("unhandledrejection event", event, event.reason);
+  console.log(
+    "unhandledrejection event",
+    event,
+    event.reason,
+    event.reason && event.reason.message
+  );
   // 会造成死循环,logger.log 在网络异常的情况下,会有unhandledrejection
   // createLog({
   //   action: "unhandledrejection错误",
@@ -115,14 +120,14 @@ window.addEventListener("unhandledrejection", function (event) {
     window._hmt.push([
       "_trackEvent",
       "全局Promise未处理错误",
-      event.reason.replace(/=\w*/g, "=").replace(/\d+/g, "{id}"),
+      event.reason.message.replace(/=\w*/g, "=").replace(/\d+/g, "{id}"),
     ]);
   } else {
     window._hmt.push([
       "_trackEvent",
       "全局Promise未处理错误",
       window.location.pathname.replace(/=\w*/g, "=").replace(/\d+/g, "{id}"),
-      event.reason.replace(/=\w*/g, "=").replace(/\d+/g, "{id}"),
+      event.reason.message.replace(/=\w*/g, "=").replace(/\d+/g, "{id}"),
     ]);
   }
 });