Last active
May 10, 2017 18:26
-
-
Save andrewtamura/61d32b1b1ea9e98c5e15cb833243d755 to your computer and use it in GitHub Desktop.
raven wrapper with monkey patch for local logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Raven = require('raven'); | |
// Configure the Raven client from the Sentry DSN. For local development, keep this environment variable unset to prevent | |
// Raven from sending events to sentry | |
var ravenClient = new Raven.Client(configOptions); | |
var originalCaptureException = ravenClient.captureException; | |
// Monkey patch the captureException function for easier development flow. | |
ravenClient.captureException = function() { | |
// this._enabled is true if SENTRY_DSN is set. When developing locally, unset this environment variable. | |
if (!this._enabled) { | |
// the first parameter to captureException is the Error object. | |
var err = arguments[0]; | |
console.error(err.stack || err); | |
} else { | |
originalCaptureException.apply(this, arguments); | |
} | |
} | |
// Return the configured Raven client | |
module.exports = ravenClient; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can also use the whitelist url option