{"id":18932,"library":"winston-transport-sentry-node","title":"winston-transport-sentry-node","description":"Winston v3 transport for sending logs to Sentry using @sentry/node. Version 3.0.0 requires @sentry/node >= 8.13.0. It integrates Sentry's error tracking and context (tags, user, extras) into the winston logging pipeline. Supports log level mapping, custom formats, and silent mode. Ships TypeScript types. Released under MIT license.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/aandrewww/winston-transport-sentry-node","tags":["javascript","logger","loggly","logging","node","tools","sentry","transport","winston","typescript"],"install":[{"cmd":"npm install winston-transport-sentry-node","lang":"bash","label":"npm"},{"cmd":"yarn add winston-transport-sentry-node","lang":"bash","label":"yarn"},{"cmd":"pnpm add winston-transport-sentry-node","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for Sentry SDK functionality","package":"@sentry/node","optional":false},{"reason":"peer dependency for winston logger","package":"winston","optional":false}],"imports":[{"note":"The package exports a default class. Use default import in ESM. CommonJS: const SentryTransport = require('winston-transport-sentry-node').default;","wrong":"import { default } from 'winston-transport-sentry-node'","symbol":"default","correct":"import SentryTransport from 'winston-transport-sentry-node'"},{"note":"No named export; always use default import.","wrong":"import { SentryTransport } from 'winston-transport-sentry-node'","symbol":"SentryTransport","correct":"import SentryTransport from 'winston-transport-sentry-node'"},{"note":"CommonJS users must call .default on require result.","wrong":"const Transport = require('winston-transport-sentry-node')","symbol":"Transport","correct":"import Transport from 'winston-transport-sentry-node'"}],"quickstart":{"code":"import winston from 'winston';\nimport SentryTransport from 'winston-transport-sentry-node';\nimport * as Sentry from '@sentry/node';\n\nSentry.init({\n  dsn: process.env.SENTRY_DSN || '',\n});\n\nconst logger = winston.createLogger({\n  transports: [\n    new SentryTransport({\n      sentry: {},\n      level: 'error',\n    }),\n  ],\n});\n\nlogger.info('This will not be sent to Sentry (level info)');\nlogger.error('This will be sent to Sentry', { tags: { route: '/api' } });","lang":"typescript","description":"Initialize Sentry globally, create a winston logger with the Sentry transport, and log an error with tags sent to Sentry."},"warnings":[{"fix":"Upgrade @sentry/node to ^8.13.0 or downgrade winston-transport-sentry-node to 2.x","message":"Version 3.0.0 requires @sentry/node >= 8.13.0 (breaking change from earlier versions)","severity":"breaking","affected_versions":">=3.0.0 <3.0.0"},{"fix":"Upgrade Node.js to 8.10.0 or later","message":"Version 3.0.0 drops support for Node.js < 8.10.0","severity":"breaking","affected_versions":">=3.0.0 <3.0.0"},{"fix":"Initialize Sentry globally with Sentry.init() and pass empty sentry option object to the transport","message":"Deprecated: winston-transport-sentry-node now uses @sentry/node v8 which has breaking API changes. Sentry.init() is now required before using the transport.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Use const SentryTransport = require('winston-transport-sentry-node').default;","message":"Default import requires .default in CommonJS. Many users mistakenly use named import or omit .default.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always provide a sentry option object (can be empty) to avoid unexpected behavior","message":"Transport expects sentry option object. If omitted, it will default to reading from process.env, which may cause silent failures.","severity":"gotcha","affected_versions":">=2.0.0 <3.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"const SentryTransport = require('winston-transport-sentry-node').default;","cause":"CommonJS require without .default","error":"TypeError: winston_transport_sentry_node_1.default is not a constructor"},{"fix":"Add Sentry.init({ dsn: 'https://...@...' }); before creating the transport","cause":"Forgetting to call Sentry.init() before using the transport","error":"Error: @sentry/node has not been initialized. Please call Sentry.init() first."},{"fix":"Remove 'Sentry' property from sentry options and import/require @sentry/node separately","cause":"Older versions expected Sentry as an option in sentry object","error":"TypeError: Cannot destructure property 'Sentry' of 'undefined' or 'null'"},{"fix":"Ensure you use default import: new (require('winston-transport-sentry-node').default)({...})","cause":"Importing wrong export (named instead of default) in winston.add","error":"AggregateError: The transport is not a valid transport, expected a Transport instance or a function returning a Transport"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}