0.0.15 • Published 4 months ago
xlwal-implant v0.0.15
自动埋点
示例文档
使用
// 注册,初始化参数
import { buryingPointInit } from 'xlwal-implant'
// 任意时候可以初始化,个人建议是在vue项目初始化之前
buryingPointInit({
router, // vue的router,用于监听路由变化
escalationCallback(ops) {
// 上报回调函数
console.log(...ops)
},
})
自助埋点
// 自定义埋点参数
import { customEscalation } from 'xlwal-implant'
customEscalation({ type: '自定义', msg: '埋点信息' })
后期需要改动参数
// 如果后期某个时候需要修改参数
import { buryingPointInit } from 'xlwal-implant'
// 初始化
buryingPointInit({
authenticationed: false, // 初始化时设置了需要等待鉴权
router, // vue的router,用于监听路由变化
escalationCallback(ops) {
// 上报回调函数
console.log(...ops)
},
})
// 后期等待鉴权完成后,通知鉴权完成
buryingPointInit({ authenticationed: true })
// 简单说 'buryingPointInit' 函数可以多次调用用于改变参数
参数说明
// 埋点配置参数
interface BuryingPointConfigType {
disabled: boolean | string[] // 是否禁用
switchRouteTimeout: number // 路由切换的超时时间,超过了认为是没有正常切换
otherBubblingRootSelectors: (string | HTMLElement | Document)[] // 获取冒泡根元素,有些元素被阻止冒泡,无法直接监听document捕获
escalationCallback: (option: BuryingPointEscalation[]) => void // 回调函数,给外部使用上报
captureTargetSelectors: string[] // 冒泡目标元素的选择器, 如:['div.box[data-x="123"]']
ignoreTargetSelectors: string[] // 要忽略的,冒泡目标元素的选择器, 如:['div.box[data-x="123"]']
captureLevel: number // 冒泡层级,操作目标元素e.target可以冒泡几层寻找我们想要的元素
authenticationed: boolean // 是否已经鉴权,和disabled不同,false时不上报,会记录队列
queueMaxNumber: number // 队列中最大存储量
router?: any // 路由数据
}
// 可以调用 'getBuryingPointConfig' 函数获取当前参数
// 返回值可以直接修改