Skip to content

Commit

Permalink
fix(bugsnag): add bugsnag params. Fixes MEMB-642
Browse files Browse the repository at this point in the history
  • Loading branch information
serge1peshcoff committed Nov 4, 2019
1 parent 3ebe637 commit a441845
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 68 deletions.
1 change: 1 addition & 0 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const config = {
silent: false,
level: process.env.LOGLEVEL || 'debug'
},
host: process.env.HOST || 'localhost',
bugsnagKey: process.env.BUGSNAG_KEY || '',
media_dir: '/usr/app/media',
media_url: '/frontend/media',
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
BUGSNAG_KEY: "${BUGSNAG_KEY_EVENTS}"
PG_PASSWORD: "${PW_POSTGRES}"
NODE_ENV: "${MYAEGEE_ENV}"
HOST: "${SUBDOMAIN_FRONTEND}${BASE_URL}"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8084/healthcheck"]
interval: 30s
Expand Down
15 changes: 15 additions & 0 deletions lib/bugsnag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const bugsnag = require('@bugsnag/js');

const config = require('../config');
const logger = require('./logger');
const packageInfo = require('../package.json');

const bugsnagClient = bugsnag({
apiKey: config.bugsnagKey,
logger,
appVersion: packageInfo.version,
hostname: config.host,
releaseStage: process.env.NODE_ENV
});

module.exports = bugsnagClient;
2 changes: 1 addition & 1 deletion lib/middlewares.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const request = require('request-promise-native');
const bugsnag = require('bugsnag');

const bugsnag = require('./bugsnag');
const errors = require('./errors');
const logger = require('./logger');
const { Event, Application } = require('../models');
Expand Down
7 changes: 1 addition & 6 deletions lib/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const express = require('express');
const bugsnag = require('bugsnag');
const router = require('express-promise-router');
const bodyParser = require('body-parser');
const boolParser = require('express-query-boolean');
Expand All @@ -14,15 +13,11 @@ const middlewares = require('./middlewares');
const metrics = require('./metrics');
const endpointsMetrics = require('./endpoints_metrics');
const config = require('../config');
const bugsnag = require('./bugsnag');

const EventsRouter = router({ mergeParams: true });
const GeneralRouter = router({ mergeParams: true });

/* istanbul ignore next */
if (process.env.NODE_ENV !== 'test') {
bugsnag.register(config.bugsnagKey);
}

const server = express();
server.use(bodyParser.json());
server.use(morgan);
Expand Down
117 changes: 57 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
},
"homepage": "https://github.com/AEGEE/oms-events#readme",
"dependencies": {
"@bugsnag/js": "^6.4.3",
"body-parser": "^1.19.0",
"bugsnag": "^2.4.3",
"express": "^4.17.1",
"express-promise-router": "^3.0.3",
"express-query-boolean": "^2.0.0",
Expand Down

0 comments on commit a441845

Please sign in to comment.