From 65ac7cff18584376c15e5f6f7a39a5652bb777cf Mon Sep 17 00:00:00 2001 From: Gianpaolo Date: Thu, 26 Feb 2026 16:35:27 +0100 Subject: [PATCH 1/2] chore: remove Sentry integration --- .env.template | 2 -- package.json | 1 - src/app.ts | 3 -- src/features/routes/Route.ts | 2 -- src/features/sentry/index.ts | 41 --------------------------- src/middleware/jwtSecurityHandler.ts | 2 -- src/middleware/postResponseHandler.ts | 15 ---------- src/middleware/validationFail.ts | 15 ---------- 8 files changed, 81 deletions(-) delete mode 100644 src/features/sentry/index.ts diff --git a/.env.template b/.env.template index b20ce862b..c89df44f8 100644 --- a/.env.template +++ b/.env.template @@ -54,8 +54,6 @@ GOOGLE_API_KEY=AIzaserejejadejedejebetudejeberesebiuno PAYMENT_INVOICE_RECAP_CC_EMAIL=it+administration@unguess.io -SENTRY_ENVIRONMENT=local - CAMPAIGN_CREATION_WEBHOOK=https://webhook.site/11111111-1111-1111-1111-11111111111 STATUS_CHANGE_WEBHOOK=https://webhook.site/11111111-1111-1111-1111-11111111111 diff --git a/package.json b/package.json index b381c482c..047aa5eef 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "@aws-sdk/util-format-url": "^3.821.0", "@googlemaps/google-maps-services-js": "^3.3.7", "@sendgrid/mail": "^7.6.0", - "@sentry/node": "^7.83.0", "avatar-initials": "^5.0.0", "aws-sdk": "^2.1087.0", "axios": "^0.25.0", diff --git a/src/app.ts b/src/app.ts index ec6077a33..2621a7e90 100644 --- a/src/app.ts +++ b/src/app.ts @@ -5,7 +5,6 @@ import express from "express"; import morgan from "morgan"; import OpenAPIBackend, { Options, Request } from "openapi-backend"; import config from "./config"; -import Sentry from "./features/sentry"; import middleware from "./middleware"; import getExample from "./middleware/getExample"; import routes from "./routes"; @@ -36,7 +35,6 @@ routes(api); api.init(); const app = express(); -const sentry = new Sentry(app); app.use( busboy({ @@ -100,5 +98,4 @@ app.use((req, res) => { return api.handleRequest(req as Request, req, res); }); -sentry.setErrorHandler(); export default app; diff --git a/src/features/routes/Route.ts b/src/features/routes/Route.ts index 3001e6da6..246e359cd 100644 --- a/src/features/routes/Route.ts +++ b/src/features/routes/Route.ts @@ -1,4 +1,3 @@ -import * as Sentry from "@sentry/node"; import debugMessage from "@src/features/debugMessage"; import OpenapiError from "../OpenapiError"; @@ -104,7 +103,6 @@ export default class Route { try { await this.prepare(); } catch (e) { - Sentry.captureException(e as Error); if (e instanceof OpenapiError) { return this.responseData; } else { diff --git a/src/features/sentry/index.ts b/src/features/sentry/index.ts deleted file mode 100644 index 2fb0bb422..000000000 --- a/src/features/sentry/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -import * as SentryHandler from "@sentry/node"; -import express from "express"; - -class Sentry { - constructor(private app: ReturnType) { - if (process.env.NODE_ENV !== "test") { - SentryHandler.init({ - integrations: [ - new SentryHandler.Integrations.Http({ tracing: true }), - new SentryHandler.Integrations.Express({ app }), - ...SentryHandler.autoDiscoverNodePerformanceMonitoringIntegrations(), - ], - environment: process.env.SENTRY_ENVIRONMENT ?? "local", - tracesSampleRate: process.env.SENTRY_SAMPLE_RATE - ? Number(process.env.SENTRY_SAMPLE_RATE) - : 1.0, - beforeSendTransaction(event) { - if (event.transaction === "GET /api") { - return null; - } - return event; - }, - }); - - app.use(SentryHandler.Handlers.requestHandler()); - app.use(SentryHandler.Handlers.tracingHandler()); - } - } - - public setErrorHandler() { - if (process.env.NODE_ENV !== "test") { - this.app.use(SentryHandler.Handlers.errorHandler()); - } - } - - public static identifyUser(username: string) { - SentryHandler.setUser({ username }); - } -} - -export default Sentry; diff --git a/src/middleware/jwtSecurityHandler.ts b/src/middleware/jwtSecurityHandler.ts index 89827836a..ef788157e 100644 --- a/src/middleware/jwtSecurityHandler.ts +++ b/src/middleware/jwtSecurityHandler.ts @@ -1,4 +1,3 @@ -import Sentry from "@src/features/sentry"; import { checkCookies } from "@src/middleware/checkCookies"; import jwt from "jsonwebtoken"; import { Context } from "openapi-backend"; @@ -26,6 +25,5 @@ export default async ( const decoded = jwt.verify(token, config.jwt.secret); req.user = decoded as unknown as UserType; - Sentry.identifyUser(req.user.user_login); return req.user; }; diff --git a/src/middleware/postResponseHandler.ts b/src/middleware/postResponseHandler.ts index bb407dd38..ee1a6f88a 100644 --- a/src/middleware/postResponseHandler.ts +++ b/src/middleware/postResponseHandler.ts @@ -1,4 +1,3 @@ -import * as Sentry from "@sentry/node"; import { Request } from "express"; import { Context } from "openapi-backend"; import process from "process"; @@ -15,20 +14,6 @@ export default (c: Context, req: Request, res: OpenapiResponse) => { if (process.env && process.env.DEBUG) { console.log(c.response); } - Sentry.addBreadcrumb({ - category: "Response Validation Failed", - message: `Validation failed for endpoint ${req.baseUrl + req.path}`, - level: "warning", - }); - Sentry.addBreadcrumb({ - category: "Invalid Data", - message: JSON.stringify(valid.errors), - level: "info", - }); - Sentry.captureMessage( - `Response Validation error on ${req.method} ${req.baseUrl + req.path}`, - "warning" - ); return res.status(502).json({ status: 502, err: valid.errors, diff --git a/src/middleware/validationFail.ts b/src/middleware/validationFail.ts index ebe9d8014..289a58ed6 100644 --- a/src/middleware/validationFail.ts +++ b/src/middleware/validationFail.ts @@ -1,23 +1,8 @@ -import * as Sentry from "@sentry/node"; import { Request } from "express"; import { Context } from "openapi-backend"; export default (c: Context, req: Request, res: OpenapiResponse) => { res.skip_post_response_handler = true; - Sentry.addBreadcrumb({ - category: "Request Validation Failed", - message: `Validation failed for endpoint ${req.baseUrl + req.path}`, - level: "warning", - }); - Sentry.addBreadcrumb({ - category: "Invalid Data", - message: JSON.stringify(c.validation.errors), - level: "info", - }); - Sentry.captureMessage( - `Request Validation error on ${req.method} ${req.baseUrl + req.path}`, - "warning" - ); return res.status(400).json({ err: c.validation.errors, }); From e0fbe39f72ed9db916951350d51a624ffb39340c Mon Sep 17 00:00:00 2001 From: Gianpaolo Date: Fri, 27 Feb 2026 10:03:20 +0100 Subject: [PATCH 2/2] chore: remove residual Sentry env vars from deployment script --- deployment/after-install.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/deployment/after-install.sh b/deployment/after-install.sh index e2e3f5a07..1df1c9d13 100644 --- a/deployment/after-install.sh +++ b/deployment/after-install.sh @@ -83,11 +83,7 @@ services: CONNECTION_COUNT: ${CONNECTION_COUNT} GOOGLE_API_KEY: '${GOOGLE_API_KEY}' PAYMENT_INVOICE_RECAP_CC_EMAIL: '${PAYMENT_INVOICE_RECAP_CC_EMAIL}' - SENTRY_ENVIRONMENT: ${ENVIRONMENT} ENVIRONMENT: ${ENVIRONMENT} - SENTRY_RELEASE: ${DOCKER_IMAGE} - SENTRY_DSN: ${SENTRY_DSN} - SENTRY_SAMPLE_RATE: ${SENTRY_SAMPLE_RATE:-1} CLOUDFRONT_KEY_ID: ${CLOUDFRONT_KEY_ID} JOTFORM_APIKEY: ${JOTFORM_APIKEY} WORDPRESS_API_URL: ${WORDPRESS_API_URL}