-
-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Add user attachments support #205
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
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
d4dc098
Add user attachments
limbonaut 6ff3797
Make attachment properties readonly
limbonaut 017cf87
Return null for empty path
limbonaut 8929e9a
Add class reference
limbonaut 70e4a13
Update SentryAttachment.xml
limbonaut 4508c99
Add remove attachments on Android
limbonaut 9568f2b
Update disabled_attachment.h
limbonaut 39db26c
Remove attachment specializations
limbonaut 568cd50
Add attachment.filename and rename path property
limbonaut 2207e02
Clarify comment
limbonaut ac340a4
Update SentryAttachment.xml
limbonaut c5172a5
Remove setters
limbonaut 6c4e679
Dont add attachments to transactions as per recommendation
limbonaut fe5b491
Add simple test
limbonaut b526f8d
Redundant call
limbonaut 2835ce0
Merge branch 'main' into feat/user-attachments
limbonaut d41169b
Create/add attachments from bytes (native)
limbonaut a174012
Update test_attachment.gd
limbonaut 7c8857c
Create/add attachments android
limbonaut 09c11a6
Update native_sdk.cpp
limbonaut 8707143
Add controls to create an attachment in the demo project
limbonaut 9000027
Update SentryAttachment.xml
limbonaut 43f7b35
Fix global attachments on Android
limbonaut 5710a6e
Update doc
limbonaut d5d40e5
Update CHANGELOG.md
limbonaut fab96b6
Fix unused variable in bridge layer
limbonaut 3a02431
Remove virtual destructor since SentryAttachment is no longer a base
limbonaut 72843c5
Improve null safety in the bridge layer while handling attachments
limbonaut 58da2f6
Add corrections to SentrySDK.xml
limbonaut eea3098
Add setters and simplify creator methods
limbonaut 31a7519
Remove default values from creator methods
limbonaut 8181977
Remove remove_attachment() method
limbonaut 624b150
Add MIME type info to SentryAttachment content_type docs
limbonaut 398a5b5
Add usage examples
limbonaut 1bc3ed1
Merge branch 'main' into feat/user-attachments
limbonaut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="SentryAttachment" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd"> | ||
<brief_description> | ||
Represents a file attachment that can be sent with Sentry events. | ||
</brief_description> | ||
<description> | ||
SentryAttachment represents a file that can be attached to Sentry events to provide additional context. Attachments are files that are uploaded alongside error reports and can include log files, screenshots, configuration files, or any other relevant data. | ||
Attachments can be created using [method SentryAttachment.create_with_path] for existing files on disk. Once created, they can be added to future events using [method SentrySDK.add_attachment]: | ||
[codeblock] | ||
var attachment := SentryAttachment.create_with_path("user://logs/godot.log") | ||
attachment.content_type = "text/plain" | ||
SentrySDK.add_attachment(attachment) | ||
[/codeblock] | ||
Attachments can also be created using [method SentryAttachment.create_with_bytes] for data already in memory: | ||
[codeblock] | ||
var bytes: PackedByteArray = "Hello, world!".to_ascii_buffer() | ||
var attachment := SentryAttachment.create_with_bytes(bytes, "hello.txt") | ||
attachment.content_type = "text/plain" | ||
SentrySDK.add_attachment(attachment) | ||
[/codeblock] | ||
To learn more about attachments, visit [url=https://docs.sentry.io/platforms/godot/enriching-events/attachments/]Attachments documentation[/url]. | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<methods> | ||
<method name="create_with_bytes" qualifiers="static"> | ||
<return type="SentryAttachment" /> | ||
<param index="0" name="bytes" type="PackedByteArray" /> | ||
<param index="1" name="filename" type="String" /> | ||
<description> | ||
Creates a new [SentryAttachment] with the specified [param bytes] data and [param filename]. The [param bytes] parameter contains the raw file data to be attached. The [param filename] parameter specifies the display name for the attachment in Sentry. | ||
This method is useful when you have file data already loaded in memory or when creating attachments from generated content rather than existing files on disk. | ||
</description> | ||
</method> | ||
<method name="create_with_path" qualifiers="static"> | ||
<return type="SentryAttachment" /> | ||
<param index="0" name="path" type="String" /> | ||
<description> | ||
Creates a new [SentryAttachment] with the specified file [param path] and optional [param filename] and [param content_type]. The [param path] should point to an existing file and supports Godot's virtual file system paths like "user://". | ||
[b]Note:[/b] Modifying attachment properties after the attachment has been added with [method SentrySDK.add_attachment] will have no effect. To apply property changes, you need to re-add the attachment. | ||
[b]Important:[/b] Attachments are read lazily at the time an event is sent to Sentry. | ||
</description> | ||
</method> | ||
</methods> | ||
<members> | ||
<member name="bytes" type="PackedByteArray" setter="set_bytes" getter="get_bytes"> | ||
Contains the raw byte data of the attachment. | ||
</member> | ||
<member name="content_type" type="String" setter="set_content_type" getter="get_content_type"> | ||
The MIME content type of the attachment file. This helps Sentry understand how to handle and display the attachment. | ||
Sentry understands and renders the following MIME types: [code]text/plain[/code], [code]text/css[/code], [code]text/csv[/code], [code]text/html[/code], [code]text/javascript[/code], [code]text/json[/code] or [code]text/x-json[/code] or [code]application/json[/code] or [code]application/ld+json[/code], [code]image/jpeg[/code], [code]image/png[/code], [code]image/gif[/code]. | ||
</member> | ||
<member name="filename" type="String" setter="set_filename" getter="get_filename"> | ||
The filename of the attachment. This is the name that will be displayed in Sentry. If not provided, the filename will be extracted from the [member path]. | ||
</member> | ||
<member name="path" type="String" setter="set_path" getter="get_path"> | ||
The file path of the attachment. This can be an absolute path or use Godot's virtual file system paths such as "user://". | ||
</member> | ||
</members> | ||
</class> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
extends GdUnitTestSuite | ||
## Basic tests for the SentryAttachment class. | ||
|
||
|
||
func test_create_with_path() -> void: | ||
var attachment := SentryAttachment.create_with_path("user://logs/godot.log") | ||
attachment.filename = "logfile.txt" | ||
attachment.content_type = "text/plain" | ||
|
||
assert_array(attachment.bytes).is_empty() | ||
assert_str(attachment.path).is_equal("user://logs/godot.log") | ||
assert_str(attachment.filename).is_equal("logfile.txt") | ||
assert_str(attachment.content_type).is_equal("text/plain") | ||
|
||
|
||
func test_create_with_bytes() -> void: | ||
var contents := """ | ||
Hello, world! | ||
""" | ||
var bytes: PackedByteArray = contents.to_utf8_buffer() | ||
|
||
var attachment := SentryAttachment.create_with_bytes(bytes, "hello.txt") | ||
attachment.content_type = "text/plain" | ||
|
||
assert_array(attachment.bytes).is_not_empty() | ||
assert_str(attachment.path).is_empty() | ||
assert_str(attachment.filename).is_equal("hello.txt") | ||
assert_str(attachment.content_type).is_equal("text/plain") | ||
|
||
assert_int(attachment.bytes.size()).is_equal(bytes.size()) | ||
for i in attachment.bytes.size(): | ||
assert_int(attachment.bytes[i]).is_equal(bytes[i]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uid://b10m6784fkgyb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.