Commit ecdb682d authored by Xuguangxing's avatar Xuguangxing

feat: 埋点

parent 7ceda05f
import config from '@/config'; import config from '@/config';
import http from '@/service/httpDecorator'; import http from '@/service/httpDecorator';
import { uiTrack } from '@/service/sa.service'; import { saDeviceId } from '@/service/sa.service';
const { talosHost } = config; const { talosHost } = config;
const PAGE = 'home'; const PAGE = 'home';
export const getBanner = () => { export const getBanner = () => {
...@@ -13,7 +13,7 @@ export const getContent = () => { ...@@ -13,7 +13,7 @@ export const getContent = () => {
}; };
export const getGoodsList = async data => { export const getGoodsList = async data => {
const scDeviceId = await uiTrack.run('saDeviceId'); const scDeviceId = await saDeviceId();
return http.get(`${talosHost}/api/kdsp/recommend/goods-list`, { return http.get(`${talosHost}/api/kdsp/recommend/goods-list`, {
params: data, params: data,
customHeader: { customHeader: {
...@@ -23,7 +23,7 @@ export const getGoodsList = async data => { ...@@ -23,7 +23,7 @@ export const getGoodsList = async data => {
}; };
export const homeSearch = async data => { export const homeSearch = async data => {
const scDeviceId = await uiTrack.run('saDeviceId'); const scDeviceId = await saDeviceId();
return http.post(`${talosHost}/api/kdsp/search/result`, data, { return http.post(`${talosHost}/api/kdsp/search/result`, data, {
customHeader: { customHeader: {
scDeviceId scDeviceId
......
import request from '@/service/httpDecorator'; import request from '@/service/httpDecorator';
import config from '@/config'; import config from '@/config';
import { uiTrack } from '@/service/sa.service'; import { saDeviceId } from '@/service/sa.service';
const { talosHost } = config; const { talosHost } = config;
const queryPayInfo = function(data) { const queryPayInfo = function(data) {
return request.post(`${talosHost}/open/checkout`, data); return request.post(`${talosHost}/open/checkout`, data);
}; };
const prepay = async function(data) { const prepay = async function(data) {
const scDeviceId = await uiTrack.run('saDeviceId'); const scDeviceId = await saDeviceId();
return request.post(`${talosHost}/open/checkout/prepay`, data, { return request.post(`${talosHost}/open/checkout/prepay`, data, {
customHeader: { customHeader: {
scDeviceId scDeviceId
...@@ -17,7 +17,7 @@ const prepay = async function(data) { ...@@ -17,7 +17,7 @@ const prepay = async function(data) {
}; };
const pay = async function(data) { const pay = async function(data) {
const scDeviceId = await uiTrack.run('saDeviceId'); const scDeviceId = await saDeviceId();
return request.post(`${talosHost}/open/checkout/pay`, data, { return request.post(`${talosHost}/open/checkout/pay`, data, {
customHeader: { customHeader: {
scDeviceId scDeviceId
...@@ -43,7 +43,7 @@ const h5AppyUrl = function() { ...@@ -43,7 +43,7 @@ const h5AppyUrl = function() {
}; };
const getCoupon = async function(params) { const getCoupon = async function(params) {
const scDeviceId = await uiTrack.run('saDeviceId'); const scDeviceId = await saDeviceId();
return request.post(`${talosHost}/open/checkout/pay_coupon_list`, params, { return request.post(`${talosHost}/open/checkout/pay_coupon_list`, params, {
customHeader: { customHeader: {
scDeviceId scDeviceId
...@@ -56,7 +56,7 @@ const ocrFaceId = function(params) { ...@@ -56,7 +56,7 @@ const ocrFaceId = function(params) {
}; };
const getGoodsList = async function(data) { const getGoodsList = async function(data) {
const scDeviceId = await uiTrack.run('saDeviceId'); const scDeviceId = await saDeviceId();
return request.get(`${talosHost}/vcc/xyqb/recommend/goods-list`, { return request.get(`${talosHost}/vcc/xyqb/recommend/goods-list`, {
params: data, params: data,
hideLoading: true, hideLoading: true,
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<script> <script>
import MpBridge from '@/service/mp'; import MpBridge from '@/service/mp';
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import { registeredEvents } from '@/service/sa.service'; import { saTrackEvent } from '@/service/sa.service';
export default { export default {
name: 'GroupShare', name: 'GroupShare',
components: {}, components: {},
...@@ -53,7 +53,7 @@ export default { ...@@ -53,7 +53,7 @@ export default {
} }
const nativeBridge = this.nativeBridge; const nativeBridge = this.nativeBridge;
this.$store.dispatch('goods_send_shareinfo', { ev, nativeBridge }); this.$store.dispatch('goods_send_shareinfo', { ev, nativeBridge });
registeredEvents('H5_GroupZeroYuanPurchaseActivityPageSharePopupWindowBtnClick', { saTrackEvent('H5_GroupZeroYuanPurchaseActivityPageSharePopupWindowBtnClick', {
sku_no: '', sku_no: '',
buttons_name: '', // 按钮名称 buttons_name: '', // 按钮名称
activity_id: '', activity_id: '',
......
...@@ -17,6 +17,7 @@ const localHost = 'https://group-buy-test1.liangkebang.net'; // 测试环境页 ...@@ -17,6 +17,7 @@ const localHost = 'https://group-buy-test1.liangkebang.net'; // 测试环境页
// const talosHost = 'http://192.168.25.122:8098'; // 王永杰 // const talosHost = 'http://192.168.25.122:8098'; // 王永杰
// const talosHost = protocol + '//192.168.28.41'; // 超人 // const talosHost = protocol + '//192.168.28.41'; // 超人
const opapiHost = 'https://opapi-test1.liangkebang.net'; const opapiHost = 'https://opapi-test1.liangkebang.net';
const shenceUrl = protocol + '//bn.xyqb.com/sa?project=default';
const VCC_CHANNEL = ''; const VCC_CHANNEL = '';
const TERMINAL = 'H5'; const TERMINAL = 'H5';
const VERSION = '7.9.00'; const VERSION = '7.9.00';
...@@ -32,5 +33,6 @@ export default { ...@@ -32,5 +33,6 @@ export default {
TERMINAL, TERMINAL,
VERSION, VERSION,
kdspHost, kdspHost,
opapiHost opapiHost,
shenceUrl
}; };
...@@ -10,6 +10,7 @@ const kdspHost = 'https://kdsp-api.q-gp.com'; ...@@ -10,6 +10,7 @@ const kdspHost = 'https://kdsp-api.q-gp.com';
const opapiHost = `${protocol}//opapi.xyqb.com`; const opapiHost = `${protocol}//opapi.xyqb.com`;
// const localHost = 'https://mall.q-gp.com/group-buying'; // 正式环境页面地址 // const localHost = 'https://mall.q-gp.com/group-buying'; // 正式环境页面地址
const localHost = 'https://group-buy-test1.liangkebang.net'; // 正式环境页面地址 const localHost = 'https://group-buy-test1.liangkebang.net'; // 正式环境页面地址
const shenceUrl = protocol + '//bn.xyqb.com/sa?project=production';
export default { export default {
localHost, localHost,
// apiHost, // apiHost,
...@@ -22,5 +23,6 @@ export default { ...@@ -22,5 +23,6 @@ export default {
VERSION, VERSION,
qiniuHost, qiniuHost,
kdspHost, kdspHost,
opapiHost opapiHost,
shenceUrl
}; };
...@@ -21,7 +21,7 @@ if (process.env.SENTRY_ENV !== 'test' && process.env.NODE_ENV === 'production') ...@@ -21,7 +21,7 @@ if (process.env.SENTRY_ENV !== 'test' && process.env.NODE_ENV === 'production')
.install(); .install();
} }
Vue.prototype.util = new Bridge(); Vue.prototype.util = new Bridge();
Vue.prototype.$track = saService;
saService.init(router); saService.init(router);
Vue.use(lazyload); Vue.use(lazyload);
Vue.config.productionTip = false; Vue.config.productionTip = false;
......
import Vue from 'vue'; import Vue from 'vue';
import sa from 'sa-sdk-javascript'; import sa from 'sa-sdk-javascript';
import config from '@/config'; import config from '@/config';
// +==========================
import UiTrack from '@qg/ui-track-web/src/index.js';
import router from '@/router';
import { getVccChannel } from '@/service/userInfo.service';
export const uiTrack = new UiTrack({
globalVars: {
platformType: 'H5',
parent_channel_id: getVccChannel('vccChannel') || '',
son_channel_id: getVccChannel('sonVccChannel') || ''
},
useUweb: false,
shenceHost: config.shenceHost,
showLog: config.test,
router: router // router实例
});
// +============+============
export default { export default {
init: function(router) { init: function(router) {
sa.init({ sa.init({
server_url: config.shenceHost, server_url: config.shenceUrl,
heatmap: { heatmap: {
//是否开启点击图,默认 default 表示开启,自动采集 $WebClick 事件,可以设置 'not_collect' 表示关闭 // 是否开启点击图,默认 default 表示开启,自动采集 $WebClick 事件,可以设置 'not_collect' 表示关闭
clickmap: 'default', clickmap: 'default',
//是否开启触达注意力图,默认 default 表示开启,自动采集 $WebStay 事件,可以设置 'not_collect' 表示关闭 // 关闭触达注意力
scroll_notice_map: 'default' scroll_notice_map: 'not_collect'
}, },
//判断外层是否有 App 的 SDK ,如果有的话,会往 App 的 SDK 发数据。如果没有,就正常发送数据。 // TODO: app是如何判断的
use_app_track: true, // 判断外层是否有 App 的 SDK ,如果有的话,会往 App 的 SDK 发数据。如果没有,就正常发送数据。
show_log: config.test, use_app_track: false,
app_js_bridge: true show_log: config.env === 'test'
}); });
// 添加公共属性 // 添加公共属性
sa.registerPage({ sa.registerPage({ platformType: 'H5' });
platformType: 'H5',
uuid: '',
qg_device_id: '',
channel_code: '',
splitStream: ''
});
router.afterEach(() => { router.afterEach(() => {
Vue.nextTick(() => { Vue.nextTick(() => {
sa.quick('autoTrackSinglePage'); sa.quick('autoTrackSinglePage');
...@@ -48,16 +27,9 @@ export default { ...@@ -48,16 +27,9 @@ export default {
}); });
} }
}; };
export function registeredEvents(eventName, eventData, callback = () => {}) { export function saTrackEvent(name, data) {
sa.track(eventName, eventData, callback); sa.track(name, data);
}
// 用户登录神策埋点
export function loginSa(uuid = localStorage.get('uuid')) {
if (!uuid) return;
localStorage.set('uuid', uuid);
sa.login(uuid);
} }
export function saDeviceId() { export function saDeviceId() {
return new Promise(resolve => { return new Promise(resolve => {
sa.quick('isReady', function() { sa.quick('isReady', function() {
...@@ -65,3 +37,7 @@ export function saDeviceId() { ...@@ -65,3 +37,7 @@ export function saDeviceId() {
}); });
}); });
} }
// 设置公共属性
export function setRegisterPage(registerPageObj) {
sa.registerPage(registerPageObj);
}
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
</dl> </dl>
</template> </template>
<script> <script>
import { registeredEvents } from '@/service/sa.service'; import { saTrackEvent } from '@/service/sa.service';
export default { export default {
name: 'GoodsCard', name: 'GoodsCard',
props: { props: {
...@@ -105,7 +105,7 @@ export default { ...@@ -105,7 +105,7 @@ export default {
} = this.goodsItem; } = this.goodsItem;
const { s } = this.btnByStatus; const { s } = this.btnByStatus;
if (s === 2) { if (s === 2) {
registeredEvents('H5_GroupZeroYuanPurchaseActivityPageOpenGroupImmediatelyBtnClick', { saTrackEvent('H5_GroupZeroYuanPurchaseActivityPageOpenGroupImmediatelyBtnClick', {
skuNo skuNo
}); });
this.$router.push({ this.$router.push({
......
...@@ -83,7 +83,7 @@ import { handleRemainTime, handleDateFormat } from './components/utils'; ...@@ -83,7 +83,7 @@ import { handleRemainTime, handleDateFormat } from './components/utils';
import localStorage from '@/service/localStorage.service'; import localStorage from '@/service/localStorage.service';
import goodsCheckMixin from '@/mixins/goodsCheck.mixin'; import goodsCheckMixin from '@/mixins/goodsCheck.mixin';
import { setAppTitleColor } from '@/service/utils.service'; import { setAppTitleColor } from '@/service/utils.service';
import { registeredEvents } from '@/service/sa.service'; import { saTrackEvent } from '@/service/sa.service';
import { isNull, isWxMp } from '@/service/validation.service'; import { isNull, isWxMp } from '@/service/validation.service';
import config from '@/config'; import config from '@/config';
let topicIndex; let topicIndex;
...@@ -196,7 +196,7 @@ export default { ...@@ -196,7 +196,7 @@ export default {
const activity_id = this.activityId; const activity_id = this.activityId;
const shareInfo = await this.getShareData(); const shareInfo = await this.getShareData();
this.$store.dispatch('goods_share_open', shareInfo); this.$store.dispatch('goods_share_open', shareInfo);
registeredEvents('H5_GroupZeroYuanPurchaseActivityPageSharePopupBtnClick', { saTrackEvent('H5_GroupZeroYuanPurchaseActivityPageSharePopupBtnClick', {
activity_id activity_id
}); });
}, },
......
...@@ -116,7 +116,6 @@ export default { ...@@ -116,7 +116,6 @@ export default {
if (addressList) { if (addressList) {
this.handleAddressChange(addressList); this.handleAddressChange(addressList);
} }
// this.$track.registeredEvents('H5_2B_OrderConfirmPageExposure');
}, },
handleToAddress() { handleToAddress() {
if (this.orderInfo.addrReceiverInfo) { if (this.orderInfo.addrReceiverInfo) {
......
...@@ -98,7 +98,7 @@ import countDown from '@/components/countDown'; ...@@ -98,7 +98,7 @@ import countDown from '@/components/countDown';
import { isWxMp, isApp } from '@/service/validation.service'; import { isWxMp, isApp } from '@/service/validation.service';
import Bridge from '@qg/js-bridge'; import Bridge from '@qg/js-bridge';
import MpBridge from '@/service/mp'; import MpBridge from '@/service/mp';
import { registeredEvents } from '@/service/sa.service'; import { saTrackEvent } from '@/service/sa.service';
import groupBuyApi from '@/api/groupBuy'; import groupBuyApi from '@/api/groupBuy';
export default { export default {
name: 'OrderSkuList', name: 'OrderSkuList',
...@@ -187,7 +187,7 @@ export default { ...@@ -187,7 +187,7 @@ export default {
// this.shareInfo = skuInfo; // this.shareInfo = skuInfo;
// this.$store.dispatch('goods_share_open'); // this.$store.dispatch('goods_share_open');
registeredEvents('H5_MyPuzzlePageGroupOrderBtnClick', { saTrackEvent('H5_MyPuzzlePageGroupOrderBtnClick', {
sku_no: '', sku_no: '',
leader_user_id: '' leader_user_id: ''
}); });
......
import cookies from '@/service/cookieStorage.service'; import cookies from '@/service/cookieStorage.service';
export const goUrlExtends = { export const goUrlExtends = {
methods: { methods: {
goHome(payStatus) { goHome() {
// 商城地址 // 商城地址
if (payStatus) {
this.$track?.registeredEvents('h5_RechargeResultPageClick', {
pay_status: payStatus,
buttons_name: '返回首页'
});
}
setTimeout(() => { setTimeout(() => {
this.$router.replace({ name: 'home' }); this.$router.replace({ name: 'home' });
}, 500); }, 500);
}, },
goOrderList(payStatus) { goOrderList() {
if (payStatus) {
this.$track?.registeredEvents('h5_RechargeResultPageClick', {
pay_status: payStatus,
buttons_name: '查看订单'
});
}
setTimeout(() => { setTimeout(() => {
this.$router.replace({ name: 'orderList', params: { status: 0 } }); this.$router.replace({ name: 'orderList', params: { status: 0 } });
}, 500); }, 500);
......
...@@ -227,12 +227,10 @@ export default { ...@@ -227,12 +227,10 @@ export default {
// 先支付再查询信息 // 先支付再查询信息
this.pay(this.payInfo?.paramsData, 'ocr', cookies.get('ocrflag')); this.pay(this.payInfo?.paramsData, 'ocr', cookies.get('ocrflag'));
} }
// !this.$route?.query?.ocrflag && this.$track?.registeredEvents('h5_CheckOutCouterExposure');
const vccToken = localStorage.get('vccToken'); const vccToken = localStorage.get('vccToken');
Current_Url = `${window.location.origin}/payWaiting?vccToken=${vccToken}&orderNo=${this.orderNo}`; Current_Url = `${window.location.origin}/payWaiting?vccToken=${vccToken}&orderNo=${this.orderNo}`;
this.queryPayInfo(); this.queryPayInfo();
this.getCouponList(this.orderNo); this.getCouponList(this.orderNo);
// this.$track.registeredEvents('H5_2B_CashierPageExposure');
}, },
methods: { methods: {
/* 查询支付信息 */ /* 查询支付信息 */
...@@ -404,8 +402,6 @@ export default { ...@@ -404,8 +402,6 @@ export default {
buttons_name: this.accountS.text buttons_name: this.accountS.text
}; };
cookies.set('payTrackInfo', trackParams); cookies.set('payTrackInfo', trackParams);
// this.$track?.registeredEvents('h5_CheckOutCounterConfirmPayClick', trackParams);
// this.$track?.registeredEvents('H5_2BCashierPageConfirmPaymentBtnClick', trackParams);
if (this.isShowProtocol) { if (this.isShowProtocol) {
if (!this.isCheckAgreement) { if (!this.isCheckAgreement) {
this.$toast('请仔细阅读并同意相关协议'); this.$toast('请仔细阅读并同意相关协议');
...@@ -562,15 +558,9 @@ export default { ...@@ -562,15 +558,9 @@ export default {
openCouponModal() { openCouponModal() {
this.random = Math.random(); this.random = Math.random();
this.couponPopup = true; this.couponPopup = true;
// this.$track?.registeredEvents('h5_CheckOutCouterCouponBannerClick');
}, },
/* 选取优惠券 */ /* 选取优惠券 */
handleSelectCoupon(id, selectedCoupon) { handleSelectCoupon(id, selectedCoupon) {
// this.$track?.registeredEvents('h5_CheckOutCounterCouponPopupWindowClick', {
// coupon_type: '享花券',
// check_or_not: id ? '勾选' : '取消',
// coupon_id: id
// });
this.selectedCoupon = selectedCoupon || {}; this.selectedCoupon = selectedCoupon || {};
this.getBtnStatus(this.isRiskLimit()); this.getBtnStatus(this.isRiskLimit());
this.couponPopup = false; this.couponPopup = false;
......
...@@ -60,28 +60,12 @@ export default { ...@@ -60,28 +60,12 @@ export default {
} }
}, },
mounted() { mounted() {
this.$track?.registeredEvents('h5_RechargeResultPageExposure', {
pay_status: '正在支付'
});
const amount = cookies.get('amount') || {};
const payTrackInfo = cookies.get('payTrackInfo') || {};
this.$track?.registeredEvents('H5_2BPaymentPageExposure', {
order_no: this.orderNo,
pay_result: '正在支付',
vcc_state: payTrackInfo.vcc_state,
pay_method: payTrackInfo.pay_method,
pay_amount: amount.finalAmt
});
this.$dialog({ this.$dialog({
message: '请确认订单已完成支付', message: '请确认订单已完成支付',
confirmButtonText: '已完成支付', confirmButtonText: '已完成支付',
cancelButtonText: '重新支付', cancelButtonText: '重新支付',
confirmButtonColor: '#EC1500', confirmButtonColor: '#EC1500',
onCancel: () => { onCancel: () => {
this.$track?.registeredEvents('h5_RechargeResultPageClick', {
pay_status: '正在支付',
buttons_name: '重新支付'
});
this.goPay(); this.goPay();
}, },
onConfirm: () => { onConfirm: () => {
......
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