nw-log
打点组件
安装
$ yarn add nw-log
example
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
- Log
-
Log
Log
Log
new Log(props)
Param | Type | Default | Description |
---|---|---|---|
props | Object |
||
props.userId | string |
用户id | |
props.key | string |
产品id(哈勃平台传入AppKey) | |
[props.env] | ENV |
ENV.ST |
环境,ENV.ST 记录到打点验证平台,ENV.GA 记录到ga平台,ENV.HB 记录到哈勃平台,默认记录到打点验证平台 |
enum
ENV : Enum env values.
Kind: global enum
Read only: true
Properties
Name | Type | Default |
---|---|---|
ST | string |
"ST" |
GA | string |
"GA" |
HB | string |
"HB" |
关于登录
哈勃会自动生成一个deviceUDID存储在cookie中,作为匿名用户的唯一标识,但是在用户登录之后,推荐传入一个userId,用于标识登录用户,这对数据分析有帮助。
调用此方法之后,后续的事件都会使用这新的userId
log.login(userId)
切换成匿名用户
log.logout()