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

@detiq/stacklens

v0.1.4

Published

Lightweight Node.js telemetry SDK for StackLens log ingestion.

Downloads

798

Readme

@detiq/stacklens

Lightweight Node.js SDK for sending backend telemetry and audit logs to StackLens.

import { StackLens } from "@detiq/stacklens";

const telemetry = new StackLens({
  apiKey: process.env.STACKLENS_AGENT_KEY,
  apiUrl: process.env.STACKLENS_API_URL || "https://stacklens.detiq.in",
  defaultService: "zeta-ai",
});

telemetry.info("Action performed", { tenantId: "123", actorId: "456" });
telemetry.warn("Rate limit approaching", { ip: "1.2.3.4" });
telemetry.error("Unhandled exception", { err: "Database timeout" });

Fastify

Register the SDK integration once at your authenticated Fastify boundary:

import { setupFastifyTelemetry } from "@detiq/stacklens";

setupFastifyTelemetry(app, {
  apiKey: process.env.STACKLENS_AGENT_KEY,
  apiUrl: process.env.STACKLENS_API_URL,
  defaultService: "zeta-ai",
  source: "zeta-api-mutation",
});

The Fastify integration records completed mutation requests by default (POST, PUT, PATCH, DELETE) and redacts request bodies.

Express

Register the SDK integration once before your authenticated routes:

import { setupExpressTelemetry } from "@detiq/stacklens";

setupExpressTelemetry(app, {
  apiKey: process.env.STACKLENS_AGENT_KEY,
  apiUrl: process.env.STACKLENS_API_URL,
  defaultService: "zeta-ai",
  source: "zeta-api-mutation",
});

The Express integration records the final route, status, duration, request id, actor context, route params, and redacted body after the response finishes.

Fetch Route Handlers

Use withStackLensFetchHandler for Fetch-compatible server handlers such as Next.js App Router routes:

import { withStackLensFetchHandler } from "@detiq/stacklens";

export const POST = withStackLensFetchHandler(async (request) => {
  return Response.json({ ok: true });
}, {
  apiKey: process.env.STACKLENS_AGENT_KEY,
  apiUrl: process.env.STACKLENS_API_URL,
  defaultService: "zeta-ai",
  route: "/api/route",
  source: "nextjs-route",
});

The SDK is failsafe by design: logging methods do not throw, network calls use timeouts, and telemetry delivery failures never break the host application.

Configuration

| Option | Default | Description | | --- | --- | --- | | apiKey | none | StackLens source agent key. Missing keys disable sending. | | apiUrl | https://stacklens.detiq.in | StackLens API or web proxy base URL. | | defaultService | node-app | Service name applied when a log does not specify one. | | timeoutMs | 3000 | Abort timeout for each ingest request. | | flushIntervalMs | 1000 | Background batching interval. | | maxBatchSize | 50 | Flush immediately when this many logs are queued. | | maxQueueSize | 1000 | Oldest logs are dropped beyond this queue size. | | debug | false | Emits SDK warnings to the configured logger. |

Framework Options

setupFastifyTelemetry and setupExpressTelemetry both accept:

| Option | Default | Description | | --- | --- | --- | | mutationOnly | true | Captures only POST, PUT, PATCH, and DELETE. | | redactBody | true | Replaces request bodies with REDACTED. | | source | framework name | Adds a stable source tag in metadata. | | shouldCapture | capture mutations | Custom predicate for including or excluding requests. | | getService | defaultService | Selects service dynamically per request. | | getMetadata | none | Adds request-specific metadata without changing app domain code. |

Shutdown

Call close() during graceful shutdown if you want to drain the queue:

await telemetry.close();

apiKey, apiUrl, and defaultService automatically fall back to STACKLENS_AGENT_KEY, STACKLENS_API_URL, and STACKLENS_SERVICE.