mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 05:06:51 +00:00
GODT-1376: Add first userID to sentry scope.
This commit is contained in:
@ -82,4 +82,5 @@ type AuthRefreshHandler func(*AuthRefresh)
|
||||
type clientManager interface {
|
||||
r(context.Context) *resty.Request
|
||||
authRefresh(context.Context, string, string) (*AuthRefresh, error)
|
||||
setSentryUserID(userID string)
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/getsentry/sentry-go"
|
||||
"github.com/go-resty/resty/v2"
|
||||
)
|
||||
|
||||
@ -35,8 +36,9 @@ type manager struct {
|
||||
connectionObservers []ConnectionObserver
|
||||
proxyDialer *ProxyTLSDialer
|
||||
|
||||
pingMutex *sync.RWMutex
|
||||
isPinging bool
|
||||
pingMutex *sync.RWMutex
|
||||
isPinging bool
|
||||
setSentryUserIDOnce sync.Once
|
||||
}
|
||||
|
||||
func New(cfg Config) Manager {
|
||||
@ -45,11 +47,12 @@ func New(cfg Config) Manager {
|
||||
|
||||
func newManager(cfg Config) *manager {
|
||||
m := &manager{
|
||||
cfg: cfg,
|
||||
rc: resty.New().EnableTrace(),
|
||||
locker: &sync.Mutex{},
|
||||
pingMutex: &sync.RWMutex{},
|
||||
isPinging: false,
|
||||
cfg: cfg,
|
||||
rc: resty.New().EnableTrace(),
|
||||
locker: &sync.Mutex{},
|
||||
pingMutex: &sync.RWMutex{},
|
||||
isPinging: false,
|
||||
setSentryUserIDOnce: sync.Once{},
|
||||
}
|
||||
|
||||
proxyDialer, transport := newProxyDialerAndTransport(cfg)
|
||||
@ -158,3 +161,11 @@ func (m *manager) handleRequestFailure(req *resty.Request, err error) {
|
||||
|
||||
go m.pingUntilSuccess()
|
||||
}
|
||||
|
||||
func (m *manager) setSentryUserID(userID string) {
|
||||
m.setSentryUserIDOnce.Do(func() {
|
||||
sentry.ConfigureScope(func(scope *sentry.Scope) {
|
||||
scope.SetTag("UserID", userID)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/ProtonMail/gopenpgp/v2/crypto"
|
||||
"github.com/getsentry/sentry-go"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@ -126,7 +125,7 @@ func (c *client) UpdateUser(ctx context.Context) (*User, error) {
|
||||
|
||||
c.user = user
|
||||
c.addresses = addresses
|
||||
sentry.ConfigureScope(func(scope *sentry.Scope) { scope.SetUser(sentry.User{ID: user.ID}) })
|
||||
c.manager.setSentryUserID(user.ID)
|
||||
|
||||
return user, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user