# @yidun/snaker

> lite collector for error or other

Latest version **0.4.3** (published 2024-04-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @yidun/snaker
pnpm add @yidun/snaker
yarn add @yidun/snaker
bun add @yidun/snaker
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.3 |
| Published | 2024-04-19 |
| First published | 2020-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Unpacked size | 234.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | gssify |
| Maintainers | hzzly, zhaoxuhui, vortesnail, gssify, yidunfe, hcyang, liulingfeng, luolihao |

## Links

- npm: https://www.npmjs.com/package/@yidun/snaker
- npm.io page: https://npm.io/package/@yidun/snaker

## Recent versions

- 0.4.3 (latest) — 2024-04-19
- 0.4.2 — 2021-05-07
- 0.4.1 — 2021-04-22
- 0.4.0 — 2021-01-20
- 0.3.0 — 2020-09-22
- 0.2.7 — 2020-09-16
- 0.2.6 — 2020-09-09
- 0.2.5 — 2020-09-07
- 0.2.4 — 2020-06-01
- 0.2.3 — 2020-06-01
- 0.2.2 — 2020-03-20
- 0.2.1 — 2020-03-20
- 0.2.0 — 2020-03-18
- 0.1.0 — 2020-03-18

## README

# Snaker

轻量级 Web 埋点和上报工具

### Usage

```bash

# 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:

```javascript
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:

```javascript
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

```js
snaker.reportAsync(evnet, type, name, extra)
```

#### Flush offline log

```js
snaker.flush()
```

---
_Source: https://npm.io/package/@yidun/snaker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
