Commit a8853fcd by 李伟康

commit 增加埋点

1 parent 8a154c48
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</view> --> </view> -->
<view <view
class="btn" class="btn"
@click="$refs.sceneTypeRef.open()" @click="openScenePopup"
> >
<view class="sprite-icon icon-scene-change"></view> <view class="sprite-icon icon-scene-change"></view>
</view> </view>
...@@ -108,18 +108,21 @@ export default { ...@@ -108,18 +108,21 @@ export default {
{ {
label: "接待中心", label: "接待中心",
icon: "record", icon: "record",
name: 'ReceptionCenter' name: 'ReceptionCenter',
eventCode: 'app_reception_center'
}, },
{ {
label: "学习中心", label: "学习中心",
icon: "study", icon: "study",
isTrack: true, isTrack: true,
name: 'StudyCenter' name: 'StudyCenter',
eventCode: 'app_study_center'
}, },
{ {
label: "场景集市", label: "场景集市",
icon: "scene", icon: "scene",
name: 'SceneMarket' name: 'SceneMarket',
eventCode: 'app_scene_market'
} }
], ],
messageData: { messageData: {
...@@ -253,6 +256,9 @@ export default { ...@@ -253,6 +256,9 @@ export default {
}) })
}, },
async changeIndex (index, item) { async changeIndex (index, item) {
if (item.eventCode) uni.$track.add({
eventCode: item.eventCode
})
// if (this.tabIndex == index) return; // if (this.tabIndex == index) return;
// 点击学习中心要跳从北森回后台配置的学习中心,学习中心为3 // 点击学习中心要跳从北森回后台配置的学习中心,学习中心为3
if (this.tabIndex == index && !item.isTrack) return; if (this.tabIndex == index && !item.isTrack) return;
...@@ -381,6 +387,9 @@ export default { ...@@ -381,6 +387,9 @@ export default {
}, },
jumpPersonCenter () { jumpPersonCenter () {
if (this.hasPerson) { if (this.hasPerson) {
uni.$track.add({
eventCode: 'app_personal_center'
})
this.clickHome() this.clickHome()
this.$emit('update:tabIndex', 99) this.$emit('update:tabIndex', 99)
} }
...@@ -402,6 +411,12 @@ export default { ...@@ -402,6 +411,12 @@ export default {
uni.reLaunch({ uni.reLaunch({
url url
}) })
},
openScenePopup () {
this.$refs.sceneTypeRef.open()
uni.$track.add({
eventCode: 'app_scene_change'
})
} }
}, },
beforeCreate () { beforeCreate () {
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<view :class="['app-content-box right-content',{'show-content-box':tabIndex == 0}]"> <view :class="['app-content-box right-content',{'show-content-box':tabIndex == 0}]">
<view <view
class="start" class="start"
@click="$emit('start')" @click="start"
> >
<view class="sprite-icon icon-start-text"></view> <view class="sprite-icon icon-start-text"></view>
</view> </view>
...@@ -272,7 +272,7 @@ export default { ...@@ -272,7 +272,7 @@ export default {
this.tabIndex = 2 this.tabIndex = 2
return return
} }
this.$emit('start') this.start()
}, },
handleShowPage (name, transfer) { handleShowPage (name, transfer) {
this.transfer = transfer this.transfer = transfer
...@@ -370,12 +370,21 @@ export default { ...@@ -370,12 +370,21 @@ export default {
} }
}, },
swiperClick (e) { swiperClick (e) {
uni.$track.add({
eventCode: 'app_product_Introduction'
})
this.previewOff = true this.previewOff = true
this.$emit('swiperClick', e) this.$emit('swiperClick', e)
}, },
previewHandler (name, off = false) { previewHandler (name, off = false) {
this.previewOff = off this.previewOff = off
this.$emit(name) this.$emit(name)
},
start () {
uni.$track.add({
eventCode: 'app_reception_begins'
})
this.$emit('start')
} }
} }
} }
...@@ -424,7 +433,7 @@ export default { ...@@ -424,7 +433,7 @@ export default {
position: fixed; position: fixed;
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 1; z-index: 2;
top: 0; top: 0;
left: 0; left: 0;
} }
......
...@@ -14,6 +14,8 @@ import utils from './utils/utils' ...@@ -14,6 +14,8 @@ import utils from './utils/utils'
import logger from './utils/logger' import logger from './utils/logger'
import { Storage } from './utils/cache/index' import { Storage } from './utils/cache/index'
import api from './api/index' import api from './api/index'
import Track from './utils/Track'
uni.$api = api uni.$api = api
// uni.$lock = false // uni.$lock = false
uni.$storage = new Storage() uni.$storage = new Storage()
...@@ -23,6 +25,7 @@ uni.$logger = logger ...@@ -23,6 +25,7 @@ uni.$logger = logger
// uni.$recordManager = RecordManager.getInstance() // uni.$recordManager = RecordManager.getInstance()
uni.$dbTempRecord = new DBRecord() uni.$dbTempRecord = new DBRecord()
uni.$dbManager = new DBManager() uni.$dbManager = new DBManager()
uni.$track = new Track()
!(async _ => { !(async _ => {
await uni.$dbManager.init() await uni.$dbManager.init()
await uni.$dbTempRecord.init() await uni.$dbTempRecord.init()
......
const TRACK_INTERVAL_TIME = 30 * 1e3
let TRACK_TIME
import dayjs from 'dayjs'
class Track {
constructor() {
console.log('---------------- 埋点初始化 ----------------')
this.sendTrack()
}
add (data = {}) {
const {
phone: phoneNumber,
name: loginAccount,
uuid,
sceneType: scene,
userType
} = uni.$storage.get('userInfo') || {},
trackList = uni.getStorageSync('TRACK_LIST') || []
let item = {
userType,
loginAccount,
phoneNumber,
uuid,
scene,
prePagePath: '/',
eventTime: dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss'),
systemSource: 3,
eventType: data.eventType || 0
}
if (data.batchId) item.batchId = data.batchId
if (data.eventCode) item.eventCode = data.eventCode
if (data.businessParam) item.businessParam = JSON.stringify(data.businessParam)
if (data.pagePath) item.pagePath = data.pagePath
trackList.push(item)
uni.setStorageSync('TRACK_LIST', trackList)
if (trackList.length > 9) this.sendTrackData()
}
/**定时发送埋点数据 */
sendTrack () {
TRACK_TIME = setInterval(() => {
this.sendTrackData()
}, TRACK_INTERVAL_TIME)
}
async sendTrackData () {
const recordList = uni.getStorageSync('TRACK_LIST') || []
if (recordList.length) {
const res = await uni.$api.commonApi.recordInsert({ recordList })
if (res) uni.setStorageSync('TRACK_LIST', [])
}
}
}
export default Track
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!