Commit 971ce0f3 by 李伟康

提交SOP埋点

1 parent 300eb55f
import api from "../request/http"
import {
getScene,
sopTrackPage,
sopTrackPageType
} from '~/utils/constantData'
......@@ -15,56 +16,82 @@ const reportClick = ({
...thisPage.options
}
reportSopCustomer(thisPage, 'PAGE_CLICK')
//
}
const reportStop = ({
thisPage
}) => {
setTimeout(() => {
thisPage.sopTimer = setInterval(() => {
reportSopCustomer(thisPage, 'PAGE_STOP')
}, 3e3)
}
const reportSopCustomer = (thisPage, event_type) => {
const reportHide = ({
thisPage
}) => {
if (thisPage.sopTimer) {
clearInterval(thisPage.sopTimer)
thisPage.sopTimer = null
}
}
const reportSopCustomer = async (thisPage, event_type) => {
const {
options,
route
} = thisPage
if (sopTrackPage.includes(route) && (options.sopId)) {
if (sopTrackPage.includes(route)) {
if (!sopTrackPage.includes(wx.p.router.getPageInstance().route)) return
const userInfo = wx.p.storage.get('userInfo') || {},
pageType = sopTrackPageType[route] || '',
activityId = options.id || '',
merchantId = options.merchantId || '',
unionId = userInfo.unionId || '',
extra = JSON.stringify({
pageType,
activityId,
unionId,
merchantId,
}),
buryingPointList = [{
customer_phone: userInfo.phone || '',
add_way: 'SOP',
// 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
}]
api.post({
method: 'marketing.api.sop.buryingPoint',
projectName: 'material',
buryingPointList
}, true)
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)
}
}
const reportSopFun = async ({
options,
route
}, event_type) => {
if (!options.sopId) return
const userInfo = wx.p.storage.get('userInfo') || {},
pageType = sopTrackPageType[route] || '',
activityId = options.id || '',
merchantId = options.merchantId || '',
unionId = userInfo.unionId || '',
extra = JSON.stringify({
pageType,
activityId,
unionId,
merchantId,
}),
buryingPointList = [{
customer_phone: userInfo.phone || '',
add_way: 'SOP',
sopId: options.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
}]
api.post({
method: 'marketing.api.sop.buryingPoint',
projectName: 'material',
buryingPointList
}, true)
}
module.exports = {
reportSopCustomer,
reportStop,
reportClick
reportClick,
reportHide
}
\ No newline at end of file
......@@ -31,6 +31,9 @@ App({
],
onLoadFun: [
api.sopApi.reportClick
],
onHideFun:[
api.sopApi.reportHide
]
}),
};
......
// export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/'
import getAppId from '~/utils/utils_wx'
import util from '~/utils/util'
import api from "~/api/request/http"
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/'
// 缓存get方法为空的默认指定值
......@@ -56,4 +59,27 @@ export const sopTrackPage = [
]
export const sopTrackPageType = {
'packageMine/pages/questionnaire/questionnaire': 7,
}
\ No newline at end of file
}
/**
* 获取scene参数
*/
export const getScene = scene => {
return new Promise(async (resolve, reject) => {
const qrcodeQuery = decodeURIComponent(scene),
id = qrcodeQuery.split("=").pop(),
res = await api.post({
method: 'scrm.api.wechat.get.scene.by.id',
id
},
true)
let obj = {}
if (res.code == "0") {
let paramsArr = res?.data?.scene?.split("&");
paramsArr.forEach((item) => {
let keyValArr = item?.split('=')
obj[keyValArr[0]] = keyValArr[1]
})
resolve(obj)
} else reject(res.message)
})
};
\ No newline at end of file
......@@ -19,7 +19,8 @@ class TRACK {
_customObject = {}
constructor(options, customObject = {
onLoadFun: [],
onShowFun: []
onShowFun: [],
onHideFun: []
}) {
if (options.scene == 1154 && options.mode == 'singlePage') return //朋友圈单页模式
console.log('---------------- 埋点初始化 ----------------')
......@@ -58,6 +59,9 @@ class TRACK {
// , (_this.getPageInstance().page_show_time = Date.now())
}
thisPage.onHide = function () {
_this.customPageFun({
thisPage: this
}, 'onHideFun')
// let { page_show_time } = _this.getPageInstance()
onHide && onHide.apply(this, arguments)
// ,_this.setTrack(
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!