# monitor-rcl

> monitor-rcl

Latest version **0.1.1** (published 2017-11-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install monitor-rcl
pnpm add monitor-rcl
yarn add monitor-rcl
bun add monitor-rcl
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2017-11-15 |
| First published | 2017-11-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | fnatic |
| Maintainers | fnatic |
| Keywords | retcode, log |

## Links

- npm: https://www.npmjs.com/package/monitor-rcl
- npm.io page: https://npm.io/package/monitor-rcl

## Dependencies (7)

- [babel-cli](https://npm.io/package/babel-cli.md) ^6.26.0
- [babel-watch](https://npm.io/package/babel-watch.md) ^2.0.7
- [babel-loader](https://npm.io/package/babel-loader.md) ^7.1.1
- [babel-preset-es2015](https://npm.io/package/babel-preset-es2015.md) ^6.24.1
- [babel-preset-stage-0](https://npm.io/package/babel-preset-stage-0.md) ^6.24.1
- [babel-plugin-transform-runtime](https://npm.io/package/babel-plugin-transform-runtime.md) ^6.23.0
- [babel-plugin-add-module-exports](https://npm.io/package/babel-plugin-add-module-exports.md) ^0.2.1

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.1.1 (latest) — 2017-11-15
- 0.1.0 — 2017-11-15

## README

# retcode log上报脚本

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

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

1. 引入npm包
```
tnpm install @ali/retcodelog --save
```
2. 在代码中配置,并上报
 
```javascript
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. 配置
```javascript
window.__WPO = {
    config: {
        sample: 100, // 抽样率，100 = 1%，1 = 100%，默认100
        spmId: 'xxx', // spmId
        startTime: xxx, // 自定义测速类页面统计起始时间
        dynamic: true // 是否启用动态配置
    }
};
```

2. 页面中引入脚本
```html
<script src="//g.alicdn.com/retcode/log/log.js"></script>
```

3. 或者在**引入脚本后**通过`setConfig`接口配置
```javascript
window.__WPO.setConfig({
    sample: 100, // 抽样率，100 = 1%，1 = 100%，默认100
    spmId: 'xxx', // spmId，如果没写默认值，会自动抓页面的spm
    modVal: 1, // 抽样的取值，取模后的数值==该值的认为符合抽样，以页面uid作为基数来抽样，默认1
    startTime: xxx, // 自定义测速类页面统计起始时间
});
```

4. 上报
```javascript
__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演示代码
- [浏览器 - cdn引入模式](http://gitlab.alibaba-inc.com/retcode/log/tree/master/demo/browser-cdn)
- [浏览器 - npm包引入模式](http://gitlab.alibaba-inc.com/retcode/log/tree/master/demo/browser-npm)
- [nodejs环境](http://gitlab.alibaba-inc.com/retcode/log/tree/master/demo/nodejs)
- [weex环境](http://gitlab.alibaba-inc.com/retcode/log/tree/master/demo/weex)
- [weex-rx环境](http://gitlab.alibaba-inc.com/retcode/log/tree/master/demo/weex-rx)

## 接口
- [《retcode用户手册》日志上报API定义](http://groups.alidemo.cn/retcode/handbook/_book/senior/log-report.html)

# History
- [HISTORY.md](http://gitlab.alibaba-inc.com/retcode/log/blob/master/HISTORY.md)

---
_Source: https://npm.io/package/monitor-rcl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
