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

@sidd6916/logger-lib

v1.0.0

Published

A robust offline-first logging library for web applications with auto-capture of clicks, navigation, and screenshots.

Readme

Logger Lib

A robust, offline-first logging library for web applications. It captures user actions, console logs, errors, and navigation events, storing them locally in IndexedDB before syncing to a configured webhook endpoint.

Features

  • Offline First: Logs are stored in IndexedDB and persist across reloads.
  • Auto-Sync: Automatically syncs logs to the server when online (configurable).
  • Auto-Capture:
    • Global Errors: Automatically catches window.onerror and unhandledrejection.
    • User Clicks: Automatically logs clicks on interactive elements (buttons, links).
    • Navigation: Tracks URL changes (pushState, replaceState, popstate) and captures Screenshots of the page state using html2canvas.
  • Screenshots: Captures a base64 screenshot of the UI before navigation events.
  • Batched Uploads: Sends logs in batches to reduce network requests.

Installation

npm install logger-lib
# or linked locally
npm install ../logger-lib

Usage

Initialize the logger at the entry point of your application (e.g., main.tsx or App.tsx).

import { Logger } from 'logger-lib';

export const logger = new Logger({
  webhookUrl: 'http://localhost:3000/webhook', // Endpoint to receive logs
  batchSize: 10,       // Number of logs to send per batch
  syncInterval: 5000,  // Msg interval (in ms) to check for logs to sync
  offlineMode: false,  // Set true to disable auto-sync (manual sync only)
});

// Expose to window for debugging if needed
(window as any).appLogger = logger;

API

logger.info(message, context?)

Log an informational message.

logger.info('User logged in', { userId: 123 });

logger.warn(message, context?)

Log a warning.

logger.warn('API latency high', { duration: 500 });

logger.error(message, context?, stack?)

Log an error. Auto-captured errors use this internally.

try {
  fail();
} catch (err) {
  logger.error('Operation failed', { attempt: 1 }, err.stack);
}

logger.action(actionName, context?)

Log a specific user action.

logger.action('Checkout Clicked', { cartValue: 99.99 });

logger.sync()

Manually trigger a sync verification. Useful if offlineMode is true or to force flush before close.

await logger.sync();

Configuration Options

| Option | Type | Default | Description | |path|to|file| |---|---|---|---| | webhookUrl | string | Required | The HTTP endpoint (POST) to receive JSON payloads. | | batchSize | number | 10 | Number of logs to accumulate before attempting a sync. | | syncInterval | number | 5000 | Interval (ms) to check for pending logs and sync. | | offlineMode | boolean | false | If true, auto-sync is disabled. Logs accumulate until sync() is called. |

Data Format

Logs sent to the webhook have the following structure:

[
  {
    "id": 1,
    "timestamp": "2023-10-27T10:00:00.000Z",
    "level": "info", // info, warn, error, action
    "message": "Page View",
    "sessionId": "x8s7f6d8...",
    "context": {
      "page": "Home"
    },
    "screenshot": "data:image/png;base64,..." // Present on navigation logs
  }
]