Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
scrm-wx-merchant-activity
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 38f03583
authored
Oct 09, 2022
by
luyt
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:添加离开埋点navigator.sendBeacon
1 parent
f9c99e2f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
11 deletions
src/App.vue
src/api/bigdatautilApi.js
src/App.vue
View file @
38f0358
...
...
@@ -49,22 +49,22 @@ export default {
openListener
()
{
this
.
timer
=
setInterval
(()
=>
{
this
.
heartbeat
()
},
60
*
1000
)
},
60
*
1000
)
},
closeListener
()
{
clearInterval
(
this
.
timer
)
},
// 心跳检测
heartbeat
()
{
this
.
trackFn
(
'heartbeat'
,
5
)
this
.
trackFn
(
'heartbeat'
,
5
)
},
//离开事件
leave
()
{
this
.
trackFn
(
'
reportTrack'
,
5
)
this
.
trackFn
(
'
leaveReportTrack'
,
5
)
},
trackFn
(
name
,
actionType
)
{
trackFn
(
name
,
actionType
)
{
const
{
id
}
=
this
.
getQuery
()
bigdatautilApi
[
name
](
id
,
actionType
)
bigdatautilApi
[
name
](
id
,
actionType
)
}
}
}
...
...
src/api/bigdatautilApi.js
View file @
38f0358
...
...
@@ -5,6 +5,8 @@ import dayjs from 'dayjs'
const
commonUrl
=
'/rop-scrm-bigdatautil/router'
// 心跳检测
const
heartbeatUrl
=
'/rop-scrm-shopmall/router'
// 离开埋点url
const
leaveUrl
=
'/rop-scrm-bigdatautil/data/report'
// 第一次进入时间
let
firstEnter
=
true
...
...
@@ -17,9 +19,10 @@ const enter_time = new Date().format('yyyy-MM-dd hh:mm:ss')
* @param {*} share_channel // 分享类型(1:转发,2:朋友圈)
* @param {*} url // 基础路径
* @param {*} method 方法地址
* @param {*} leave 是否离开事件 默认是false
* @returns
*/
const
reportTrack
=
(
id
,
view
=
1
,
share_channel
=
''
,
url
=
commonUrl
,
method
=
'entmicro.api.customercollect.reportCustomerList'
)
=>
{
const
reportTrack
=
(
id
,
view
=
1
,
share_channel
=
''
,
url
=
commonUrl
,
method
=
'entmicro.api.customercollect.reportCustomerList'
,
leave
=
false
)
=>
{
const
userInfo
=
util
.
getUserInfo
()
const
params
=
util
.
getLocalStorage
(
'wx_scrm_link_params'
)
||
{}
const
ISWXWORK
=
util
.
getLocalStorage
(
'is_wxwork'
)
...
...
@@ -63,10 +66,24 @@ const reportTrack = (id, view = 1, share_channel = '', url = commonUrl, method =
jsonList
:
[
JSON
.
stringify
(
data
)]
}
firstEnter
=
false
return
window
.
$HTTP
({
url
,
data
})
// 是否离开事件
if
(
leave
)
{
if
(
navigator
.
sendBeacon
)
{
const
params
=
JSON
.
stringify
(
data
)
return
navigator
.
sendBeacon
(
url
,
params
)
}
else
{
return
window
.
$HTTP
({
url
,
data
})
}
}
else
{
return
window
.
$HTTP
({
url
,
data
})
}
}
// 心跳检测
...
...
@@ -74,7 +91,14 @@ const heartbeat = (id, view = 5, share_channel = '', url = heartbeatUrl, method
reportTrack
(
id
,
view
,
share_channel
,
url
,
method
)
}
//离开事件数据上报
const
leaveReportTrack
=
(
id
,
view
=
5
)
=>
{
// console.log('离开事件数据上报')
reportTrack
(
id
,
view
,
''
,
leaveUrl
,
''
,
true
)
}
export
default
{
reportTrack
,
heartbeat
heartbeat
,
leaveReportTrack
}
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