forked from Silverfish/proton-bridge
feat(GODT-2356): unify sentry release description and add more context to it.
This commit is contained in:
@ -26,7 +26,7 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/ProtonMail/gluon/reporter"
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/constants"
|
||||
"github.com/ProtonMail/proton-bridge/v3/pkg/restarter"
|
||||
"github.com/getsentry/sentry-go"
|
||||
@ -38,13 +38,23 @@ var skippedFunctions = []string{} //nolint:gochecknoglobals
|
||||
func init() { //nolint:gochecknoinits
|
||||
sentrySyncTransport := sentry.NewHTTPSyncTransport()
|
||||
sentrySyncTransport.Timeout = time.Second * 3
|
||||
appVersion := constants.Version
|
||||
version, _ := semver.NewVersion(appVersion)
|
||||
if version != nil {
|
||||
appVersion = version.Original()
|
||||
}
|
||||
|
||||
if err := sentry.Init(sentry.ClientOptions{
|
||||
Dsn: constants.DSNSentry,
|
||||
Release: constants.Revision,
|
||||
BeforeSend: EnhanceSentryEvent,
|
||||
Transport: sentrySyncTransport,
|
||||
}); err != nil {
|
||||
options := sentry.ClientOptions{
|
||||
Dsn: constants.DSNSentry,
|
||||
Release: constants.AppVersion(appVersion),
|
||||
BeforeSend: EnhanceSentryEvent,
|
||||
Transport: sentrySyncTransport,
|
||||
ServerName: getProtectedHostname(),
|
||||
Environment: constants.BuildEnv,
|
||||
MaxBreadcrumbs: 50,
|
||||
}
|
||||
|
||||
if err := sentry.Init(options); err != nil {
|
||||
logrus.WithError(err).Error("Failed to initialize sentry options")
|
||||
}
|
||||
|
||||
@ -64,7 +74,6 @@ type Reporter struct {
|
||||
appVersion string
|
||||
identifier Identifier
|
||||
hostArch string
|
||||
serverName string
|
||||
}
|
||||
|
||||
type Identifier interface {
|
||||
@ -80,13 +89,12 @@ func getProtectedHostname() string {
|
||||
}
|
||||
|
||||
// NewReporter creates new sentry reporter with appName and appVersion to report.
|
||||
func NewReporter(appName, appVersion string, identifier Identifier) *Reporter {
|
||||
func NewReporter(appName string, identifier Identifier) *Reporter {
|
||||
return &Reporter{
|
||||
appName: appName,
|
||||
appVersion: appVersion,
|
||||
appVersion: constants.Revision,
|
||||
identifier: identifier,
|
||||
hostArch: getHostArch(),
|
||||
serverName: getProtectedHostname(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,12 +146,11 @@ func (r *Reporter) scopedReport(context map[string]interface{}, doReport func())
|
||||
}
|
||||
|
||||
tags := map[string]string{
|
||||
"OS": runtime.GOOS,
|
||||
"Client": r.appName,
|
||||
"Version": r.appVersion,
|
||||
"UserAgent": r.identifier.GetUserAgent(),
|
||||
"HostArch": r.hostArch,
|
||||
"server_name": r.serverName,
|
||||
"OS": runtime.GOOS,
|
||||
"Client": r.appName,
|
||||
"Version": r.appVersion,
|
||||
"UserAgent": r.identifier.GetUserAgent(),
|
||||
"HostArch": r.hostArch,
|
||||
}
|
||||
|
||||
sentry.WithScope(func(scope *sentry.Scope) {
|
||||
|
||||
Reference in New Issue
Block a user