普通版本

封装 js 错误监控

安装

# 选择一个你喜欢的包管理器

# NPM
$ npm install @tomorrow-catcher/browser
# Yarn
$ yarn add @tomorrow-catcher/browser
# pnpm
$ pnpm add @tomorrow-catcher/browser

基础用法

点击查看代码
import { init } from '@tomorrow-catcher/browser'

init({
  key: 'key',
  expireDate: 1,
  reportUrl: 'http://localhost:4873/',
  handlersList: ['error', 'unhandledrejection', 'fetch', 'xhr'],
})

SDK 属性

属性说明类型可选值默认值
key应用对应 keystring--
expireDate日志过期时间,单位为天,如果为 0 时捕获错误后马上上传number--
reportUrl日志上传 api 地址,请求方法为 post(resquest body:{appkey:string,list:TomorrowLog[]})string--
handlersList错误捕获类型:arrayerror/unhandledrejection/fetch/xhr/sourceLoad[]
handlersOpts错误捕获处理器参数:HandlersOpts-null
sdkVersionSDK 信息string-当前 sdk 版本 version

HandlersOpts 属性

属性说明类型可选值默认值
lagFPS 监测参数{threshold:number,second:number}-{threshold:20,second:3}

lastUpdate: