Files
soul-yongping/miniprogram/utils/trackClick.js
卡若 34f7c7bbdc feat(miniprogram): 用 karuo-316 替换小程序目录
- 从 github/karuo-316 覆盖 miniprogram/
- 排除 project.private.config.json 与 *.backup

Made-with: Cursor
2026-03-17 18:25:24 +08:00

26 lines
776 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 }