Commit b2072824 by Jaxon

修复(埋点上报混入): 完善埋点发送错误处理并统一代码格式

为所有单行if语句补充块级大括号,统一代码书写规范
为埋点数据发送请求添加错误捕获,打印错误日志
1 parent a798793f
......@@ -59,15 +59,19 @@ export default {
eventType,
pagePath: route.path,
};
if (!prePagePath)
if (!prePagePath) {
prePagePath = this.getPrePagePath(this);
}
item.prePagePath = prePagePath || "/index";
if (batchId)
if (batchId) {
item.batchId = batchId;
if (eventCode)
}
if (eventCode) {
item.eventCode = eventCode;
if (businessParam)
}
if (businessParam) {
item.businessParam = JSON.stringify(businessParam);
}
if (!recordList) {
recordList = [item];
} else {
......@@ -79,8 +83,9 @@ export default {
console.log("---------------- 重新打开定时埋点 ----------------");
this.sendTrack(); // 开启定时埋点
}
if (recordList.length > 9)
if (recordList.length > 9) {
this.sendTrackData();
}
},
getRandomString(length = 30) {
const characters
......@@ -94,8 +99,9 @@ export default {
return result;
},
onPageShow() {
if (this.track_page_view_flag)
if (this.track_page_view_flag) {
return;
}
if (!this.track_batchId) {
this.track_batchId = `DJ_${this.getRandomString()}_${Date.now()}`;
}
......@@ -127,8 +133,9 @@ export default {
}, 10e3);
}
let trackParams = {};
if (this.track_businessParam_key)
if (this.track_businessParam_key) {
trackParams = this[this.track_businessParam_key] || {};
}
this.setReportTrackData(
2,
this.track_event_code,
......@@ -166,8 +173,11 @@ export default {
reportTrack({
recordList: JSON.parse(recordList),
}).then((res) => {
if (res)
if (res) {
localStorage.removeItem("recordList");
}
}).catch((e) => {
console.log("发送出错", e);
});
} else {
clearInterval(window.TRACK_TIMER);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!