diff --git a/backend/cmd/ipranges/main.go b/backend/cmd/ipranges/main.go index bcd4cde..7aacecc 100644 --- a/backend/cmd/ipranges/main.go +++ b/backend/cmd/ipranges/main.go @@ -16,7 +16,6 @@ import ( var commit string var version string -var sentryDSN string var cloudfrontURL = "https://ip-ranges.amazonaws.com/ip-ranges.json" var cloudflare4URL = "https://www.cloudflare.com/ips-v4" @@ -24,7 +23,7 @@ var cloudflare6URL = "https://www.cloudflare.com/ips-v6" func main() { config.InitArgs(&version, &commit) - if err := config.InitIPRanges(&version, &commit, &sentryDSN); err != nil { + if err := config.InitIPRanges(&version, &commit); err != nil { fmt.Printf("# Config ERROR: %v\n", err) os.Exit(1) } diff --git a/backend/cmd/server/main.go b/backend/cmd/server/main.go index ad64bfe..543fd37 100644 --- a/backend/cmd/server/main.go +++ b/backend/cmd/server/main.go @@ -10,7 +10,6 @@ import ( "npm/internal/database" "npm/internal/entity/certificate" "npm/internal/entity/host" - "npm/internal/entity/setting" "npm/internal/entity/user" "npm/internal/errors" "npm/internal/jobqueue" @@ -20,11 +19,10 @@ import ( var commit string var version string -var sentryDSN string func main() { config.InitArgs(&version, &commit) - config.Init(&version, &commit, &sentryDSN) + config.Init(&version, &commit) database.Migrate(func() { if err := jwt.LoadKeys(); err != nil { @@ -32,7 +30,6 @@ func main() { os.Exit(1) } - setting.ApplySettings() checkSetup() // Internal Job Queue @@ -79,9 +76,6 @@ func checkSetup() { config.IsSetup = true logger.Info("Application is setup") } - if config.ErrorReporting { - logger.Warn("Error reporting is enabled - Application Errors WILL be sent to Sentry, you can disable this in the Settings interface") - } } else { logger.Error("DatabaseError", errors.ErrDatabaseUnavailable) } diff --git a/backend/embed/api_docs/components/HealthObject.json b/backend/embed/api_docs/components/HealthObject.json index eee1e5f..cf2897a 100644 --- a/backend/embed/api_docs/components/HealthObject.json +++ b/backend/embed/api_docs/components/HealthObject.json @@ -2,7 +2,7 @@ "type": "object", "description": "HealthObject", "additionalProperties": false, - "required": ["version", "commit", "healthy", "setup", "error_reporting"], + "required": ["version", "commit", "healthy", "setup"], "properties": { "version": { "type": "string", @@ -22,10 +22,6 @@ "type": "boolean", "description": "Is the application set up?" }, - "error_reporting": { - "type": "boolean", - "description": "Will the application send any error reporting?" - }, "acme.sh": { "type": "string", "description": "Acme.sh version", diff --git a/backend/embed/api_docs/paths/get.json b/backend/embed/api_docs/paths/get.json index 181e8a8..567b2e7 100644 --- a/backend/embed/api_docs/paths/get.json +++ b/backend/embed/api_docs/paths/get.json @@ -22,8 +22,7 @@ "version": "3.0.0", "commit": "9f119b6", "healthy": true, - "setup": true, - "error_reporting": true + "setup": true } } }, @@ -33,8 +32,7 @@ "version": "3.0.0", "commit": "9f119b6", "healthy": false, - "setup": true, - "error_reporting": true + "setup": true } } } diff --git a/backend/embed/migrations/mysql/20201013035839_initial_data.sql b/backend/embed/migrations/mysql/20201013035839_initial_data.sql index 145007a..924ea47 100644 --- a/backend/embed/migrations/mysql/20201013035839_initial_data.sql +++ b/backend/embed/migrations/mysql/20201013035839_initial_data.sql @@ -30,14 +30,6 @@ INSERT INTO `setting` ( `description`, `value` ) VALUES --- Default error reporting setting -( - ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000), - ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000), - "error-reporting", - "If enabled, any application errors are reported to Sentry. Sensitive information is not sent.", - "true" -- remember this is json -), -- Default site ( ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000), diff --git a/backend/embed/migrations/postgres/20201013035839_initial_data.sql b/backend/embed/migrations/postgres/20201013035839_initial_data.sql index 59459da..9dde41f 100644 --- a/backend/embed/migrations/postgres/20201013035839_initial_data.sql +++ b/backend/embed/migrations/postgres/20201013035839_initial_data.sql @@ -30,14 +30,6 @@ INSERT INTO "setting" ( "description", "value" ) VALUES --- Default error reporting setting -( - EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000, - EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000, - 'error-reporting', - 'If enabled, any application errors are reported to Sentry. Sensitive information is not sent.', - 'true' -- remember this is json -), -- Default site ( EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000, diff --git a/backend/embed/migrations/sqlite/20201013035839_initial_data.sql b/backend/embed/migrations/sqlite/20201013035839_initial_data.sql index 4d8b801..6ef00c5 100644 --- a/backend/embed/migrations/sqlite/20201013035839_initial_data.sql +++ b/backend/embed/migrations/sqlite/20201013035839_initial_data.sql @@ -23,21 +23,6 @@ INSERT INTO `capability` ( ("streams.manage"), ("users.manage"); --- Default error reporting setting -INSERT INTO `setting` ( - created_at, - updated_at, - name, - description, - value -) VALUES ( - unixepoch() * 1000, - unixepoch() * 1000, - "error-reporting", - "If enabled, any application errors are reported to Sentry. Sensitive information is not sent.", - "true" -- remember this is json -); - -- Default site INSERT INTO `setting` ( created_at, diff --git a/backend/go.mod b/backend/go.mod index 24fcd2c..0882dcc 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -9,7 +9,6 @@ require ( github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/drexedam/gravatar v0.0.0-20210327211422-e94eea8c338e github.com/fatih/color v1.15.0 - github.com/getsentry/sentry-go v0.21.0 github.com/glebarez/sqlite v1.8.0 github.com/go-chi/chi/v5 v5.0.8 github.com/go-chi/cors v1.2.1 diff --git a/backend/go.sum b/backend/go.sum index e6c5203..834be1f 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -20,8 +20,6 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= -github.com/getsentry/sentry-go v0.21.0 h1:c9l5F1nPF30JIppulk4veau90PK6Smu3abgVtVQWon4= -github.com/getsentry/sentry-go v0.21.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/glebarez/go-sqlite v1.21.1 h1:7MZyUPh2XTrHS7xNEHQbrhfMZuPSzhkm2A1qgg0y5NY= github.com/glebarez/go-sqlite v1.21.1/go.mod h1:ISs8MF6yk5cL4n/43rSOmVMGJJjHYr7L2MbZZ5Q4E2E= github.com/glebarez/sqlite v1.8.0 h1:02X12E2I/4C1n+v90yTqrjRa8yuo7c3KeHI3FRznCvc= @@ -32,7 +30,6 @@ github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= github.com/go-chi/jwtauth/v5 v5.1.0 h1:wJyf2YZ/ohPvNJBwPOzZaQbyzwgMZZceE1m8FOzXLeA= github.com/go-chi/jwtauth/v5 v5.1.0/go.mod h1:MA93hc1au3tAQwCKry+fI4LqJ5MIVN4XSsglOo+lSc8= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= @@ -108,7 +105,6 @@ github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7P github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= -github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/backend/internal/api/handler/health.go b/backend/internal/api/handler/health.go index b4df7a0..8204014 100644 --- a/backend/internal/api/handler/health.go +++ b/backend/internal/api/handler/health.go @@ -8,12 +8,11 @@ import ( ) type healthCheckResponse struct { - Version string `json:"version"` - Commit string `json:"commit"` - AcmeShVersion string `json:"acme.sh"` - Healthy bool `json:"healthy"` - IsSetup bool `json:"setup"` - ErrorReporting bool `json:"error_reporting"` + Version string `json:"version"` + Commit string `json:"commit"` + AcmeShVersion string `json:"acme.sh"` + Healthy bool `json:"healthy"` + IsSetup bool `json:"setup"` } // Health returns the health of the api @@ -21,12 +20,11 @@ type healthCheckResponse struct { func Health() func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { health := healthCheckResponse{ - Version: config.Version, - Commit: config.Commit, - Healthy: true, - IsSetup: config.IsSetup, - AcmeShVersion: acme.GetAcmeShVersion(), - ErrorReporting: config.ErrorReporting, + Version: config.Version, + Commit: config.Commit, + Healthy: true, + IsSetup: config.IsSetup, + AcmeShVersion: acme.GetAcmeShVersion(), } h.ResultResponseJSON(w, r, http.StatusOK, health) diff --git a/backend/internal/api/router_test.go b/backend/internal/api/router_test.go index 78ec784..1d0e1a6 100644 --- a/backend/internal/api/router_test.go +++ b/backend/internal/api/router_test.go @@ -12,15 +12,14 @@ import ( ) var ( - r = NewRouter() - version = "3.0.0" - commit = "abcdefgh" - sentryDSN = "" + r = NewRouter() + version = "3.0.0" + commit = "abcdefgh" ) // Tear up/down func TestMain(m *testing.M) { - config.Init(&version, &commit, &sentryDSN) + config.Init(&version, &commit) code := m.Run() os.Exit(code) } diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go index f430923..64deb43 100644 --- a/backend/internal/config/config.go +++ b/backend/internal/config/config.go @@ -3,19 +3,14 @@ package config import ( "fmt" golog "log" - "runtime" "npm/internal/logger" - "github.com/getsentry/sentry-go" "github.com/vrischmann/envconfig" ) // Init will parse environment variables into the Env struct -func Init(version, commit, sentryDSN *string) { - // ErrorReporting is enabled until we load the status of it from the DB later - ErrorReporting = true - +func Init(version, commit *string) { Version = *version Commit = *commit @@ -23,23 +18,22 @@ func Init(version, commit, sentryDSN *string) { fmt.Printf("%+v\n", err) } - initLogger(*sentryDSN) + initLogger() logger.Info("Build Version: %s (%s)", Version, Commit) createDataFolders() } // InitIPRanges will initialise the config for the ipranges command -func InitIPRanges(version, commit, sentryDSN *string) error { - ErrorReporting = true +func InitIPRanges(version, commit *string) error { Version = *version Commit = *commit err := envconfig.InitWithPrefix(&Configuration, "NPM") - initLogger(*sentryDSN) + initLogger() return err } // Init initialises the Log object and return it -func initLogger(sentryDSN string) { +func initLogger() { // this removes timestamp prefixes from logs golog.SetFlags(0) @@ -57,16 +51,6 @@ func initLogger(sentryDSN string) { err := logger.Configure(&logger.Config{ LogThreshold: logLevel, Formatter: Configuration.Log.Format, - SentryConfig: sentry.ClientOptions{ - // This is the jc21 NginxProxyManager Sentry project, - // errors will be reported here (if error reporting is enable) - // and this project is private. No personal information should - // be sent in any error messages, only stacktraces. - Dsn: sentryDSN, - Release: Commit, - Dist: Version, - Environment: fmt.Sprintf("%s-%s", runtime.GOOS, runtime.GOARCH), - }, }) if err != nil { diff --git a/backend/internal/config/vars.go b/backend/internal/config/vars.go index 59e1dee..f448850 100644 --- a/backend/internal/config/vars.go +++ b/backend/internal/config/vars.go @@ -13,9 +13,6 @@ var Commit string // IsSetup defines whether we have an admin user or not var IsSetup bool -// ErrorReporting defines whether we will send errors to Sentry -var ErrorReporting bool - var logLevel logger.Level type log struct { diff --git a/backend/internal/entity/setting/methods.go b/backend/internal/entity/setting/methods.go index 63d6fb1..3aa971f 100644 --- a/backend/internal/entity/setting/methods.go +++ b/backend/internal/entity/setting/methods.go @@ -1,9 +1,7 @@ package setting import ( - "npm/internal/config" "npm/internal/entity" - "npm/internal/logger" "npm/internal/model" ) @@ -55,16 +53,3 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse, return result, nil } - -// ApplySettings will load settings from the DB and apply them where required -func ApplySettings() { - logger.Debug("Applying Settings") - - // Error-reporting - m, err := GetByName("error-reporting") - if err != nil { - logger.Error("ApplySettingsError", err) - } else { - config.ErrorReporting = m.Value.String() == "true" - } -} diff --git a/backend/internal/entity/setting/model.go b/backend/internal/entity/setting/model.go index abfa108..d2e71f1 100644 --- a/backend/internal/entity/setting/model.go +++ b/backend/internal/entity/setting/model.go @@ -45,6 +45,6 @@ func (m *Model) Save() error { if result := db.Save(m); result.Error != nil { return result.Error } - ApplySettings() + return nil } diff --git a/backend/internal/logger/config.go b/backend/internal/logger/config.go index c0f8a35..9e64111 100644 --- a/backend/internal/logger/config.go +++ b/backend/internal/logger/config.go @@ -1,7 +1,5 @@ package logger -import "github.com/getsentry/sentry-go" - // Level type type Level int @@ -21,7 +19,6 @@ const ( type Config struct { LogThreshold Level Formatter string - SentryConfig sentry.ClientOptions } // Interface for a logger diff --git a/backend/internal/logger/logger.go b/backend/internal/logger/logger.go index adb95b3..4ded181 100644 --- a/backend/internal/logger/logger.go +++ b/backend/internal/logger/logger.go @@ -10,7 +10,6 @@ import ( "time" "github.com/fatih/color" - "github.com/getsentry/sentry-go" "github.com/rotisserie/eris" ) @@ -113,13 +112,6 @@ func (l *Logger) Configure(c *Config) error { l.LogThreshold = c.LogThreshold l.Formatter = c.Formatter - l.SentryConfig = c.SentryConfig - - if c.SentryConfig.Dsn != "" { - if sentryErr := sentry.Init(c.SentryConfig); sentryErr != nil { - fmt.Printf("Sentry initialization failed: %v\n", sentryErr) - } - } stdlog.SetFlags(0) // this removes timestamp prefixes from logs return nil @@ -228,21 +220,4 @@ func (l *Logger) Warn(format string, args ...interface{}) { // Attempts to log to bugsang. func (l *Logger) Error(errorClass string, err error) { l.logLevel(ErrorLevel, err.Error(), errorClass) - l.notifySentry(errorClass, err) -} - -func (l *Logger) notifySentry(errorClass string, err error) { - if l.SentryConfig.Dsn != "" && l.SentryConfig.Dsn != "-" { - - sentry.ConfigureScope(func(scope *sentry.Scope) { - scope.SetLevel(sentry.LevelError) - scope.SetTag("service", "backend") - scope.SetTag("error_class", errorClass) - }) - - sentry.CaptureException(err) - // Since sentry emits events in the background we need to make sure - // they are sent before we shut down - sentry.Flush(time.Second * 5) - } } diff --git a/backend/internal/logger/logger_test.go b/backend/internal/logger/logger_test.go index 6ddad72..54321d0 100644 --- a/backend/internal/logger/logger_test.go +++ b/backend/internal/logger/logger_test.go @@ -7,7 +7,6 @@ import ( "os" "testing" - "github.com/getsentry/sentry-go" "github.com/rotisserie/eris" "github.com/stretchr/testify/assert" ) @@ -115,7 +114,6 @@ func TestConfigure(t *testing.T) { args: args{ &Config{ LogThreshold: InfoLevel, - SentryConfig: sentry.ClientOptions{}, }, }, wantErr: false, @@ -123,9 +121,7 @@ func TestConfigure(t *testing.T) { { name: "invalid log level", args: args{ - &Config{ - SentryConfig: sentry.ClientOptions{}, - }, + &Config{}, }, wantErr: true, },