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

honeybadger-sdk

v1.0.5

Published

honeybadger sdk

Downloads

9

Readme

honeyBadger-sdk

honeyBadger-sdk 是一个可以上报移动端业务代码错误的 js-sdk。

安装

  • latest 稳定版: [sudo] npm install honeybadger-sdk

node.js 版本

  • node >=8

使用文档

在项目中引入
import honeyBadger from 'honeybadger-sdk'
引入后直接调用 honeyBadger.init()方法初始化公共参数:

appIdappNamechannelplatformaesKey如果缺少任意一个,则不会发起上报

honeyBadger.init({
  appId: 'appId',
  appName: 'appName',
  channel: '渠道',
  platform: '平台',
  aesKey: '密钥'
})
事件上报
常规事件上报,调用 honeyBadger.reportAbnormal()方法
honeyBadger.reportAbnormal('事件名', {
  url: '请求的接口的url',
  msg: '自定义的错误信息',
  statusCode: '状态码'
})
  • report 方法参数说明:

    • 第一个参数为事件名:有以下几个可选值,【也可以自己新增】,使用以下事件时,可以不传 msg,会默认上报对应的错误 msg
      • responseLogicError: 接口请求失败的上报,即 status !== 0 时
      • responseDataError: 接口返回的参数格式校验错误的上报
      • uploadError: 拍照/选择照片失败/图片上传(未拿到文件流)的上报
      • liveFaceError: 活体拍摄视频失败(未拿到视频流)的上报
      • timeoutError: 接口请求超时的上报
      • defensiveError: 防御性编程的一些容错情况的上报
      • vueJsError: vue 生命周期中的 js 报错时的上报
    • 第二个参数是一个对象,可传以下 3 个基本参数,也可以增加任意想上报的字段
      • url: 接口地址(非必传)
      • msg: 错误信息(非必传)
      • statusCode: 状态码(必传)
      • ua: 浏览器的 User Agent(默认上报,可不传!!)
网络请求上报,调用 honeyBadger.reportRequest()方法
honeyBadger.reportRequest({
  url: '请求的接口的url',
  msg: '自定义的错误信息',
  statusCode: 'http请求状态码', // 200等..
  method: '请求方式', // post、get..
  requestStartTime: '请求开始时间戳',
  requestEndTime: '请求结束时间戳',
  requestDuration: '请求耗时' // requestEndTime - requestStartTime
})

change log

  1. 封装错误信息的上报机制
  2. 新增网络请求上报