Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
mini-program
/
zhwy
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 ffc88c09
authored
Jan 10, 2024
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
更新SOP埋点
1 parent
a42340c0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
47 deletions
api/env/index.js
api/module/sopApi.js
app.js
utils/track/Track.js
api/env/index.js
View file @
ffc88c0
import
{
preReleaseAppId
}
from
'~/config'
const
target
=
[
'ip'
,
'dev'
,
'uat'
,
'prod'
,
'preRelease'
]
let
index
=
1
let
index
=
2
/**
*
...
...
api/module/sopApi.js
View file @
ffc88c0
...
...
@@ -7,6 +7,7 @@ import {
/**
* sop客户埋点上报
*/
const
getDuration
=
page_show_time
=>
(
Date
.
now
()
-
page_show_time
)
/
1
e3
const
reportClick
=
({
thisPage
,
options
...
...
@@ -17,20 +18,10 @@ const reportClick = ({
}
reportSopCustomer
(
thisPage
,
'PAGE_CLICK'
)
}
const
reportStop
=
({
thisPage
})
=>
{
thisPage
.
sopTimer
=
setInterval
(()
=>
{
reportSopCustomer
(
thisPage
,
'PAGE_STOP'
)
},
3
e3
)
}
const
reportHide
=
({
thisPage
})
=>
{
if
(
thisPage
.
sopTimer
)
{
clearInterval
(
thisPage
.
sopTimer
)
thisPage
.
sopTimer
=
null
}
reportSopCustomer
(
thisPage
,
'PAGE_STOP'
)
}
const
reportSopCustomer
=
async
(
thisPage
,
event_type
)
=>
{
const
{
...
...
@@ -42,20 +33,15 @@ const reportSopCustomer = async (thisPage, event_type) => {
if
(
options
&&
options
.
scene
)
{
const
data
=
await
getScene
(
options
.
scene
)
thisPage
.
options
=
data
reportSopFun
({
options
:
data
,
route
},
event_type
)
}
else
reportSopFun
({
options
,
route
},
event_type
)
reportSopFun
(
thisPage
,
event_type
)
}
else
reportSopFun
(
thisPage
,
event_type
)
}
}
const
reportSopFun
=
async
({
options
,
route
},
event_type
)
=>
{
const
reportSopFun
=
async
(
thisPage
,
event_type
)
=>
{
const
{
options
,
route
}
=
thisPage
if
(
!
options
.
sopId
)
return
const
userInfo
=
wx
.
p
.
storage
.
get
(
'userInfo'
)
||
{},
pageType
=
sopTrackPageType
[
route
]
||
''
,
...
...
@@ -63,28 +49,29 @@ const reportSopFun = async ({
merchantId
=
options
.
merchantId
||
''
,
unionId
=
userInfo
.
unionId
||
''
,
sopId
=
options
.
sopId
||
''
,
extra
=
JSON
.
stringify
(
{
extra
=
{
pageType
,
activityId
,
unionId
,
merchantId
,
sopId
}),
buryingPointList
=
[{
customer_phone
:
userInfo
.
phone
||
''
,
add_way
:
'SOP'
,
sopId
,
// id_number: '',
// org_user_id: '',
// wechat_id: '',
wechat_union_id
:
unionId
,
org_id
:
merchantId
,
system_source
:
'scrm'
,
platform
:
'MimiProgram'
,
event_type
,
event_time
:
new
Date
().
format
(
'yyyy-MM-dd hh:mm:ss'
),
extra
}]
}
if
(
event_type
==
'PAGE_STOP'
)
extra
.
time
=
getDuration
(
thisPage
.
page_show_time
)
const
buryingPointList
=
[{
customer_phone
:
userInfo
.
phone
||
''
,
add_way
:
'SOP'
,
sopId
,
// id_number: '',
// org_user_id: '',
// wechat_id: '',
wechat_union_id
:
unionId
,
org_id
:
merchantId
,
system_source
:
'scrm'
,
platform
:
'MimiProgram'
,
event_type
,
event_time
:
new
Date
().
format
(
'yyyy-MM-dd hh:mm:ss'
),
extra
:
JSON
.
stringify
(
extra
)
}]
api
.
post
({
method
:
'marketing.api.sop.buryingPoint'
,
projectName
:
'material'
,
...
...
@@ -93,7 +80,6 @@ const reportSopFun = async ({
}
module
.
exports
=
{
reportSopCustomer
,
reportStop
,
reportClick
,
reportHide
}
\ No newline at end of file
app.js
View file @
ffc88c0
...
...
@@ -26,9 +26,6 @@ App({
router
,
storage
:
new
utils
.
cache
.
Storage
(),
$Track
:
new
TRACK
(
options
,
{
onShowFun
:
[
api
.
sopApi
.
reportStop
],
onLoadFun
:
[
api
.
sopApi
.
reportClick
],
...
...
utils/track/Track.js
View file @
ffc88c0
...
...
@@ -56,7 +56,7 @@ class TRACK {
thisPage
:
this
},
'onShowFun'
)
onShow
&&
onShow
.
apply
(
this
,
arguments
)
//
, (_this.getPageInstance().page_show_time = Date.now())
,
(
_this
.
getPageInstance
().
page_show_time
=
Date
.
now
())
}
thisPage
.
onHide
=
function
()
{
_this
.
customPageFun
({
...
...
@@ -72,6 +72,9 @@ class TRACK {
// )
}
thisPage
.
onUnload
=
function
()
{
_this
.
customPageFun
({
thisPage
:
this
},
'onHideFun'
)
// let { page_show_time } = _this.getPageInstance()
onUnload
&&
onUnload
.
apply
(
this
,
arguments
)
// ,_this.setTrack(
...
...
@@ -228,7 +231,7 @@ class TRACK {
/**在全局埋点onShow增加自定义埋点事件 */
customPageFun
(
options
,
name
)
{
this
.
_customObject
[
name
].
map
(
e
=>
{
this
.
_customObject
[
name
]
?
.
map
(
e
=>
{
e
&&
e
(
options
)
})
}
...
...
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