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

collect-data-jssdk

v1.0.0

Published

数据采集Javascript SDK

Readme

cosdk

数据采集Javascript SDK

安装和引入方式

在你的项目的 html 文件中引入

<script src="https://dp-sdk.bdfint.com/dpsdk.min.js"></script>

在你的head标签内加入

  <script>
        var dpsdk = dpsdk || [];
  </script>

quick start

dpsdk.push('init', {
  platform_code: '平台代码'
});

dpsdk.push('auto_track');

方法列表

| name | 说明 | 函数形式 | 返回值 | | -------- | ----- | ---- | ---- | | push | 推入执行某动作 | function (action, options) { ... } | |

push方法参数说明:

| arguments | 说明 | 类型 | 默认值 | required | | -------- | ----- | ---- | ---- | ---- | | [0]action | 要执行的动作,详见下方push方法第一个参数说明 | string | | true | | [1]options | 参数 | object | | false |

push方法第一个参数说明

| 可选值 | 动作说明 | push方法options参数需要传递 | | -------- | ----- | ----- | | 'init' | 初始化 | {server_url: '接收数据的地址', platform_code: '平台代码(required)'} | | 'auto_track' | 开启默认统计 | | | 'track' | 手动统计 | {event_type: '可选参数见下方事件名列表', event_properties: { ...业务类参数 }} | | 'set_distinct_id' | 设置distinct_id(一般不使用) | '需要自定义的distinct_id' |

事件名列表(options参数event_type字段可选值)

| value | 说明 | 当event为该值时,track方法params参数的event_properties字段需要传递的属性 | | -------- | ----- | ---- | | 'view_page' | 访问页面 | | | 'search_commodity' | 搜索商品 | key_word: '搜索关键字' | | 'click_ad' | 点击广告位 | ad_position: '广告位置', ad_link: '广告链接' | | 'click_news' | 点击资讯 | news_title: '资讯标题', news_link: '资讯链接', news_column: '资讯栏目' |

example:

    var searchBtn = document.querySelector('#searchBtn');

    // 初始化
    dpsdk.push('init', {
        platform_code: "trade",   // 必填
        // server_url: 'api/v2/collect'  // 可选,如果需要修改接收数据的地址
    });

    // 开启默认的数据搜集(page_view)
    dpsdk.push('auto_track');


    /**
     * 根据业务场景手动调用数据采集
     * 以下为目前要采集数据的4种业务场景示例
     */

    // 场景1:搜索商品
    btn.addEventListener('click', function () {
        dpsdk.push('track', {
            event_type: 'search_commodity',
            event_properties: {
              key_word: '轧钢',
            }
        });
    });

    // 场景2:点击广告位
    btn.addEventListener('click', function () {
        dpsdk.push('track', {
            event_type: 'click_ad',
            event_properties: {
              "ad_position": "header",   // 广告位置
              "ad_link": "http://ad.com/123"   // 链接
            }
        });
    });

    // 场景3:点击资讯
    btn.addEventListener('click', function () {
        dpsdk.push('track', {
            event_type: 'click_news',
            event_properties: {
              "news_id": "sdfsd"    // 资讯id
            }
        });
    });

    // 场景4:浏览页面
    btn.addEventListener('click', function () {
        dpsdk.push('track', {
            event_type: 'view_page',
            event_properties: {}
        });
    });

SPA项目的page_view统计(以react为例)

在全局的(一般为App.js)componentDidUpdate内调用统计api

componentDidUpdate () {
    dpsdk.push('track', {
      event_type: 'view_page',
      event_properties: {
        ...
      }
    });
  }