Skip to content

Commit

Permalink
Sentry: add Mongo/Mongoose integration (#2108)
Browse files Browse the repository at this point in the history
  • Loading branch information
simison committed Apr 10, 2021
1 parent aa16cc7 commit e129cc9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/env/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ module.exports = {
enabled: false,
options: {
dsn: '',
// Note: integrations are defined directly at `Sentry.init()`, don't add them here.
},
},
// Webpack bundle analyzer
Expand Down
12 changes: 11 additions & 1 deletion config/lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ const mongoose = require('./mongoose');
const express = require('./express');
const chalk = require('chalk');
const Sentry = require('@sentry/node');
const Tracing = require('@sentry/tracing');

if (config.sentry.enabled) {
Sentry.init(config.sentry.options);
Sentry.init({
...config.sentry.options,
integrations: [new Tracing.Integrations.Mongo({ useMongoose: true })],
});
}

// Initialize Models
Expand Down Expand Up @@ -78,6 +82,12 @@ module.exports.start = function start(callback) {
: 'off'),
),
);
console.log(
chalk.green(
'Sentry:\t\t' +
(config.sentry && config.sentry.enabled === true ? 'on' : 'off'),
),
);

// Reset console color
console.log(chalk.white('--'));
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@sentry/browser": "6.2.5",
"@sentry/integrations": "6.2.5",
"@sentry/node": "6.2.5",
"@sentry/tracing": "6.2.5",
"acl": "0.4.11",
"agenda": "1.0.3",
"angular": "1.6.10",
Expand Down

0 comments on commit e129cc9

Please sign in to comment.