Add sentry config

This commit is contained in:
kolaente 2020-06-18 19:45:31 +02:00
parent 021e3e307b
commit e62c35b2db
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 17 additions and 0 deletions

View File

@ -32,6 +32,8 @@ service:
enabletaskcomments: true
# Whether totp is enabled. In most cases you want to leave that enabled.
enabletotp: true
# If not empty, enables logging of crashes and unhandled errors in sentry.
sentrydsn: ''
database:
# Database type to use. Supported types are mysql, postgres and sqlite.

View File

@ -75,6 +75,8 @@ service:
enabletaskcomments: true
# Whether totp is enabled. In most cases you want to leave that enabled.
enabletotp: true
# If not empty, enables logging of crashes and unhandled errors in sentry.
sentrydsn: ''
database:
# Database type to use. Supported types are mysql, postgres and sqlite.

View File

@ -49,6 +49,7 @@ const (
ServiceTimeZone Key = `service.timezone`
ServiceEnableTaskComments Key = `service.enabletaskcomments`
ServiceEnableTotp Key = `service.enabletotp`
ServiceSentryDsn Key = `service.sentrydsn`
DatabaseType Key = `database.type`
DatabaseHost Key = `database.host`

View File

@ -62,6 +62,7 @@ import (
"code.vikunja.io/web"
"code.vikunja.io/web/handler"
"github.com/asaskevich/govalidator"
"github.com/getsentry/sentry-go"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
elog "github.com/labstack/gommon/log"
@ -116,6 +117,17 @@ func NewEcho() *echo.Echo {
}))
}
if config.ServiceSentryDsn.GetString() != "" {
e.HTTPErrorHandler = func(err error, c echo.Context) {
sentry.Init(sentry.ClientOptions{
Dsn: config.ServiceSentryDsn.GetString(),
})
e.DefaultHTTPErrorHandler(err, c)
}
}
// Validation
e.Validator = &CustomValidator{}