Commit 0cee28fd by 李嘉林

feat: 页面加载时间埋点

parent 44ec7684
...@@ -91,19 +91,19 @@ module.exports = merge(baseWebpackConfig, { ...@@ -91,19 +91,19 @@ module.exports = merge(baseWebpackConfig, {
// inject: true // inject: true
// }), // }),
new FriendlyErrorsPlugin(), new FriendlyErrorsPlugin(),
new UglifyJsPlugin({ // new UglifyJsPlugin({
sourceMap: true, // sourceMap: true,
uglifyOptions: { // uglifyOptions: {
// 删除注释 // // 删除注释
output: { // output: {
comments: false // comments: false
}, // },
compress: { // compress: {
warnings: false, // warnings: false,
drop_console: true, // drop_console: true,
pure_funcs: ['console.log'] // pure_funcs: ['console.log']
} // }
} // }
}) // })
] ]
}) })
...@@ -121,20 +121,20 @@ if (config.build.bundleAnalyzerReport) { ...@@ -121,20 +121,20 @@ if (config.build.bundleAnalyzerReport) {
var useUglifyJs = process.env.PLATFORM !== 'swan' var useUglifyJs = process.env.PLATFORM !== 'swan'
if (useUglifyJs) { if (useUglifyJs) {
webpackConfig.plugins.push(new UglifyJsPlugin({ // webpackConfig.plugins.push(new UglifyJsPlugin({
sourceMap: true, // sourceMap: true,
uglifyOptions: { // uglifyOptions: {
// 删除注释 // // 删除注释
output: { // output: {
comments: false // comments: false
}, // },
compress: { // compress: {
warnings: false, // warnings: false,
drop_console: true, // drop_console: true,
pure_funcs: ['console.log'] // pure_funcs: ['console.log']
} // }
} // }
})) // }))
} }
module.exports = webpackConfig module.exports = webpackConfig
...@@ -1539,13 +1539,15 @@ ...@@ -1539,13 +1539,15 @@
} }
}, },
"call-bind": { "call-bind": {
"version": "1.0.5", "version": "1.0.7",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
"integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
"requires": { "requires": {
"es-define-property": "^1.0.0",
"es-errors": "^1.3.0",
"function-bind": "^1.1.2", "function-bind": "^1.1.2",
"get-intrinsic": "^1.2.1", "get-intrinsic": "^1.2.4",
"set-function-length": "^1.1.1" "set-function-length": "^1.2.1"
}, },
"dependencies": { "dependencies": {
"function-bind": { "function-bind": {
...@@ -3267,13 +3269,13 @@ ...@@ -3267,13 +3269,13 @@
} }
}, },
"define-data-property": { "define-data-property": {
"version": "1.1.1", "version": "1.1.4",
"resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
"integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
"requires": { "requires": {
"get-intrinsic": "^1.2.1", "es-define-property": "^1.0.0",
"gopd": "^1.0.1", "es-errors": "^1.3.0",
"has-property-descriptors": "^1.0.0" "gopd": "^1.0.1"
} }
}, },
"define-properties": { "define-properties": {
...@@ -3676,6 +3678,19 @@ ...@@ -3676,6 +3678,19 @@
"string.prototype.trimstart": "^1.0.1" "string.prototype.trimstart": "^1.0.1"
} }
}, },
"es-define-property": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
"integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
"requires": {
"get-intrinsic": "^1.2.4"
}
},
"es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="
},
"es-to-primitive": { "es-to-primitive": {
"version": "1.2.1", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz",
...@@ -4464,10 +4479,11 @@ ...@@ -4464,10 +4479,11 @@
"dev": true "dev": true
}, },
"get-intrinsic": { "get-intrinsic": {
"version": "1.2.2", "version": "1.2.4",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
"integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
"requires": { "requires": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2", "function-bind": "^1.1.2",
"has-proto": "^1.0.1", "has-proto": "^1.0.1",
"has-symbols": "^1.0.3", "has-symbols": "^1.0.3",
...@@ -4632,17 +4648,17 @@ ...@@ -4632,17 +4648,17 @@
"dev": true "dev": true
}, },
"has-property-descriptors": { "has-property-descriptors": {
"version": "1.0.1", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
"integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
"requires": { "requires": {
"get-intrinsic": "^1.2.2" "es-define-property": "^1.0.0"
} }
}, },
"has-proto": { "has-proto": {
"version": "1.0.1", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==" "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q=="
}, },
"has-symbols": { "has-symbols": {
"version": "1.0.1", "version": "1.0.1",
...@@ -4729,9 +4745,9 @@ ...@@ -4729,9 +4745,9 @@
} }
}, },
"hasown": { "hasown": {
"version": "2.0.0", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
"integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"requires": { "requires": {
"function-bind": "^1.1.2" "function-bind": "^1.1.2"
}, },
...@@ -5752,9 +5768,9 @@ ...@@ -5752,9 +5768,9 @@
"dev": true "dev": true
}, },
"mayi-analytics": { "mayi-analytics": {
"version": "1.1.57", "version": "1.1.59",
"resolved": "https://registry.npmjs.org/mayi-analytics/-/mayi-analytics-1.1.57.tgz", "resolved": "https://registry.npmjs.org/mayi-analytics/-/mayi-analytics-1.1.59.tgz",
"integrity": "sha512-iN+IQjLKH30enCYMt0iMz+CgGuRoDXC3vBxwuDeIBTuAPN7s3dYqQL3Vf8sPqLYUSZC1OxhEwo6et4KzZxC9Cg==", "integrity": "sha512-ci3G4JOHsaKfgu31DzAVVvllToxPU3XuBvQEuorzxVYmCL5yeyG6fX4e6QqcWx2DvJG0g4Sa2GWAvSAfjr3hEA==",
"requires": { "requires": {
"js-cookie": "^2.2.0", "js-cookie": "^2.2.0",
"qs": "^6.7.0", "qs": "^6.7.0",
...@@ -5762,11 +5778,11 @@ ...@@ -5762,11 +5778,11 @@
}, },
"dependencies": { "dependencies": {
"qs": { "qs": {
"version": "6.11.2", "version": "6.12.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.1.tgz",
"integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", "integrity": "sha512-zWmv4RSuB9r2mYQw3zxQuHWeU+42aKi1wWig/j4ele4ygELZ7PEO6MM7rim9oAQH2A5MWfsAVf/jPvTPgCbvUQ==",
"requires": { "requires": {
"side-channel": "^1.0.4" "side-channel": "^1.0.6"
} }
} }
} }
...@@ -8817,15 +8833,16 @@ ...@@ -8817,15 +8833,16 @@
"dev": true "dev": true
}, },
"set-function-length": { "set-function-length": {
"version": "1.2.0", "version": "1.2.2",
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.0.tgz", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
"integrity": "sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==", "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==",
"requires": { "requires": {
"define-data-property": "^1.1.1", "define-data-property": "^1.1.4",
"es-errors": "^1.3.0",
"function-bind": "^1.1.2", "function-bind": "^1.1.2",
"get-intrinsic": "^1.2.2", "get-intrinsic": "^1.2.4",
"gopd": "^1.0.1", "gopd": "^1.0.1",
"has-property-descriptors": "^1.0.1" "has-property-descriptors": "^1.0.2"
}, },
"dependencies": { "dependencies": {
"function-bind": { "function-bind": {
...@@ -8916,13 +8933,14 @@ ...@@ -8916,13 +8933,14 @@
} }
}, },
"side-channel": { "side-channel": {
"version": "1.0.4", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==",
"requires": { "requires": {
"call-bind": "^1.0.0", "call-bind": "^1.0.7",
"get-intrinsic": "^1.0.2", "es-errors": "^1.3.0",
"object-inspect": "^1.9.0" "get-intrinsic": "^1.2.4",
"object-inspect": "^1.13.1"
}, },
"dependencies": { "dependencies": {
"object-inspect": { "object-inspect": {
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
"build:my": "node build/build.js my" "build:my": "node build/build.js my"
}, },
"dependencies": { "dependencies": {
"mayi-analytics": "^1.1.57", "mayi-analytics": "^1.1.59",
"mayi-front-tools": "^1.0.3", "mayi-front-tools": "^1.0.3",
"mpvue": "^2.0.0", "mpvue": "^2.0.0",
"mpvue-wxparse": "^0.6.5", "mpvue-wxparse": "^0.6.5",
......
...@@ -20,6 +20,11 @@ export default { ...@@ -20,6 +20,11 @@ export default {
return requestPOST(`${process.env.OLSHOP_URL}/cms/get_shop_install_pages?homePageFlag=${params.homePageFlag || false}&shopMixId=${params.shopMixId}`, return requestPOST(`${process.env.OLSHOP_URL}/cms/get_shop_install_pages?homePageFlag=${params.homePageFlag || false}&shopMixId=${params.shopMixId}`,
); );
}, },
// 页面数据V2
themePagesInfoV2(params) {
return requestPOST(`${process.env.OLSHOP_URL}/cms/get_shop_install_pages_v2?homePageFlag=${params.homePageFlag || false}&shopMixId=${params.shopMixId}`,
);
},
// 查单页面 // 查单页面
singlePageInfo(params) { singlePageInfo(params) {
return requestPOST(`${process.env.OLSHOP_URL}/cms/get_shop_page_by_id?id=${params.id}`, return requestPOST(`${process.env.OLSHOP_URL}/cms/get_shop_page_by_id?id=${params.id}`,
......
...@@ -188,15 +188,14 @@ function getThemePage({ mixid, shopid }) { ...@@ -188,15 +188,14 @@ function getThemePage({ mixid, shopid }) {
let userId let userId
// 分销员 id // 分销员 id
let spokesmanId let spokesmanId
let startViewTime = new Date().getTime(); // 进入时间
let endViewTime = null; // 跳出时间
let viewPageList = []; // 两个参数 上一个页面、当前页面
/** /**
* 全局页面切换监听 * 全局页面切换监听
*/ */
wx.onAppRoute(res => { wx.onAppRoute(res => {
// 获取当前页面信息 console.log(res, '--res')
let currentPage = getCurrentPages()
console.log(currentPage,'--currentPage')
console.log(res,'--res')
// let fromPath = currentPage[currentPage.length - 1].__displayReporter.showReferpagepath
let whetherToForceLogin = mpApp.globalData.shopInfo && mpApp.globalData.shopInfo.whetherToForceLogin || 0 let whetherToForceLogin = mpApp.globalData.shopInfo && mpApp.globalData.shopInfo.whetherToForceLogin || 0
log.info("wx.onAppRoute", res, mpApp.globalData.shopInfo, whetherToForceLogin, wx.getStorageSync('sessionid'), res.path != "pages/login/main"); log.info("wx.onAppRoute", res, mpApp.globalData.shopInfo, whetherToForceLogin, wx.getStorageSync('sessionid'), res.path != "pages/login/main");
console.log(res,mpApp.globalData.shopInfo,whetherToForceLogin,wx.getStorageSync('sessionid'),res.path !="pages/login/main",'---------wx.onAppRoute') console.log(res,mpApp.globalData.shopInfo,whetherToForceLogin,wx.getStorageSync('sessionid'),res.path !="pages/login/main",'---------wx.onAppRoute')
...@@ -250,5 +249,40 @@ wx.onAppRoute(res => { ...@@ -250,5 +249,40 @@ wx.onAppRoute(res => {
log.info("mpBehavior.trackPageView",trackPageViewQuery) log.info("mpBehavior.trackPageView",trackPageViewQuery)
console.log("mpBehavior.trackPageView",trackPageViewQuery) console.log("mpBehavior.trackPageView",trackPageViewQuery)
mpBehavior.trackPageView(trackPageViewQuery); mpBehavior.trackPageView(trackPageViewQuery);
trackPageLeave(res);
}) })
}) })
/**
* 页面访问时长埋点
* @param {*} res
*/
function trackPageLeave() {
endViewTime = new Date().getTime();
const duration = endViewTime - startViewTime;
// 获取当前页面信息
let currentPage = getCurrentPages()
if (viewPageList.length == 0) {
viewPageList = [currentPage[currentPage.length - 1]]
} else {
viewPageList = [currentPage[currentPage.length - 1], viewPageList[0]]
}
console.log('trackPageLeave-viewPageList->', viewPageList);
if (!isNaN(duration) && viewPageList.length > 1) {
let pagePath = viewPageList[1].route;
let pageQuery = viewPageList[1].options;
let query = {
title: '',
location: pagePath, // 需要存上一个页面的
path: `${pagePath}${serialize(pageQuery)?('?'+serialize(pageQuery)):''}`,
sales: spokesmanId || "",
userId: userId || "",
lsdcode: getStoreInfo().offlineShopCode,
lsdname: getStoreInfo().offlineShopName,
}
query.amount = duration / 1000
mpBehavior.trackPageLeave(query)
}
console.log('trackPageLeave-duration->', query.amount);
startViewTime = endViewTime;
}
\ No newline at end of file
...@@ -423,7 +423,6 @@ const componentOptions = { ...@@ -423,7 +423,6 @@ const componentOptions = {
}); });
}, },
goodsListVal(goodsList, type, flag) { goodsListVal(goodsList, type, flag) {
console.log('goodsListVal', goodsList, type, flag);
let { attributeValueList } = this.data.datas.componentData; let { attributeValueList } = this.data.datas.componentData;
goodsList.forEach((item, index) => { goodsList.forEach((item, index) => {
item.marketingTag = item.defaultTags item.marketingTag = item.defaultTags
...@@ -481,7 +480,6 @@ const componentOptions = { ...@@ -481,7 +480,6 @@ const componentOptions = {
pageGoodsList[that.data.datasIndex] = list; pageGoodsList[that.data.datasIndex] = list;
} }
this.setStorageSync('pageGoodsList', pageGoodsList); this.setStorageSync('pageGoodsList', pageGoodsList);
console.log('goodsListVal->2', that.data.goodsListIndex, that.data.datasIndex, list)
// 获取是否要开启请求拦截 // 获取是否要开启请求拦截
...@@ -756,7 +754,6 @@ const componentOptions = { ...@@ -756,7 +754,6 @@ const componentOptions = {
}); });
}, },
setStorageSync(key, val) { setStorageSync(key, val) {
console.log('setStorageSync->', this.data.storageKey, key, val)
return wx.setStorageSync(`${this.data.storageKey}_${key}`,val) return wx.setStorageSync(`${this.data.storageKey}_${key}`,val)
}, },
getStorageSync(key) { getStorageSync(key) {
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
style="display:grid;grid-template-columns:repeat({{datas.componentData.columnNum}},minmax(0px, 1fr));gap:{{datas.componentData.proGap*2}}rpx;" style="display:grid;grid-template-columns:repeat({{datas.componentData.columnNum}},minmax(0px, 1fr));gap:{{datas.componentData.proGap*2}}rpx;"
> >
<view <view
wx:for="{{pageGoodsList[datasIndex]}}" wx:for="{{datas.componentData.goodsList}}"
wx:key="index" wx:key="index"
class="goods-item {{'goodsItemIndex'+index}}" class="goods-item {{'goodsItemIndex'+index}}"
style="margin-bottom:20rpx;" style="margin-bottom:20rpx;"
......
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