ab-tracker
v1.1.4
Published
自动埋点,支持配置化,方便提供给运维人员数据
Downloads
2
Readme
ab-tracker
自动埋点用于在前台的鼠标事件,error和promise抛出异常,history和hashchange的上传统计数据
- history和hash路由的改变进行上报
- js监听error事件上报
- promise的reject错误上报
- 提供可配置选项
install
npm install ab-tracker
es模块使用
import abTracker from 'ab-tarcker'
const Bpoint = new abTracker({reqUrl:"http:localhost:9000/tracker",version:'v1.0.0',extra:{msg:'额外字段'},historyPlugin:true,hashPlugin:true,domPlugin:true,errorPlugin:true})
// 自定义dom上报
const Bpoint = new abTracker({uuid:'xxxxxxx191919',reqUrl:"http:localhost:9000/tracker",version:'v1.0.0',extra:{msg:'额外字段'},historyPlugin:true,hashPlugin:true,domPlugin:{is:true,options:['click'],dataKey:'tracker-key'},errorPlugin:true})
// 使用暴露的接口手动触发上传
Bpoint.setDataKey({event:Event,targetKey:string,[key:string]:any}})
// 使用暴露的接口手动触设置额外字段
Bpoint.setExtra({})
// 使用暴露的接口自定义uuid
Bpoint.setUserId('xxxxxxx191919')
cjs模块使用
const abTracker = require('ab-tarcker')
const Bpoint = new abTracker({reqUrl:"http:localhost:9000/tracker",version:'v1.0.0',extra:{msg:'额外字段'},historyPlugin:true,hashPlugin:true,domPlugin:true,errorPlugin:true})
// 自定义dom上报
const Bpoint = new abTracker({uuid:'xxxxxxx191919',reqUrl:"http:localhost:9000/tracker",version:'v1.0.0',extra:{msg:'额外字段'},historyPlugin:true,hashPlugin:true,domPlugin:{is:true,options:['click'],dataKey:'tracker-key'},errorPlugin:true})
// 使用暴露的接口手动触发上传
Bpoint.setDataKey({event:Event,targetKey:string,[key:string]:any}})
// 使用暴露的接口手动触设置额外字段
Bpoint.setExtra({})
// 使用暴露的接口自定义uuid
Bpoint.setUserId('xxxxxxx191919')
cdn加载
<div>
<h1>自动埋点</h1>
<button tracker-key="鼠标事件上报">鼠标移到我上面点击试试</button>
</div>
<script>
const abTracker = new Bpoint({uuid:'xxxxxxx191919',reqUrl:"http:localhost:9000/tracker",version:'v1.0.0',extra:{msg:'额外字段'},historyPlugin:true,hashPlugin:true,domPlugin:{is:true,options:['click'],dataKey:'tracker-key'},errorPlugin:true})
</script>