# catch-info

> catch javascript errors and getting system related information

Latest version **1.1.1** (published 2020-10-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install catch-info
pnpm add catch-info
yarn add catch-info
bun add catch-info
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2020-10-28 |
| First published | 2020-08-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 45.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | FeiHe-R |
| Maintainers | renyi |

## Links

- npm: https://www.npmjs.com/package/catch-info
- npm.io page: https://npm.io/package/catch-info

## Recent versions

- 1.1.1 (latest) — 2020-10-28
- 1.1.0 — 2020-10-28
- 1.0.9 — 2020-10-28
- 1.0.8 — 2020-10-28
- 1.0.7 — 2020-10-27
- 1.0.6 — 2020-09-03
- 1.0.5 — 2020-08-17
- 1.0.4 — 2020-08-17
- 1.0.3 — 2020-08-11
- 1.0.2 — 2020-08-11
- 1.0.1 — 2020-08-11
- 1.0.0 — 2020-08-11

## README

# 捕获异常

catch javascript errors and getting system related information

## 安装

```bash
$ npm i catch-info
```

## 引入

```js
import {publicReport, customReport, DeviceInfo} from 'catch-info'
```

`publicReport：`上报全局错误

`customReport：`上报自定义错误

`DeviceInfo：`设备信息获取

## 使用简介


#### publicReport：

```
功能：捕获javascript异常、资源异常、promis异常，并上传到服务器

方法：
publicReport(主机名, 用户唯一标识);

示例：
publicReport('http://localhost:8000/api/', 'useridXXX!!XXXX');
```
 
 
#### customReport：
```
功能：捕获自定义异常，并上传到服务器

方法：
customReport(主机名, 用户唯一标识, 异常名称, 异常描述, 错误栈)

示例：
try{
    b()  //错误代码
}catch(e){
    customReport('http://localhost:8000/api/', 'useridXXX!!XXXX', 'name', 'des', e.stack)
}
```

#### DeviceInfo：
```
功能：获取设备信息

获取参数：
OS: 操作系统
browserInfo: 浏览器信息
deviceType: 设备类型
model: 机型
language: 语言
netWork: 当前网络
orientation: 横屏/竖屏
screenHeight: 屏幕高度
screenWidth: 屏幕宽
userAgent: userAgent信息

示例：
const info = DeviceInfo;
```

#### 约定接口
```
// js上报路径
PATH_JAVASCRIPT: '/report/javascriptError',
// 接口上报路径
PATH_INTERFACE: '/report/interfaceError',
// 资源上报路径
PATH_RESOURCE: '/report/resourceError',
// 自定义异常上报路径
PATH_CUSTOM: '/report/customError'
```

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