@yidun/snaker
v0.4.3
Published
lite collector for error or other
Downloads
415
Keywords
Readme
Snaker
轻量级 Web 埋点和上报工具
Usage
# Run npm install and write your library name when asked. That's all!
npm install @yidun/snaker -S
Features
- 轻量级,只保留核心逻辑
- 内置支持Vue单页面项目
- 支持离线日志
- 支持日志取样
Importing library
You can import the generated bundle to use the whole library generated by this starter:
import Snaker from '@yidun/snaker'
const snaker = new Snaker(options)
options 配置项:
- pid: 产品标识
- bid:业务标识
- url:上报地址(可选)
- random:取样比例(0-100,可选)
- limit:离线日志阈值(可选)
- version: 前端版本(可选)
Additionally in Vue, you can import the transpiled modules from dist/lib
in case you have a modular library:
import SnakerPlugin from '@yidun/snaker/dist/lib/install'
Vue.use(SnakePlugin, options)
// this.$snaker.report()
Advanced
Set user
snaker.setUser(userid)
Anyc report
snaker.report(event, type, name, extra)
Async report
snaker.reportAsync(evnet, type, name, extra)
Flush offline log
snaker.flush()