Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Features

- Auto-enable required project settings ([#260](https://github.com/getsentry/sentry-godot/pull/260))
- Add `disabled_in_editor_play` option ([#262](https://github.com/getsentry/sentry-godot/pull/262))

### Fixes

Expand Down
3 changes: 3 additions & 0 deletions doc_classes/SentryOptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<member name="disabled_in_editor" type="bool" setter="set_disabled_in_editor" getter="is_disabled_in_editor" default="true">
If [code]true[/code], the SDK will not initialize in the Godot editor.
</member>
<member name="disabled_in_editor_play" type="bool" setter="set_disabled_in_editor_play" getter="is_disabled_in_editor_play" default="false">
If [code]true[/code], the SDK will not initialize when the project is run from within the Godot editor. This differs from [member disabled_in_editor] which prevents initialization when working in the editor itself.
</member>
<member name="dist" type="String" setter="set_dist" getter="get_dist" default="&quot;&quot;">
The application's distribution. Distributions are used to disambiguate build or deployment variants of the same release of an application.
</member>
Expand Down
1 change: 1 addition & 0 deletions project/test/suites/test_options.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func before_test() -> void:
func test_bool_properties(property: String, test_parameters := [
["enabled"],
["disabled_in_editor"],
["disabled_in_editor_play"],
["debug"],
["attach_log"],
["attach_screenshot"],
Expand Down
3 changes: 3 additions & 0 deletions src/sentry/sentry_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void SentryOptions::_define_project_settings(const Ref<SentryOptions> &p_options

_define_setting("sentry/options/enabled", p_options->enabled);
_define_setting("sentry/options/disabled_in_editor", p_options->disabled_in_editor, false);
_define_setting("sentry/options/disabled_in_editor_play", p_options->disabled_in_editor_play);
_requires_restart("sentry/options/disabled_in_editor");
_define_setting("sentry/options/dsn", p_options->dsn);
_define_setting("sentry/options/release", p_options->release, false);
Expand Down Expand Up @@ -102,6 +103,7 @@ void SentryOptions::_load_project_settings(const Ref<SentryOptions> &p_options)

p_options->enabled = ProjectSettings::get_singleton()->get_setting("sentry/options/enabled", p_options->enabled);
p_options->disabled_in_editor = ProjectSettings::get_singleton()->get_setting("sentry/options/disabled_in_editor", p_options->disabled_in_editor);
p_options->disabled_in_editor_play = ProjectSettings::get_singleton()->get_setting("sentry/options/disabled_in_editor_play", p_options->disabled_in_editor_play);
p_options->dsn = ProjectSettings::get_singleton()->get_setting("sentry/options/dsn", p_options->dsn);
p_options->dist = ProjectSettings::get_singleton()->get_setting("sentry/options/dist", p_options->dist);

Expand Down Expand Up @@ -175,6 +177,7 @@ void SentryOptions::remove_event_processor(const Ref<SentryEventProcessor> &p_pr
void SentryOptions::_bind_methods() {
BIND_PROPERTY(SentryOptions, PropertyInfo(Variant::BOOL, "enabled"), set_enabled, is_enabled);
BIND_PROPERTY(SentryOptions, PropertyInfo(Variant::BOOL, "disabled_in_editor"), set_disabled_in_editor, is_disabled_in_editor);
BIND_PROPERTY(SentryOptions, PropertyInfo(Variant::BOOL, "disabled_in_editor_play"), set_disabled_in_editor_play, is_disabled_in_editor_play);
BIND_PROPERTY(SentryOptions, PropertyInfo(Variant::STRING, "dsn"), set_dsn, get_dsn);
BIND_PROPERTY(SentryOptions, PropertyInfo(Variant::STRING, "release"), set_release, get_release);
BIND_PROPERTY(SentryOptions, PropertyInfo(Variant::STRING, "dist"), set_dist, get_dist);
Expand Down
4 changes: 4 additions & 0 deletions src/sentry/sentry_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class SentryOptions : public RefCounted {

bool enabled = true;
bool disabled_in_editor = true;
bool disabled_in_editor_play = false;
String dsn = "";
String release = "{app_name}@{app_version}";
String dist = "";
Expand Down Expand Up @@ -97,6 +98,9 @@ class SentryOptions : public RefCounted {
_FORCE_INLINE_ bool is_disabled_in_editor() const { return disabled_in_editor; }
_FORCE_INLINE_ void set_disabled_in_editor(bool p_disabled_in_editor) { disabled_in_editor = p_disabled_in_editor; }

_FORCE_INLINE_ bool is_disabled_in_editor_play() const { return disabled_in_editor_play; }
_FORCE_INLINE_ void set_disabled_in_editor_play(bool p_disabled_in_editor_play) { disabled_in_editor_play = p_disabled_in_editor_play; }

_FORCE_INLINE_ String get_dsn() const { return dsn; }
_FORCE_INLINE_ void set_dsn(const String &p_dsn) { dsn = p_dsn; }

Expand Down
5 changes: 5 additions & 0 deletions src/sentry/sentry_sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ void SentrySDK::_initialize() {
sentry::util::print_debug("Sentry SDK is disabled in the editor. Tip: This can be changed in the project settings.");
}

if (!Engine::get_singleton()->is_editor_hint() && OS::get_singleton()->has_feature("editor") && SentryOptions::get_singleton()->is_disabled_in_editor_play()) {
should_enable = false;
sentry::util::print_debug("Sentry SDK is disabled during editor play. Tip: This can be changed in the project settings.");
}

if (should_enable) {
#ifdef NATIVE_SDK
internal_sdk = std::make_shared<NativeSDK>();
Expand Down
Loading