2.2.2 • Published 3 years ago

wd-web-log v2.2.2

Weekly downloads
136
License
MIT
Repository
github
Last release
3 years ago

wd-web-log

a simple web log 埋点统计插件,支持腾讯 百度,友盟

npm Build Status npm install size GitHub license

开发调试

安装相关依赖,执行

npm run dev

浏览器打开 examples 文件夹下 html 即可调试

构建

npm run build

配置

npm

npm i wd-web-log
// config
const config = {
  // 是否自动收集点击事件
  autoClick: false,
  // 是否开启自动上报 若关闭自行请在在事件中手动上报
  autoSend: true,
  // 是否开启异常上报
  autoError: false,
  // 异常上报
  autoErrorSend: false,
  // 开启debug
  debug: false,
  // 上报平台 目前支持 baidu,uweb
  type: 'uweb',
  // 上报平台配置
  config: {},
  // 发送事件
  onSend: (sendEvent, sendData, reporter, event) => {},
  // 错误捕捉
  onError: (error) => {},
}

使用

config--上报平台配置

腾讯 uweb

参数必输默认说明备注
sid统计用的 appid
cid如果开启自定义事件,此项目为必填,否则不填
autoReport是否开启自动上报(1:init 完成则上报一次,0:使用 pgv 方法才上报)
senseHashhash 锚点是否进入 url 统计
senseQueryurl 参数是否进入 url 统计
autoReport绑定要接受 API 请求的统计代码 siteid
performanceMonitor是否开启性能监控
ignoreParams开启 url 参数上报时,可忽略部分参数拼接上报

友盟 uweb

参数必输默认说明备注
siteId绑定要接受 API 请求的统计代码 siteid
autoPageviewtrue是否开启自动统计 PV
src精简代码 http://s11.cnzz.com/z_stat.php?id=SITEID&web_id=SITEID指定统计脚本标签的 src 属性

百度 baidu

参数必输默认说明备注
siteId绑定要接受 API 请求的统计代码 siteid
src精简代码 https://hm.baidu.com/hm.js?SITEID指定统计脚本标签的 src 属性
// vue
import Logger from 'wd-web-log'
Vue.use(Logger.Vue, config)

// use v-log="'event'" or v-log="{event:'',data:{}}"
this.$stat({
  event: '',
  data: {},
})
// uweb原生方法
this.$wdLog.reporter.setAccount(siteId)

import Logger from 'wd-web-log'
Logger()
// uweb example
Logger.send('')
// uweb 原生方法
Logger.reporter.pgv()

浏览器

<script src="https://cdn.jsdelivr.net/npm/wd-web-log/dist/wd-web-log.js"></script>
<script>
  WdWebLog({
    debug: true,
    // autoSend: true,
    autoSend: false,
    // 是否开启异常上报
    autoError: true,
    // 开启debug
    debug: true,
    // 上报平台 支持 baidu,uweb
    type: 'uweb',
    // 上报平台配置
    config: {},
    // 发送事件
    onSend: (sendEvent, sendData, reporter, event) => {
      console.log(sendEvent)
      // reporter.send(sendEvent, sendData)
      reporter.send('sendEvent' + sendEvent, sendData)
    },
    // 错误捕捉
    onError: (error) => {
      console.log('异常捕捉:', error)
    },
  }).then(function (logger) {
    document.querySelector('#test').addEventListener('click', function (e) {
      logger.send('test')
      // logger.send({});
    })
  })
</script>
2.2.2

3 years ago

2.1.0

3 years ago

2.0.8

3 years ago

2.0.5

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.3

3 years ago

2.0.4

3 years ago

2.0.2

4 years ago

2.0.1

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

1.0.0

4 years ago