# nw-log

> > 打点组件

Latest version **2.3.0** (published 2021-04-30) · 0 weekly downloads

## Install

```sh
npm install nw-log
pnpm add nw-log
yarn add nw-log
bun add nw-log
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.0 |
| Published | 2021-04-30 |
| First published | 2017-11-18 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 18.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | azgaga, liushichuan, yaochen, shenyuan, aflyermin, ignous, jeekdong, yun77op |

## Links

- npm: https://www.npmjs.com/package/nw-log
- npm.io page: https://npm.io/package/nw-log

## Dependencies (1)

- [qs](https://npm.io/package/qs.md) ^6.5.2

## Recent versions

- 2.3.0 (latest) — 2021-04-30
- 2.2.3 — 2020-11-11
- 1.22.0 — 2018-10-22
- 1.21.9 — 2018-10-19
- 1.21.5 — 2018-10-19
- 1.17.6 — 2018-06-07
- 1.11.3 — 2017-12-04
- 1.9.6 — 2017-11-19
- 1.9.5 — 2017-11-19
- 1.9.4 — 2017-11-18

## README

# nw-log

> 打点组件

## 安装

```sh
$ yarn add nw-log
```
## example

```javascript
import Log, {ENV} from 'nw-log';

const log = new Log({
    env: ENV.GA,
    key: 'comic',
    userId: '23223' 
});

log.capture('hds-2:nwe,sdf,s');
```

### 哈勃平台实例化完毕之后即可统计pv,uv

## API

## Classes

<dl>
<dt><a href="#Log">Log</a></dt>
<dd><p>Log</p>
</dd>
</dl>

<a name="Log"></a>

## Log
Log

**Kind**: global class  
<a name="new_Log_new"></a>

### new Log(props)

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| props | <code>Object</code> |  |  |
| props.userId | <code>string</code> |  | 用户id |
| props.key | <code>string</code> |  | 产品id(哈勃平台传入AppKey) | 
| [props.env] | [<code>ENV</code>](#ENV) | <code>ENV.ST</code> | 环境，`ENV.ST`记录到打点验证平台，`ENV.GA`记录到ga平台，`ENV.HB`记录到哈勃平台，默认记录到打点验证平台 |

<a name="ENV"></a>

## ENV : <code>enum</code>
Enum env values.

**Kind**: global enum  
**Read only**: true  
**Properties**

| Name | Type | Default |
| --- | --- | --- |
| ST | <code>string</code> | <code>&quot;ST&quot;</code> | 
| GA | <code>string</code> | <code>&quot;GA&quot;</code> |
| HB | <code>string</code> | <code>&quot;HB&quot;</code> | 

## 关于登录

#### 哈勃会自动生成一个deviceUDID存储在cookie中，作为匿名用户的唯一标识，但是在用户登录之后，推荐传入一个userId，用于标识登录用户，这对数据分析有帮助。


#### 调用此方法之后，后续的事件都会使用这新的userId
```
log.login(userId)
```

#### 切换成匿名用户

```
log.logout()
```

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