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

@millepath/logmanager-client

v0.1.1

Published

Browser SDK client for LogManager

Readme

@millepath/logmanager-client

Browser SDK client for LogManager — send events from the browser to LogManager API securely using RSA-OAEP handshake + HMAC-SHA256 signature.

Installation

npm install @millepath/logmanager-client

Usage

import { LogManager, setupAutocapture } from '@millepath/logmanager-client'

const lm = new LogManager({
  mode: 'browser',
  client_id: 'client_xxxxx',
  public_key: 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...',
  base_url: 'https://api-logm.millepath.com',
})

// Convenience methods (auto-buffer)
lm.error('Something went wrong', { metadata: { code: 500 } })
lm.audit('User logged in', { metadata: { userId: 1 } })
lm.crash('Out of memory')
lm.support('Ticket #123')
lm.event('click', { target: 'button-submit', page: 'checkout' })

// Flush buffer
await lm.flush()

// Or send directly
await lm.ingest([{
  event_type: 'ERROR',
  message: 'Direct send',
  severity: 'error',
}])

API

new LogManager(config)

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | mode | 'browser' | ✅ | Browser mode only | | client_id | string | ✅ | Client ID from dashboard | | public_key | string | ✅ | RSA public key (raw base64 DER SPKI) | | base_url | string | ✅ | Server base URL | | kid | string | | Key ID (default: 'latest') |

lm.connect()

RSA-OAEP handshake to obtain a session token. Automatically called by ingest() / flush() if not connected.

lm.ingest(events, options?)

Send events directly to the server (bypasses buffer).

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | events | RawEvent[] | | Array of events (max 100) | | options.format | 'json' \| 'ndjson' | 'json' | Request body format |

lm.disconnect()

Remove session from memory.

lm.flush()

Send all buffered events. Auto-flushes every 5 seconds or when buffer reaches 50 events.

lm.close()

Flush buffer + stop auto-flush timer + disconnect.

Convenience Methods

All these methods buffer events (not sent immediately).

lm.error(message, options?)    // event_type: ERROR   default severity: error
lm.audit(message, options?)    // event_type: AUDIT   default severity: info
lm.crash(message, options?)    // event_type: CRASH   default severity: critical
lm.support(message, options?)  // event_type: SUPPORT default severity: info
lm.event(name, metadata?)       // AUDIT, for click/hover/etc.

EventOptions:

| Field | Type | Description | |-------|------|-------------| | severity | Severity | Override severity | | source | string | Event source | | timestamp | string | ISO timestamp | | metadata | object | Additional data | | environment | string | Environment (production, staging, etc.) |

Autocapture

const cleanup = setupAutocapture(lm, {
  error: true,                        // window.onerror
  unhandledRejection: true,           // Promise rejection
  console: {
    level: ['error', 'warn'],         // filter methods (string | string[])
    include: true,                    // send to LogManager
  },
  click: {
    selector: 'button, a',            // CSS selector
    attribute: 'data-track',          // read data attribute
  },
})

// Remove all listeners + restore console
cleanup()

| Feature | Event Type | Detail | |---------|-----------|--------| | error | ERROR | Global error + stack trace | | unhandledRejection | ERROR | Promise rejection + reason | | console | ERROR | Intercept console.log/warn/error/etc., severity matches level | | click | AUDIT | Click events (throttled 1s), selector filter, attribute reads data-* |

Event Types

| Event Type | Convenience Method | |------------|-------------------| | ERROR | lm.error() | | AUDIT | lm.audit() / lm.event() | | AGENT | lm.ingest([{ event_type: 'AGENT', ... }]) | | CRASH | lm.crash() | | SUPPORT | lm.support() |

Severity Levels

debug, info, warning, error, critical

NDJSON Format

await lm.ingest(events, { format: 'ndjson' })

Error Handling

import { LogManagerError } from '@millepath/logmanager-client'

try {
  await lm.ingest([...])
} catch (err) {
  if (err instanceof LogManagerError) {
    console.error(`[${err.status}] ${err.message}`)
  }
}

| Status | Meaning | |--------|---------| | 400 | Bad request | | 401 | Invalid session / signature mismatch / timestamp expired | | 403 | Origin not allowed / client deactivated | | 404 | Client not found | | 429 | Rate limit exceeded | | 413 | Payload exceeds 1 MB |

Security Flow

  1. Client generates AES 256-bit key
  2. AES key is encrypted with RSA-OAEP-256 (server's public key)
  3. Server decrypts with private key, stores session
  4. Each ingestion request is signed with HMAC-SHA256
  5. Signature covers client_id.session_id.expiry — expiry is inside the HMAC, cannot be tampered with

Build

npm run build

License

MIT