Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
npm
/
gltracker
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7944b64d
authored
Jul 08, 2022
by
杨北旺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改上报数据结构
1 parent
b49d6499
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
src/main.js
src/main.js
View file @
7944b64
...
...
@@ -7,11 +7,11 @@ const defaultData = {
server_url
:
'http://tracking-backend.test.glsx.com/track'
,
send_timeout
:
6000
,
max_length
:
10
,
show_log
:
tru
e
,
show_log
:
fals
e
,
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
=
{})
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment