getsentry / sentry

Developer-first error tracking and performance monitoring
https://sentry.io
Other
38.84k stars 4.17k forks source link

[expressjs] issues verify step says an event was received, but no issues are shown #78825

Open vgrozdanic opened 1 hour ago

vgrozdanic commented 1 hour ago

After following the onboarding steps for expressjs app, and triggering the demo error, no error is shown in Sentry. Verify step says that event was received, but nothings happening after clicking on the button, I am returned to the same onboarding page

instrument.js:

// Import with `import * as Sentry from "@sentry/node"` if you are using ESM
import * as Sentry from "@sentry/node";
// import { nodeProfilingIntegration } from "@sentry/profiling-node";

Sentry.init({
  dsn: "<dsn>",
//   integrations: [
//     nodeProfilingIntegration(),
//   ],
  // Tracing
  tracesSampleRate: 1.0, //  Capture 100% of the transactions

  // Set sampling rate for profiling - this is relative to tracesSampleRate
//   profilesSampleRate: 1.0,
});

index.js

import app from "./app.js";
import "./instrument.js";
import * as Sentry from "@sentry/node";

Sentry.setupExpressErrorHandler(app);

app.get("/debug-sentry", function mainHandler(req, res) {
  throw new Error("My first Sentry error!");
});

const port = 3000;
console.log(`Server is running on port ${port}`);

app.listen(port);

app.ts

import express from 'express';
const app = express();

// Middleware to parse JSON bodies
app.use(express.json());

// Basic route
app.get('/', (req: express.Request, res: express.Response) => {
  res.json({ message: 'Hello world' });
});

export default app;
vgrozdanic commented 1 hour ago

https://github.com/user-attachments/assets/41c54137-bfc0-4ded-99b0-12d368d7ef0d

vgrozdanic commented 1 hour ago

The problem with this setup is that I did Sentry.setupExpressErrorHandler(app); before all routes were declared, but we still shown user that we have received an event, although we had nothing to show