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

fe-timeline-watcher

v0.0.1-beta.3

Published

a tool can retrieve user-side page load timeand resource time and send them to your backend

Downloads

2

Readme

用于前端页面及资源加载的性能监控及错误上报(依赖Performance API)。 告别繁杂配置,只需短短几行,即可看到效果。

使用方法

script引入

直接将min.js文件放入html中,并加一行配置(并启动)。

    <script src="path/to/fe-timeline-watcher.min.js"></script>
    <script>
        __FE_TIMELINE_WATCHER__.start(
            watcherUrl: string, // 必填参数
            needResourceInfo?: boolean = true, // 是否需要资源加载信息
            needPageLoadInfo?: boolean = true, // 是否需要首屏加载信息
            needErrorInfo?: boolean = true // 是否需要全局错误捕获
        );
    </script>

在webpack、rollup等配置下引入

    const Watcher = require('fe-timeline-watcher');
    Watcher.start(
        watcherUrl: string,
        needResourceInfo?: boolean = true,
        needPageLoadInfo?: boolean = true,
        needErrorInfo?: boolean = true
    );

相关API

Watcher.start(...rest)

全等于new Watcher(...rest)

Watcher.useOwnSender(sender)

sender = function(data) { fetch(...); } 使用自定义的函数发送请求

Watcher.prototype.sendCustom(data)

发送自定义数据(自定义的数据键名为cData)。

数据格式说明

type: 0,表示首屏数据,包含browserInfo,pageLoad,resource。 type: 1,表示更新的数据,包含resource。 type: 2,表示捕获到的错误。

注意事项

  1. 监控默认请求采用 fetch(低版本浏览器需polyfill), 在数据量不大的情况下使用GET请求,反之使用POST
  2. 当需要捕获全局错误时,请务必保持所有 跨域 script脚本含有 crossorigin 属性,并且资源响应头含有正确的 Access-Control-Allow-Origin 设置。可参考touch.qunar.com中对js资源的响应头设置。
  3. 如果需要上报所有资源的加载时间,需要给资源的响应头设置 Allow-Timing-Origin 为正确的值,否则有部分计算值不正确。

常见问题

Q: 请求发出后,network中查看到该请求无body? A: 可能存在跨域问题

版本更新说明

0.0.1-beta.3

更新文档

0.0.1-beta.2

修复首屏可能不能获取到首屏加载数据的bug