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

Truncate the message sent to sentry to max allowable chars #806

Merged
merged 3 commits into from
Apr 27, 2020
Merged
Changes from 1 commit
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
15 changes: 12 additions & 3 deletions desktop/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ import (
)

const (
SENTRY_DSN = "https://[email protected]/2222244"
SENTRY_TIMEOUT = time.Second * 30
SENTRY_DSN = "https://[email protected]/2222244"
SENTRY_TIMEOUT = time.Second * 30
SENTRY_MAX_MESSAGE_CHARS = 8000
)

var (
Expand Down Expand Up @@ -131,6 +132,14 @@ func (app *App) loadSettings() *Settings {
return loadSettingsFrom(common.Version, common.RevisionDate, common.BuildDate, path, app.chrome)
}

func truncateString(s string, maxLength int) string {
if maxLength < len(s) {
return s[:maxLength]
} else {
return s
}
}

max-b marked this conversation as resolved.
Show resolved Hide resolved
// LogPanicAndExit logs a panic and then exits the application. This function
// is only used in the panicwrap parent process.
func (app *App) LogPanicAndExit(msg string) {
Expand All @@ -139,7 +148,7 @@ func (app *App) LogPanicAndExit(msg string) {
scope.SetLevel(sentry.LevelFatal)
})

sentry.CaptureMessage(msg)
sentry.CaptureMessage(truncateString(msg, SENTRY_MAX_MESSAGE_CHARS))
if result := sentry.Flush(SENTRY_TIMEOUT); result == false {
log.Error("Flushing to Sentry timed out")
}
Expand Down