|
9 | 9 |
|
10 | 10 |
|
11 | 11 | if TYPE_CHECKING:
|
| 12 | + from collections.abc import MutableMapping |
| 13 | + |
| 14 | + from datetime import datetime |
| 15 | + |
12 | 16 | from types import TracebackType
|
13 | 17 | from typing import Any
|
14 | 18 | from typing import Callable
|
|
19 | 23 | from typing import Tuple
|
20 | 24 | from typing import Type
|
21 | 25 | from typing import Union
|
22 |
| - from typing_extensions import Literal |
| 26 | + from typing_extensions import Literal, TypedDict |
| 27 | + |
| 28 | + # "critical" is an alias of "fatal" recognized by Relay |
| 29 | + LogLevelStr = Literal["fatal", "critical", "error", "warning", "info", "debug"] |
| 30 | + |
| 31 | + Event = TypedDict( |
| 32 | + "Event", |
| 33 | + { |
| 34 | + "breadcrumbs": dict[ |
| 35 | + Literal["values"], list[dict[str, Any]] |
| 36 | + ], # TODO: We can expand on this type |
| 37 | + "check_in_id": str, |
| 38 | + "contexts": dict[str, dict[str, object]], |
| 39 | + "dist": str, |
| 40 | + "duration": Optional[float], |
| 41 | + "environment": str, |
| 42 | + "errors": list[dict[str, Any]], # TODO: We can expand on this type |
| 43 | + "event_id": str, |
| 44 | + "exception": dict[ |
| 45 | + Literal["values"], list[dict[str, Any]] |
| 46 | + ], # TODO: We can expand on this type |
| 47 | + "extra": MutableMapping[str, object], |
| 48 | + "fingerprint": list[str], |
| 49 | + "level": LogLevelStr, |
| 50 | + "logentry": Mapping[str, object], |
| 51 | + "logger": str, |
| 52 | + "measurements": dict[str, object], |
| 53 | + "message": str, |
| 54 | + "modules": dict[str, str], |
| 55 | + "monitor_config": Mapping[str, object], |
| 56 | + "monitor_slug": Optional[str], |
| 57 | + "platform": Literal["python"], |
| 58 | + "profile": object, # Should be sentry_sdk.profiler.Profile, but we can't import that here due to circular imports |
| 59 | + "release": str, |
| 60 | + "request": dict[str, object], |
| 61 | + "sdk": Mapping[str, object], |
| 62 | + "server_name": str, |
| 63 | + "spans": list[dict[str, object]], |
| 64 | + "stacktrace": dict[ |
| 65 | + str, object |
| 66 | + ], # We access this key in the code, but I am unsure whether we ever set it |
| 67 | + "start_timestamp": datetime, |
| 68 | + "status": Optional[str], |
| 69 | + "tags": MutableMapping[ |
| 70 | + str, str |
| 71 | + ], # Tags must be less than 200 characters each |
| 72 | + "threads": dict[ |
| 73 | + Literal["values"], list[dict[str, Any]] |
| 74 | + ], # TODO: We can expand on this type |
| 75 | + "timestamp": Optional[datetime], # Must be set before sending the event |
| 76 | + "transaction": str, |
| 77 | + "transaction_info": Mapping[str, Any], # TODO: We can expand on this type |
| 78 | + "type": Literal["check_in", "transaction"], |
| 79 | + "user": dict[str, object], |
| 80 | + "_metrics_summary": dict[str, object], |
| 81 | + }, |
| 82 | + total=False, |
| 83 | + ) |
23 | 84 |
|
24 | 85 | ExcInfo = Tuple[
|
25 | 86 | Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]
|
26 | 87 | ]
|
27 | 88 |
|
28 |
| - Event = Dict[str, Any] |
29 | 89 | Hint = Dict[str, Any]
|
30 | 90 |
|
31 | 91 | Breadcrumb = Dict[str, Any]
|
|
0 commit comments