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

winston-3-bugsnag-transport

v1.0.2

Published

Bugsnag Transport for Winston 3

Readme

Winston 3 Bugsnag Transport

Bugsnag transport for the logger Winston (v3+).
Relies on the official client @bugsnag/js.

esModuleInterop is required in your tsconfig in order for this project to be imported.

Getting started

yarn add winston-3-bugsnag-transport
# or
npm install --save winston-3-bugsnag-transport

How to

Create a winston logger and pass a new instance of BugsnagTransport to it. The constructor accepts any property from the default configuration of Winston Transports and an additional property bugsnag taking a configuration for the bugsnag client (@bugsnag/js, as of v6.3+).

import winston from 'winston';
import { BugsnagTransport } from 'winston-3-bugsnag-transport';

const logger = winston.createLogger({
  level: 'info',
  format: winston.format.json(),
  transports: [new BugsnagTransport({ bugsnag: { apiKey: 'API_KEY' } })],
});

// use your logger 🎉

Details of implementation

Severity

Bugsnag has a "Severity" feature which allows tagging errors as either error, warning or info. Winston has "Logging levels".
A mapping is made between Severity "info", "warning", "error" and Logging levels "info", "warn", "error". This is not something customizable at the present time but PRs are most welcome if you need to.

Logging recommendations

  • Logging levels have an importance, chose them carefully. Most of the time:
    • error should be used for critical situations requiring a manual intervention
    • warn is for unsual circumstances (to be reported!) that the application can recover from
    • info can report anything useful: events, state changes, etc
  • Put all the useful details about the context/state of your application in the metadata of your logs (easy debugging, filtering, etc)
  • Consider Structured logging for even more useful/powerful logs (see what Bugsnag can do)

There are multiple ways to notify an error (or an event) to Bugsnag

  • Embedding an Error in log metadata (recommended)
try {
  // ...
} catch (error) {
  logger.warn('Thumbnail creation failed: original picture will be used', {
    error, // report "error" as-is in the metadata
    feature: 'picture-thumbnail',
    path: filePath,
    size: fileSize,
  });
}

The parameter meta of winston is passed as the metaData of @bugsnag/js. This way, in the Bugsnag dashboard, every scalar values are available in the "Custom" tab of the report, and each object (or error) has its own tab.

  • But it is also possible to report an error directly:
try {
  // ...
} catch (error) {
  logger.warn(error);
}

The message and stack of the error will be notified to Bugsnag.

  • Or by passing the error as meta (discouraged!)
try {
  // ...
} catch (error) {
  logger.warn('Thumbnail creation failed: original picture will be used', error);
}