npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ccic-h5-apm

v4.1.1

Published

ccic-h5-apm

Downloads

210

Readme

CCICWebErrorMonitor

引入方法

  1. npm install --save ccic-h5-apm
import CCICWebErrorMonitor from 'ccic-h5-apm'
  1. cdn 链接

Usage

初始化

var errorMonitor = new CCICWebErrorMonitor({
    exclude: {
        'E1008': [],         //过滤所有E1001错误
        'E1004': ['<img']    //过滤E1004错误中包含<img的错误,多个指定字符用逗号分隔
    },
    autoSend: true, // 是否自动投递 默认 true
    sendOptions: {
        url: '', // 日志投递地址(当type=gio时无需传入)
        type: 'single', // 日志投递模式,默认single单个投递,可选mutiple批量投递和gio投递growingio
        environment: 'dev', // 埋点投递环境可选dev,pro(type = gio 必填),默认测试环境
        network: 'external', // 网络类型可选intranet,external(type = gio 必填) 默认外网
        logSendDur: 30 // 异常日志队列扫描间隔,默认30s
    }
    frame: {
        name: 'vue', //框架名称
        obj: Vue //框架对象
    }
    logMergeTime: 3000,  //合并重复异常的间隔时间,默认3000ms
    errorTemp: ...  //本地存储的日志,默认通过localStorage存取
});

投递接口options:
{
    body: JSON.stringify({
        apm: {
            code: ...,
            info: ...
        }
    }),
    headers: {
        'Content-Type': 'application/json'
    },
    method: 'POST'
}
  • 配置项

| options | 是否必填 | 说明 | | :----------- | :------: | :----------------------------------------------------------------------------------------------------------------- | | exclude | N | 需要过滤的错误类型和指定错误;需要过滤的错误类型作为 key,值为该错误类型中需要过滤的包含指定字符的错误 | | autoSend | N | 是否通过 sdk 集成的方法自动发送异常日志,默认为 true,需要配置 sendUrl。通过其他方式自定义发送异常日志,设为 false | | url | N | 自动发送异常日志的接口地址 | | name | N | 开启框架自身的异常监控,框架名称'vue' |
| obj | N | 开启框架自身的异常监控,目前支持 Vue [传入全局 Vue 对象 | | type | Y | 投递类型 single单个投递、mutiple、批量头题gio 投递growingIO | | | logMergeTime | N | 合并重复异常的间隔时间,默认 3000ms | | logSendDur | N | 异常日志队列扫描间隔时间,默认 30s | | errorTemp | N | 本地存储的日志,默认通过 localStorage 存取 |

注册设备信息

errorMonitor.registerDevice(params);

params 为需要记录到日志中的设备信息,可自行传入需要的信息,默认参数 deviceId,os,ua

{
    deviceId: '',       //设备id
    os: navi.platform,  //操作系统,默认通过navigator取
    ua: navi.userAgent  //ua,默认通过navigator取
}

注册应用信息

errorMonitor.registerIdentity(params);

params 为需要记录到日志中的设备信息,可自行传入需要的信息,默认参数 system,userInfo,accountId,dataSourceId,version

{
    system: '',     //业务系统信息
    userInfo: ''    //用户信息
    accountId: '', // gio accountId
    dataSourceId: '', // gio dataSourceId
    version: '', // 版本号
}

存储异常日志

errorMonitor.saveLog = (res) => {
    //do something
    默认存入localStorage,res是异常信息json对象
};

启动监测

errorMonitor.start();

关闭异常投递

errorMonitor.stop();

错误代码

| 异常 code | 说明 | | :-------: | :--------------- | | E1001 | 系统未知错误 | | E1002 | vue 逻辑错误 | | E1003 | JavaScript 错误 | | E1004 | 静态资源加载错误 | | E1005 | 请求错误 | | E1006 | Promise 错误 | | E1007 | 网络离线 | | E1008 | 网络状态变化 |

日志分级

['track', 'TRACK'], 等级最低 ['debug', 'DEBUG'], ['info', 'INFO'], ['warn', 'WARN'], ['error', 'ERROR'], ['fatal', 'FATAL'] 等级最高