📈(collaboration) add sentry

Add sentry to the collaboration server.
It will be used to log errors and exceptions.
This commit is contained in:
Anthony LC
2024-12-03 15:10:05 +01:00
committed by Anthony LC
parent 94a1ba7989
commit 932ab13d97
5 changed files with 101 additions and 2 deletions

View File

@@ -17,6 +17,8 @@
},
"dependencies": {
"@hocuspocus/server": "2.14.0",
"@sentry/node": "8.41.0",
"@sentry/profiling-node": "8.41.0",
"express": "4.21.1",
"express-ws": "5.0.2",
"y-protocols": "1.0.6"

View File

@@ -5,3 +5,4 @@ export const COLLABORATION_SERVER_ORIGIN =
export const COLLABORATION_SERVER_SECRET =
process.env.COLLABORATION_SERVER_SECRET || 'secret-api-key';
export const PORT = Number(process.env.PORT || 4444);
export const SENTRY_DSN = process.env.SENTRY_DSN || '';

View File

@@ -1,4 +1,7 @@
// eslint-disable-next-line import/order
import './services/sentry';
import { Server } from '@hocuspocus/server';
import * as Sentry from '@sentry/node';
import express, { Request, Response } from 'express';
import expressWebsockets from 'express-ws';
@@ -130,6 +133,8 @@ export const initServer = () => {
},
);
Sentry.setupExpressErrorHandler(app);
app.get('/ping', (req, res) => {
res.status(200).json({ message: 'pong' });
});

View File

@@ -0,0 +1,11 @@
import * as Sentry from '@sentry/node';
import { nodeProfilingIntegration } from '@sentry/profiling-node';
import { SENTRY_DSN } from '../env';
Sentry.init({
dsn: SENTRY_DSN,
integrations: [nodeProfilingIntegration()],
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
});