cmd/stcrashreceiver: Propagate synthetic user ID for crashes

This commit is contained in:
Jakob Borg 2023-09-20 08:39:01 +02:00
parent 483ecada80
commit d4c2acf6f6
2 changed files with 5 additions and 4 deletions

View File

@ -40,6 +40,7 @@ type sentryService struct {
type sentryRequest struct { type sentryRequest struct {
reportID string reportID string
userID string
data []byte data []byte
} }
@ -52,7 +53,7 @@ func (s *sentryService) Serve(ctx context.Context) {
log.Println("Failed to parse crash report:", err) log.Println("Failed to parse crash report:", err)
continue continue
} }
if err := sendReport(s.dsn, pkt, req.reportID); err != nil { if err := sendReport(s.dsn, pkt, req.userID); err != nil {
log.Println("Failed to send crash report:", err) log.Println("Failed to send crash report:", err)
} }
@ -62,9 +63,9 @@ func (s *sentryService) Serve(ctx context.Context) {
} }
} }
func (s *sentryService) Send(reportID string, data []byte) bool { func (s *sentryService) Send(reportID, userID string, data []byte) bool {
select { select {
case s.inbox <- sentryRequest{reportID, data}: case s.inbox <- sentryRequest{reportID, userID, data}:
return true return true
default: default:
return false return false

View File

@ -87,7 +87,7 @@ func (r *crashReceiver) servePut(reportID string, w http.ResponseWriter, req *ht
} }
// Send the report to Sentry // Send the report to Sentry
if !r.sentry.Send(reportID, bs) { if !r.sentry.Send(reportID, userIDFor(req), bs) {
log.Println("Failed to send report to sentry (queue full):", reportID) log.Println("Failed to send report to sentry (queue full):", reportID)
} }
} }