<commit_before>const bunyan = require('bunyan');
const bunyanFormat = require('bunyan-format');
const sentryStream = require('bunyan-sentry-stream');
const cacheManager = require('cache-manager');
const createIntegration = require('github-integration');
const createWebhook = require('github-webhook-handler');
const Raven = require('raven');

const createRobot = require('./lib/robot');
const createServer = require('./lib/server');

module.exports = options => {
  const cache = cacheManager.caching({
    store: 'memory',
    ttl: 60 * 60 // 1 hour
  });

  const logger = bunyan.createLogger({
    name: 'PRobot',
    level: process.env.LOG_LEVEL || 'debug',
    stream: bunyanFormat({outputMode: process.env.LOG_FORMAT || 'short'})
  });

  const webhook = createWebhook({path: '/', secret: options.secret});
  const integration = createIntegration({
    id: options.id,
    cert: options.cert,
    debug: process.env.LOG_LEVEL === 'trace'
  });
  const server = createServer(webhook);
  const robot = createRobot({integration, webhook, cache, logger});

  if (process.env.SENTRY_URL) {
    Raven.config(process.env.SENTRY_URL, {
      captureUnhandledRejections: true,
      autoBreadcrumbs: true
    }).install({});

    logger.addStream(sentryStream(Raven));
  }

  // Handle case when webhook creation fails
  webhook.on('error', err => {
    logger.error(err);
  });

  return {
    server,
    robot,

    start() {
      server.listen(options.port);
      logger.trace('Listening on http://localhost:' + options.port);
    },

    load(plugin) {
      plugin(robot);
    }
  };
};
<commit_msg>Disable raven console alerts<commit_after>const bunyan = require('bunyan');
const bunyanFormat = require('bunyan-format');
const sentryStream = require('bunyan-sentry-stream');
const cacheManager = require('cache-manager');
const createIntegration = require('github-integration');
const createWebhook = require('github-webhook-handler');
const Raven = require('raven');

const createRobot = require('./lib/robot');
const createServer = require('./lib/server');

module.exports = options => {
  const cache = cacheManager.caching({
    store: 'memory',
    ttl: 60 * 60 // 1 hour
  });

  const logger = bunyan.createLogger({
    name: 'PRobot',
    level: process.env.LOG_LEVEL || 'debug',
    stream: bunyanFormat({outputMode: process.env.LOG_FORMAT || 'short'})
  });

  const webhook = createWebhook({path: '/', secret: options.secret});
  const integration = createIntegration({
    id: options.id,
    cert: options.cert,
    debug: process.env.LOG_LEVEL === 'trace'
  });
  const server = createServer(webhook);
  const robot = createRobot({integration, webhook, cache, logger});

  if (process.env.SENTRY_URL) {
    Raven.disableConsoleAlerts();
    Raven.config(process.env.SENTRY_URL, {
      captureUnhandledRejections: true,
      autoBreadcrumbs: true
    }).install({});

    logger.addStream(sentryStream(Raven));
  }

  // Handle case when webhook creation fails
  webhook.on('error', err => {
    logger.error(err);
  });

  return {
    server,
    robot,

    start() {
      server.listen(options.port);
      logger.trace('Listening on http://localhost:' + options.port);
    },

    load(plugin) {
      plugin(robot);
    }
  };
};

{'fraction_non_alphanumeric': 0.15403498005523167, 'fraction_numerical': 0.003068425897514575, 'mean_word_length': 3.7941176470588234, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4271734', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1004, 'n_words': 212}