aandrewww / winston-transport-sentry-node

🍡 @sentry/node transport for the winston v3 logger
MIT License
63 stars 37 forks source link

ES6 Usage #45

Open net-tech opened 1 year ago

net-tech commented 1 year ago

Hi there, how are you supposed to import the transport when moduleResolution is set to node next, and ESNext is being used? I tried

import Sentry from 'winston-transport-sentry-node';

However that results in This expression is not constructable.

  Type 'typeof import("/Users/net-tech-/Desktop/Programming/old-kydzs-splatoon/node_modules/.pnpm/winston-transport-sentry-node@2.7.0/node_modules/winston-transport-sentry-node/dist/transport")' has no construct signatures.

48     new Sentry({
           ~~~~~~
sergioisidoro commented 1 year ago

This worked for me:

import SentryWinston from 'winston-transport-sentry-node';
const WinstonSentry = SentryWinston.default 

 const logger = createLogger({
  transports: [
    new transports.Console(),
    ...
    new WinstonSentry(options)
  ],
});
d-neri commented 6 months ago

@sergioisidoro that unfortunately didn't work for me, but this code compiled and ran okay:

import * as SentryWinston from 'winston-transport-sentry-node';
const Sentry = SentryWinston.default;