2.0.1 • Published 4 years ago

@xsyx/x-monitor-web v2.0.1

Weekly downloads
3
License
ISC
Repository
-
Last release
4 years ago

x-monitor-web

安装

  • npm 引用方式
npm i -S @xsyx/x-monitor-web
  • cdn 引入(待定)

基本使用

//项目入口处,如main.js 引入
import XMonitorWeb from '@xsyx/x-monitor-web'
// 调用,尽量在靠前的位置,可以捕获更多的错误
try {
    new XMonitorWeb({
        key: 'h5sdk-test-0501',//棱镜的平台的key,找蒋怀新申请
        url: 'https://flog.xsyxsc.com/r',//错误上报的URL
        //后端的返回,根据返回的状态码来上报错误 回调函数 return true 表示上报错误
        sentry(response) {
            try {
                if (typeof response === 'string') {
                    response = JSON.parse(response);
                }
                if (response.rspCode !== 'success') {
                    return true;
                }
            } catch (e) {
            }
            return false;
        },
    });
} catch (e) {

}

参数

  'location': any[],
  'key': string,// 应用唯一key
  'mergeSize': number,// 合并尺寸
  'mergeReport': boolean, // mergeReport 是否合并上报, false 关闭, true 启动(默认)
  'delay': number, // 当 mergeReport 为 true 可用,延迟多少毫秒,合并缓冲区中的上报(默认)
  'url': string, // 指定错误上报地址 https http://monitor.localtest.me/index.php/api/collect/reportError
  'performanceUrl': string, // 性能数据上报地址
  'isPerformancePage': boolean, // 是否监控页面性能
  'reportAllPerformancePage':boolean, // 是否开启所有页面性能上报,false则只上报错误页面性能
  'isPerformanceResource':boolean, // 是否开启资源性能监控
  'except': any[], // 忽略某个错误
  'userRandom': number,// 抽样用户采集率 1~0 之间数值,1为100%采样所有用户
  'random': number, // 单个用户错误抽样上报抽样率,1~0 之间数值,1为100%上报(默认 1)
  'repeat': number, // 重复上报次数(对于同一个错误超过多少次不上报)
  'extra': Object, // 额外请求参数
  'sentry': Function,// 业务级错误自定义函数上报

  'errorType': ErrorType,// log error warn info
  'errorLevel': number,
  'guid': string,// 用户会话唯一标识
  'userId': string, // 用户唯一标识
  'contentType': string,// application/json;charset=utf-8 application/x-www-form-urlencoded
  'reportDecode': boolean
3.0.0-beta.5

4 years ago

3.0.0-beta.4

4 years ago

3.0.0-beta.3

4 years ago

3.0.0-beta.2

4 years ago

3.0.0-beta.1

4 years ago

3.0.0-beta.0

4 years ago

2.0.1

4 years ago

1.0.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.1

5 years ago

0.1.0

5 years ago