injectEventID adds "event_id" to a JSON payload that lacks it. Used to normalize Sentry SDK v4+ payloads which omit event_id from item bodies.
(payload json.RawMessage, eventID string)
| 287 | // injectEventID adds "event_id" to a JSON payload that lacks it. |
| 288 | // Used to normalize Sentry SDK v4+ payloads which omit event_id from item bodies. |
| 289 | func injectEventID(payload json.RawMessage, eventID string) json.RawMessage { |
| 290 | var obj map[string]json.RawMessage |
| 291 | if err := json.Unmarshal(payload, &obj); err != nil { |
| 292 | return payload |
| 293 | } |
| 294 | obj["event_id"] = json.RawMessage(`"` + eventID + `"`) |
| 295 | result, err := json.Marshal(obj) |
| 296 | if err != nil { |
| 297 | return payload |
| 298 | } |
| 299 | return result |
| 300 | } |
| 301 | |
| 302 | // decompress handles gzip and deflate Content-Encoding. |
| 303 | // Also auto-detects gzip/zlib by magic bytes if header is missing. |