New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

monitor-rcl

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monitor-rcl

monitor-rcl

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

retcode log上报脚本

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

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: ''
});

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

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 // 是否启用动态配置
    }
};
  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, // 自定义测速类页面统计起始时间
});
  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

Keywords

FAQs

Package last updated on 15 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc