|
43 | 43 | from typing import Dict
|
44 | 44 | from typing import Optional
|
45 | 45 | from typing import Sequence
|
| 46 | + from typing import Type |
| 47 | + from typing import Union |
46 | 48 |
|
| 49 | + from sentry_sdk.integrations import Integration |
47 | 50 | from sentry_sdk.scope import Scope
|
48 | 51 | from sentry_sdk._types import Event, Hint
|
49 | 52 | from sentry_sdk.session import Session
|
@@ -153,6 +156,8 @@ class _Client(object):
|
153 | 156 | forwarding them to sentry through the configured transport. It takes
|
154 | 157 | the client options as keyword arguments and optionally the DSN as first
|
155 | 158 | argument.
|
| 159 | +
|
| 160 | + Alias of :py:class:`Client`. (Was created for better intelisense support) |
156 | 161 | """
|
157 | 162 |
|
158 | 163 | def __init__(self, *args, **kwargs):
|
@@ -563,8 +568,8 @@ def capture_event(
|
563 | 568 |
|
564 | 569 | :param hint: Contains metadata about the event that can be read from `before_send`, such as the original exception object or a HTTP request object.
|
565 | 570 |
|
566 |
| - :param scope: An optional scope to use for determining whether this event |
567 |
| - should be captured. |
| 571 | + :param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events. |
| 572 | + The `scope` and `scope_kwargs` parameters are mutually exclusive. |
568 | 573 |
|
569 | 574 | :returns: An event ID. May be `None` if there is no DSN set or of if the SDK decided to discard the event for other reasons. In such situations setting `debug=True` on `init()` may help.
|
570 | 575 | """
|
@@ -667,6 +672,22 @@ def capture_session(
|
667 | 672 | else:
|
668 | 673 | self.session_flusher.add_session(session)
|
669 | 674 |
|
| 675 | + def get_integration( |
| 676 | + self, name_or_class # type: Union[str, Type[Integration]] |
| 677 | + ): |
| 678 | + # type: (...) -> Any |
| 679 | + """Returns the integration for this client by name or class. |
| 680 | + If the client does not have that integration then `None` is returned. |
| 681 | + """ |
| 682 | + if isinstance(name_or_class, str): |
| 683 | + integration_name = name_or_class |
| 684 | + elif name_or_class.identifier is not None: |
| 685 | + integration_name = name_or_class.identifier |
| 686 | + else: |
| 687 | + raise ValueError("Integration has no name") |
| 688 | + |
| 689 | + return self.integrations.get(integration_name) |
| 690 | + |
670 | 691 | def close(
|
671 | 692 | self,
|
672 | 693 | timeout=None, # type: Optional[float]
|
|
0 commit comments