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

trackflow

v0.2.6

Published

Track scenarios with precision using telemetry markers

Downloads

3

Readme

Trackflow 📈

trackflow is a lightweight package to track scenarios in an app using telemetry markers.

💡 Example scenario

Check out the Live demo 🚀

Assume we have an app where we need to track the submit button scenario.

SubmitButton React component:

import * as React from "react";
import { FlowStore } from "trackflow";

const SubmitButton: React.FC = () => {

  const onSubmit = () => {
    // start the submit_button_click Flow with a timeout of 5000 ms
    const flow = FlowStore.newFlow("submit_button_click", 5000);
    fetchApi(flow).then(res => {
      console.log(flow.info());
    });
  } 

  return (
    <button onClick={onSubmit}>Submit</button>
  );
}

In the above snippet, we start the Flow when the button is clicked. Lets continue to track this Flow in the fetchApi() method:

import { Flow } from "trackflow";

// method that makes a network request on submit button click
const fetchApi = (flow: Flow) => {
  const url = "https://restcountries.com/v3.1/independent?status=true";

  // add some useful data to the Flow
  flow.addFlowData({
    url,
    requestType: "GET"
  });

  return fetch(url)
    .then(res => {
      // mark the successful network request
      flow.mark("api_fetch_complete");

      await parseResponse(res);

      // mark the parsing completed step with some step data
      flow.mark("response_parsed", {
        parseType: 2,
      });

      await render(parsedResponse);

      // stop the Flow after the response has been rendered
      flow.stop({
        reason: "response rendered",
      });
    })
    .catch(error => {
      // fail the Flow if the network request throws an error
      flow.fail({
        reason: error,
      });
    });
};

Lets take a deeper look at the completed Flow using flow.info():

{
  id: "082d691f-40a3-4821-b538-a47b6b07b119",
  name: "submit_button_click",
  stepCount: 4,
  data: {
    url: "https://restcountries.com/v3.1/independent?status=true",
    requestType: "GET"
  },
  delta: 3200,
  startedAt: 1711788835295,
  finishedAt: 1711788838495,
  status: "success",
  steps: [
    {
      step: "start",
      timestamp: 1711788835295,
      delta: 0,
      stepDelta: 0,
      status: "success",
      data: {},
      sequence: 1,
      previousStep: "",
    },
    {
      step: "api_fetch_complete",
      timestamp: 1711788836795,
      delta: 1500,
      stepDelta: 1500,
      status: "success",
      data: {},
      sequence: 2,
      previousStep: "start",
    },
    {
      step: "response_parsed",
      timestamp: 1711788837095,
      delta: 1800,
      stepDelta: 300,
      status: "success",
      data: {
        parseType: 2
      },
      sequence: 3,
      previousStep: "api_fetch_complete",
    },
    {
      step: "stop",
      timestamp: 1711788838495,
      delta: 3800,
      stepDelta: 1000,
      status: "success",
      data: {
        reason: "response rendered"
      },
      sequence: 4,
      previousStep: "response_parsed",
    },
  ],
}

🏁 Getting started

$ npm install trackflow

or

$ yarn add trackflow

💻 Installation

$ git clone https://github.com/hasnainroopawalla/trackflow.git
$ cd trackflow
$ yarn install

📄 Documentation

Check out the wiki page.

✏️ Contributing

  • Post any issues and suggestions on the GitHub issues page.
  • To contribute, fork the project and then create a pull request back to master.

License

This project is licensed under the MIT License - see the LICENSE file for details.