How to use the @sentry/node.init function in @sentry/node

To help you get started, we’ve selected a few @sentry/node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LessWrong2 / Lesswrong2 / packages / vulcan-lib / lib / server / apollo-server / apollo_server.js View on Github external
import { getApolloApplyMiddlewareOptions, getApolloServerOptions } from './settings';

import { getSetting } from '../../modules/settings.js';
import { formatError } from 'apollo-errors';

//import timber from 'timber';
const timberApiKey = getSetting('timber.apiKey');

const sentryUrl = getSetting('sentry.url');
const sentryEnvironment = getSetting('sentry.environment');
const sentryRelease = getSetting('sentry.release');
import Sentry from '@sentry/node';

if (sentryUrl) {
  Sentry.init({ dsn: sentryUrl, environment: sentryEnvironment, release: sentryRelease });
} else {
  // eslint-disable-next-line no-console
  console.warn("Sentry is not configured. To activate error reporting, please set the sentry.url variable in your settings file.");
}

export const setupGraphQLMiddlewares = (apolloServer, config, apolloApplyMiddlewareOptions) => {
  // IMPORTANT: order matters !
  // 1 - Add request parsing middleware
  // 2 - Add apollo specific middlewares
  // 3 - CLOSE CONNEXION (otherwise the endpoint hungs)
  // 4 - ONLY THEN you can start adding other middlewares (graphql voyager etc.)

  // WebApp.connectHandlers is a connect server
  // you can add middlware as usual when using Express/Connect

  // parse cookies and assign req.universalCookies object
github ShabadOS / desktop / app / lib / analytics.js View on Github external
async initSentry() {
    if ( isDev || !settings.get( 'system.serverAnalytics' ) ) return

    logger.info( 'Enabling Sentry error reporting' )

    // Set the sentry release
    const release = `${SENTRY_PROJECT}@${version}`

    Sentry.init( {
      dsn: SENTRY_DSN,
      release,
    } )
  }
github zeit / next.js / packages / next-plugin-sentry / src / on-init-server.js View on Github external
export default async function initServer() {
  // by default `@sentry/node` is configured with defaultIntegrations
  // which capture uncaughtExceptions and unhandledRejections
  // see here for more https://github.com/getsentry/sentry-javascript/blob/46a02209bafcbc1603c769476ba0a1eaa450759d/packages/node/src/sdk.ts#L22
  Sentry.init({
    dsn: process.env.SENTRY_DSN,
    release: process.env.SENTRY_RELEASE,
  })
}
github nuxt-community / sentry-module / lib / module.js View on Github external
},
        initialize: initializationRequired,
        integrations: filterDisabledIntegration(options.clientIntegrations)
          .reduce((res, key) => {
            res[key] = options.clientIntegrations[key]
            return res
          }, {})
      }
    })
  }

  // Register the server plugin
  if (!options.disableServerSide) {
    // Initialize Sentry
    if (initializationRequired) {
      Sentry.init({
        dsn: options.dsn,
        ...options.serverConfig,
        integrations: filterDisabledIntegration(options.serverIntegrations)
          .map(name => new Integrations[name](options.serverIntegrations[name]))
      })
    }

    process.sentry = Sentry
    logger.success('Started logging errors to Sentry')

    this.addPlugin({
      src: path.resolve(__dirname, 'sentry.server.js'),
      fileName: 'sentry.server.js',
      mode: 'server'
    })
    this.nuxt.hook('render:setupMiddleware', app => app.use(Sentry.Handlers.requestHandler()))
github rodrigotamura / go-stack-2019 / module02 / src / app.js View on Github external
constructor() {
    this.server = express();

    // initializing Sentry for bug track managing
    Sentry.init(sentryConfig);

    // it`s important to execute in order to
    // apply the middlewares and routers
    this.middlewares();
    this.routes();
    this.exceptionHandler(); // handling errors for user interface
  }
github ethereum-optimism / optimism / packages / data-transport-layer / src / services / server / service.ts View on Github external
private _initSentry() {
    Sentry.init({
      dsn: this.options.sentryDsn,
      release: this.options.release,
      environment: this.options.ethNetworkName,
      integrations: [
        new Sentry.Integrations.Http({ tracing: true }),
        new Tracing.Integrations.Express({
          app: this.state.app,
        }),
      ],
      tracesSampleRate: this.options.sentryTraceRate,
    })
    this.state.app.use(Sentry.Handlers.requestHandler())
    this.state.app.use(Sentry.Handlers.tracingHandler())
  }
github taskcluster / taskcluster / libraries / monitor / src / plugins / sentry.js View on Github external
constructor({dsn, taskclusterVersion, serviceName, processName}) {
    if (!dsn) {
      throw new Error('SentryReporter plugin must have a `dsn` set to work.');
    }
    Sentry.init({
      dsn,
      release: taskclusterVersion,
    });
    Sentry.configureScope(scope => {
      scope.setTag('service', serviceName);
      scope.setTag('proc', processName);
    });
  }
github keyteki / keyteki / server / server.js View on Github external
init(options) {
        if(!this.isDeveloping) {
            Sentry.init({ dsn: this.configService.getValue('sentryDsn'), release: version.build });
            app.use(Sentry.Handlers.requestHandler());
            app.use(Sentry.Handlers.errorHandler());
        }

        var opts = {};
        opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken();
        opts.secretOrKey = this.configService.getValue('secret');

        passport.use(new JwtStrategy(opts, (jwtPayload, done) => {
            this.userService.getUserById(jwtPayload._id).then(user => {
                if(user) {
                    return done(null, user.getWireSafeDetails());
                }

                return done(null, false);
            }).catch(err => {
github tonesto7 / homebridge-smartthings-v2 / src / ST_Platform.js View on Github external
constructor(log, config, api) {
        this.config = config;
        this.homebridge = api;
        this.Service = api.hap.Service;
        this.Characteristic = api.hap.Characteristic;
        PlatformAccessory = api.platformAccessory;
        this.uuid = api.hap.uuid;
        if (config === undefined || config === null || config.app_url === undefined || config.app_url === null || config.app_id === undefined || config.app_id === null) {
            log(`${platformName} Plugin is not Configured | Skipping...`);
            return;
        }
        Sentry.init({ dsn: 'https://c126c2d965e84da8af105d80c5e92474@sentry.io/1878896', release: `${pluginName}@${pluginVersion}`, attachStacktrace: true });
        Sentry.configureScope(function(scope) {
            scope.setUser({ id: machineId });
            scope.setTag("username", os.userInfo().username);
            scope.setTag("node", process.version);
            scope.setTag("version", pluginVersion);
            scope.setTag("platform", os.platform());
            scope.setTag("type", os.type());
            scope.setTag("arch", os.arch());
            scope.setTag("release", os.release());
        });
        this.Sentry = Sentry;
        this.ok2Run = true;
        this.direct_port = this.findDirectPort();
        this.logConfig = this.getLogConfig();
        this.logging = new Logging(this, this.config["name"], this.logConfig);
        this.log = this.logging.getLogger();
github astroband / astrograph / src / init / sentry.ts View on Github external
export function initSentry(): Promise {
  if (!SENTRY_DSN) {
    return Promise.resolve(false);
  }

  Sentry.init({
    dsn: SENTRY_DSN,
    integrations: [
      new Integrations.RewriteFrames({
        root: __dirname ? `${__dirname}/../..` : process.cwd()
      })
    ]
  });

  return Promise.resolve(true);
}