npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wd-web-log

v2.2.2

Published

a simple web log sdk

Downloads

164

Readme

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 方法才上报) | | | senseHash | 否 | | hash 锚点是否进入 url 统计 | | | senseQuery | 否 | | url 参数是否进入 url 统计 | | | autoReport | 否 | | 绑定要接受 API 请求的统计代码 siteid | | | performanceMonitor | 否 | | 是否开启性能监控 | | | ignoreParams | 否 | | 开启 url 参数上报时,可忽略部分参数拼接上报 | |

友盟 uweb

| 参数 | 必输 | 默认 | 说明 | 备注 | | ------------ | ---- | --------------------------------------------------------------- | ------------------------------------ | ---- | | siteId | 是 | | 绑定要接受 API 请求的统计代码 siteid | | | autoPageview | 否 | true | 是否开启自动统计 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>