From 4c9946d00a19c2455899456d5bb0d218f5e549e5 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 6 Jul 2024 11:08:18 +0200 Subject: [PATCH] #99 Fix sentry v8 breaking changes --- prisma/schema.prisma | 3 ++- src/index.ts | 20 ++------------------ src/instrument.ts | 10 ++++++++++ 3 files changed, 14 insertions(+), 19 deletions(-) create mode 100644 src/instrument.ts diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 1eed829..7a54d1c 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,5 +1,6 @@ generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" + previewFeatures = ["tracing"] } datasource db { diff --git a/src/index.ts b/src/index.ts index b2b25c4..942e19d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ +import './instrument'; import { ApolloServer } from '@apollo/server'; import { expressMiddleware } from '@apollo/server/express4'; import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'; @@ -78,25 +79,9 @@ async function initialise() { }, }); - Sentry.init({ - dsn: config.SENTRY_DSN, - integrations: [ - new Sentry.Integrations.Http({ tracing: true }), - new Sentry.Integrations.Express({ app }), - new Sentry.Integrations.Postgres(), - new Sentry.Integrations.Prisma({ client: prismaService.client() }), - new Sentry.Integrations.Apollo(), - ], - tracesSampleRate: 1.0, - profilesSampleRate: 1.0, - environment: config.DOPPLER_CONFIG, - release: config.QUIZLORD_VERSION, - }); - await server.start(); - app.use(Sentry.Handlers.requestHandler()); - app.use(Sentry.Handlers.tracingHandler()); + Sentry.setupExpressErrorHandler(app); app.use( '/', @@ -139,7 +124,6 @@ async function initialise() { }, }), ); - app.use(Sentry.Handlers.errorHandler()); queueService.subscribeToFileUploads(); await new Promise((resolve) => httpServer.listen({ port: 4000 }, resolve)); diff --git a/src/instrument.ts b/src/instrument.ts new file mode 100644 index 0000000..af6c3b2 --- /dev/null +++ b/src/instrument.ts @@ -0,0 +1,10 @@ +import * as Sentry from '@sentry/node'; +import config from './config/config'; +Sentry.init({ + dsn: config.SENTRY_DSN, + integrations: [Sentry.prismaIntegration()], + tracesSampleRate: 1.0, + profilesSampleRate: 1.0, + environment: config.DOPPLER_CONFIG, + release: config.QUIZLORD_VERSION, +});