Skip to content

Commit

Permalink
Enable sentry reporting on Panic (home-assistant#18)
Browse files Browse the repository at this point in the history
* Enable sentry reporting on Panic
  • Loading branch information
pvizeli authored Apr 8, 2021
1 parent 39b0d4f commit 0b38f28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ const (
sentryDsn = "https://[email protected]/5710878"
)

var version string = "dev"
var (
version string = "dev"
enableCapture bool = true
)

func main() {
logging.Info.Printf("Start OS-Agent %s", version)
Expand All @@ -38,6 +41,7 @@ func main() {
}

defer sentry.Flush(2 * time.Second)
defer sentry.Recover()

// Connect DBus
conn, err := dbus.SystemBus()
Expand Down Expand Up @@ -79,6 +83,16 @@ func InitializeDBus(conn *dbus.Conn) {
Emit: prop.EmitInvalidates,
Callback: nil,
},
"Telemetry": {
Value: enableCapture,
Writable: true,
Emit: prop.EmitTrue,
Callback: func(c *prop.Change) *dbus.Error {
logging.Info.Printf("Telemetry is now %t", c.Value)
enableCapture = c.Value.(bool)
return nil
},
},
},
}

Expand Down
2 changes: 1 addition & 1 deletion sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import "github.com/getsentry/sentry-go"

func filterSentry(event *sentry.Event, hint *sentry.EventHint) *sentry.Event {
if version == "dev" {
if version == "dev" || !enableCapture {
return nil
}
return event
Expand Down

0 comments on commit 0b38f28

Please sign in to comment.