Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add an attachment in a before_send handler? #4763

Unanswered
fajpunk asked this question in Q&A
Discussion options

Can I add an attachment in a before_send handler? It looks like this is possible in the JS SDK:
https://docs.sentry.io/platforms/javascript/enriching-events/attachments/#add-or-modify-attachments-before-sending

You must be logged in to vote

Replies: 1 comment

Comment options

Hi @fajpunk,

You can add an attachments just like in JavaScript!

import sentry_sdk
from sentry_sdk.types import Event, Hint
from sentry_sdk.attachments import Attachment
def before_send(event: Event, hint: Hint):
 hint["attachments"] = [Attachment(bytes=b"Hello World!", filename="attachment.txt")]
 return event
sentry_sdk.init(
 ...
 before_send=before_send,
)
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /