Skip to content

Commit

Permalink
fix: add console logs when in dev. change webpack target to node
Browse files Browse the repository at this point in the history
Changing the webpack target to node allows process.env vars to pass through to this built component.
  • Loading branch information
robrap authored and abutterworth committed Apr 10, 2019
1 parent 9095aaf commit a826c19
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/LoggingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ function fixErrorLength(error) {

class LoggingService {
static logInfo(message) {
if (process.env.NODE_ENV === 'development') {
console.log(message); // eslint-disable-line
}
if (typeof window.newrelic !== 'undefined') {
window.newrelic.addPageAction('INFO', { message });
}
}

static logError(error, customAttributes) {
if (process.env.NODE_ENV === 'development') {
console.error(error, customAttributes); // eslint-disable-line
}
if (typeof window.newrelic !== 'undefined') {
// Note: customProperties are not sent. Presumably High-Security Mode is being used.
window.newrelic.noticeError(fixErrorLength(error), customAttributes);
Expand Down
4 changes: 4 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
devtool: 'source-map',
target: 'node',
optimization: {
nodeEnv: false,
},
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
Expand Down

0 comments on commit a826c19

Please sign in to comment.