Skip to content

Commit

Permalink
Ajoute Sentry pour capturer les erreurs (EcrituresNumeriques#1103)
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Parisot <[email protected]>
Co-authored-by: Guillaume Grossetie <[email protected]>
Co-authored-by: Guillaume Grossetie <[email protected]>
  • Loading branch information
4 people committed Nov 27, 2024
1 parent 76b084b commit 3d40473
Show file tree
Hide file tree
Showing 18 changed files with 5,570 additions and 5,188 deletions.
8,084 changes: 2,972 additions & 5,112 deletions export/package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
},
"homepage": "https://github.com/EcrituresNumeriques/stylo#readme",
"dependencies": {
"@sentry/node": "^8.38.0",
"@sentry/profiling-node": "^8.38.0",
"archiver": "5.3.2",
"convict": "^6.2.4",
"convict-format-with-validator": "^6.2.0",
Expand Down
23 changes: 21 additions & 2 deletions export/src/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
const Sentry = require('@sentry/node')
const { nodeProfilingIntegration } = require('@sentry/profiling-node')

const config = require('./config.js')
config.validate({ allowed: 'strict' })


const express = require('express')
const cors = require('cors')
const { logger } = require('./logger')
const pino = require('pino-http')({
logger
})
const config = require('./config.js')
config.validate({ allowed: 'strict' })

const {
exportArticleHtml,
Expand All @@ -31,6 +36,20 @@ app.use(cors({
origin: '*'
}))

if (config.get('sentry.dsn')) {
Sentry.init({
dsn: config.get('sentry.dsn'),
environment: process.env.NODE_ENV,
attachStacktrace: true,
includeLocalVariables: true,
integrations: [
nodeProfilingIntegration()
]
})

Sentry.setupExpressErrorHandler(app)
}

const listenPort = config.get('port')

const asyncExportVersionHtml = asyncHandler(exportVersionHtml)
Expand Down
8 changes: 8 additions & 0 deletions export/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,13 @@ module.exports = convict({
env: 'SNOWPACK_PUBLIC_PANDOC_EXPORT_ENDPOINT',
default: 'http://127.0.0.1:3080'
}
},
sentry: {
dsn: {
format: 'url',
env: 'SENTRY_EXPORT_DSN',
default: null,
nullable: true
}
}
})
2 changes: 2 additions & 0 deletions front/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ module.exports = {
},
globals: {
APP_VERSION: true,
APP_ENVIRONMENT: true,
SENTRY_DSN: true,
__BACKEND_ENDPOINT__: true,
__GRAPHQL_ENDPOINT__: true,
__EXPORT_ENDPOINT__: true,
Expand Down
Loading

0 comments on commit 3d40473

Please sign in to comment.