-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: Event objects #51
base: main
Are you sure you want to change the base?
Conversation
So we don't return a null object when SDK is disabled
src/sentry_sdk.h
Outdated
String get_last_event_id() const; | ||
|
||
Ref<SentryEvent> create_event() const; | ||
Ref<SentryEvent> create_message_event(const String &p_message, sentry::Level p_level = sentry::LEVEL_INFO, const String &p_logger = ""); |
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.
Do we need to expose logger
? It's unclear what it's used for.
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.
I don't see the use for logger either. Logging itself is setup during initialization, right?
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.
Our error logger is set up at initialization and has nothing to do with this. I'm not even sure what this field is used for. This logger
bit is a part of event payload:
Maybe we just remove this part from function call, but leave it as property of SenteryEvent
?
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.
It's a part of sentry-native call, so I left it as is:
https://github.com/getsentry/sentry-native/blob/3981ea7e7fd012524e4c04501c9dd647563aa391/include/sentry.h#L377-L380
We also have it in capture_message
signature.
|
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.
This looks good to me!
I'm just questioning the usecase of create_message_event
.
|
||
#include "sentry_event.h" | ||
|
||
// Event class that is used when the SDK is disabled. |
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.
Where does the need for a DisabledEvent
come from? Can't we use the SentryEvent and still have the SDK disabled?
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.
SentryEvent
is abstract and cannot be instantiated, and it's supposed to be implemented by NativeEvent
class and such (for each internal SDK used). The reason behind DisabledEvent
is to return a non-null value, so that it doesn't break scripts which may not be checking if SentrySDK
is enabled. I could put this logic into SentryEvent
, but it would add some bloated state to each event. I.e. SentryEvent
is basically an interface.
|
||
namespace { | ||
|
||
inline void _sentry_value_set_or_remove_string_by_key(sentry_value_t value, const char *k, const String &v) { |
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.
So we end up with shortcuts and instead of event.remove_release()
we want users to use event.set_release("")
?
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.
Not sure if I understand the question. This is a helper method. It sets a string value on a sentry_value
object, unless the string is empty, in which case it removes such key. Hence, the name of the method.
So we don't store such values:
os.name = ""
Instead, we remove the os.name
key-value from the object.
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.
Oh, I think I see what you mean. We have a pair of setter/getter for each property of SentryEvent
.
event.release
is how we access it in GDScript. event.release = "some_release"
is how we set it. So in order to remove the value, we would be doing event.release = ""
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.
@bitsandfoxes Do you think we need explicit methods for removing event properties?
src/sentry/native/native_sdk.cpp
Outdated
Ref<SentryEvent> NativeSDK::create_message_event(const String &p_message, sentry::Level p_level, const String &p_logger) { | ||
sentry_value_t event_value = sentry_value_new_message_event( | ||
native::level_to_native(p_level), | ||
p_logger.utf8().get_data(), | ||
p_message.utf8().get_data()); | ||
Ref<SentryEvent> event = memnew(NativeEvent(event_value)); | ||
return event; | ||
} |
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.
I'm wondering, what's the usecase for this over capture_message
?
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.
Technically, this is not necessary, as you can add an event, set its message and level properties, and whichever other properties you need. So this can be removed - it's a shortcut for creating customized message events. I think I took it from some other SDKs, I'm not sure.
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.
Removed in 8e3ac2c
src/sentry_sdk.h
Outdated
String get_last_event_id() const; | ||
|
||
Ref<SentryEvent> create_event() const; | ||
Ref<SentryEvent> create_message_event(const String &p_message, sentry::Level p_level = sentry::LEVEL_INFO, const String &p_logger = ""); |
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.
I don't see the use for logger either. Logging itself is setup during initialization, right?
988c53a
to
8e3ac2c
Compare
This PR implements:
SentryEvent
objects, which can be used to create or modify an event, and a native implementation.NativeEvent
class -- implementation used withNativeSDK
SentrySDK.capture_event(event)
,SentrySDK.create_event()
,SentrySDK.create_message_event()
methods.SentryEvent
class and SDK methods.In future PRs, we can implement accessing tags, breadcrumbs, contexts, fingerprint, etc.
Dependency for: