fix(sentry)_: trim production env variable (#6149)
This commit is contained in:
parent
7a967e1775
commit
cffd2cfefb
|
@ -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)
|
||||
|
|
|
@ -20,7 +20,7 @@ var stacktraceFilters = []struct {
|
|||
},
|
||||
{
|
||||
Module: "github.com/status-im/status-go/mobile/callog",
|
||||
Functions: []string{"Call.func1"},
|
||||
Functions: []string{"Recover"},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -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"},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue