Here’s quick guide on how to install Sentry on the back end.
Note: this can get overwritten by a wappler update.
-
Make sentry account
-
Create a project and select that you want to install for Express
-
Do the following npm install:
npm install --save @sentry/node @sentry/tracing
-
Open server.js in /lib
-
Under
const cors = require('cors');
add code:
const Sentry = require('@sentry/node');
const Tracing = require("@sentry/tracing");
- Under
const app=express();
add code (don’t forget to enter your DSN:
Sentry.init({
dsn: "YOUR_DSN_LINK_HERE",
integrations: [
// enable HTTP calls tracing
new Sentry.Integrations.Http({ tracing: true }),
// enable Express.js middleware tracing
new Tracing.Integrations.Express({ app }),
],
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 0.1,
});
// RequestHandler creates a separate execution context using domains, so that every
// transaction/span/breadcrumb is attached to its own Hub instance
app.use(Sentry.Handlers.requestHandler());
// TracingHandler creates a trace for every incoming request
app.use(Sentry.Handlers.tracingHandler());
At this point it should look like:
-
Add app.use(Sentry.Handlers.errorHandler()); in the module.exports like so:
-
Trigger an error (for example a database query that doesn’t work and check in your sentry.io dashboard under Issues if you can see the error.
Sentry back-end is now installed.
(Thanks @Eldynn - it’s based on your thread!)
Community Page
Last updated:
Last updated: