mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-16 16:19:48 -05:00
Set up Raven within init.js
Now that Raven is bundled with webpack, it's not available in the global context, so require it and configure it within the init module. I struggled to figure out how to expose the raven-js module as a global, as all the combinations of `externals` and `ProvidePlugin` only applied to webpacked modules, not the global window. The correct way to do it seems to be exports-loader but that looked rather hacky and hard to understand.
This commit is contained in:
parent
2c21a96c2d
commit
b65332c5d4
4 changed files with 13 additions and 14 deletions
11
src/init.js
11
src/init.js
|
@ -1,5 +1,16 @@
|
|||
var jar = require('./lib/jar');
|
||||
var Raven = require('raven-js');
|
||||
|
||||
/**
|
||||
* -----------------------------------------------------------------------------
|
||||
* Error handling
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
(function () {
|
||||
if (process.env.SENTRY_DSN !== '') {
|
||||
Raven.config(process.env.SENTRY_DSN).install();
|
||||
}
|
||||
})();
|
||||
|
||||
/**
|
||||
* -----------------------------------------------------------------------------
|
||||
|
|
|
@ -21,12 +21,6 @@ module.exports = {
|
|||
// Analytics & Monitoring
|
||||
ga_tracker: process.env.GA_TRACKER || '',
|
||||
|
||||
// Error handling
|
||||
sentry_dsn: process.env.SENTRY_DSN || '',
|
||||
|
||||
// Use minified JS libraries
|
||||
min: (process.env.NODE_ENV === 'production') ? '.min' : '',
|
||||
|
||||
// Redux likes to have this
|
||||
NODE_ENV: process.env.NODE_ENV
|
||||
};
|
||||
|
|
|
@ -49,13 +49,6 @@
|
|||
<script src="/js/{{name}}.intl.js"></script>
|
||||
<script src="/js/{{name}}.bundle.js"></script>
|
||||
|
||||
<!-- Error logging (Sentry) -->
|
||||
<script>
|
||||
if ('{{&sentry_dsn}}' !== '') {
|
||||
Raven.config('{{&sentry_dsn}}').install();
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Analytics (GA) -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
|
|
|
@ -110,7 +110,8 @@ module.exports = {
|
|||
}
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': '"' + process.env.NODE_ENV + '"'
|
||||
'process.env.NODE_ENV': '"' + (process.env.NODE_ENV || 'development') + '"',
|
||||
'process.env.SENTRY_DSN': '"' + (process.env.SENTRY_DSN || '') + '"'
|
||||
}),
|
||||
new webpack.optimize.CommonsChunkPlugin('common', 'js/common.bundle.js'),
|
||||
new webpack.optimize.OccurenceOrderPlugin()
|
||||
|
|
Loading…
Reference in a new issue