This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
backend/cmd/internal/sentry.go

34 lines
578 B
Go

package internal
import (
"os"
"github.com/Kichiyaki/appmode"
"github.com/getsentry/sentry-go"
"github.com/pkg/errors"
)
const (
sentryAppName = "zdam-egzamin-zawodowy-backend"
)
func InitSentry(version string) error {
dsn := os.Getenv("SENTRY_DSN")
if dsn == "" {
return nil
}
err := sentry.Init(sentry.ClientOptions{
Dsn: dsn,
Environment: appmode.Get(),
Release: sentryAppName + "@" + version,
Debug: false,
TracesSampleRate: 0.1,
})
if err != nil {
return errors.Wrap(err, "sentry.Init")
}
return nil
}