Skip to content

Godot: Add attachment handling documentation #14210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
86 changes: 86 additions & 0 deletions docs/platforms/godot/enriching-events/attachments/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
title: Attachments
description: "Learn more about how Sentry can store additional files in the same request as event attachments."
---

Sentry can enrich your events for further investigation by storing additional files, such as config or log files, as attachments.

## Creating Attachments

The simplest way to create an attachment is to use a `path`. The SDK will read the contents of the file each time it prepares an event or transaction, then adds the attachment to the same [envelope](https://develop.sentry.dev/sdk/data-model/envelopes/). If the SDK can't read the file, the SDK logs an error message and drops the attachment.

<PlatformContent includePath="enriching-events/attachment-init-with-path" />

Alternately, use `bytes` to initialize an attachment. When doing so, you also need to specify a filename.

<PlatformContent includePath="enriching-events/attachment-init-with-bytes" />

<Alert title="Note">

If your SDK supports offline caching, which is typical for mobile, each attachment is stored to disk for each event or transaction you capture when the device is offline. When using large attachments, this storage can consume the disk space if the device is offline for a longer time period.

</Alert>

In addition, you can set these parameters:

`filename`

The filename is the name of the file to display in Sentry. When using bytes you have to specify a filename, whereas with a path you don't as the SDK is going to use the last path component.

`content_type`

The specific media content type that determines how the attachment is rendered in the Sentry UI. Any [MIME type](https://www.iana.org/assignments/media-types/media-types.xhtml) may be used; the default is `application/octet-stream`.

We currently support and can render the following MIME types:

- `text/plain`
- `text/css`
- `text/csv`
- `text/html`
- `text/javascript`
- `text/json` or `text/x-json` or `application/json` or `application/ld+json`
- `image/jpeg`
- `image/png`
- `image/gif`

## Uploading Attachments

You can add attachments that will be sent with every event using <PlatformIdentifier name="SentrySDK.add-attachment()" /> method.

<PlatformContent includePath="enriching-events/attachment-upload" />

<Alert>

Sentry allows at most 20MB for a compressed request, and at most 100MB of uncompressed attachments per event, including the crash report file (if applicable). Uploads exceeding this size are rejected with HTTP error `413 Payload Too Large` and the data is dropped immediately. To add larger or more files, consider secondary storage options.

</Alert>

Attachments persist for 30 days; if your total storage included in your quota is exceeded, attachments will not be stored. You can delete attachments or their containing events at any time. Deleting an attachment does not affect your quota - Sentry counts an attachment toward your quota as soon as it is stored.

Learn more about how attachments impact your [quota](/pricing/quotas/).

### Access to Attachments

To limit access to attachments, navigate to your organization's **General Settings**, then select the _Attachments Access_ dropdown to set appropriate access — any member of your organization, the organization billing owner, member, admin, manager, or owner.

<Include name="common-imgs/attachments-access" />

By default, access is granted to all members when storage is enabled. If a member does not have access to the project, the ability to download an attachment is not available; the button will be greyed out in Sentry. The member may only view that an attachment is stored.

## Store Minidumps as Attachments

<Include name="store-minidumps-as-attachments-intro" />

<Alert>☝ This feature is supported on Windows, Linux, and Android.</Alert>

<Include name="store-minidumps-as-attachments-configuration" />

## Viewing Attachments

Attachments display on the bottom of the **Issue Details** page for the event that is shown.

<Include name="common-imgs/attachments-access-denied" />

Alternately, attachments also appear in the _Attachments_ tab on the **Issue Details** page, where you can view the _Type_ of attachment, as well as associated events. Click the Event ID to open the **Issue Details** of that specific event.

<Include name="common-imgs/attachments-list-example" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```GDScript
var bytes: PackedByteArray = "Hello, world!".to_ascii_buffer()
var attachment := SentryAttachment.create_with_bytes(bytes, "hello.txt")
attachment.content_type = "text/plain"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```GDScript
var attachment := SentryAttachment.create_with_path("user://logs/godot.log")
attachment.content_type = "text/plain"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```GDScript
# Global scope
var attachment := SentryAttachment.create_with_path("user://logs/godot.log")
attachment.content_type = "text/plain"
SentrySDK.add_attachment(attachment)
```