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

data-tracker-uni

v0.1.18

Published

非通用埋点追踪器,仅适用于 uni-app 的app前端项目。

Readme

data-tracker-uni

非通用埋点,仅适用于 uni-app 的 app 前端项目。

安装

npm install data-tracker-uni

使用方法

1. 在 main.js 引入并全局挂载

import Tracker from "data-tracker-uni";

const tracker = new Tracker({
  uni, // 传入 uni 实例
  serverUrl: "http://your-server-url/openapi/gateway", // 埋点服务端地址
  method: "dronehome.burypoint.put", // 上报方法(后端提供)
  appSecret: "你的私钥", // 必选,用于签名
  pagesJson: pagesJson, // 必选,pages.json 配置
  appId: "1001", // 应用ID(可选,默认1001)
  version: "1.0.0", // 埋点版本(可选,默认1.0.0)
  batchDelay: 10000, // 批量发送延迟(ms),可选,默认10000
});

uni.$tracker = tracker; // 全局挂载

2. 初始化埋点系统(建议在应用启动时调用)

await uni.$tracker.init(); // 必须初始化埋点

3. 常用埋点方法

  • 页面访问统计
    uni.$tracker.trackPageView("热门");
  • 视频点击统计
    uni.$tracker.trackVideoClick("v_click", "热门", { id: 123, title: "xxx" });
  • 搜索事件
    uni.$tracker.trackSearch("无人机");
  • 视频发布
    uni.$tracker.trackVideoPublish("热门", { id: 123, title: "xxx" });
  • 用户注册
    uni.$tracker.trackUserRegister({ mobile: '138****8888', ... })
  • 通用点击事件统计
    uni.$tracker.trackClickEvent("事件名称", "菜单名称", { 事件参数 });
  • 应用启动
    uni.$tracker.trackAppStart();
  • 用户信息变更(如登录/登出/资料变更)
    uni.$emit("storageChange", "userInfo");

4. 销毁与清理

  • 应用退出时建议调用:
    uni.$tracker.destroy();
  • 如需手动清理批量发送定时器:
    uni.$tracker.clearBatchTimer();

参数说明

| 参数 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | -------------------------- | | uni | Object | 是 | uni-app 实例 | | serverUrl | String | 是 | 服务端地址 | | method | String | 是 | 上报方法 | | appSecret | String | 是 | 用于签名的密钥 | | pagesJson | Object | 是 | pages.json 配置 | | appId | String | 否 | 应用 ID,默认 1001 | | version | String | 否 | 埋点版本,默认 1.0.0 | | batchDelay | Number | 否 | 批量发送延迟,默认 10000ms |

后端参数说明

数据类型=1(应用启动)

  • data_type: 数据类型 1
  • deviceId: 设备 id
  • osName: 操作系统 android、ios
  • pt: 平台类型 app、h5、mp-weixin
  • v: 应用版本
  • timestamp: 时间戳
  • uid: 用户唯一标识(从本地存储的 userInfo.userId 获取,未登录时为空字符串)
  • user: 手机号(从本地存储的 userInfo.mobile 获取,未登录时为空字符串)
  • ut: 用户类型(根据 user.userId 判断,"正式"或"游客")
  • url: 当前页面的完整 url,包含参数在内
  • ttc: 页面当前的 title
  • ttct: 二级 tab 的 title 如热门、关注等
  • prop:
    • net: 网络类型 (wifi/2g/3g/4g/5g/ethernet/unknown/none 等)
    • md: 手机型号
    • brand: 设备品牌 (小米/华为/苹果等)

数据类型=11(页面跳转)

  • data_type: 数据类型 11
  • deviceId: 设备 id
  • pt: 平台类型 app、h5、mp-weixin
  • osName: 操作系统
  • v: 应用版本
  • timestamp: 时间戳
  • uid: 用户唯一标识(从本地存储的 userInfo.userId 获取,未登录时为空字符串)
  • user: 手机号(从本地存储的 userInfo.mobile 获取,未登录时为空字符串)
  • ut: 用户类型(根据 user.userId 判断,"正式"或"游客")
  • url: 当前页面的完整 url,包含参数在内
  • ttc: 页面当前的 title
  • ttct: 二级 tab 的 title 如热门、关注等
  • prop: {}

数据类型=101(事件触发)

  • data_type: 数据类型 101
  • deviceId: 设备 id
  • pt: 平台类型 app、h5、mp-weixin
  • osName: 操作系统
  • v: 应用版本
  • timestamp: 时间戳
  • uid: 用户唯一标识(从本地存储的 userInfo.userId 获取,未登录时为空字符串)
  • user: 手机号(从本地存储的 userInfo.mobile 获取,未登录时为空字符串)
  • ut: 用户类型(根据 user.userId 判断,"正式"或"游客")
  • url: 当前页面的完整 url,包含参数在内
  • ttc: 页面当前的 title
  • ttct: 二级 tab 的 title 如热门、关注等
  • prop:
    • e_n: 事件名称
    • e_p: 事件参数 (JSON 格式)

常见事件类型

  • 注册:

    • e_n: register
    • e_p: 注册时的全部参数
  • 搜索:

    • e_n: search
    • e_p: 搜索的词
  • 视频点击:

    • e_n: v_click
    • e_p: 点击时的全部参数
  • 推荐视频点击:

    • e_n: rv_click
    • e_p: 点击时的全部参数
  • 搜索结果视频点击:

    • e_n: svr_click
    • e_p: 点击时的全部参数
  • 发布视频:

    • e_n: pub_r
    • e_p: 发布时的全部参数
  • 所有参数均有类型和有效性校验,传参错误会抛出异常。

设备与用户信息

  • 设备信息:deviceId, osName, brand, md, pt, v

    • brand 设备品牌 如:apple、huawei 等 字段为全小写
    • osName 操作系统 android、ios
    • md 设备型号
    • pt 平台类型 app、h5
    • v 应用版本
  • 用户信息:uid, user, ut

    • uid 用户 id
    • user 手机号
    • ut 用户类型(正式/游客)

事件类型说明

  • data_type: 1=应用启动,11=页面跳转,101=事件触发
  • 常用事件名(后续根据后端定义的事件名进行添加):
    • v_click:视频点击
    • svr_click 搜索结果视频点击
    • rv_click 推荐视频点击
    • search:搜索
    • pub_r:发布视频
    • register:注册

说明

  • 需在 uni-app 环境下使用,并传入 uni 实例。
  • serverUrl、appSecret 等参数请根据实际后端配置填写。

如有问题欢迎反馈。