1
This commit is contained in:
25
new-soul/miniprogram/utils/trackClick.js
Normal file
25
new-soul/miniprogram/utils/trackClick.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const app = getApp()
|
||||
|
||||
/**
|
||||
* 全局按钮/标签点击埋点
|
||||
* @param {string} module 模块:home|chapters|read|my|vip|wallet|match|referral|search|settings|about
|
||||
* @param {string} action 行为:tab_click|btn_click|nav_click|card_click|link_click 等
|
||||
* @param {string} target 目标标识:按钮文案、章节ID、标签名等
|
||||
* @param {object} [extra] 附加数据
|
||||
*/
|
||||
function trackClick(module, action, target, extra) {
|
||||
const userId = app.globalData.userInfo?.id || ''
|
||||
if (!userId) return
|
||||
app.request('/api/miniprogram/track', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
userId,
|
||||
action,
|
||||
target,
|
||||
extraData: Object.assign({ module, page: module }, extra || {})
|
||||
},
|
||||
silent: true
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
module.exports = { trackClick }
|
||||
Reference in New Issue
Block a user