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

npmhooksentry

v0.3.1

Published

npmhooksentry ajax-hook npmhooksentry

Downloads

24

Readme

引入方法

yarn add npmhooksentry
import "npmhooksentry";
import { createApp } from 'vue';
// ....自己的代码

app.vue

使用:

export default {
  name: 'App',
  mounted(){
    window.SdkSentry = new window.NpmHookSdkSentry({
        api: "http://api.npmhook.com",
        start: true, 
        appkey: "04JW63XyYfLe0u9Rva",
        httpErrorKeyName:"code",
        userInfo: "15021676592", 
        //发送接口间隔时间
        timeNum: 5000, 
        error: (res) => {
          console.error("注册失败",res);
        },
        success: (res) => {
          console.info(`注册成功`,res);
        }
    });

    //saveError使用案例
     window.SdkSentry.saveError("ajax",{
          url:"https://127.0.0.1/login",//接口url,
          body:{userName:"虎克",pwd:"123456"},//接口请求参数,
          response:{msg:"密码错误"},//错误对象
      }).then(()=>{
        
      })
      window.SdkSentry.saveError("js",{
          jsPath:"https://127.0.0.1/a.js",//错误js路径,
          error:{
            message:"错误信息",
            stack:"错误栈信息",
          },//对象对象栈对象,
      }).then(()=>{
        
      })

  }
}

引入之后,会在window上绑定一个全局实例对象,NpmHookSdkSentry

NpmHookSdkSentry 类说明

| 字段名称 | 类型 | 描述 | | --- | --- | --- | | stopWatch | function | 停止监听 | | startWatch | function | 开启监听 | | setUserInfo | function | 动态设置唯一标识 | | saveError | function(type,error) | type:ajax|js两种类型 error:为上报的错误数据 暴露外部,用于主动上报错误函数,具体参数请看底下文档描述 |

NpmHookSdkSentry 参数说明

| 字段名称 | 类型 | 描述 | | --- | --- | --- | | httpCodes | Array | 成功状态集合 默认[200] | | api | string | 自己的接口地址,具体上报的数据格式,请查看network | | start | boole | 是否启动监听 主要是排除测试环境不需要开启监听 或者使用stopWatch startWatch 开启或者关闭 | | appkey | string | 产品key | | httpErrorKeyName | string | http错误字段名称,默认为http的请求返回的respone中的code字段 | | httpValidateError | function(response) | 自定义http错误规则,该字段默认没有。默认根据http状态码规则验证,true:代表异常 false:代表正确| | userInfo | string | 当前账户唯一标识,也可以通过window.SdkSentry实例对象的window.SdkSentry.setUUID函数动态设置| | timeNum | number | 发送接口间隔时间| | otherInfo | object | 其他额外信息,想怎么加就怎么加,妈妈再也不用担心,此字段默认为:navigator.connection对象中的数据|

注意事项

1:在项目最顶端入口处《请保证引入的位置是js的最顶端入口》

有问题随时联系个人微信号