mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
chore: improve instrumentSentry.ts import before another import
Signed-off-by: Roberto Arruda <roberto0arruda@hotmail.com>
This commit is contained in:
parent
682eaa995f
commit
cdab5e2ae8
25
src/main.ts
25
src/main.ts
@ -1,3 +1,7 @@
|
||||
// Import this first from sentry instrument!
|
||||
import '@utils/instrumentSentry';
|
||||
|
||||
// Now import other modules
|
||||
import { ProviderFiles } from '@api/provider/sessions';
|
||||
import { PrismaRepository } from '@api/repository/repository.service';
|
||||
import { HttpStatus, router } from '@api/routes/index.router';
|
||||
@ -21,19 +25,6 @@ function initWA() {
|
||||
async function bootstrap() {
|
||||
const logger = new Logger('SERVER');
|
||||
const app = express();
|
||||
const dsn = process.env.SENTRY_DSN;
|
||||
|
||||
if (dsn) {
|
||||
logger.info('Sentry - ON');
|
||||
Sentry.init({
|
||||
dsn: dsn,
|
||||
environment: process.env.NODE_ENV || 'development',
|
||||
tracesSampleRate: 1.0,
|
||||
profilesSampleRate: 1.0,
|
||||
});
|
||||
|
||||
Sentry.setupExpressErrorHandler(app);
|
||||
}
|
||||
|
||||
let providerFiles: ProviderFiles = null;
|
||||
if (configService.get<ProviderSession>('PROVIDER').ENABLED) {
|
||||
@ -141,6 +132,14 @@ async function bootstrap() {
|
||||
|
||||
eventManager.init(server);
|
||||
|
||||
if (process.env.SENTRY_DSN) {
|
||||
logger.info('Sentry - ON');
|
||||
|
||||
// Add this after all routes,
|
||||
// but before any and other error-handling middlewares are defined
|
||||
Sentry.setupExpressErrorHandler(app);
|
||||
}
|
||||
|
||||
server.listen(httpServer.PORT, () => logger.log(httpServer.TYPE.toUpperCase() + ' - ON: ' + httpServer.PORT));
|
||||
|
||||
initWA();
|
||||
|
12
src/utils/instrumentSentry.ts
Normal file
12
src/utils/instrumentSentry.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import * as Sentry from "@sentry/node";
|
||||
|
||||
const dsn = process.env.SENTRY_DSN;
|
||||
|
||||
if (dsn) {
|
||||
Sentry.init({
|
||||
dsn: dsn,
|
||||
environment: process.env.NODE_ENV || 'development',
|
||||
tracesSampleRate: 1.0,
|
||||
profilesSampleRate: 1.0,
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user