Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajoute Sentry pour capturer les erreurs #1103

Merged
merged 6 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bien vu 👍🏻

}
}
})
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
Loading