Commit 712580c6 by 李伟康

SOP埋点需求

1 parent 3860d1f0
import { preReleaseAppId } from '~/config'
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease']
let index = 3
let index = 1
/**
*
......
......@@ -12,6 +12,7 @@ import entmicroApi from './entmicro'
import strategyApi from './strategy'
import questionnaireApi from './questionnaire'
import rescueApi from './rescueApi'
import sopApi from './sopApi'
module.exports = {
wechatApi,
......@@ -27,5 +28,6 @@ module.exports = {
entmicroApi,
strategyApi,
questionnaireApi,
rescueApi
rescueApi,
sopApi
}
\ No newline at end of file
import api from "../request/http"
import {
sopTrackPage,
sopTrackPageType
} from '~/utils/constantData'
/**
* sop客户埋点上报
*/
const reportClick = ({
thisPage,
options
}) => {
thisPage.options = {
...options,
...thisPage.options
}
reportSopCustomer(thisPage, 'PAGE_CLICK')
//
}
const reportStop = ({
thisPage
}) => {
setTimeout(() => {
reportSopCustomer(thisPage, 'PAGE_STOP')
}, 3e3)
}
const reportSopCustomer = (thisPage, event_type) => {
const {
options,
route
} = thisPage
if (sopTrackPage.includes(route) && (options.sopId)) {
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)
}
}
module.exports = {
reportSopCustomer,
reportStop,
reportClick
}
\ No newline at end of file
......@@ -3,9 +3,13 @@
import sentryInit from "~/utils/sentryConfig/sentryInit";
sentryInit();
import api from "./api/index";
import { router } from "./router/index";
import {
router
} from "./router/index";
// 判断小程序是否需要更新
import { getUpdateManager } from "./lib/index";
import {
getUpdateManager
} from "./lib/index";
import utils from "./utils/index";
// 埋点 有需要再引入
import TRACK from './utils/track/Track'
......@@ -21,9 +25,15 @@ App({
api,
router,
storage: new utils.cache.Storage(),
$Track: new TRACK(options),
$Track: new TRACK(options, {
onShowFun: [
api.sopApi.reportStop
],
onLoadFun: [
api.sopApi.reportClick
]
}),
};
console.log(wx.p);
// 存储设备信息
utils.cache.storageApi.setSystem_info();
},
......@@ -35,11 +45,11 @@ App({
globalData: {
ROUTE_QUERY: {},
goodsPageParam: {
appearance: 1,
pageSize: 0,
pageCount: 3
appearance: 1,
pageSize: 0,
pageCount: 3
},
goodsLoaded: false,
goodsCommodityList: []
},
});
});
\ No newline at end of file
......@@ -49,4 +49,11 @@ export const STORAGE_OBJECTkEY = {
export const IMG_VERSION = async () => {
const accountInfo = await util.getMockData()
return accountInfo?.version || Date.now()
}
export const sopTrackPage = [
'packageMine/pages/questionnaire/questionnaire'
]
export const sopTrackPageType = {
'packageMine/pages/questionnaire/questionnaire': 7,
}
\ No newline at end of file
......@@ -3,7 +3,9 @@
*/
import mapApi from '../mapapi/mapapi'
import api from '~/api/request/http'
import { getUserInfo } from '~/utils/cache/userInfo'
import {
getUserInfo
} from '~/utils/cache/userInfo'
// 实例化对象存储
// import { Storage } from '~/utils/cache/storage'
import Storage from '~/utils/cache/storage'
......@@ -14,12 +16,18 @@ let TRACK_TIME = null,
const track_interval_time = 60 * 1e3
class TRACK {
constructor() {
_customObject = {}
constructor(options, customObject = {
onLoadFun: [],
onShowFun: []
}) {
if (options.scene == 1154 && options.mode == 'singlePage') return //朋友圈单页模式
console.log('---------------- 埋点初始化 ----------------')
this.initPageProxy()
// this.sendTrack()
//this.getAddressInfo().then(res => (ADDRESS_INFO = res))
// this.appHide()
this._customObject = customObject
}
/**监听页面 */
pageLeaveProxy(thisPage) {
......@@ -34,12 +42,18 @@ class TRACK {
// , _this.setTrack({}, 1)
}
thisPage.onLoad = function () {
_this.customPageFun({
thisPage: this
}, 'onLoadFun')
onLoad && onLoad.apply(this, arguments)
//, _this.setTrack({
// enterTime: new Date().format('yyyy-MM-dd hh:mm:ss')
// })
}
thisPage.onShow = function () {
_this.customPageFun({
thisPage: this
}, 'onShowFun')
onShow && onShow.apply(this, arguments)
// , (_this.getPageInstance().page_show_time = Date.now())
}
......@@ -113,7 +127,11 @@ class TRACK {
jsonList: prepare_data
}
if (prepare_data && prepare_data.length)
api.post(data, true).then(({ code, data, message }) => {
api.post(data, true).then(({
code,
data,
message
}) => {
if (code == 0 && data) {
$Storage.set('prepare_data', [])
console.log('---------------- 埋点定时推送成功 ----------------', new Date().format('yyyy-MM-dd hh:mm:ss'), ':', prepare_data)
......@@ -128,11 +146,16 @@ class TRACK {
}
/**获取页面标题 */
getPageTitle() {
let { route, navigationBarTitleText } = this.getPageInstance()
let {
route,
navigationBarTitleText
} = this.getPageInstance()
if ('\u672a\u53d6\u5230' === route || !route) return ''
let title = ''
if (__wxConfig) {
let { window } = __wxConfig.page[`${route}.html`]
let {
window
} = __wxConfig.page[`${route}.html`]
title = window.navigationStyle == 'custom' ? navigationBarTitleText : window.navigationBarTitleText
}
if (!title) title = '中海物业'
......@@ -140,7 +163,13 @@ class TRACK {
}
/**获取设备信息 */
getSystemInfo() {
let { SDKVersion, brand, model, system, version } = $Storage.get('system_info')
let {
SDKVersion,
brand,
model,
system,
version
} = $Storage.get('system_info')
return {
SDK_version: SDKVersion,
brand,
......@@ -151,7 +180,9 @@ class TRACK {
}
/**获取门店信息 */
getMerchantInfo() {
let { merchantId } = $Storage.get('merchant_info')
let {
merchantId
} = $Storage.get('merchant_info')
return {
merchant_id: merchantId
}
......@@ -164,7 +195,10 @@ class TRACK {
else
wx.getLocation({
type: 'gcj02'
}).then(({ latitude, longitude }) => {
}).then(({
latitude,
longitude
}) => {
if (!addressInfo) this.setTrack({}, 5)
console.log('---------------- 更新地理位置 ----------------')
mapApi.detailedAdrress([latitude, longitude]).then(detail => {
......@@ -187,6 +221,13 @@ class TRACK {
}
return `GH_${name}_${Date.now()}`
}
/**在全局埋点onShow增加自定义埋点事件 */
customPageFun(options, name) {
this._customObject[name].map(e => {
e && e(options)
})
}
}
export default TRACK
export default TRACK
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!