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 🙏

© 2024 – Pkg Stats / Ryan Hefner

shuyilink-track

v1.0.10

Published

shuyilink 埋点 sdk

Downloads

5

Readme

Install

npm i shuyilink-track

Quick Start

import syTrack,{track} from 'shuyilink-track'
// 自定义事件 
// track(eventName:string, data:Object)
setTimeout(() => {
  track('$myEvent',{time:Date.now()})
}, 1000);

const heatmap = {
  scroll_delay_time: 4000, // 页面采集停留时长 默认 4s
  clickmap: 'default', // 是否开启点击图,default 表示开启,自动采集 $WebClick 事件,可以设置 'not_collect' 表示关闭。
  scroll_notice_map: 'default', // 是否开启触达图,not_collect 表示关闭,不会自动采集 $WebStay 事件,可以设置 'default' 表示开启。
  collect_tags: {
    div: {
      max_level: 1 // 默认是 1,即只支持叶子 div。可配置范围是 [1, 2, 3],非该范围配置值,会被当作 1 处理。
    },
    span: true,
    li: true,
    img: true,
    svg: true
    // ... 其他标签
  },
  loadTimeout: 3000,
  collect_url: function () {
    return true
  },
  // 此参数针对预置 $WebClick 事件(包括 quick('trackHeatMap') quick('trackAllHeatMap') 触发的)生效。
  collect_element: function (element_target) {
    return true
  },
  // 此参数针对预置 $WebClick 事件(包括 quick('trackHeatMap') quick('trackAllHeatMap') 触发的)生效。
  custom_property: function (element_target) {
    return true
  },
  collect_input: function (element_target) {
    return true
  },
  element_selector: 'not_use_id',
  renderRefreshTime: 1000
}

syTrack.init({
  // server_url: 'http://test-syg.datasink.sensorsdata.cn/sa?token=xxxxx&project=xxxxxx',
  // show_log: true,
  max_time_out: 30 * 1000, // 触发上报埋点的最小时延 设置为 0 则没有时延 全部上报
  max_queue_length: 5, // 触发上报埋点的最小队列长度
  is_track_single_page: true, // 单页面配置,默认开启,若页面中有锚点设计,需要将该配置删除,否则触发锚点会多触发 $pageview 事件
  use_client_time: true,
  send_type: 'beacon',
  $is_channel_callback_event: false,
  heatmap,
  onTracked: function (data) {
    // 处理你的上报逻辑
    console.log('🚀 ~ data', data)
  }
})

// 注册公共属性
const { appVersion, userAgent, platform, connection: { effectiveType } } = navigator
const globalProperties = {
  platform_type: 'H5',
  appVersion,
  userAgent,
  platform,
  effectiveType
}

syTrack.registerPage(globalProperties)
syTrack.use('PageLoad')
syTrack.use('PageLeave', { custom_props: { page_title: '我的标题' }, heartbeat_interval_time: 5 }) // 设置页面浏览时长自定义属性 page_title 为 '我的标题',并设置页面浏览时长心跳记录刷新时间为 5 秒。
syTrack.quick('autoTrack') // 用于采集 $pageview 事件。