Commit 4d92445d by 侯体倬

【新华优选】小程序埋点功能开发

parent aac246a8
......@@ -29,7 +29,7 @@
"dependencies": {
"hashids": "^2.2.8",
"mayi-analytics": "^1.1.47",
"mayi-front-tools": "^1.0.1",
"mayi-front-tools": "^1.0.3",
"mpvue": "^2.0.0",
"mpvue-wxparse": "^0.6.5",
"posthog-js": "^1.39.1",
......
......@@ -389,6 +389,13 @@ export default {
title: '加入成功',
icon: 'success',
})
// 新华优选埋点
if (app.trackEvent) {
app.trackEvent('resourceCartClick', {
resourceId: this.getProductInfos[0].productId,
resourceName: this.getProductInfos[0].pdtName
})
}
this.show = false;
} else {
wx.showToast({
......
......@@ -29,6 +29,7 @@ import "@/utils/themeModule";
import shop from "./api/shop";
import spokesman from "@/api/spokesman";
import live from "@/api/live"
import xhyxTrack from '@/utils/xhyxShop.js'
Vue.config.productionTip = false
App.mpType = 'app'
......@@ -54,6 +55,8 @@ app.$mount()
// glob挂载到
let mpApp = getApp();
// 新华优选埋点
xhyxTrack.init(mpApp);
Vue.prototype.mpApp = mpApp
// 初始化
mpApp.fenxiaoModel = new fenxiaoModel({
......@@ -222,6 +225,11 @@ wx.onAppRoute(res => {
Store.commit("setShopUserInfo", res.data.data);
wx.setStorageSync('loginUserInfo',res.data.data ? res.data.data : {})
userId = res.data.data ? res.data.data.userId : ''
// 新华优选埋点
if (mpApp.trackLogin) {
const mobilePhone = res.data.data && res.data.data.mobilephone;
mpApp.trackLogin(mobilePhone);
}
}
})
......
......@@ -184,6 +184,10 @@ export default {
key: "openid",
data: res1.data.data
});
// 新华优选埋点
if (app.trackSetOpenid) {
app.trackSetOpenid(res1.data.data);
}
}
this.params += '&open_id='+wx.getStorageSync("openid");
this.withoutScene = true;
......@@ -320,6 +324,10 @@ export default {
key: "openid",
data: res1.data.data
});
// 新华优选埋点
if (app.trackSetOpenid) {
app.trackSetOpenid(res1.data.data);
}
log.info('判断是否登录过=登陆过直接调用..未登录过需要授权头像昵称信息。')
if (wx.getStorageSync('sessionid')) {
log.info('已登陆了')
......
......@@ -956,6 +956,10 @@ export default {
key: "openid",
data: res1.data.data
});
// 新华优选埋点
if (app.trackSetOpenid) {
app.trackSetOpenid(res1.data.data);
}
}
})
},
......
import compass from "mayi-front-tools/compass"
const TRACK_NAME = 'compass'
function trackSetOpenid(openid) {
compass.setOpenid(openid);
}
function trackEvent(eventName, payload) {
compass.track(eventName, payload);
}
function trackLogin(phoneNumber) {
compass.login(phoneNumber)
}
export default {
init(mpApp) {
if (!['xhyx_uat', 'xhyx_prod'].includes(process.env.NODE_ENV)) return;
if (!mpApp[TRACK_NAME]) {
// 配置初始化参数
compass.init({
name: 'compass',
server_url: 'https://track.hebeijiaoyu.cn/api/trackminimessage?productId=xinhuayouxuan',
// 全埋点控制开关
autoTrack:{
appLaunch: true, // 默认为 true,false 则关闭 $MPLaunch 事件采集
appShow: true, // 默认为 true,false 则关闭 $MPShow 事件采集
appHide: true, // 默认为 true,false 则关闭 $MPHide 事件采集
pageShow: true, // 默认为 true,false 则关闭 $MPViewScreen 事件采集
pageShare: true, // 默认为 true,false 则关闭 $MPShare 事件采集
mpClick: false, // 默认为 false,true 则开启 $MPClick 事件采集
mpFavorite: true, // 默认为 true,false 则关闭 $MPAddFavorites 事件采集
pageLeave: false // 默认为 false, true 则开启 $MPPageLeave事件采集
},
// 是否允许控制台打印查看埋点数据(建议开启查看)
show_log: true
});
mpApp[TRACK_NAME] = compass;
mpApp.trackSetOpenid = trackSetOpenid;
mpApp.trackEvent = trackEvent;
mpApp.trackLogin = trackLogin;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment