-
-
Notifications
You must be signed in to change notification settings - Fork 12
feat: Allow initializing manually and shutting down SentrySDK #321
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 45 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
d7f8249
Explicit singleton
limbonaut cdaa093
Refactor Sentry class registration
limbonaut 0a91456
Auto-initialize in a separate step, ensure internal SDK is ready early
limbonaut 044263a
Rename func => _auto_initialize()
limbonaut d809e8b
Move event processor initialization to prepare step
limbonaut 62bb04f
Correct comment
limbonaut 6e4835f
Fix Android compilation
limbonaut 6cba510
Simplify Android enabling code
limbonaut a721f65
Rename initialize => init
limbonaut 6cf9fd7
Update CHANGELOG.md
limbonaut c61ad72
Return plugin check on Android
limbonaut 744d5a3
Update CHANGELOG.md
limbonaut 5670b80
Merge branch 'main' into ref/impove-initialization-extracted
limbonaut 847f49e
Add SentrySDK.init(), close(), is_enabled()
limbonaut 1250511
Remove enabled flag and move logger registration into init()
limbonaut ee888c4
Add error handling for _configure
limbonaut 8a8304f
Move contexts init logic into init()
limbonaut 9310679
Whitespace fix
limbonaut 0b5f933
Expose new methods, and add docs
limbonaut b25c545
Add tests for lifecycle methods
limbonaut dc71c41
Rename lifecycle test to test_sdk_lifecycle.gd
limbonaut 3356bc2
Add tests for closing SDK
limbonaut 9b31037
Fix issues with SentryLogger connecting to signal
limbonaut a21f3e9
Fix initialized flag should be set to false in NativeSDK on close(), and
limbonaut b8a9732
Merge branch 'main' into ref/improve-initialization
limbonaut 11fcc68
Rename enabled/disabled options, remove them from exposed properties,
limbonaut bb1681d
Remove configuration script option
limbonaut b6c0a9c
Add configuration callback in init()
limbonaut 6f07401
Remove SentryConfiguration class
limbonaut 5c2a211
Merge branch 'main' into ref/improve-initialization
limbonaut 1dbdbcb
Replace configuration script with init() & before_send example from
limbonaut 320a903
Adjust isolation tests for new init
limbonaut bdb697e
Remove testing_configuration.gd
limbonaut 38f016b
Adjust normal test suites for the new init
limbonaut f5a7da9
Update docs
limbonaut a26c9a5
Update SentrySDK.xml
limbonaut 9baac57
Update docs with initialization & configuration examples
limbonaut 1ee4106
Fix user not initialized if init() is not called
limbonaut cc00783
Restore SDK lifecycle isolated test
limbonaut a2c541b
Cosmetic fixes for docs
limbonaut 3ee3da5
Auto doc fixes
limbonaut 680d16f
Remove test_sdk_close as redundant
limbonaut d548380
Move contexts initialization into sentry::contexts
limbonaut e4b1ac3
Refactor context initialization to avoid Godot errors
limbonaut c99f787
Rename initialize => init on Android
limbonaut dd112bd
Revert "Move contexts initialization into sentry::contexts"
limbonaut 2e15faf
Only close SDK if enabled in destructors
limbonaut 888c017
Remove unused should_delay_contexts function
limbonaut c591cd9
Update CHANGELOG.md
limbonaut cd31f66
Update CHANGELOG.md
limbonaut 89dbb9b
Fix link in CHANGELOG
limbonaut 03dd1bb
Don't auto-initialize if DSN is empty
limbonaut 973403f
Explain gui-only options in SentryOptions
limbonaut 940df89
Fix unterminated bbcode
limbonaut 521276e
Sync with docs
limbonaut 7c34f6e
Update SentryOptions.xml
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 was deleted.
Oops, something went wrong.
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 |
|---|---|---|
|
|
@@ -44,6 +44,12 @@ | |
| Captures an event with [param message] and sends it to Sentry, returning the event ID. | ||
| </description> | ||
| </method> | ||
| <method name="close"> | ||
| <return type="void" /> | ||
| <description> | ||
| Closes the SDK and flushes any pending events to ensure all queued data is sent to Sentry before shutdown. Called automatically when the application exits. | ||
| </description> | ||
| </method> | ||
| <method name="create_event" qualifiers="const"> | ||
| <return type="SentryEvent" /> | ||
| <description> | ||
|
|
@@ -62,6 +68,35 @@ | |
| Returns the currently set user. See [SentryUser]. | ||
| </description> | ||
| </method> | ||
| <method name="init"> | ||
| <return type="void" /> | ||
| <param index="0" name="configuration_callback" type="Callable" default="Callable()" /> | ||
| <description> | ||
| Initializes the SDK. Called automatically during startup if "Auto Init" is enabled in the project settings. | ||
| Manual initialization is only needed when you want to control the exact timing of SDK startup, or when you need to initialize options from code, or use callbacks such as [member SentryOptions.before_send]. Make sure to disable "Auto Init" in the project settings if you intend to manually initialize the SDK. | ||
| [b]Note[/b]: The earliest place to initialize Sentry from script is in the [method MainLoop._initialize]. | ||
| You can customize the SDK's options by passing a [param configuration_callback] function. Here's a complete example: | ||
| [codeblock] | ||
| class_name ProjectMainLoop | ||
| extends SceneTree | ||
| # Tip: Assign ProjectMainLoop as your main loop type in the project settings | ||
| # under `application/run/main_loop_type`. | ||
|
|
||
| func _initialize() -> void: | ||
| SentrySDK.init(func(options: SentryOptions) -> void: | ||
| options.debug = true | ||
| options.release = "[email protected]" | ||
| options.environment = "production" | ||
| options.before_send = _on_before_send_to_sentry | ||
| ) | ||
|
|
||
| func _on_before_send_to_sentry(event: SentryEvent) -> SentryEvent: | ||
| # Process event and return either the same event object, | ||
| # with or withour modifications, or null to skip reporting the event. | ||
| return event | ||
| [/codeblock] | ||
| </description> | ||
| </method> | ||
| <method name="is_enabled" qualifiers="const"> | ||
| <return type="bool" /> | ||
| <description> | ||
|
|
||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ config_version=5 | |
| config/name="Sentry demo project" | ||
| config/version="1.0.0-beta.1" | ||
| run/main_scene="uid://cqiowj0jydds1" | ||
| run/main_loop_type="ProjectMainLoop" | ||
| config/features=PackedStringArray("4.5") | ||
| run/flush_stdout_on_print=true | ||
| config/icon="uid://djdyhgbcdue6n" | ||
|
|
@@ -45,8 +46,8 @@ textures/vram_compression/import_etc2_astc=true | |
|
|
||
| [sentry] | ||
|
|
||
| options/auto_init=false | ||
| options/dsn="https://[email protected]/6680910" | ||
| options/configuration_script="uid://dmavxxyqbqght" | ||
| options/attach_screenshot=true | ||
| options/attach_scene_tree=true | ||
| logger/include_variables=true | ||
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,36 @@ | ||
| class_name ProjectMainLoop | ||
| extends SceneTree | ||
| ## Example of initializing and configuring Sentry from code. | ||
| ## | ||
| ## The earliest place to initialize Sentry in script is in the MainLoop._initialize(). | ||
| ## Tip: You can assign "ProjectMainLoop" as your main loop class in the project settings | ||
| ## under `application/run/main_loop_type`. | ||
|
|
||
|
|
||
| func _initialize() -> void: | ||
| SentrySDK.init(func(options: SentryOptions) -> void: | ||
| print("INFO: [ProjectMainLoop] Initializing SDK from GDScript") | ||
|
|
||
| options.debug = true | ||
| options.release = "sentry-godot-demo@" + ProjectSettings.get_setting("application/config/version") | ||
| options.environment = "demo" | ||
|
|
||
| # Set up event callbacks | ||
| options.before_send = _on_before_send_to_sentry | ||
| ) | ||
|
|
||
| # Post-initialize | ||
| # SentrySDK.add_attachment(...) | ||
| # ... | ||
limbonaut marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| ## before_send example | ||
| func _on_before_send_to_sentry(ev: SentryEvent) -> SentryEvent: | ||
| print("INFO: [ProjectMainLoop] Processing event: ", ev.id) | ||
| if ev.message.contains("Bruno"): | ||
| print("INFO: [ProjectMainLoop] Removing sensitive information from the event") | ||
| ev.message = ev.message.replace("Bruno", "REDACTED") | ||
| elif ev.message == "junk": | ||
| print("INFO: [ProjectMainLoop] Discarding event with message 'junk'") | ||
| return null | ||
| return ev | ||
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://ckyjdnckvfm8b |
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.