Bläddra i källkod

强化百度统计日志

Michael Wang 6 år sedan
förälder
incheckning
e7c64681f7

+ 24 - 0
src/components/FaceRecognition/FaceRecognition.vue

@@ -98,13 +98,31 @@ export default {
             }
           } else {
             this.$Message.error("没有可用的视频流");
+            window._hmt.push([
+              "_trackEvent",
+              "摄像头框",
+              "摄像头状态",
+              "没有可用的视频流"
+            ]);
           }
         } catch (error) {
           console.log(error);
           this.$Message.error("无法启用摄像头");
+          window._hmt.push([
+            "_trackEvent",
+            "摄像头框",
+            "摄像头状态",
+            "无法启用摄像头"
+          ]);
         }
       } else {
         this.$Message.error("没有找到可用的摄像头");
+        window._hmt.push([
+          "_trackEvent",
+          "摄像头框",
+          "摄像头状态",
+          "没有找到可用的摄像头"
+        ]);
       }
     },
     async snapTimer() {
@@ -175,6 +193,12 @@ export default {
         const video = this.$refs.video;
         if (video.readyState !== 4 || !video.srcObject.active) {
           this.$Message.error({ content: "摄像头没有正常启用", duration: 5 });
+          window._hmt.push([
+            "_trackEvent",
+            "摄像头框",
+            "摄像头状态",
+            "摄像头没有正常启用-退出"
+          ]);
           reject("摄像头没有正常启用");
           this.logout();
           return;

+ 3 - 0
src/features/Login/Login.vue

@@ -256,6 +256,7 @@ export default {
         Math.abs(moment(response.headers.date).diff(moment())) >
         5 * 60 * 1000
       ) {
+        window._hmt.push(["_trackEvent", "登录页面", "本机时间误差过大"]);
         this.$Message.error({
           content: "与服务器时间差异超过5分钟,请校准本机时间之后再重试!",
           duration: 30
@@ -277,6 +278,7 @@ export default {
           this.updateUser(user);
           window.localStorage.setItem("user-for-reload", JSON.stringify(user));
           await this.checkExamInProgress();
+          window._hmt.push(["_trackEvent", "登录页面", "登录成功"]);
         } catch (error) {
           this.$Message.error({
             content: "获取学生信息失败,请重试!",
@@ -299,6 +301,7 @@ export default {
               return <div style="font-size: 24px">正在进入断点续考...</div>;
             }
           });
+          window._hmt.push(["_trackEvent", "登录页面", "断点续考", "重新登录"]);
           this.$router.push(
             `/online-exam/exam/${examingRes.examId}/examRecordData/${
               examingRes.examRecordDataId

+ 1 - 0
src/features/OfflineExam/OfflineExamHome.vue

@@ -27,6 +27,7 @@ export default {
   },
   async mounted() {
     try {
+      window._hmt.push(["_trackEvent", "离线考试页面", "进入列表", ""]);
       await this.fetchData();
     } catch (error) {
       this.$Message.error("获取离线考试列表失败");

+ 13 - 0
src/features/OfflineExam/OfflineExamList.vue

@@ -117,6 +117,12 @@ export default {
       this.$emit("reloadList");
     },
     previewPaper(course) {
+      window._hmt.push([
+        "_trackEvent",
+        "离线考试页面",
+        "预览",
+        course.courseName
+      ]);
       var user = {
         loginName: course.examStudentId,
         backUrl: window.document.location.href,
@@ -130,9 +136,16 @@ export default {
         "?isback=true";
     },
     downloadOfflineFile(url) {
+      window._hmt.push(["_trackEvent", "离线考试页面", "下载作答", url]);
       window.location.href = url;
     },
     tempDisableBtn(course) {
+      window._hmt.push([
+        "_trackEvent",
+        "离线考试页面",
+        "下载试卷",
+        course.courseName
+      ]);
       this.disableDownloadPaperBtn = true;
       setTimeout(() => (this.disableDownloadPaperBtn = false), 10 * 1000);
 

+ 8 - 0
src/features/OfflineExam/OfflineExamUpload.vue

@@ -89,6 +89,12 @@ export default {
             resolve();
           } else {
             console.log("binary file type check: not zip or pdf");
+            window._hmt.push([
+              "_trackEvent",
+              "离线考试页面",
+              "上传作答",
+              "文件格式非zip或pdf"
+            ]);
             this.$Notice.warning({
               title: "作答文件损坏",
               desc: file.name + " 文件无法以 .zip 或 .pdf 读取。"
@@ -103,12 +109,14 @@ export default {
       filereader.readAsArrayBuffer(blob);
     },
     handleSuccess() {
+      window._hmt.push(["_trackEvent", "离线考试页面", "上传作答", "上传成功"]);
       this.file = null;
       this.loadingStatus = false;
       this.$Message.success("上传成功");
       this.$emit("reloadList");
     },
     handleError() {
+      window._hmt.push(["_trackEvent", "离线考试页面", "上传作答", "上传失败"]);
       this.file = null;
       this.loadingStatus = false;
       this.$Message.error("上传失败");

+ 10 - 0
src/features/OnlineExam/Examing/ExamingEnd.vue

@@ -89,8 +89,10 @@ export default {
     };
   },
   async mounted() {
+    window._hmt.push(["_trackEvent", "考试结束页面", "进入页面"]);
     const examRecordDataId = this.$route.params.examRecordDataId;
     const examId = this.$route.params.examId;
+    this.waitingNumber = 0;
     const f = async () => {
       try {
         this.getResultTimes = this.getResultTimes + 1;
@@ -100,11 +102,19 @@ export default {
         )).data;
 
         if (examResult === undefined || examResult === null) {
+          this.waitingNumber++;
           setTimeout(() => f(), 3000);
           return;
         }
+        window._hmt.push([
+          "_trackEvent",
+          "考试结束页面",
+          "等待分数",
+          "等待次数=" + this.waitingNumber
+        ]);
         this.examResult = examResult;
       } catch (error) {
+        this.waitingNumber++;
         setTimeout(() => f(), 3000);
       }
     };

+ 3 - 0
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -179,6 +179,8 @@ export default {
     // iview bug: https://github.com/iview/iview/issues/4061
     // document.body.style = "";
 
+    window._hmt.push(["_trackEvent", "正在考试页面", "进入页面"]);
+
     if (typeof nodeRequire != "undefined") {
       try {
         var fs = window.nodeRequire("fs");
@@ -200,6 +202,7 @@ export default {
     }
   },
   beforeRouteUpdate(from, to, next) {
+    window._hmt.push(["_trackEvent", "正在考试页面", "题目切换"]);
     if (process.env.NODE_ENV === "development") {
       console.log("beforeRouteUpdate from: " + this.$route.fullPath);
     }

+ 18 - 0
src/features/OnlineExam/OnlineExamFaceCheckModal.vue

@@ -117,6 +117,12 @@ export default {
 
       if (!pass) {
         this.$Message.error("人脸比对失败");
+        window._hmt.push([
+          "_trackEvent",
+          "在线考试列表页面",
+          "人脸比对框",
+          "比对失败"
+        ]);
         if (!this.course.faceCheck) {
           this.toggleFaceCheckModal(false);
           this.$Modal.confirm({
@@ -134,6 +140,18 @@ export default {
         return;
       }
       this.$Message.success("人脸比对成功");
+      window._hmt.push([
+        "_trackEvent",
+        "在线考试列表页面",
+        "人脸比对框",
+        "比对成功"
+      ]);
+      window._hmt.push([
+        "_trackEvent",
+        "在线考试列表页面",
+        "进入考试",
+        "人脸检测成功"
+      ]);
       this.toggleFaceCheckModal(false);
       this.$router.push(
         `/online-exam/exam/${this.course.examId}/overview?examStudentId=${

+ 1 - 0
src/features/OnlineExam/OnlineExamHome.vue

@@ -26,6 +26,7 @@ export default {
     };
   },
   async mounted() {
+    window._hmt.push(["_trackEvent", "在线考试列表页面", "进入页面"]);
     const res = await this.$http.get(
       "/api/ecs_oe_student/examControl/queryExamList"
     );

+ 20 - 0
src/features/OnlineExam/OnlineExamList.vue

@@ -108,6 +108,12 @@ export default {
           "/api/ecs_oe_student/examControl/checkExamInProgress"
         )).data;
         if (examingRes) {
+          window._hmt.push([
+            "_trackEvent",
+            "在线考试列表页面",
+            "断点续考",
+            "概览页返回"
+          ]);
           this.$Spin.show({
             render: () => {
               return <div style="font-size: 24px">正在进入断点续考...</div>;
@@ -141,6 +147,7 @@ export default {
         )).data;
         // sleep function: await new Promise(resolve => setTimeout(() => resolve(), 3000));
         if (ipLimit.limited) {
+          window._hmt.push(["_trackEvent", "在线考试列表页面", "IP受限"]);
           this.spinShow = false;
           this.$Message.error("IP受限,请到中心指定地点进行考试!");
           return;
@@ -155,6 +162,7 @@ export default {
         // if 人脸检测 && 没有底照,提示,并返回
         if (!this.user.photoPath) {
           this.spinShow = false;
+          window._hmt.push(["_trackEvent", "在线考试列表页面", "无底照"]);
           this.$Message.info(
             "本场考试需要进行人脸检测,但是您没有上传底照,请联系老师!"
           );
@@ -201,9 +209,21 @@ export default {
         // if 人脸识别失败 && 考试未开启强制人脸识别
         //    让学生手动确认进入考试,若取消,则返回
         this.selectedCourse = course;
+        window._hmt.push([
+          "_trackEvent",
+          "在线考试列表页面",
+          "人脸识别框",
+          "弹出框"
+        ]);
         this.toggleFaceCheckModal(true);
       } else {
         this.spinShow = false;
+        window._hmt.push([
+          "_trackEvent",
+          "在线考试列表页面",
+          "进入考试",
+          "无人脸检测"
+        ]);
         this.$router.push(
           `/online-exam/exam/${course.examId}/overview?examStudentId=${
             course.examStudentId

+ 1 - 0
src/features/OnlineExam/OnlineExamOverview.vue

@@ -73,6 +73,7 @@ export default {
     };
   },
   async mounted() {
+    window._hmt.push(["_trackEvent", "在线考试概览页面", "进入页面"]);
     this.intervalId = setInterval(() => {
       this.remainTime -= 1;
       this.isForceRead = TOTAL_READ_TIME - this.remainTime < FORCE_READ_TIME;

+ 1 - 0
src/features/OnlinePractice/OnlinePracticeHome.vue

@@ -47,6 +47,7 @@ export default {
     };
   },
   async mounted() {
+    window._hmt.push(["_trackEvent", "在线练习列表页面", "进入页面"]);
     if (this.$route.query.examId) {
       this.examId = this.$route.query.examId - 0;
       try {

+ 1 - 0
src/features/OnlinePractice/OnlinePracticeList.vue

@@ -108,6 +108,7 @@ export default {
       const alreadyInExam = await this.checkExamInProgress();
       if (alreadyInExam) return;
 
+      window._hmt.push(["_trackEvent", "在线练习页面", "进入练习"]);
       this.$router.push(
         `/online-exam/exam/${course.examId}/overview?examStudentId=${
           course.examStudentId

+ 1 - 0
src/features/Password/Password.vue

@@ -155,6 +155,7 @@ export default {
         );
         if (res.status == 200) {
           this.$Message.success("保存成功");
+          window._hmt.push(["_trackEvent", "修改密码页面", "修改成功"]);
         }
       } catch (e) {
         this.$Message.error("保存失败");

+ 1 - 0
src/main.js

@@ -11,6 +11,7 @@ import "./plugins/tracking.js";
 import "./plugins/face.js";
 
 import axiosPlugin from "./utils/axios";
+import "./utils/monitors";
 
 import MainLayout from "@/components/MainLayout/MainLayout.vue";
 

+ 64 - 0
src/utils/monitors.js

@@ -0,0 +1,64 @@
+import Vue from "vue";
+
+Vue.config.errorHandler = error => {
+  window._hmt.push(["_trackEvent", "Vue组件错误", error.stack]);
+  throw error;
+};
+
+// window.onerror = function(message, source, lineno, colno, error) {
+//   console.log(message);
+//   window._hmt.push([
+//     "_trackEvent",
+//     "全局JS错误",
+//     message,
+//     `source: ${source}\nlineno: ${lineno}\ncolno: ${colno}\nerror: ${
+//       error.stack
+//     }`
+//   ]);
+// };
+
+window.addEventListener("error", function(event) {
+  window._hmt.push([
+    "_trackEvent",
+    "全局JS错误",
+    event.message,
+    `source: ${event.filename}\nlineno: ${event.lineno}\ncolno: ${
+      event.colno
+    }\nerror: ${event.error.stack}`
+  ]);
+});
+
+window.addEventListener("unhandledrejection", function(event) {
+  let detail = "";
+  if (event.reason.config) {
+    detail += "url:" + event.reason.config.url + "\n";
+    detail += "data: " + event.reason.config.data + "\n";
+    if (event.reason.request && event.reason.request.response) {
+      detail += "response: " + event.reason.request.response + "\n";
+    }
+  }
+  window._hmt.push([
+    "_trackEvent",
+    "全局Promise未处理错误",
+    event.reason,
+    detail
+  ]);
+});
+
+window.addEventListener("rejectionhandled", function(event) {
+  console.log("rejectionhandled"); // 似乎并不触发
+  let detail = "";
+  if (event.reason.config) {
+    detail += "url:" + event.reason.config.url + "\n";
+    detail += "data: " + event.reason.config.data + "\n";
+    if (event.reason.request && event.reason.request.response) {
+      detail += "response: " + event.reason.request.response + "\n";
+    }
+  }
+  window._hmt.push([
+    "_trackEvent",
+    "全局Promise已处理错误",
+    event.reason,
+    detail
+  ]);
+});