Skip to content

Conversation

@Litarnus
Copy link
Contributor

@Litarnus Litarnus commented Sep 25, 2025

Introducing attachment support for PHP!

Attachments can be set on Scopes and will be added to Errors and Transaction events when sending them to sentry.

The PR currently does not enforce limits and reads the entire attachment content in memory before sending it. There is room for improvement such as respecting attachment limits as well as streaming the envelope to reduce the memory impact.

@Litarnus Litarnus self-assigned this Sep 29, 2025
@Litarnus Litarnus added the 5.x label Sep 29, 2025
Copy link
Collaborator

@stayallive stayallive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single suggestion but nothing major. Looks good to me!

switch ($event->getType()) {
case EventType::event():
$items[] = EventItem::toEnvelopeItem($event);
$items[] = AttachmentItem::toEnvelopeItem($event);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clarity I think I would go for this (also in the transaction) instead and move the loop here. Yes it's a little more duplicated code but I think the clarity is a little better to also keep all the toEnvelopeItem methods returning a single item instead of multiple or none.

Suggested change
$items[] = AttachmentItem::toEnvelopeItem($event);
foreach ($event->getAttachments() as $attachment) {
$items[] = AttachmentItem::toEnvelopeItem($attachment);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, very good point!

@Litarnus Litarnus marked this pull request as ready for review October 14, 2025 09:28
cursor[bot]

This comment was marked as outdated.

@Litarnus Litarnus merged commit aad2e28 into 5.x Oct 23, 2025
38 checks passed
@Litarnus Litarnus deleted the martinl/attachments branch October 23, 2025 14:12
@Litarnus Litarnus linked an issue Oct 28, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[5.x] Explore supporting Attachments

3 participants