Commit 7944b64d by 杨北旺

修改上报数据结构

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