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 🙏

© 2026 – Pkg Stats / Ryan Hefner

nw-log-distribution

v2.34.1

Published

分流打点组件,根据配置实现将某个点打到哈勃或部门点接收平台

Readme

nw-log-distribution

分流打点组件

重要更新日志

  • 2026-06-04 2.32.15版本SDK新增ENV.GAME环境和APP_KEY.GAME,用于游戏场景的打点上报。
  • 2024-04-02 2.32.2版本SDK增加了getClientHubbleDeviceIdgetClientCustomUDID同步方法,用于获取设备ID。
  • 2022-09-06 2.25.2版本SDK在attributes参数增加了一个method属性,值为get|post,指定打点请求通过GET还是POST方式发送,不传默认为POST方式。
  • 2022-07-26 2.20.0版本SDK增加了客户端7.1.0以上版本自动读取UA中的hubble deviceId,附带在attributes中上报的功能。
  • 2021-12-17 2.18.0版本SDK支持在打点时指定useAppTrack,用于在某些特定的打点选择是否通过app上传,用法见下面示例。
  • 2021-10-21 2.16.0版本SDK支持在打点时指定activityId,用于在某些特定的打点上附加指定activityId,用法见下面示例。
  • 2021-08-18 2.14.0版本SDK实例化增加一个参数activityId,用于上报打点的attributes中附加指定activityId,使得活动数据报表系统能够实现自动收集。
  • 2020-08-05 本SDK改为全部向分流服务器打点,不再发送到哈勃,所以不再需要传入pointConfig

安装

$ yarn add nw-log-distribution

example

import {ENV,APP_KEY,HubLog as Log} from 'nw-log-distribution';

const log = new Log({
    userId: '',
    key: APP_KEY.PC | APP_KEY.H5 | APP_KEY.GAME, // 根据当前开发的环境选择正确的appkey
    hbInitOptions: {
        truncateLength: 255,
        persistence: "localStorage",
        cross_subdomain_cookie: true
    },
    k: 'lofter',
    v: '6.15.0',
    env: ENV.ST,
    activityId: 'ac-log' // 非必须,SDK 初始化传入activityId,后续所有打点都会带上activityId
})

log.capture('h5-4-1', {
  category: 'h5-4',
  activityId: 'ac-log', // 非必须,只有本次打点带上activityId,同时会覆盖SDK初始化的activityId
  useAppTrack: false    // 非必须,针对某一打点设置是否通过app上传,不传默认为false,既默认使用js ajax上传,true则通过app上传
})

// 获取hubble sdk deviceId
const deviceId = log.getClientHubbleDeviceId();
// 获取customUDID,客户端协议header中会附带的设备id
const customUDID = log.getClientCustomUDID();

开发

  1. 如果没有修改DATracker.sync._yuedu1.6.12.4.js上报SDK,直接执行第4步;
  2. 如果有修改DATracker.sync._yuedu1.6.12.4.js上报SDK,则先执行npm run upload,将上报SDK的代码压缩并上传;
  3. 压缩上传后的地址会自动写入剪切板,将该地址复制到/src/index.js_initHB方法中;
  4. 执行npm run build,打包esiife两种格式的Log SDK;
  5. Git提交清晰完整的commit msg,然后在根目录执行npm run publish

ST平台验证注意事项

userAgent

本地开发验证打点时,k需要指定为lofter,同时浏览器的userAgent需要设置为符合对应的平台特征,否则在对应的平台会找不到打点记录,因为st平台会根据打点请求的userAgent来判断打点请求所对应的平台是WebH5还是其他。

版本号

本地开发验证打点时,v注意指定准确的统计点所属版本号,如果不指定统计点版本号,st平台会认为统计点属于最新版的版本号,可能会出现版本不匹配的问题。

API

{{>main}}