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

@mts-pjsc/bretrics

v1.0.1

Published

Web Monitoring

Downloads

2

Readme

Codacy Badge npm version Contributor Covenant GitHub license

Bretrics - Realtime user Browser Monitoring

Monitor the performance of the user's browser and code for real users. Allows you to collect WebVitals metrics, performance and business metrics through the Prometheuse monitoring system.

Features

  • WebVitals - allows you to collect the main performance metrics of the WebVitals initiative,
  • Custom Metrics - allows you to collect the custom performance metrics,
  • Business Metrics - allows you to collect any business metrics and sales funnels,
  • Network Metrics - allows you to evaluate the quality of the connection from clients to your servers,
  • Leaks Detection - allows you to detect leaks in DOM elements, listeners, js and others.

Instalation

npm:

npm install @mts-pjsc/bretrics

yarn

yarn add @mts-pjsc/bretrics

Examples

Example Default Monitoring

The package has a pre-configured monitoring mode that includes the necessary webvitals metrics.

import {bretrics} from "@mts-pjsc/bretrics";

bretrics
    .setup({apiPath: "/bretrics"}) // <-- microservice deploy location
    .useDefaultMonitoring()
    .sendMetrics({my_metric: 5}); // <-- custom metrics

If you need to send custom metric, you must use the sendMetrics method.

Example Metrics with labels

Prometheus labels can be set as default for all metrics, or individually for each value.

import {bretrics} from "@mts-pjsc/bretrics";

bretrics
    .setup({apiPath: "/bretrics"})
    .useDefaultMonitoring()
    .setLabels({stage: "beta", path: location.pathname})
    .sendMetrics({
        my_metric: {
            value: 5,
            labels: {path: "/blog"}
        }
    });

The default labels will be added to the metrics if you didn't pass them in the sendMetrics method.

Example Bretrics customization

The library exports the web monitoring constructor class, so you can inherit from it and implement logic according to OOP principles.

import {Bretrics} from "@mts-pjsc/bretrics";

export class BretricsService extends Bretrics {

    public override sendMetrics (metric: Record<string, number>): this {
        super.sendMetrics(metric);

        // ... your code here ...

        return this;
    }

}

License

WebMon is MIT licensed.