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

jz-policy-stat-helper

v0.1.0

Published

用户操作日志记录辅助工具(内部使用)

Downloads

12

Readme

jz-policy-stat-helper

使用说明

记录与上报是在同一个页面

import PolicyStat from "jz-policy-stat-helper";

// 第一步: 实例化,实例化时可预先填入已知的配置
const ps = new PolicyStat({project: '0001', version: '0.2.1'})

// 第二步: 配置要上报的数据
// 配置用户id、订单号、操作类型
ps.config({uid: 'xxx', orderNo: 'xxx', event: '下单'})

// 添加操作日志(内部会根据name参数进行去重)
ps.append({name: '勾选阅读须知', value: ''})
ps.append({name: '取消勾选阅读须知', value: ''})

// 第三步: 调用report上报
ps.report()

记录与上报不在同一个页面

// 页面1
import PolicyStat from "jz-policy-stat-helper";

// 第一步: 实例化,实例化时可预先填入已知的配置
const ps = new PolicyStat({project: '0001', version: '0.2.1'})

// 第二步: 配置要上报的数据
// 配置用户id、订单号、操作类型
ps.config({uid: 'xxx'})

// 添加操作日志(内部会根据name参数进行去重)
ps.append({name: '勾选阅读须知', value: ''})
ps.append({name: '取消勾选阅读须知', value: ''})

// 第三步: 离开页面之前调用save命令保存本页面的操作
ps.save('storage_key_prefix', window.localStorage.setItem.bind(window.localStorage))
// 页面2
import PolicyStat from "jz-policy-stat-helper";

// 第四步: 在下一个页面从缓存中读取
let ps = new PolicyStat()
ps = ps.restore('storage_key_prefix', window.localStorage.getItem.bind(window.localStorage))

// 可继续添加配置与操作记录
ps.config({orderNo: 'xxx', event: '下单'})
ps.append({name: '阅读保险条款', value: ''})

// 第五步: 调用report
ps.report()

API

构造函数与config

这两处都可以填入配置信息,当前内部共有5个配置项:

  1. project 项目标识
  2. uid 用户id
  3. orderNo 订单号
  4. version 项目版本
  5. event 操作类型

在调用report之前需要保证所有这5个配置都已填入。

append

用来记录用户的操作日志

save

如果涉及跨页面的话,可以使用save接口把当前页面已经记录的操作和配置保存到缓存

restore

如果涉及跨页面的话,可以使用restore接口恢复前一个页面保存的配置

report

调用该接口会自动把当前所记录的操作提交给服务器,并且会清空所有通过append记录的日志
注意:通过config填入的配置不会被删除