|
@@ -1,4 +1,5 @@
|
|
|
import Vue from "vue";
|
|
|
+import { createLog } from "@/utils/logger";
|
|
|
|
|
|
Vue.config.errorHandler = error => {
|
|
|
// Vue.prototype.$httpNoAuth.post(
|
|
@@ -11,6 +12,14 @@ Vue.config.errorHandler = error => {
|
|
|
// }
|
|
|
// );
|
|
|
window._hmt.push(["_trackEvent", "Vue组件错误"]);
|
|
|
+ createLog({
|
|
|
+ action: "Vue组件错误",
|
|
|
+ message: error.message,
|
|
|
+ stack: error.stack,
|
|
|
+ error: JSON.stringify(error, (key, value) =>
|
|
|
+ key === "token" ? "" : value
|
|
|
+ ),
|
|
|
+ });
|
|
|
throw error;
|
|
|
};
|
|
|
|
|
@@ -44,6 +53,15 @@ window.addEventListener("error", function(event) {
|
|
|
event.message,
|
|
|
event.error.stack.replace(/\n/g, "||||"),
|
|
|
]);
|
|
|
+ createLog({
|
|
|
+ action: "全局JS错误",
|
|
|
+ page: window.location.pathname,
|
|
|
+ message: event.message,
|
|
|
+ stack: event.error.stack,
|
|
|
+ error: JSON.stringify(event.error, (key, value) =>
|
|
|
+ key === "token" ? "" : value
|
|
|
+ ),
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
window.addEventListener("unhandledrejection", function(event) {
|
|
@@ -64,6 +82,12 @@ window.addEventListener("unhandledrejection", function(event) {
|
|
|
// }
|
|
|
// }
|
|
|
// );
|
|
|
+ createLog({
|
|
|
+ action: "unhandledrejection错误",
|
|
|
+ page: window.location.pathname,
|
|
|
+ reason: event.reason,
|
|
|
+ message: event.reason ? event.reason.message : "",
|
|
|
+ });
|
|
|
if (
|
|
|
event.reason &&
|
|
|
event.reason.message &&
|