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

@openameba/cwv-logger

v0.5.0

Published

[web-vitals](https://github.com/GoogleChrome/web-vitals/tree/next)から取得した Core Web Vitals のメトリクスをデータとして使いやすい形式に変換して出力するライブラリです。

Downloads

239

Readme

cwv-logger

web-vitalsから取得した Core Web Vitals のメトリクスをデータとして使いやすい形式に変換して出力するライブラリです。

Installation

yarn add -D @openameba/cwv-logger

or

npm i --save-dev @openameba/cwv-logger

Usage

const reportPerformance = () => {
  const startTime = Date.now();

  // Logging is not critical for most application,
  // so you can avoid loading this library in initial bundle by using dynamic import.
  import("@openameba/cwv-logger").then(
    ({ reportCLS, reportFID, reportLCP, reportTTFB, reportINP }) => {
      /**
       * reportCLS has option in second argument.
       * @see https://github.com/GoogleChrome/web-vitals/tree/main#oncls
       */
      reportCLS(
        ({
          metricsName,
          metricsValue,
          networkType,
          selectorName,
          rectDiff,
        }) => {
          firebase
            .performance()
            .trace(metricsName)
            .record(startTime, metricsValue, {
              selectorName,
              networkType,
              rectDiff,
            });
        },
        {
          reportAllChanges: false, // or true
          durationThreshold: 40, // or number
        }
      );
      reportFID(({ metricsName, metricsValue, networkType, selectorName }) => {
        firebase
          .performance()
          .trace(metricsName)
          .record(startTime, metricsValue, {
            selectorName,
            networkType,
          });
      });
      reportLCP(({ metricsName, metricsValue, networkType, selectorName }) => {
        firebase
          .performance()
          .trace(metricsName)
          .record(startTime, metricsValue, {
            selectorName,
            networkType,
          });
      });
      reportTTFB(({ metricsName, metricsValue, networkType }) => {
        firebase
          .performance()
          .trace(metricsName)
          .record(startTime, metricsValue, {
            networkType,
          });
      });
      /**
       * reportINP has option in second argument.
       * @see https://github.com/GoogleChrome/web-vitals/tree/main#oninp
       */
      reportINP(
        ({ metricsName, metricsValue, networkType, selectorName }) => {
          firebase
            .performance()
            .trace(metricsName)
            .record(startTime, metricsValue, {
              selectorName,
              networkType,
            });
        },
        {
          reportAllChanges: false, // or true
          durationThreshold: 40, // or number
        }
      );
    }
  );
};

Supported Metrics

Report params

type ReportParams = {
  metricsName: "CLS" | "LCP" | "FID" | "TTFB" | "INP";
  metricsValue: number;
  // Get value from https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType.
  networkType: string;
  // Currently not supported
  country?: string;
  // Available with CLS, LCP, FID and INP.
  selectorName?: string;
  // Available only with FID and INP.
  eventTime?: string;
  // Available only with FID and INP.
  // @see: https://github.com/GoogleChrome/web-vitals#loadstate
  loadState?: 'loading' | 'dom-interactive' | 'dom-content-loaded' | 'complete';
  // Available only with CLS.
  rectDiff?: string;
};

リリースフロー

mainまたはbetaブランチにマージすることで自動的にリリースされます。 リリースが完了するとリリースノートも自動的に生成されます。

基本はmainブランチにマージします。 実験的な機能や大きな変更を含む場合に、betaブランチを通して段階的にリリースします。