|
7 | 7 |
|
8 | 8 | from sentry_sdk._compat import string_types, text_type, iteritems
|
9 | 9 | from sentry_sdk.utils import (
|
10 |
| - handle_in_app, |
11 |
| - get_type_name, |
12 | 10 | capture_internal_exceptions,
|
13 | 11 | current_stacktrace,
|
14 | 12 | disable_capture_event,
|
| 13 | + format_timestamp, |
| 14 | + get_type_name, |
| 15 | + handle_in_app, |
15 | 16 | logger,
|
16 | 17 | )
|
17 | 18 | from sentry_sdk.serializer import serialize
|
|
20 | 21 | from sentry_sdk.integrations import setup_integrations
|
21 | 22 | from sentry_sdk.utils import ContextVar
|
22 | 23 | from sentry_sdk.sessions import SessionFlusher
|
23 |
| -from sentry_sdk.envelope import Envelope |
| 24 | +from sentry_sdk.envelope import Envelope, Item, PayloadRef |
24 | 25 |
|
25 | 26 | from sentry_sdk._types import MYPY
|
26 | 27 |
|
@@ -334,7 +335,22 @@ def capture_event(
|
334 | 335 | if session:
|
335 | 336 | self._update_session_from_event(session, event)
|
336 | 337 |
|
337 |
| - self.transport.capture_event(event_opt) |
| 338 | + if event_opt.get("type") == "transaction": |
| 339 | + # Transactions should go to the /envelope/ endpoint. |
| 340 | + self.transport.capture_envelope( |
| 341 | + Envelope( |
| 342 | + headers={ |
| 343 | + "event_id": event_opt["event_id"], |
| 344 | + "sent_at": format_timestamp(datetime.utcnow()), |
| 345 | + }, |
| 346 | + items=[ |
| 347 | + Item(payload=PayloadRef(json=event_opt), type="transaction"), |
| 348 | + ], |
| 349 | + ) |
| 350 | + ) |
| 351 | + else: |
| 352 | + # All other events go to the /store/ endpoint. |
| 353 | + self.transport.capture_event(event_opt) |
338 | 354 | return event_id
|
339 | 355 |
|
340 | 356 | def capture_session(
|
|
0 commit comments