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

lzx-analysis

v1.1.11

Published

乐知行通用统计组件

Readme

引用

从static中引用统计js, 传入统计的配置地址。

<head>
    <script type="text/javascript" src="/static/script/lzx-analysis.min.js"></script>
</head>
<body>
   <script>
     var analy = new LzxAnalysis({
		url:  '/lexueserver/config/statistics.do?configId=tongji-wenjuan' // 如果是非前后分类,可以不传参数
	 })
   </script>
</body>

对应前后端分离的项目,还可以使用npm方式安装lzx-analysis

npm install --save  lzx-analysis

调用方式不变

import { LzxAnalysis } from 'lzx-analysis'
var analy = new LzxAnalysis({
url:  '/lexueserver/config/statistics.do?configId=tongji-wenjuan'
})

注意:一个单页面应用或者一个页面,除非有特殊情况。建议只初始化(new LzxAnalysis)一次。 url表示获取统计代码的地址,前端找后端要,后端去看green

自定义事件

setEvent 如果项目处理基础的PV,UV统计之外,产品和运营还需要更多粒度的统计,可以调用自定义事件。例如智能考勤,用户点击跳过新手指引,产品希望记录点击跳过新手指引的人的用户名和学校名,给出的事件为ID click_znkq_web_xsts_cancel。则可以在界面上,用户触发点击跳过新手指引是,绑定事件然后触发如下代码。

analy.setEvent('click_znkq_web_xsts_cancel', {
    name: 'xxx',
    schoolName:  '北京实验xxx小学'
})

setCommonEventData 如果一个项目所有的自定义事件都需要传入一个公共数据,如用户角色和学习名称。可以在初始化后,设置自定义事件的公共数据。这样就不用每个自定义事件手动的去写这些数据了。

  analy.setCommonEventData({
    '用户角色': '教师',
	schoolName: '北京实验xxx小学'
  })

setAllEventCurrentTime 如果产品希望所有的自定义事件都带上当前时间,这只需要设置所有的自定义事件带上时间就好。

analy.setAllEventCurrentTime()

本地模拟

在没有获取到url的时候,本地开发时,可以在index.html head前面,加上下面的代码,来模拟,这个时候,调用new LzxAnalysis就不用穿url参数了;

<script>
var _lzxtongji_paq = _lzxtongji_paq || {};
(function() { 
    _lzxtongji_paq.app = "xxxx";
    _lzxtongji_paq.site = "xxx";
    _lzxtongji_paq.user = "xxx";
    _lzxtongji_paq.debug = true;
    
    var hm = document.createElement("script"); 
    var scriptVersion = new Date().getFullYear() + (new Date().getMonth() + 1) + new Date().getDate();
    hm.src = "http://public.res.lezhiyun.com/public-js/analysis.js?" + scriptVersion; 
    hm.defer = true;
    hm.async = 1;
    var s = document.getElementsByTagName("script")[0]; 
    s.parentNode.insertBefore(hm, s);
})(); 
</script>