✨ Installing sentry
This commit is contained in:
parent
7031bb1d48
commit
15bb52015e
@ -45,6 +45,7 @@
|
||||
"@mailchimp/mailchimp_transactional": "^1.0.50",
|
||||
"@pinata/sdk": "^2.1.0",
|
||||
"@prisma/client": "^4.11.0",
|
||||
"@sentry/node": "^7.91.0",
|
||||
"adm-zip": "^0.5.10",
|
||||
"axios": "^1.6.2",
|
||||
"bcrypt": "^5.1.1",
|
||||
|
@ -1,6 +1,7 @@
|
||||
import HttpException from "@Common/system/controller-pattern/exceptions/HttpException";
|
||||
import HttpCodes from "@Common/system/controller-pattern/HttpCodes";
|
||||
import { NextFunction, Request, Response } from "express";
|
||||
import * as Sentry from "@sentry/node";
|
||||
|
||||
export default function errorHandler(error: any, req: Request, response: Response, next: NextFunction) {
|
||||
const errorStatus: number = error["status"];
|
||||
@ -15,6 +16,18 @@ export default function errorHandler(error: any, req: Request, response: Respons
|
||||
return;
|
||||
}
|
||||
|
||||
const transaction = Sentry.startTransaction({
|
||||
op: "Crashed Application",
|
||||
name: "Crashed Application",
|
||||
});
|
||||
|
||||
if (error instanceof Error) {
|
||||
Sentry.captureException(error.stack);
|
||||
} else {
|
||||
Sentry.captureException(error);
|
||||
}
|
||||
transaction.finish();
|
||||
|
||||
if (error instanceof HttpException) {
|
||||
response.status(error.httpCode).send(error.message);
|
||||
return;
|
||||
|
@ -8,6 +8,7 @@ import bodyParser from "body-parser";
|
||||
import errorHandler from "@App/middlewares/ErrorHandler";
|
||||
import { BackendVariables } from "@Common/config/variables/Variables";
|
||||
import multer from "multer";
|
||||
import "../sentry.config";
|
||||
|
||||
const storage = multer.memoryStorage();
|
||||
|
||||
|
16
src/sentry.config.ts
Normal file
16
src/sentry.config.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { BackendVariables } from "@Common/config/variables/Variables";
|
||||
import * as Sentry from "@sentry/node";
|
||||
import Container from "typedi";
|
||||
|
||||
const variables = Container.get(BackendVariables);
|
||||
|
||||
Sentry.init({
|
||||
dsn: "https://ca6a89e8b480c814e1b5828b8412c681@o4506382103281664.ingest.sentry.io/4506399972130816",
|
||||
|
||||
// We recommend adjusting this value in production, or using tracesSampler
|
||||
// for finer control
|
||||
tracesSampleRate: 1.0,
|
||||
environment: variables.ENV,
|
||||
});
|
||||
|
||||
Sentry.setTag("service", "leCoffre-back");
|
Loading…
x
Reference in New Issue
Block a user