How to add monitoring to a wails app #4511
Replies: 1 comment 2 replies
-
|
Hi @moisesrj97! I'm Dosu and I’m helping the wails team. You can add Sentry monitoring to your Wails v2 app by initializing Sentry in the Example outline: import (
"github.com/getsentry/sentry-go"
"context"
"time"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
)
func main() {
wails.Run(&options.App{
DisablePanicRecovery: true, // Let you handle panics
OnStartup: func(ctx context.Context) {
sentry.Init(sentry.ClientOptions{
Dsn: "your-dsn-here",
})
},
Bind: []interface{}{
&MyService{},
},
})
}
type MyService struct{}
func (m *MyService) DangerousMethod() {
defer func() {
if err := recover(); err != nil {
sentry.CurrentHub().Recover(err)
sentry.Flush(2 * time.Second)
// Optionally: handle recovery logic here
}
}()
// ... your code that might panic
}Initialize Sentry in To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! We are working on a Wails v2 app, and we'd love to include Sentry to monitor panics. Is there any way of implementing a custom panic handler that allows for recoveries?
Thanks in advance!
Edit: We'd like to "configure once and forget" so we don't have to catch every single potential error
Beta Was this translation helpful? Give feedback.
All reactions