Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh

### New Features

- Added `add_attachment()` as a top level API, so you can do now: `sentry_sdk.add_attachment(...)` (up until now it was only available on the `Scope`)

### Changed

- The SDK now supports Python 3.7 and higher.
Expand Down
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Capturing Data
Enriching Events
================

.. autofunction:: sentry_sdk.api.add_attachment
.. autofunction:: sentry_sdk.api.add_breadcrumb
.. autofunction:: sentry_sdk.api.set_context
.. autofunction:: sentry_sdk.api.set_extra
Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"integrations",
# From sentry_sdk.api
"init",
"add_attachment",
"add_breadcrumb",
"capture_event",
"capture_exception",
Expand Down
15 changes: 15 additions & 0 deletions sentry_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
# When changing this, update __all__ in __init__.py too
__all__ = [
"init",
"add_attachment",
"add_breadcrumb",
"capture_event",
"capture_exception",
Expand Down Expand Up @@ -171,6 +172,20 @@ def capture_exception(
return get_current_scope().capture_exception(error, scope=scope, **scope_kwargs)


@scopemethod
def add_attachment(
bytes=None, # type: Union[None, bytes, Callable[[], bytes]]
filename=None, # type: Optional[str]
path=None, # type: Optional[str]
content_type=None, # type: Optional[str]
add_to_transactions=False, # type: bool
):
# type: (...) -> None
return get_isolation_scope().add_attachment(
bytes, filename, path, content_type, add_to_transactions
)


@scopemethod
def add_breadcrumb(
crumb=None, # type: Optional[sentry_sdk._types.Breadcrumb]
Expand Down
Loading