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

edsger-logs

v0.1.0

Published

Send product logs to Edsger for user behavior analytics

Readme

edsger-logs

Send product logs to Edsger for user behavior analytics and product improvement.

Installation

npm install edsger-logs

Quick Start (Recommended)

Use createLogger() for non-blocking, fire-and-forget logging that never interferes with your product's normal flow:

import { createLogger } from 'edsger-logs'

const logger = createLogger({
  productId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
  userId: 'user-uuid',
  sessionId: 'sess_abc123',
})

// Fire-and-forget — no await, no try/catch, no this-binding issues
logger.log('page_view', 'User viewed feature list', { metadata: { page: '/features' } })
logger.log('button_click', 'Clicked create feature')

// Safe to destructure
const { log, flush, dispose } = logger
log('search', 'Searched for auth')

// Create a scoped child logger with different context (immutable)
const adminLogger = logger.withContext({ userId: 'admin-uuid' })
adminLogger.log('settings_changed', 'Updated notification preferences')

// On app shutdown
await flush()
dispose()

API

createLogger(options) (Recommended)

Closure-based non-blocking logger. No this, no classes, safe to destructure. Buffers logs in memory and flushes to server every 5 seconds or when buffer reaches 50 entries.

const logger = createLogger({
  productId: 'xxx',         // Required
  userId: 'user-id',        // Optional: default user for all logs
  sessionId: 'sess-id',     // Optional: default session for all logs
  endpoint: '...',          // Optional: custom endpoint
  flushInterval: 5000,      // Optional: flush every N ms (default: 5000)
  maxBufferSize: 50,        // Optional: auto-flush at N entries (default: 50)
  onError: (err) => {},     // Optional: error callback (silent by default)
})

logger.log('event', 'message')              // Non-blocking, never throws
logger.log('event', 'msg', { metadata })    // With metadata
logger.log('event', 'msg', { userId })      // Override user per-call

const child = logger.withContext({ sessionId: 'new-sess' })  // Immutable child
await logger.flush()                        // Manual flush (e.g. on shutdown)
logger.dispose()                            // Stop timer, release resources

sendLog(options)

Low-level async function. Send a single log entry. Returns Promise<SendLogResult>. Note: This is async and throws on error — use createLogger() instead for non-blocking usage.

| Option | Type | Required | Description | |--------|------|----------|-------------| | productId | string | Yes | Product UUID | | logType | string | Yes | Event type (max 50 chars), e.g. page_view, button_click, error | | message | string | Yes | Human-readable description (max 5000 chars) | | userId | string | No | Authenticated user UUID | | sessionId | string | No | Session identifier to group related events | | metadata | object | No | Structured data for the event |

Returns:

{ id: string; createdAt: string }

sendLogs(options)

Send multiple log entries in a single request. Returns Promise<BatchSendLogResult>.

import { sendLogs } from 'edsger-logs'

await sendLogs({
  logs: [
    { productId: '...', logType: 'page_view', message: 'Viewed home' },
    { productId: '...', logType: 'button_click', message: 'Clicked create' },
  ],
})

Max 100 logs per batch. Returns { count: number }.

Error Handling

import { sendLog, LogError } from 'edsger-logs'

try {
  await sendLog({ ... })
} catch (err) {
  if (err instanceof LogError) {
    console.error(err.message, err.statusCode)
  }
}

Requirements

  • Node.js >= 18 (uses native fetch)

License

ISC