mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 20:56:51 +00:00
GODT-1410: Remove event ID from sentry report description
This commit is contained in:
@ -61,9 +61,17 @@ func NewReporter(appName, appVersion string, userAgent fmt.Stringer) *Reporter {
|
||||
}
|
||||
|
||||
func (r *Reporter) ReportException(i interface{}) error {
|
||||
return r.ReportExceptionWithContext(i, make(map[string]interface{}))
|
||||
}
|
||||
|
||||
func (r *Reporter) ReportMessage(msg string) error {
|
||||
return r.ReportMessageWithContext(msg, make(map[string]interface{}))
|
||||
}
|
||||
|
||||
func (r *Reporter) ReportExceptionWithContext(i interface{}, context map[string]interface{}) error {
|
||||
err := fmt.Errorf("recover: %v", i)
|
||||
|
||||
return r.scopedReport(func() {
|
||||
return r.scopedReport(context, func() {
|
||||
if eventID := sentry.CaptureException(err); eventID != nil {
|
||||
logrus.WithError(err).
|
||||
WithField("reportID", *eventID).
|
||||
@ -72,8 +80,8 @@ func (r *Reporter) ReportException(i interface{}) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (r *Reporter) ReportMessage(msg string) error {
|
||||
return r.scopedReport(func() {
|
||||
func (r *Reporter) ReportMessageWithContext(msg string, context map[string]interface{}) error {
|
||||
return r.scopedReport(context, func() {
|
||||
if eventID := sentry.CaptureMessage(msg); eventID != nil {
|
||||
logrus.WithField("message", msg).
|
||||
WithField("reportID", *eventID).
|
||||
@ -83,7 +91,7 @@ func (r *Reporter) ReportMessage(msg string) error {
|
||||
}
|
||||
|
||||
// Report reports a sentry crash with stacktrace from all goroutines.
|
||||
func (r *Reporter) scopedReport(doReport func()) error {
|
||||
func (r *Reporter) scopedReport(context map[string]interface{}, doReport func()) error {
|
||||
SkipDuringUnwind()
|
||||
|
||||
if os.Getenv("PROTONMAIL_ENV") == "dev" {
|
||||
@ -101,6 +109,7 @@ func (r *Reporter) scopedReport(doReport func()) error {
|
||||
sentry.WithScope(func(scope *sentry.Scope) {
|
||||
SkipDuringUnwind()
|
||||
scope.SetTags(tags)
|
||||
scope.SetContexts(context)
|
||||
doReport()
|
||||
})
|
||||
|
||||
|
||||
@ -247,7 +247,12 @@ func (loop *eventLoop) processNextEvent() (more bool, err error) { // nolint[fun
|
||||
l.WithError(err).WithField("errors", loop.errCounter).Error("Error skipped")
|
||||
loop.errCounter++
|
||||
if loop.errCounter == errMaxSentry {
|
||||
if sentryErr := loop.store.sentryReporter.ReportMessage("Warning: event loop issues: " + err.Error() + ", " + loop.currentEventID); sentryErr != nil {
|
||||
context := map[string]interface{}{
|
||||
"EventLoop": map[string]interface{}{
|
||||
"EventID": loop.currentEventID,
|
||||
},
|
||||
}
|
||||
if sentryErr := loop.store.sentryReporter.ReportMessageWithContext("Warning: event loop issues: "+err.Error(), context); sentryErr != nil {
|
||||
l.WithError(sentryErr).Error("Failed to report error to sentry")
|
||||
}
|
||||
}
|
||||
@ -302,7 +307,12 @@ func (loop *eventLoop) processEvent(event *pmapi.Event) (err error) {
|
||||
eventLog.Info("Processing refresh event")
|
||||
loop.store.triggerSync()
|
||||
|
||||
if sentryErr := loop.store.sentryReporter.ReportMessage("Warning: refresh occurred, " + loop.currentEventID); sentryErr != nil {
|
||||
context := map[string]interface{}{
|
||||
"EventLoop": map[string]interface{}{
|
||||
"EventID": loop.currentEventID,
|
||||
},
|
||||
}
|
||||
if sentryErr := loop.store.sentryReporter.ReportMessageWithContext("Warning: refresh occurred", context); sentryErr != nil {
|
||||
loop.log.WithError(sentryErr).Error("Failed to report refresh to sentry")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user