# ab-tracker **Repository Path**: bibinocode/ab-tracker ## Basic Information - **Project Name**: ab-tracker - **Description**: 自动埋点npm包源码 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-07-28 - **Last Updated**: 2022-10-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ab-tracker > 自动埋点用于在前台的鼠标事件,error和promise抛出异常,history和hashchange的上传统计数据 1. history和hash路由的改变进行上报 2. js监听error事件上报 3. promise的reject错误上报 4. 提供可配置选项 ## install ```bash npm install ab-tracker ``` ## es模块使用 ```typescript 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模块使用 ```js 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加载 ```Html