Last active
August 1, 2016 23:52
-
-
Save foxyblocks/d0186f9a8d58ebef071ba2f2ab14ea6f to your computer and use it in GitHub Desktop.
A simple isomorphic bugsnag module. (requires that process.env.IS_BROWSER be present in browser build)
This file contains 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
// The bugsnag javascript libraries are not isomorphic so we need to specify which one we want to use depending on environment. | |
let Bugsnag; | |
if (process.env.IS_BROWSER) { | |
Bugsnag = require('bugsnag-js'); | |
Bugsnag.apiKey = process.env.MY_BROWSER_PROJECT_API_KEY; | |
} else { | |
Bugsnag = require('bugsnag-node'); | |
Bugsnag.register(process.env.MY_NODE_PROJECT_API_KEY); | |
} | |
// Re-export it so the rest of the app can use it. | |
module.exports = Bugsnag; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For usage with webpack add the following to webpack.config.js