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 🙏

© 2025 – Pkg Stats / Ryan Hefner

yach.util.bpit

v0.1.8

Published

bpit upload elk data

Downloads

3

Readme

安装

    npm i yach.util.bpit

使用

浏览器使用

    <!-- 引入 -->
    <script src="node_modules/yach.util.bpit/dist/yach.util.bpit.b.js"></script>
    <!-- 使用 -->
    window.bpitCommonDataLog(options);

npm使用

// 引入
var bpitCommonData = require('yach.util.bpit');
// 使用
bpitCommonData.log(options);

options

公用

|key|必填|备注|举例| |------|------|------|------| |group|是|项目组|yach| |project|是|项目名|yach_86_index| |env|是|环境|dev,test,pre,online| |version|是|版本|yach端内上传yach端版本,其他上传业务版本| |yachid|否|yach用户id| |workcode|否|工号|

页面响应时间

|key|必填|备注|举例| |------|------|------|------| |page|否|页面|index| |time|否|响应时间|100|

接口响应时间

|key|必填|备注|举例| |------|------|------|------| |api|否|api地址|/ucenter/user/login| |time|否|响应时间|100|

页面响应时间示例1:js库类的应用

在html的head中记录页面开始加载时间

    <script type="text/javascript">
        window.bpit_elk_page_start_time = (new Date()).getTime();
    </script>

在body末尾适当位置记录结束时间

    <script src="node_modules/yach.util.bpit/dist/yach.util.bpit.b.js"></script>
    <script>
        if(window.bpit_elk_page_start_time){
            var end_time = (new Date()).getTime();
            var load_time = end_time - window.bpit_elk_page_start_time;
            window.bpitCommonDataLog({
               group   : 'yach',
               project : 'yach_86_index',
               env     : 'online',
               page    : 'index',
               time    : load_time,
	       yachid  : '123',
	       workcode: '123',
	       version : '0.0.1'
            });
        }
    </script>

页面响应时间示例2:react类的应用

在html的head中记录页面开始加载时间

    <script type="text/javascript">
        window.bpit_elk_page_start_time = (new Date()).getTime();
    </script>

在页面渲染完成后计算页面加载时间(componentDidMount)

    var bpitCommonData = require('yach.util.bpit');

    componentDidMount(){
        if(window.bpit_elk_page_start_time){
            var end_time = (new Date()).getTime();
            var load_time = end_time - window.bpit_elk_page_start_time;
            bpitCommonData.log({
                group   : 'yach',
                project : 'yach_86_index',
                env     : 'online',
                page    : 'index',
                time    : load_time,
		yachid	: '123',
		workcode: '123',
		version	: '0.0.1'
            });
        }
    }

接口响应时间示例1:js库类应用-ajax请求接口

    <script src="node_modules/yach.util.bpit/dist/yach.util.bpit.b.js"></script>
    <script>
        // 在请求开始时记录开始时间
        var bpit_elk_api_start_time = (new Date()).getTime();

        // ajax请求
        ajax...

        // 在请求结束时计算请求响应时间
        if(bpit_elk_api_start_time){
            var end_time = (new Date()).getTime();
            var load_time = end_time - bpit_elk_api_start_time;
            window.bpitCommonDataLog({
                group   : 'yach',
                project : 'yach_86_index',
                env     : 'online',
                api     : '/ucenter/user/login',
                time    : load_time,
		yachid	: '123',
		workcode: '123',
		version	: '0.0.1'
            });
        }   
    </script>

接口响应时间示例2:react类的应用-ajax请求接口

    var bpitCommonData = require('yach.util.bpit');
    
    // 在请求开始时记录开始时间
    var bpit_elk_api_start_time = (new Date()).getTime();

    // ajax请求
    ajax...

    // 在请求结束时计算请求响应时间
    if(bpit_elk_api_start_time){
        var end_time = (new Date()).getTime();
        var load_time = end_time - bpit_elk_api_start_time;
        bpitCommonData.log({
            group   : 'yach',
            project : 'yach_86_index',
            env     : 'online',
            api     : '/ucenter/user/login',
            time    : load_time,
	    yachid  : '123',
	    workcode: '123',
	    version : '0.0.1'
        });
    }

接口响应时间示例3:nodejs

封装request方法,在这个方法内计算接口响应时间

/**
 * post
 */
qiao.post = async function(options){
    // api start
    var api_start_time = (new Date()).getTime();

    // api
    var item = await qiao.ajax.postSync(options);

    // api end
    var api_end_time = (new Date()).getTime();
    var load_time = api_end_time - api_start_time;
    qiao.log({
        group   : 'yach',
        project : 'yach_86_index',
        env     : qiao.config.env,
        api     : qiao.configServer.url.getVersion,
        time    : load_time,
	yachid	: '123',
	workcode: '123',
	version	: '0.0.1'
    });

    return item;
};

数据打点,异步请求无需等待结果

/**
 * log
 */
qiao.log = function(options){
    // upload data
    var uploadData = ["https://es.zhiyinlou.com/log.js?"];
    uploadData.push("group=" + options.group);
    uploadData.push("&project=" + options.project);
    uploadData.push("&env=" + options.env);

    // api load time
    if(options.api && options.time){
        uploadData.push("&api=" + options.api);
        uploadData.push("&load_time=" + options.time);
    }

    var uploadDataUrl = uploadData.join('');
    qiao.ajax.get({url	: uploadDataUrl});
    console.log(uploadDataUrl);
};

version

0.0.8.20201224

  1. add universal
  2. rename to yach.util.bpit from bpit.common.data

0.0.7.20200521

  1. add agora

0.0.6.20200513

  1. add os

0.0.5.20200329

  1. add version

0.0.4.20200318

  1. add yachid
  2. add workcode

0.0.3.20200114

  1. publish
  2. del log

0.0.2.20191230

  1. load_time --> time
  2. modify readme.md
  3. add api load time
  4. md

0.0.1.20191219

  1. init
  2. modify readme.md
  3. add dist