Skip to content

Commit 52e4583

Browse files
committed
Add a top level API for add_attachment
1 parent 060b2cf commit 52e4583

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

sentry_sdk/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"integrations",
1717
# From sentry_sdk.api
1818
"init",
19+
"add_attachment",
1920
"add_breadcrumb",
2021
"capture_event",
2122
"capture_exception",

sentry_sdk/api.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
# When changing this, update __all__ in __init__.py too
4040
__all__ = [
4141
"init",
42+
"add_attachment",
4243
"add_breadcrumb",
4344
"capture_event",
4445
"capture_exception",
@@ -171,6 +172,20 @@ def capture_exception(
171172
return get_current_scope().capture_exception(error, scope=scope, **scope_kwargs)
172173

173174

175+
@scopemethod
176+
def add_attachment(
177+
bytes=None, # type: Union[None, bytes, Callable[[], bytes]]
178+
filename=None, # type: Optional[str]
179+
path=None, # type: Optional[str]
180+
content_type=None, # type: Optional[str]
181+
add_to_transactions=False, # type: bool
182+
):
183+
# type: (...) -> None
184+
return get_isolation_scope().add_attachment(
185+
bytes, filename, path, content_type, add_to_transactions
186+
)
187+
188+
174189
@scopemethod
175190
def add_breadcrumb(
176191
crumb=None, # type: Optional[sentry_sdk._types.Breadcrumb]

0 commit comments

Comments
 (0)