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

vk-track

v2.1.1

Published

前端业务打点系统

Readme

vk-track 自研业务日志埋点前端SDK


背景:提供统一的接入管理、全球加速、跨洋专线传输、数据监控、清洗、备份、查询等功能,并保证业务系统对数据服务稳定性、数据完整性、实时性的要求,我们联合运维、BI团队,准备推出一套公司级的前端业务打点系统,覆盖公司所有业务线对前端业务数据打点的需求,同时最大程度为公司节省成本。

安装方法

方式1: npm install vk-track --save --registry=http://registry.vnpm.vipkid.com.cn

方式2: npm install http://registry.vnpm.vipkid.com.cn/vk-track/-/vk-track-2.0.7.tgz --save // 2.0.7为版本号

使用方法

import vktrack from 'vk-track'
const cookies = require('cookies-js')

vktrack.toolDebug = true  //打点类型错误提示log 默认fasle

vktrack.init({
  app_id: '' // 需要到后台申请app_id, 必须
})

// 默认触发$pageview,配置全局打点携带字段
vktrack.register({
  business: 'parent_h5', //必须
  product: 'parent', // 必须
  parent_id: '', // 非必须
  student_id: () => {return cookies.get('mbstudentid') || ''}, //function 动态赋值, 非必须
})


// click 打点, vktrack.click(clickId, otherObj), 需要附带其他打点信息,可通过otherObj设置, 非必须
vktrack.click('parent_h5_teacherlist_timefilter_click', {content_title:'vipkid'})

// trigger 打点,vktrack.trigger(triggerId, otherObj), 需要附带其他打点信息,可通过otherObj设置
vktrack.trigger('parent_h5_booktab_fixedClass_success')

API

toolDebug

控制console.log提示的开关,默认false, 需要进行 vktrack.toolDebug = true设置

init

vktrack.init({app_id: ''})

| name | type | require | desc | | -------- | -----: | ----: | :-----: | | app_id | String | true | 后台生成的app_id

register

vktrack.register({event_content: 'example'}) // 自动打点pageview, key要为打点约定字段和约定字段类型

click

vktrack.click(triggerId, otherObj)

| name | type | require | desc | | -------- | -----: | ----: | :-----: | | clickId | String | true | 点击事件类型打点 | | otherObj | Object | false | 用来设置其他打点时需要设置的约定字段 |

trigger

vktrack.trigger(triggerId, otherObj)

| name | type | require | desc | | -------- | -----: | ----: | :-----: | | triggerId | String | true | 接口事件类型打点 | | otherObj | Object | false | 用来设置其他打点时需要设置的约定字段 |

约定规则列表字段

约定规则列表,如果类型错误,控制台会提示错误,举例如下:

// 验证不通过,不进行打点,因为course_id是 Number类型
vktrack.click(parent_h5_teacherlist_timefilter_click, {course_id:  '1111', content_title:'vipkid'})

文档记录

BI团队制定了此打点规范,后续业务打点均遵循此规范执行 埋点规范及可选字段

注意事项

如果验证不通过,则在浏览器控制台有提示