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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Add support for script context and variables on Apple platforms ([#306](https://github.com/getsentry/sentry-godot/pull/306))

### Improvements

- Improve initialization flow ([#322](https://github.com/getsentry/sentry-godot/pull/322))

### Dependencies

- Bump Cocoa SDK from v8.54.0 to v8.55.0 ([#318](https://github.com/getsentry/sentry-godot/pull/318))
Expand Down
74 changes: 41 additions & 33 deletions src/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,59 +39,67 @@
using namespace godot;
using namespace sentry;

void initialize_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_CORE) {
} else if (p_level == godot::MODULE_INITIALIZATION_LEVEL_SERVERS) {
} else if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
GDREGISTER_CLASS(SentryLoggerLimits);
GDREGISTER_CLASS(SentryOptions);
GDREGISTER_INTERNAL_CLASS(RuntimeConfig);
GDREGISTER_CLASS(SentryConfiguration);
GDREGISTER_CLASS(SentryUser);
GDREGISTER_CLASS(SentryTimestamp);
GDREGISTER_CLASS(SentrySDK);
GDREGISTER_ABSTRACT_CLASS(SentryAttachment);
GDREGISTER_ABSTRACT_CLASS(SentryEvent);
GDREGISTER_INTERNAL_CLASS(DisabledEvent);
GDREGISTER_INTERNAL_CLASS(SentryEventProcessor);
GDREGISTER_INTERNAL_CLASS(ScreenshotProcessor);
GDREGISTER_INTERNAL_CLASS(ViewHierarchyProcessor);
GDREGISTER_INTERNAL_CLASS(SentryLogger);
void register_runtime_classes() {
GDREGISTER_CLASS(SentryLoggerLimits);
GDREGISTER_CLASS(SentryOptions);
GDREGISTER_INTERNAL_CLASS(RuntimeConfig);
GDREGISTER_CLASS(SentryConfiguration);
GDREGISTER_CLASS(SentryUser);
GDREGISTER_CLASS(SentryTimestamp);
GDREGISTER_CLASS(SentrySDK);
GDREGISTER_ABSTRACT_CLASS(SentryAttachment);
GDREGISTER_ABSTRACT_CLASS(SentryEvent);
GDREGISTER_INTERNAL_CLASS(DisabledEvent);
GDREGISTER_INTERNAL_CLASS(SentryEventProcessor);
GDREGISTER_INTERNAL_CLASS(ScreenshotProcessor);
GDREGISTER_INTERNAL_CLASS(ViewHierarchyProcessor);
GDREGISTER_INTERNAL_CLASS(SentryLogger);

#ifdef SDK_NATIVE
GDREGISTER_INTERNAL_CLASS(NativeEvent);
GDREGISTER_INTERNAL_CLASS(NativeEvent);
#endif

#ifdef SDK_ANDROID
GDREGISTER_INTERNAL_CLASS(AndroidEvent);
GDREGISTER_INTERNAL_CLASS(SentryAndroidBeforeSendHandler);
GDREGISTER_INTERNAL_CLASS(AndroidEvent);
GDREGISTER_INTERNAL_CLASS(SentryAndroidBeforeSendHandler);
#endif

#ifdef SDK_COCOA
GDREGISTER_INTERNAL_CLASS(cocoa::CocoaEvent);
GDREGISTER_INTERNAL_CLASS(cocoa::CocoaEvent);
#endif
}

SentryOptions::create_singleton();

SentrySDK *sentry_singleton = memnew(SentrySDK);
Engine::get_singleton()->register_singleton("SentrySDK", SentrySDK::get_singleton());
} else if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
void register_editor_classes() {
#ifdef TOOLS_ENABLED
GDREGISTER_INTERNAL_CLASS(SentryEditorExportPluginAndroid);
GDREGISTER_INTERNAL_CLASS(SentryEditorPlugin);

#ifndef WINDOWS_ENABLED
GDREGISTER_INTERNAL_CLASS(SentryEditorExportPluginUnix);
GDREGISTER_INTERNAL_CLASS(SentryEditorExportPluginUnix);
#endif // !WINDOWS_ENABLED
GDREGISTER_INTERNAL_CLASS(SentryEditorExportPluginAndroid);
GDREGISTER_INTERNAL_CLASS(SentryEditorPlugin);

#endif // TOOLS_ENABLED
}

void initialize_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_CORE) {
} else if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) {
} else if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
register_runtime_classes();
SentryOptions::create_singleton();
SentrySDK::create_singleton();
SentrySDK::get_singleton()->prepare_and_auto_initialize();
} else if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
#ifdef TOOLS_ENABLED
register_editor_classes();
EditorPlugins::add_by_type<SentryEditorPlugin>();
#endif // TOOLS_ENABLED
}
}

void uninitialize_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
if (SentrySDK::get_singleton()) {
memdelete(SentrySDK::get_singleton());
}
SentrySDK::destroy_singleton();
SentryOptions::destroy_singleton();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/android/android_sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void AndroidSDK::add_attachment(const Ref<SentryAttachment> &p_attachment) {
}
}

void AndroidSDK::initialize(const PackedStringArray &p_global_attachments) {
void AndroidSDK::init(const PackedStringArray &p_global_attachments) {
ERR_FAIL_NULL(android_plugin);

sentry::util::print_debug("Initializing Sentry Android SDK");
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/android/android_sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AndroidSDK : public InternalSDK {

virtual void add_attachment(const Ref<SentryAttachment> &p_attachment) override;

virtual void initialize(const PackedStringArray &p_global_attachments) override;
virtual void init(const PackedStringArray &p_global_attachments) override;

bool has_android_plugin() const { return android_plugin != nullptr; }

Expand Down
3 changes: 1 addition & 2 deletions src/sentry/cocoa/cocoa_sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class CocoaSDK : public InternalSDK {

virtual void add_attachment(const Ref<SentryAttachment> &p_attachment) override;

virtual void initialize(const PackedStringArray &p_global_attachments) override;

virtual void init(const PackedStringArray &p_global_attachments) override;
bool is_enabled() const;

CocoaSDK();
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/cocoa/cocoa_sdk.mm
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
}];
}

void CocoaSDK::initialize(const PackedStringArray &p_global_attachments) {
void CocoaSDK::init(const PackedStringArray &p_global_attachments) {
[PrivateSentrySDKOnly setSdkName:@"sentry.cocoa.godot"];

[objc::SentrySDK startWithConfigureOptions:^(objc::SentryOptions *options) {
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/disabled/disabled_sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DisabledSDK : public InternalSDK {

virtual void add_attachment(const Ref<SentryAttachment> &p_attachment) override {}

virtual void initialize(const PackedStringArray &p_global_attachments) override {}
virtual void init(const PackedStringArray &p_global_attachments) override {}
};

} // namespace sentry
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/internal_sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class InternalSDK {

virtual void add_attachment(const Ref<SentryAttachment> &p_attachment) = 0;

virtual void initialize(const PackedStringArray &p_global_attachments) = 0;
virtual void init(const PackedStringArray &p_global_attachments) = 0;

virtual ~InternalSDK() = default;
};
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/native/native_sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void NativeSDK::add_attachment(const Ref<SentryAttachment> &p_attachment) {
}
}

void NativeSDK::initialize(const PackedStringArray &p_global_attachments) {
void NativeSDK::init(const PackedStringArray &p_global_attachments) {
ERR_FAIL_NULL(OS::get_singleton());
ERR_FAIL_NULL(ProjectSettings::get_singleton());

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/native/native_sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class NativeSDK : public InternalSDK {

virtual void add_attachment(const Ref<SentryAttachment> &p_attachment) override;

virtual void initialize(const PackedStringArray &p_global_attachments) override;
virtual void init(const PackedStringArray &p_global_attachments) override;

NativeSDK();
virtual ~NativeSDK() override;
Expand Down
Loading
Loading