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 🙏

© 2025 – Pkg Stats / Ryan Hefner

za-js-sdk

v4.19.2

Published

## 使用

Downloads

38

Readme

za-js-sdk

使用

从 npm 引入是推荐的方式,便于安装和管理:

import za from 'za-js-sdk'

// 记录页面展现
za.trackPageShow(view, extra)
// 记录元素展现
za.trackShow(ElementInfo)
// 记录元素点击
za.trackClick(ElementInfo)
// 记录s事件
za.trackEvent({...ElementInfo, eventType})
// 记录链接打开
za.trackOpenUrl(ElementInfo, ExtraInfo)

备选的引用方式是从 CDN 引入,然后使用全局对象 za 来访问接口:

<script src="https://unpkg.zhimg.com/za-js-sdk@2.24.6/dist/loader.js"></script>

注:可以使用 npm dist-tag za-js-sdk 来查询最新的版本号。

ElementInfo 的字段定义如下:

| 名称 | 类型 | 必填 | 说明 | | ------- | -------- | ------- | ----------------------------------------------------------------------------------------- | | type | string | true | 元素类型,可能的值为 Button\|Text\|Image\|Page\|Audio\|Video\|Block\|Popup\|File\|Input | | block | string | false | 元素标识,可以为任意值 | | text | string | false | 元素文本,可以为任意值 |

ExtraInfo 的字段定义如下:

| 名称 | 类型 | 必填 | 说明 | | ----- | -------- | ------- | ------------------------ | | url | string | false | 元素标识,可以为任意网址 |

样例

// 记录页面展示
za.trackPageShow({
  element_location: {
    page: {page_id: '111', page_level: 4},
    url: 'https://www.zhihu.com#hash',
  },
})
// 记录 Reaction 弹层展示
za.trackShow({type: 'Popup', block: 'ReactionList'})
// 记录 Reaction 按钮点击
za.trackClick({type: 'Button', block: 'AddReaction', text: '赞'})
za.trackClick({type: 'Button', block: 'AddReaction', text: '踩'})
// 记录上划事件
za.trackEvent({eventType: 'SwipeUp', type: 'Card'})
// 记录返回首页
za.trackOpenUrl({type: 'Button', block: 'Home'}, {url: 'https://www.zhihu.com'})

线上的示例程序可以查看:https://codesandbox.io/s/za-js-sdk-yl7cs