Commit 9078994e by 李伟康

feat(Track): 优化轨迹记录功能

- 添加重新打开定时埋点逻辑
- 增加无数据时暂停定时埋点的功能
1 parent c7d75452
...@@ -37,6 +37,10 @@ class Track { ...@@ -37,6 +37,10 @@ class Track {
if (data.businessId) item.businessId = data.businessId if (data.businessId) item.businessId = data.businessId
trackList.push(item) trackList.push(item)
uni.setStorageSync('TRACK_LIST', trackList) uni.setStorageSync('TRACK_LIST', trackList)
if (!TRACK_TIME) {
console.log('---------------- 重新打开定时埋点 ----------------')
this.sendTrack() //开启定时埋点
}
if (trackList.length > 9) this.sendTrackData() if (trackList.length > 9) this.sendTrackData()
} }
...@@ -52,8 +56,11 @@ class Track { ...@@ -52,8 +56,11 @@ class Track {
const recordList = uni.getStorageSync('TRACK_LIST') || [] const recordList = uni.getStorageSync('TRACK_LIST') || []
if (recordList.length) { if (recordList.length) {
const res = await uni.$api.commonApi.recordInsert({ recordList }) const res = await uni.$api.commonApi.recordInsert({ recordList })
if (res) if (res) uni.setStorageSync('TRACK_LIST', [])
uni.setStorageSync('TRACK_LIST', []) } else {
clearInterval(TRACK_TIME)
TRACK_TIME = null
console.log('---------------- 暂停定时埋点 ----------------')
} }
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!