From cffd2cfefb891f0d200f1660a7af05f9f207ffa0 Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Mon, 2 Dec 2024 16:32:26 +0000 Subject: [PATCH] fix(sentry)_: trim production env variable (#6149) --- internal/sentry/params.go | 9 +++++++-- internal/sentry/stacktrace.go | 2 +- internal/sentry/stacktrace_test.go | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/internal/sentry/params.go b/internal/sentry/params.go index 50755d34a..69ed2c8e4 100644 --- a/internal/sentry/params.go +++ b/internal/sentry/params.go @@ -3,6 +3,7 @@ package sentry import ( _ "embed" "os" + "strings" ) //go:generate sh -c "echo $SENTRY_CONTEXT_NAME > SENTRY_CONTEXT_NAME" @@ -22,6 +23,10 @@ var ( production string ) +func init() { + production = strings.TrimSpace(production) +} + func DefaultContext() string { return defaultContextName } @@ -38,8 +43,8 @@ func Environment() string { return environment(Production(), DefaultEnvVarEnvironment) } -func environment(production bool, envvar string) string { - if production { +func environment(forceProduction bool, envvar string) string { + if forceProduction { return productionEnvironment } env := os.Getenv(envvar) diff --git a/internal/sentry/stacktrace.go b/internal/sentry/stacktrace.go index 2b0ea3de8..308156131 100644 --- a/internal/sentry/stacktrace.go +++ b/internal/sentry/stacktrace.go @@ -20,7 +20,7 @@ var stacktraceFilters = []struct { }, { Module: "github.com/status-im/status-go/mobile/callog", - Functions: []string{"Call.func1"}, + Functions: []string{"Recover"}, }, } diff --git a/internal/sentry/stacktrace_test.go b/internal/sentry/stacktrace_test.go index 87a728f3d..b293a468e 100644 --- a/internal/sentry/stacktrace_test.go +++ b/internal/sentry/stacktrace_test.go @@ -34,7 +34,7 @@ func TestTrimStacktrace(t *testing.T) { stacktrace: &sentry.Stacktrace{ Frames: []sentry.Frame{ {Module: "github.com/status-im/status-go/other", Function: "OtherFunc"}, - {Module: "github.com/status-im/status-go/mobile/callog", Function: "Call.func1"}, + {Module: "github.com/status-im/status-go/mobile/callog", Function: "Recover"}, {Module: "github.com/status-im/status-go/internal/sentry", Function: "RecoverError"}, }, }, @@ -92,7 +92,7 @@ func TestTrimStacktrace(t *testing.T) { {Module: "github.com/status-im/status-go/other", Function: "OtherFunc2"}, {Module: "github.com/status-im/status-go/other", Function: "OtherFunc3"}, {Module: "github.com/status-im/status-go/internal/sentry", Function: "Recover"}, - {Module: "github.com/status-im/status-go/mobile/callog", Function: "Call.func1"}, + {Module: "github.com/status-im/status-go/mobile/callog", Function: "Recover"}, {Module: "github.com/status-im/status-go/common", Function: "LogOnPanic"}, }, }, @@ -107,13 +107,13 @@ func TestTrimStacktrace(t *testing.T) { name: "break if non-matching frame found", stacktrace: &sentry.Stacktrace{ Frames: []sentry.Frame{ - {Module: "github.com/status-im/status-go/mobile/callog", Function: "Call.func1"}, + {Module: "github.com/status-im/status-go/mobile/callog", Function: "Recover"}, {Module: "github.com/status-im/status-go/internal/sentry", Function: "RecoverError"}, {Module: "github.com/status-im/status-go/other", Function: "OtherFunc1"}, }, }, expected: []sentry.Frame{ - {Module: "github.com/status-im/status-go/mobile/callog", Function: "Call.func1"}, + {Module: "github.com/status-im/status-go/mobile/callog", Function: "Recover"}, {Module: "github.com/status-im/status-go/internal/sentry", Function: "RecoverError"}, {Module: "github.com/status-im/status-go/other", Function: "OtherFunc1"}, },