MCPcopy Create free account
hub / github.com/buggregator/server / handleEventItem

Method handleEventItem

modules/sentry/handler.go:188–219  ·  view source on GitHub ↗

handleEventItem processes an "event" envelope item (error/message event). envelopeEventID is the event_id from the envelope header — Sentry SDK v4+ omits event_id from the item payload, so we inject it when missing.

(item EnvelopeItem, envelopeEventID string, project string)

Source from the content-addressed store, hash-verified

186// envelopeEventID is the event_id from the envelope header — Sentry SDK v4+
187// omits event_id from the item payload, so we inject it when missing.
188func (h *handler) handleEventItem(item EnvelopeItem, envelopeEventID string, project string) (string, json.RawMessage) {
189 var ev ErrorEvent
190 if err := json.Unmarshal(item.Payload, &ev); err != nil {
191 slog.Warn("sentry: failed to parse error event", "err", err)
192 return "", item.Payload
193 }
194
195 // Sentry SDK v4+ sends event_id only in the envelope header, not in
196 // the item payload. Inject it so downstream consumers (frontend, API)
197 // always see it in the payload.
198 uuid := ev.EventID
199 payload := item.Payload
200 if uuid == "" && envelopeEventID != "" {
201 uuid = envelopeEventID
202 ev.EventID = envelopeEventID
203 payload = injectEventID(payload, envelopeEventID)
204 }
205
206 // Resolve source code for browser/JS frames that only carry file+line.
207 if enriched, changed := enrichSourceContext(payload, nil); changed {
208 payload = enriched
209 _ = json.Unmarshal(payload, &ev) // re-parse so structured storage carries the code too
210 }
211
212 if h.db != nil {
213 if _, err := storeErrorEvent(h.db, &ev, payload, project); err != nil {
214 slog.Warn("sentry: failed to store structured error event", "err", err)
215 }
216 }
217
218 return uuid, payload
219}
220
221// handleTransactionItem processes a "transaction" envelope item.
222func (h *handler) handleTransactionItem(item EnvelopeItem) (string, json.RawMessage) {

Callers 1

handleEnvelopeMethod · 0.95

Calls 3

injectEventIDFunction · 0.85
enrichSourceContextFunction · 0.85
storeErrorEventFunction · 0.85

Tested by

no test coverage detected