-
-
Notifications
You must be signed in to change notification settings - Fork 9
feat: User feedback API #204
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
base: main
Are you sure you want to change the base?
Changes from all commits
269db3f
d056b19
76c0836
ea3b6db
99dd4f8
9ec133d
8bc173e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="SentryFeedback" 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 user feedback in Sentry. | ||
</brief_description> | ||
<description> | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<members> | ||
<member name="associated_event_id" type="String" setter="set_associated_event_id" getter="get_associated_event_id" default=""""> | ||
The identifier of an error event in the same project. [i]Optional[/i]. | ||
Use this to explicitly link a related error in the feedback UI. | ||
</member> | ||
<member name="contact_email" type="String" setter="set_contact_email" getter="get_contact_email" default=""""> | ||
The email of the user who submitted the feedback. [i]Optional[/i]. | ||
If excluded, Sentry attempts to fill this in with user context. Anonymous feedbacks (no name or email) are still accepted. | ||
</member> | ||
<member name="message" type="String" setter="set_message" getter="get_message" default=""""> | ||
Comments of the user, describing what happened and/or sharing feedback. [i]Required[/i]. | ||
The max length is 4096 characters. | ||
</member> | ||
<member name="name" type="String" setter="set_name" getter="get_name" default=""""> | ||
The name of the user who submitted the feedback. [i]Optional[/i]. | ||
If excluded, Sentry attempts to fill this in with user context. Anonymous feedbacks (no name or email) are still accepted. | ||
</member> | ||
</members> | ||
</class> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
extends GdUnitTestSuite | ||
## Test Feedback class. | ||
@warning_ignore("unused_parameter") | ||
|
||
|
||
func test_feedback_properties() -> void: | ||
var feedback := SentryFeedback.new() | ||
|
||
assert_str(feedback.associated_event_id).is_empty() | ||
feedback.associated_event_id = "082ce03eface41dd94b8c6b005382d5e" | ||
assert_str(feedback.associated_event_id).is_equal("082ce03eface41dd94b8c6b005382d5e") | ||
|
||
assert_str(feedback.name).is_empty() | ||
feedback.name = "Bob" | ||
assert_str(feedback.name).is_equal(feedback.name) | ||
|
||
assert_str(feedback.contact_email).is_empty() | ||
feedback.contact_email = "bob@example.com" | ||
assert_str(feedback.contact_email).is_equal("bob@example.com") | ||
|
||
assert_str(feedback.message).is_empty() | ||
feedback.message = "something happened" | ||
assert_str(feedback.message).is_equal("something happened") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,6 +340,26 @@ String NativeSDK::capture_event(const Ref<SentryEvent> &p_event) { | |
return _uuid_as_string(uuid); | ||
} | ||
|
||
void NativeSDK::capture_feedback(const Ref<SentryFeedback> &p_feedback) { | ||
ERR_FAIL_COND(p_feedback.is_null()); | ||
ERR_FAIL_COND(p_feedback->get_message().is_empty()); | ||
|
||
sentry_uuid_t event_uuid; | ||
if (p_feedback->get_associated_event_id().is_empty()) { | ||
event_uuid = sentry_uuid_nil(); | ||
} else { | ||
event_uuid = sentry_uuid_from_string(p_feedback->get_associated_event_id().ascii()); | ||
} | ||
|
||
sentry_value_t uf = sentry_value_new_user_feedback( | ||
&event_uuid, | ||
p_feedback->get_name().utf8(), | ||
p_feedback->get_contact_email().utf8(), | ||
p_feedback->get_message().utf8()); | ||
|
||
sentry_capture_user_feedback(uf); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we wrapping the old capture_user_feedback here? This will still send the old envelope format There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Godot SDK is built on top of sentry-native, which doesn't yet have the new |
||
} | ||
|
||
void NativeSDK::initialize() { | ||
ERR_FAIL_NULL(OS::get_singleton()); | ||
ERR_FAIL_NULL(ProjectSettings::get_singleton()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "sentry_feedback.h" | ||
|
||
#include "sentry/simple_bind.h" | ||
|
||
void SentryFeedback::_bind_methods() { | ||
BIND_PROPERTY(SentryFeedback, PropertyInfo(Variant::STRING, "name"), set_name, get_name); | ||
BIND_PROPERTY(SentryFeedback, PropertyInfo(Variant::STRING, "contact_email"), set_contact_email, get_contact_email); | ||
BIND_PROPERTY(SentryFeedback, PropertyInfo(Variant::STRING, "message"), set_message, get_message); | ||
BIND_PROPERTY(SentryFeedback, PropertyInfo(Variant::STRING, "associated_event_id"), set_associated_event_id, get_associated_event_id); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef SENTRY_FEEDBACK_H | ||
#define SENTRY_FEEDBACK_H | ||
|
||
#include <godot_cpp/classes/ref_counted.hpp> | ||
|
||
using namespace godot; | ||
|
||
class SentryFeedback : public RefCounted { | ||
GDCLASS(SentryFeedback, RefCounted); | ||
|
||
private: | ||
String name; | ||
String contact_email; | ||
String message; | ||
String associated_event_id; | ||
|
||
protected: | ||
static void _bind_methods(); | ||
|
||
public: | ||
String get_name() const { return name; } | ||
void set_name(const String &p_name) { name = p_name; } | ||
|
||
String get_contact_email() const { return contact_email; } | ||
void set_contact_email(const String &p_contact_email) { contact_email = p_contact_email; } | ||
|
||
String get_message() const { return message; } | ||
void set_message(const String &p_message) { message = p_message; } | ||
|
||
String get_associated_event_id() const { return associated_event_id; } | ||
void set_associated_event_id(const String &p_associated_event_id) { associated_event_id = p_associated_event_id; } | ||
}; | ||
|
||
#endif // SENTRY_FEEDBACK_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a random uuid? If the id doesn't correspond to an error event the feedback won't be created in sentry, if you're using the old
capture_user_feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bringing this up, I didn't realize it's a different protocol.