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

@aligov/retcodelog

v0.3.5

Published

retcode log上报npm包,适用于 browser|nodejs|weex|E应用

Downloads

41

Readme

retcode log上报脚本

通过npm包引用(browser/weex/rax/nodejs/E应用)

http://web.npm.alibaba-inc.com/package/@ali/retcodelog

  1. 引入npm包
tnpm install @ali/retcodelog --save
  1. 在代码中配置,并上报
var wpo = require('@ali/retcodelog');

// 配置
wpo.setConfig({
    //抽样分母,1代表100%上报,10代表10%上报,100代表1%上报
    sample: 1,
    // spmId必须设置,如果没写默认值,会自动抓页面的spm
    spmId: '', 
    // weex容器内上报必须配置
    request: require('@weex-module/stream').fetch,
    // 取nick name需要用到cookie
    cookie: '',
    // 报错过滤,**符合**特征的会被**过滤**,可设置RegEx,function或string
    errMsgFilter: /(debug)|(testing)/  ,
    // weex request callback,可选,只在weex native环境下有效,response参考
	// [weex文档](http://weex.apache.org/references/modules/stream.html#fetch-options-callback-progresscallback)
	requestCallback: function(response, requestUrl){},
    // 标签,支持String或者Function
    tag: 'new tag'
});

// 上报
wpo.error('testing...');
wpo.retCode('api', true, 100, 'testing api sampling');

E应用使用retcode文档移步

TIPS

  1. 浏览器环境下,借助webpack等工具,也可以引入npm包版本的retcodelog
  2. weex容器内上报时,必须配置request = require('@weex-module/stream').fetch

通过cdn地址引用(browser)

http://g.alicdn.com/retcode/log/log.js

  1. 配置
window.__WPO = {
    config: {
        sample: 100, // 抽样率,100 = 1%,1 = 100%,默认100
        spmId: 'xxx', // spmId
        startTime: xxx, // 自定义测速类页面统计起始时间
        dynamic: true, // 是否启用动态配置
        errMsgFilter: (msg) => {return (/Uncaught Error/.test(msg) && /test/.test(msg));} // 报错过滤,**符合**特征的会被**过滤**,可设置RegEx,function或string
    }
};
  1. 页面中引入脚本
<script src="//g.alicdn.com/retcode/log/log.js"></script>
  1. 或者在引入脚本后通过setConfig接口配置
window.__WPO.setConfig({
    sample: 100, // 抽样率,100 = 1%,1 = 100%,默认100
    spmId: 'xxx', // spmId,如果没写默认值,会自动抓页面的spm
    modVal: 1, // 抽样的取值,取模后的数值==该值的认为符合抽样,以页面uid作为基数来抽样,默认1
    startTime: xxx, // 自定义测速类页面统计起始时间
    errMsgFilter: 'testing' // 报错过滤,**符合**特征的会被**过滤**,可设置RegEx,function或string
});
  1. 上报
__WPO.error('testing...');
__WPO.retCode('api', true, 100, 'testing api sampling');

TIPS

  1. @param dynamic无法通过setConfig来配置
  2. 地址中加入wpodebug=1进入debug模式,强制sampling=1,modVal=1;100%发送请求
  3. 用户的淘宝昵称会默认上报,userNick来自于cookie中的以下字段_nk_ | _w_tb_nick_ | lgc
  4. 通过地址 http://g.alicdn.com/retcode/log/log.debug.js 可以引用到未压缩版的log.js用于本地调试日志上报

demo演示代码

接口

History