How to use the raven.context function in raven

To help you get started, we’ve selected a few raven 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 artsy / positron / scripts / daily_upload_s3.js View on Github external
//
// A script that collects article data from our mongo database, creates a CSV document,
// and sends that data to S3 for consumption by Fulcrum.
//

import knox from 'knox'
import mongojs from 'mongojs'
import fs from 'fs'
import moment from 'moment'
import { map, pick } from 'lodash'
import RavenServer from 'raven'
const { SENTRY_PRIVATE_DSN } = process.env

RavenServer.config(SENTRY_PRIVATE_DSN).install()
RavenServer.context(() => {
  // Connect to database
  const db = mongojs(process.env.MONGOHQ_URL, ['articles'])

  // Setup file naming
  const filename = `export_${moment().format('YYYYMMDDhhmmss')}.csv`
  const dir = 'scripts/tmp/'

  const attrs = [
    'id',
    'author_id',
    'auction_ids',
    'contributing_authors',
    'fair_ids',
    'featured',
    'featured_artist_ids',
    'featured_artwork_ids',
github artsy / positron / scripts / scheduled_posts.js View on Github external
import { publishScheduledArticles } from '../src/api/apps/articles/model'
import RavenServer from 'raven'
const { SENTRY_PRIVATE_DSN } = process.env

RavenServer.config(SENTRY_PRIVATE_DSN).install()
RavenServer.context(() => {
  publishScheduledArticles((err, results) => {
    if (err) {
      console.log(err)
      return process.exit(err)
    }

    console.log(`Completed Scheduling ${results.length} articles.`)
    return process.exit()
  })
})
github pr-triage / app / index.js View on Github external
async function triage(context) {
  const prTriage = forRepository(context);
  const pullRequest = getPullRequest(context);

  Raven.context(() => {
    Raven.setContext({
      extra: {
        owner: context.repo()["owner"],
        repo: context.repo()["repo"],
        number: pullRequest.number
      }
    });
    prTriage.triage(pullRequest);
  });
}
github willyb321 / elite-journal / app / lib / log-process.js View on Github external
lr.on('line', line => {
		Raven.context(function() {
			Raven.captureBreadcrumb({
				message: 'Log-process line',
				data: {
					line: line,
					filename: log
				}
			});
			let parsed;
			if (!parsed) {
				try {
					parsed = JSON.parse(line);
				} catch (e) {
					Raven.captureException(e);
					line = line
						.replace(/\u000e/igm, '')
						.replace(/\u000f/igm, '');
github willyb321 / media_mate / app / main / index.js View on Github external
db.find({_id: torrent.link}, (err, docs) => {
		if (err) {
			Raven.context(() => {
				Raven.captureBreadcrumb({
					data:
						{
							torrent: torrent.link,
							docs
						}
				});
				Raven.captureException(err);
			});
		}
		if (_.isEmpty(docs)) {
			db.insert({
				_id: torrent.link,
				magnet: torrent.link,
				title: torrent.title,
				tvdbID: torrent['tv:show_name']['#'],
github bobvanderlinden / probot-auto-merge / src / index.ts View on Github external
async function useWorkerContext (options: {app: Application, context: Context, installationId: number}, fn: (WorkerContext: WorkerContext) => Promise): Promise {
  await Raven.context({
    tags: {
      owner: options.context.payload.repository.owner.login,
      repository: `${options.context.payload.repository.owner.login}/${options.context.payload.repository.name}`
    },
    extra: {
      event: options.context.event
    }
  }, async () => {
    const workerContext = await getWorkerContext(options)
    await fn(workerContext)
  })
}
github willyb321 / media_mate / app / main / index.js View on Github external
db.find({_id: torrent.link}, (err, docs) => {
		if (err) {
			Raven.context(() => {
				Raven.captureBreadcrumb({torrent: torrent.link, docs});
				Raven.captureException(err);
			});
		}
		if (_.isEmpty(docs)) {
			db.insert({
				_id: torrent.link,
				magnet: torrent.link,
				title: torrent.title,
				tvdbID: torrent['tv:show_name']['#'],
				airdate: torrent.pubDate,
				downloaded: false
			});
			callback();
		} else {
			_.each(docs, doc => {
github bobvanderlinden / probot-auto-merge / src / repository-worker.ts View on Github external
}
    })
    const pullRequestReference = {
      ...this.repository,
      number: pullRequestNumber
    }
    const pullRequestContext: PullRequestContext = {
      github: await this.context.createGitHubAPI(),
      log,
      config: this.context.config,
      reschedulePullRequest: (delay: number = 60 * 1000) => {
        this.waitQueue.queueFirst(pullRequestNumber, delay)
      },
      startedAt: new Date()
    }
    await Raven.context({
      extra: { pullRequestReference }
    }, async () => {
      try {
        await handlePullRequest(pullRequestContext, pullRequestReference)
      } catch (err) {
        this.onPullRequestError(pullRequestReference, err)
      }
    })
  }
github willyb321 / elite-journal / app / lib / log-watcher.js View on Github external
.map(l => {
								try {
									return JSON.parse(l)
								} catch (e) {
									debug('json.parse error', {line: l});
									Raven.context(function () {
										Raven.captureBreadcrumb({
											message: 'File that crashed log watcher',
											data: {
												filename
											}
										});
										Raven.captureBreadcrumb({
											message: 'Log-watcher JSON.parse failed',
											data: {
												line: l,
												chunk: chunk.toString()
											}
										});
										Raven.captureException(e);
									})
								}