v-point
v-point 旨在为做埋点能最简化的处理
安装
npm install v-point
引用
import vPoint from 'v-point'
vue 2
Vue.use(vPoint, { options })
vue 3
app.use(vPoint, { options })
options 参数
autoUpload 是否自动请求埋点请求 (默认:true)
url 埋点请求 url
method 埋点请求类型 (默认:post)
headers 埋点请求header
success 请求成功回调函数
error 请求失败回调函数
callback 收集埋点信息后回调函数 (只作用于autoUpload 为false)
...其他参数,作用于 埋点请求参数/callback 参数
使用
在需要埋点的地方写入
<div v-point="{ type: 'click', code: 'todo' }"></div>
参数
type(click, view)
code(埋点位置所代码的唯一值、用做区分埋点位置)
示例
自定义埋点
import vPoint from 'v-point'
Vue.use(vPoint, {
autoUpload: false,
callback: data => {
console.log(data);
}
});
自动埋点
Vue.use(vPoint, {
url: '/xxxxx',
method: 'get',
headers: {
token: 'token'
},
success: (res) => {
console.log(res);
},
error: err => {
console.log(err);
}
});