Commit 971ce0f3 by 李伟康

提交SOP埋点

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