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

@wasu-jssdk/track

v1.1.2

Published

WASU WEB全埋点插件,基于[sensors 神策数据分析](https://manual.sensorsdata.cn/sa/latest/zh_cn/tech_sdk_client_web-1573905.html)二次开发,结合数据接口接入已有API,方便使用。

Downloads

284

Readme

@wasu-jssdk/track

WASU WEB全埋点插件,基于sensors 神策数据分析二次开发,结合数据接口接入已有API,方便使用。


特性

  • 全埋点支持,默认包含页面浏览、页面加载时间、页面停留时间等数据采集自动批量上报
    • 埋点事件
      • MPPageView 页面浏览事件
      • MPPageLoad 页面加载时间事件
      • MPPageLeave 页面leave事件
    • 自定义埋点
      • MPClick 页面元素点击

安装

安装依赖

npm install @wasu-jssdk/track -S

使用

1、快速使用
import { wasuTrackInit } from '@wasu-jssdk/track'

// 项目全局初始化
wasuTrackInit({
  server_url: 'https://xxxxxxx', // 埋点url
  app_name: 'xxxx' //项目名称埋点标识, 必填, 用于区分项目
})
2、SDK 初始化参数

| 参数名 | 类型 | 必填 | 默认值 | 描述 | | -------------------- | ------------------ | ---- | ------ | --------------------------------------------- | | app_name | string | 是 | - | 项目标识,用于区分项目,建议:xmClub-20241010 | | url | string | 是 | - | 埋点url | | is_track_single_page | boolean |function | 否 | true | 是否是单页面埋点,默认开启 | | show_log | boolean | 否 | false | 是否允许控制台打印查看埋点数据 | | channel | string | 否 | web | 渠道,可自定义其他类型,如:h5,app等 | | transformRequest | function | 否 | - | 埋点数据上报前,可做数据处理,默认不处理 |

注意

1 、is_track_single_page 为函数时,必须return一个值,用于排除哪些页面不采集埋点数据等功能

使用示例:

is_track_single_page : function (){
	return true 时候,使用默认发送的 $pageview, 表示当前页面会发送数据
	return false 时候,不执行默认的 $pageview, 表示不会发数据
	return {} 时候,把对象中的属性,覆盖默认 $pageview 里的属性。表示会把对象的属性新增到当前 $pageview 里。
}

2、transformRequest 配置为函数时,必须return一个处理后的数组。可用于对特定页面、特定事件追加参数/标识等功能

使用示例:

transformRequest: function (data) {
  data.map(item => {
    item.properties.objectId = handlePageFlag(item.properties)
  })

  return data
}


// 业务逻辑,给特定页面增加参数标识
function handlePageFlag(props) {
  let objectId = null
  const { url } = props ?? {}
  const index = url.indexOf('?')
  let query = ''
  if (index !== -1) query = url.substring(index + 1)

  if (url.includes('pages/detail/activity')) {
    objectId = getQueryParam(query, 'id')
  }
  // ...

  return objectId
}
3、点击事件埋点
  • 事件回调埋点

用法:window.wasuDataAnalytic.trackClick(props, cb)

`props`: 自定义按钮信息Object
`cb`: 完成埋点发送的事件回调

使用示例

原生js写法

// 下面演示一个 button 按钮被点击时触发预置的元素点击事件

$('#testp').on('click', function () {
  wasuDataAnalytic.trackClick({ objectId: 'testp' })
})
4、自定义埋点

基本用法window.wasuDataAnalytic.track(eventName, props, cb)

eventName: 事件名称 - 命名要求:以MP开头,如:MPClick,驼峰命名

自定义埋点事件或trackClick点击事件如果需要立即发送埋点日志数据,需在事件附加参数中新增字段 send_immediate设置为true

立即触发埋点数据上报使用示例

$('#testp').on('click', function () {
  wasuDataAnalytic.trackClick({
    send_immediate: true
    // ... 其他附加参数
  })
})

// 自定义事件
window.wasuDataAnalytic.track(
  eventName,
  {
    send_immediate: true
    // ... 其他附加参数
  },
  cb
)

用户关联

  • 事件: SignUp

未登录时,sdk会创建一个匿名id。创建关联用户,登录后会关联用户

用法:window.wasuDataAnalytic.login(用户uid) 使用示例

window.wasuDataAnalytic.login(uid)
  • 事件: MPLogout

退出登录,取消用户关联

用法:window.wasuDataAnalytic.logout()

使用示例

window.wasuDataAnalytic.logout()