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

@loyalvalleycapital/monitor

v1.2.1

Published

A log lib for RN and web project

Downloads

11

Readme

埋点,错误上报 sdk

安装

如果通过一些其他工具配置了安装源,那么--registry参数可以忽略

# npm
npm install @loyalvalleycapital/monitor --registry=xxxxx
# yarn
yarn add @loyalvalleycapital/monitor --registry=xxxx

使用

目前打出 2 个版本的 js,一个包含UserAgent库的,一个不包含的(为了减少包体积,概况可以减少33kb),默认指向不包括的UserAgent。如果需要引入包含UserAgent的 js,需要配置下 webpack 别名:

{
	alias: {
		// ...other alias
		monitorsdk: 'monitorsdk/dist/monitorsdk-web.js',
	}
}
import monitor, { setCustomError } from ' @loyalvalleycapital/monitor'

monitor.trackEv(...)

setCustomError(err, {code: 'xxx', custom: {}})

用法跟之前相同,因为抽取成 npm 包的形式复用,所有有些参数必须通过外部传递进来。 以下几点需要注意:

  • 每个项目的全局Promise捕获,希望每个项目有不同的错误码,所以在初始的时候monitor.init(),传入一个projectErrCode参数:
monitor.init({
  projectErrCode: 'ERR020000',
  其他选项,
  // ...
})
  • 因为现在wrapperRequest这个 redux 中间件里把请求的错误都抛出了,所以在使用的时候,通过setCustomError把相关的一些错误信息配置到error对象上,方便全局统一捕获
import { setCustomError  } from "@loyalvalleycapital/monitor";
.catch(error => {
	next({
		type,
		payload: {
			error,
			loading: false,
			status: 'failure',
			params,
		},
	});
	if (errorCallback) errorCallback();
	// 这里
	setCustomError(error, {
		code: 'ERR02000002',
		custom: payload
	})
	return Promise.reject(error);
)

上面的错误码只是示例,具体的项目可以自定义,定义的时候可以在这里维护下