Commit 7944b64d by 杨北旺

修改上报数据结构

1 parent b49d6499
Showing 1 changed file with 20 additions and 16 deletions
......@@ -7,11 +7,11 @@ const defaultData = {
server_url: 'http://tracking-backend.test.glsx.com/track',
send_timeout: 6000,
max_length: 10,
show_log: true,
show_log: false,
switch:true
}
const commonData = {}
function init({ settings, common,getTitle }) {
function init({ settings, common, getTitle }) {
initSetting(settings)
setPublicProperties(common)
util.getTitle = getTitle
......@@ -62,17 +62,19 @@ window.history.replaceState = aop('replaceState'); // 更改路由,不会留
// window.addEventListener('onload',()=>{
// timeStr = new Date().getTime()
// })
window.addEventListener('popstate',()=>{
window.addEventListener('popstate', () => {
let curTime = util.dateFormat(new Date())
let intoTime = getStorageSync('intoTime')
let pageUrl = getStorageSync('pageUrl')
const pageParam = {
pageUrl:window.location.href,
leaveTime:curTime,
pageUrl,
leaveTime: curTime,
intoTime,
pageName:util.getTitle()
pageName: util.getTitle()
}
tracker.track(pageParam,'pv')
tracker.track(pageParam, 'pv')
setStorageSync('intoTime', curTime)
setStorageSync('pageUrl', window.location.href)
})
// window.addEventListener('pushState', function() {
// let t = new Date().getTime() - timeStr
......@@ -171,19 +173,21 @@ const uploadStroageData = (params = {}, option) => {
// eslint-disable-next-line func-names
kit.buildData = function (trackParam) {
const data = {}
const temp = {
event: trackParam.event,
...trackParam.properties
}
console.log(trackParam);
if (trackParam.event == 'pv') {
Object.assign(data,temp)
Object.assign(data, trackParam.properties,{event:'pv'})
} else {
temp.create_time = util.dateFormat(new Date())
temp.pageUrl = window.location.href
data.exta = JSON.stringify(temp)
const obj = {
pageUrl:window.location.href,
intoTime:getStorageSync('intoTime'),
event:trackParam.event,
pageName:trackParam.properties.pageName
}
data.exta = JSON.stringify(trackParam.properties)
Object.assign(data, obj)
}
Object.assign(data, commonData)
return data
return data
}
// 设置公共属性信息
function setPublicProperties(common = {}) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!