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

@bugreels/web-script

v0.0.7

Published

Session recording and analytics script for DelogX/BugReels - captures user interactions, DOM mutations, console logs, and network requests

Readme

@bugreels/web-script

DelogX session recording SDK. It captures rrweb snapshots, DOM mutations, console output, network request metadata, runtime errors, and metadata-aware custom tags.

Installation

npm install @bugreels/web-script
# or
yarn add @bugreels/web-script
# or
pnpm add @bugreels/web-script

Quick Start

Use sendMode: "immediate" if you want uploads to start as soon as recording begins.

import { init, startTracking } from "@bugreels/web-script";

init({
  apiKey: "your-api-key",
  ingestUrl: "http://localhost:4000/ingest/batch",
  queryServiceUrl: "http://localhost:4002",
  sendMode: "immediate",
});

startTracking();

If ingestUrl or queryServiceUrl are omitted, the SDK uses the BugReels production defaults.

Buffered Recording

sendMode defaults to "buffered". In buffered mode, the SDK records immediately but defers uploads until you explicitly trigger sending.

import { init, startTracking, triggerRecording } from "@bugreels/web-script";

init({
  apiKey: "your-api-key",
  sendMode: "buffered",
});

startTracking();

document.addEventListener(
  "click",
  () => {
    triggerRecording();
  },
  { once: true },
);

You can also defer start/upload until specific events fire with recordOn.

Configuration

export interface DelogxConfig {
  apiKey: string;
  ingestUrl?: string; // Default: https://bugreels.com/ingest/batch
  queryServiceUrl?: string; // Default: https://bugreels.com/be/be-query
  recordOn?: string[];
  recordOnOptions?: AddEventListenerOptions;
  sendMode?: "immediate" | "buffered";
  rrwebCheckoutEveryNms?: number; // Default: 30000
  captureRedux?: boolean; // Default: false
}

Notes:

  • recordOn lets you delay recording until specific browser events fire, for example ["click", "keydown"].
  • recordOnOptions is passed directly to window.addEventListener.
  • sendMode: "immediate" enables uploads right away. sendMode: "buffered" keeps events local until triggerRecording() fires.
  • rrwebCheckoutEveryNms controls how often rrweb takes a fresh full snapshot. Raising it reduces large replay payloads without changing the normal upload batch interval.
  • captureRedux: true enables automatic Redux capture through the Redux DevTools hook when the app exposes it.

API

Initialization and Recording

  • init(config) initializes the SDK and stores runtime config.
  • startTracking() starts recording asynchronously.
  • trackAll() is the async form of startTracking().
  • startRecording() is an explicit alias for starting recording.
  • initSession() creates the session without starting rrweb capture yet.
  • stopRecording() pauses recording.
  • resumeRecordingManually() resumes a paused recording.
  • startRecordingOnEvents(events, options?) starts recording when one of the listed browser events fires.
  • createRecordingTrigger() returns a one-shot function that starts recording/uploading only once.
  • triggerRecording() starts recording if needed and enables uploads in buffered mode.
  • attachReduxStore(store) attaches a plain Redux store directly when the app does not expose the Redux DevTools hook.
  • trackReduxStore(store, options?) remains available for explicit debug-oriented Redux tracing.

Session Helpers

  • getSessionId() returns the current session id if it is already known.
  • getSessionIdAsync() resolves the session id, creating/loading the session first if needed.

User Identification

import { setUserId, getUserId, clearUserId } from "@bugreels/web-script";

setUserId("user-123");
const userId = getUserId();
clearUserId();

getUserId() always returns a string. If you have not called setUserId(), the SDK falls back to a stable anonymous ID in local storage.

Custom Tags

The package exports type CustomTag = { tag: string; meta?: Record<string, unknown> }.

import {
  clearCustomTags,
  getCustomTags,
  setCustomTags,
  type CustomTag,
} from "@bugreels/web-script";

const tags: CustomTag[] = [
  { tag: "premium-user", meta: { plan: "pro" } },
  { tag: "image-compression-failed", meta: { ext: "jpg", taskId: "abc123" } },
];

setCustomTags(tags);
const currentTags = getCustomTags();
clearCustomTags();

Validation and normalization:

  • tag values are trimmed and must be non-empty and at most 100 characters.
  • Duplicate tag values are deduplicated with latest value winning.
  • At most 50 tags are kept.
  • meta must be a plain JSON-serializable object; invalid values are normalized to {}.
  • Writes are serialized through an internal queue so setCustomTags() / clearCustomTags() calls are persisted in order.

Framework Integration

React

import { useEffect } from "react";
import { init, startTracking } from "@bugreels/web-script";

export function App() {
  useEffect(() => {
    init({
      apiKey: import.meta.env.VITE_DELOGX_API_KEY,
      ingestUrl: import.meta.env.VITE_DELOGX_INGEST_URL,
      queryServiceUrl: import.meta.env.VITE_DELOGX_QUERY_URL,
      sendMode: "immediate",
    });
    startTracking();
  }, []);

  return <div>Your App</div>;
}

Next.js

"use client";

import { useEffect } from "react";
import { init, startTracking } from "@bugreels/web-script";

export function DelogxProvider({ children }: { children: React.ReactNode }) {
  useEffect(() => {
    init({
      apiKey: process.env.NEXT_PUBLIC_DELOGX_API_KEY!,
      ingestUrl: process.env.NEXT_PUBLIC_DELOGX_INGEST_URL,
      queryServiceUrl: process.env.NEXT_PUBLIC_DELOGX_QUERY_URL,
      sendMode: "immediate",
    });
    startTracking();
  }, []);

  return children;
}

Vanilla JS

<script src="/path/to/index.global.js"></script>
<script>
  DelogX.init({
    apiKey: "your-api-key",
    ingestUrl: "http://localhost:4000/ingest/batch",
    queryServiceUrl: "http://localhost:4002",
    sendMode: "immediate",
  });
  DelogX.startTracking();
</script>

What Gets Recorded

  • DOM snapshots and mutations via rrweb
  • User interactions such as clicks, scrolls, and inputs
  • Console logs (log, info, warn, error)
  • Network request metadata such as method, URL, status, and timing
  • Redux action/state traces when captureRedux: true is enabled or the store is attached directly
  • JavaScript errors and unhandled promise rejections

Privacy and Security Notes

  • Sensitive headers are filtered before persistence.
  • SDK auth uses an API-key exchange at /auth/token to obtain a short-lived WebSocket token.

Local Debug Logging

Set DEBUG_MODE=true in packages/web-script/.env before building to enable verbose browser-side logs.

License

MIT