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

perfyll

v1.1.8

Published

Perfyll, a lightweight JavaScript library, seamlessly integrates Real User Monitoring (RUM), Application Performance Monitoring (APM), Log Management, and Error Tracking with the efficiency of a cloud service. Elevate your application's performance effort

Downloads

128

Readme

jest workflow npm version

Perfyll (VERSION 1 IS NOW AVAILABLE 🎉)

Get started by signing up at perfyll.com and create your account

Perfyll is a lightweight JavaScript library designed to empower developers in tracking performance and user actions from an end-to-end (E2E) perspective. This library allows you to seamlessly gather and display performance data either on the cloud platform perfyll.com or for local debugging purposes.

Installation

To start using Perfyll, run the follow command on terminal:

npm install --save perfyll

or

yarn add perfyll

Usage

init()

Must be included in the the root of the project, you can access your apikeys here

import { init } from "perfyll";

init({
  publicKey: "<publicKey>",
  // secret must be provided only in the server environment
  secret: "<secret>",
});

log()

import { init, log } from "perfyll";

init({ publicKey: "<publicKey>" });

function myFunction() {
  log("My Log Example", { myExtraArg: 1 });
}

logError()

import { init, logError } from "perfyll";

init({ publicKey: "<publicKey>" });

function myFunction() {
  logError(new Error("My Error"), { myExtraArg: 1 });
}

mark()

import { init, mark } from "perfyll";

init({ publicKey: "<publicKey>" });

export default function MyComponent() {
  function onCheckoutButtonClicked() {
    mark("checkoutButtonClicked", {extra: {buttonColor:  "blue"}}).send()
  }

  return ...
}

startMark(), endMark()

Simple example

import { startMark, endMark, init } from "perfyll";

init({ publicKey: "<publicKey>" });

async function onProductClicked() {
  const registerUser = async () => {
    startMark("productClick");
    // ...
    endMark("productClick").send();
  };
}

Example with subMark

import { startMark, endMark, init } from "perfyll";

init({ publicKey: "<publicKey>", secret: "<secret>" });

async function myApiRoute() {
  const databaseQuery = async () => {
    startMark("databaseQuery");
    // ...
    endMark("databaseQuery");
  };

  const registerUser = async () => {
    startMark("registerUser");
    // ...
    await databaseQuery();
    // ...
    endMark("registerUser").send(["databaseQuery"]);
  };

  await registerUser();
}

startMarkAsync(), endMarkAsync()

import { init, startMarkAsync, endMarkAsync } from "perfyll";

init(...)

const sendEmail = async () => {
  // ...
};

async function myApiRoute() {
  const ref = startMarkAsync("sendEmail");
  // ...
  sendEmail().finally(() => endMarkAsync(ref));
}

Use Cases

E2E Marking

Tracking performance in an end to end transaction (client and server).

// In Your Client Component
import { init, getHeaders, startMark, endMark } from "@/lib/perfyll";

init({publicKey: "..."})

export function MyCompoennt() {
  ...

  const onSubmit = () => {
    startMark("registerUserRequest");
    fetch(
      "/api/<resource>",
      {headers: getHeaders("registerUserRequest")}
    ).finally(
      () => endMark("registerUserRequest").send([])
    );
  }
}
// In Your Server
import { init, startMark, endMark } from "@/lib/perfyll";

init({publicKey: "...", secret: '...'})

export function reqisterUserApiRoute(req: Request) {
  startMark("reqisterUserRoute", {headers: req.headers});
  ...
  endMark("registerUserRequest").send([]);
}

Using Extra arguments

You can pass extra properties to your marks:

// In Your Client Component
import { init, startMark, endMark } from "@/lib/perfyll";

init({publicKey: "..."})

export function MyCompoennt() {
  ...
  const onClickHandler = () => {
    startMark("productClick", {extra: {productType: "TV"}});
    ...
    endMark("productClick").send([])
  }
}

Config

logTimeline

When initializing perfyll with the attribute logTimeline true, a graphical timeline is displayed in the terminal. (Use this in the DEV environment only!)

init({
  publicKey: "<publicKey>",
  logTimeline: true,
});

Examples of output

console result

console2 result