How to use the @sentry/node.captureMessage 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 WFCD / genesis / src / Logger.js View on Github external
Logger.prototype[level.toLowerCase()] = (message) => {
    const simple = fmt(level, process.env.SCOPE || 'BOT', message);
    if ((Object.keys(levels).indexOf(level) >= Object.keys(levels)
      .indexOf(l.logLevel)) && Object.keys(levels).indexOf(level) < 3) {
      // eslint-disable-next-line no-console
      console.log(simple);
    }

    if (level.toLowerCase() === 'fatal' && Sentry) {
      Sentry.captureMessage(message, {
        level: 'fatal',
      });
      process.exit(4);
    }
    if (level.toLowerCase() === 'error') {
      // eslint-disable-next-line no-console
      console.error(simple);
      if (typeof message === 'object') {
        // eslint-disable-next-line no-console
        console.error(message);
      }
      if (Sentry) {
        Sentry.captureException(message);
      }
    }
  };
github ShoppinPal / StockUp / notification-service / index.js View on Github external
const path = require('path');
const cors = require('cors');
const fileName = path.basename(__filename, '.js'); // gives the filename without the .js extension
let utils = require('./utils/utils');
let initRedis = require('./utils/initRedis');
const logger = require('sp-json-logger')({fileName: + 'notification-service' + fileName});
let SSE = require('express-sse');
let authUsers = require('./middleware/authUsers');
const Sentry = require('@sentry/node');
var sentryData = process.env.STOCKUP_WEB
Sentry.init({ dsn: sentryData });
// The request handler must be the first middleware on the app
app.use(Sentry.Handlers.requestHandler());
// The error handler must be before any other error middleware
app.use(Sentry.Handlers.errorHandler());
Sentry.captureMessage('Notification Server');


app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

// let sseMap = {};
let sseUsers = {};
let sseAPI = {};
/**
 * Publish will emit message on redis publsher connection
 * from where each running notification-service process will pick up the notification and send to client
 */
require('./publisher')(app);
app.get('/:userId/waitForResponse', (req, res) => {
    let userId = req.params.userId;
github nusmodifications / nusmods / scrapers / nus-v2 / src / services / logger / SentryStream.ts View on Github external
Sentry.withScope((scope) => {
        scope.setLevel(level);

        each(tags, (value, prop) => {
          scope.setTag(prop, String(value));
        });

        each(extra, (value, prop) => {
          scope.setExtra(prop, value || null);
        });

        if (record.err) {
          scope.setExtra('msg', record.msg);
          Sentry.captureException(deserializeError(record.err));
        } else {
          Sentry.captureMessage(record.msg);
        }
      });
github splash-cli / splash-cli / src / client.js View on Github external
if (error) return errorHandler(error);
		});
	}

	if (!config.has('lastWP') || !config.get('lastWP')) {
		const lastWP = await wallpaper.get();
		config.set('lastWP', lastWP);
	}

	updateNotifier({ pkg: manifest, updateCheckInterval: 1000 * 30 }).notify();

	if (frun()) {
		await clearSettings();
		await Unsplash.shared.picOfTheDay();

		Sentry.captureMessage('New User', Sentry.Severity.Info);

		printBlock(
			chalk`Welcome to ${manifest.name}@{dim ${manifest.version}} {bold @${userInfo().username}}`,
			'',
			chalk`{dim CLI setup {green completed}!}`,
			'',
			chalk`{bold Enjoy "{yellow ${manifest.name}}" running {green splash}}`,
		);

		dns.lookup('https://analytics.splash-cli.app/api/users', async (err) => {
			if (err) return;

			try {
				await got('https://analytics.splash-cli.app/api/users', {
					method: 'POST',
				});
github strapi / strapi / packages / strapi-generate-new / lib / utils / usage.js View on Github external
async function captureError(message) {
  try {
    sentry.captureMessage(message, 'error');
    await sentry.flush();
  } catch (err) {
    /** ignore errors*/
    return Promise.resolve();
  }
}
github cnwangjie / better-onetab-sync-server / src / app.js View on Github external
Sentry.withScope(scope => {
        if (ctx.state) scope.setExtra('state', ctx.state)
        if (ctx.input) scope.setExtra('input', ctx.input)
        if (error) {
          Sentry.captureException(error)
        } else {
          Sentry.captureMessage(ctx.body)
        }
      })
    }
github Apollon77 / ioBroker.tuya / main.js View on Github external
Sentry.withScope(scope => {
                    scope.setLevel('info');
                    scope.setExtra("schema", '"' + deviceInfo.id + '": ' + JSON.stringify(deviceInfo.schemaInfo));
                    Sentry.captureMessage('Schema ' + deviceInfo.id, 'info');
                });
            }