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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@brainz_llc/js

v0.1.5

Published

BrainzLab JavaScript SDK - Stimulus controllers for full-stack observability

Downloads

66

Readme

@brainz_llc/js

JavaScript SDK for BrainzLab - Full-stack observability for JavaScript/TypeScript applications with Stimulus controllers.

Installation

npm install @brainz_llc/js
# or
yarn add @brainz_llc/js

Usage with Importmaps (Rails 7+)

Add to your config/importmap.rb:

pin "@brainz_llc/js", to: "https://cdn.jsdelivr.net/npm/@brainz_llc/[email protected]/dist/index.esm.js"
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true

Then in your app/javascript/controllers/index.js:

import { application } from "./application"
import { BrainzlabController } from "@brainz_llc/js"

application.register("brainzlab", BrainzlabController)

Usage with Stimulus (esbuild/webpack)

1. Register the controller

// app/javascript/controllers/index.js
import { application } from "./application"
import { BrainzlabController } from "@brainz_llc/js"

application.register("brainzlab", BrainzlabController)

2. Add to your layout

<body data-controller="brainzlab"
      data-brainzlab-endpoint-value="<%= ENV['BRAINZLAB_PLATFORM_URL'] %>"
      data-brainzlab-api-key-value="<%= ENV['BRAINZLAB_API_KEY'] %>"
      data-brainzlab-environment-value="<%= Rails.env %>"
      data-brainzlab-service-value="my-app"
      data-brainzlab-debug-value="<%= Rails.env.development? %>">

Configuration Options

| Data Attribute | Description | Default | |----------------|-------------|---------| | endpoint-value | BrainzLab API endpoint | Required | | api-key-value | Your BrainzLab API key | Required | | environment-value | Environment name | production | | service-value | Service/app name | - | | release-value | Release/version | - | | debug-value | Enable debug logging | false | | sample-rate-value | Performance event sample rate (0-1) | 1.0 | | enable-errors-value | Track JavaScript errors | true | | enable-network-value | Track fetch/XHR requests | true | | enable-performance-value | Track Web Vitals | true | | enable-console-value | Track console output | true |

Standalone Usage

import { init } from "@brainz_llc/js"

init({
  endpoint: "https://platform.brainzlab.ai",
  apiKey: "your-api-key",
  environment: "production",
  service: "my-app",
  debug: false,
})

Features

Error Tracking

  • Captures window.onerror events
  • Captures unhandled promise rejections
  • Manual error capture with captureError(error)

Network Monitoring

  • Intercepts fetch() requests
  • Intercepts XMLHttpRequest requests
  • Tracks request duration, status, and errors

Performance Monitoring

  • Core Web Vitals (LCP, FID, CLS, INP)
  • Navigation timing (TTFB, FCP)
  • Long task detection
  • Slow resource detection

Console Tracking

  • Captures console.log, console.warn, console.error
  • Truncates long messages automatically

Manual Event Tracking

// Track custom events via Stimulus actions
<button data-action="brainzlab#track"
        data-brainzlab-name-param="button_click"
        data-brainzlab-button-param="signup">
  Sign Up
</button>

// Track page views (useful for SPA)
<div data-action="turbo:load->brainzlab#pageView"></div>

// Identify users
<div data-controller="brainzlab"
     data-action="login:success->brainzlab#identify"
     data-brainzlab-user-id-param="123"
     data-brainzlab-traits-param='{"email":"[email protected]"}'>
</div>

License

MIT