Commit ffc88c09 by 李伟康

更新SOP埋点

1 parent a42340c0
import { preReleaseAppId } from '~/config'
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease']
let index = 1
let index = 2
/**
*
......
......@@ -7,6 +7,7 @@ import {
/**
* sop客户埋点上报
*/
const getDuration = page_show_time => (Date.now() - page_show_time) / 1e3
const reportClick = ({
thisPage,
options
......@@ -17,20 +18,10 @@ const reportClick = ({
}
reportSopCustomer(thisPage, 'PAGE_CLICK')
}
const reportStop = ({
thisPage
}) => {
thisPage.sopTimer = setInterval(() => {
reportSopCustomer(thisPage, 'PAGE_STOP')
}, 3e3)
}
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
......@@ -26,9 +26,6 @@ App({
router,
storage: new utils.cache.Storage(),
$Track: new TRACK(options, {
onShowFun: [
api.sopApi.reportStop
],
onLoadFun: [
api.sopApi.reportClick
],
......
......@@ -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)
})
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!