-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Unity Sentry SDK programmatic setup #130
Conversation
src/Sentry.Unity/Integrations/UnityApplicationLoggingIntegration.cs
Outdated
Show resolved
Hide resolved
src/Sentry.Unity/Integrations/UnityApplicationLoggingIntegration.cs
Outdated
Show resolved
Hide resolved
src/Sentry.Unity/Integrations/UnityBeforeSceneLoadIntegration.cs
Outdated
Show resolved
Hide resolved
Green, yay! |
@@ -105,10 +107,16 @@ public void OnLostFocus() | |||
// ReSharper disable once UnusedMember.Local | |||
private void OnGUI() | |||
{ | |||
GUILayout.Label(new GUIContent(GUIContent.none), EditorStyles.boldLabel); | |||
Options.DisableProgrammaticInitialization = EditorGUILayout.BeginToggleGroup( | |||
new GUIContent("Disable Programmatic Initialization", "Disable manual Sentry setup. Rely on SentryOptions config."), |
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 feels backwards though.
Ideally the experience is defined via SentryWindow. In order to opt-out from the "auto init", we can have a checkbox:
"Initialize SDK programatically'. If the user selects that, the whole SentryWindow
should be disabled. Or best: we hide everything.
Another option it to just rely on the Enable
flag that' already there. If the user Disables it, it means SentryWindow won't be defining the options to initialize the SDK. The user is always free to call SentryUnity.Init
.
I think the best approach is ideal. What are your thoughts? @semuserable @bitsandfoxes
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.
Yeah, I tried to make it like you described, that's why it feels backwards for now. I encountered some problems with the way Unity provides API for this enable/disable functionality. Probably need to take another shot at this.
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.
Another option it to just rely on the Enable flag that' already there. If the user Disables it, it means SentryWindow won't be defining the options to initialize the SDK. The user is always free to call
SentryUnity.Init
.
I think this is the way to go. Any reasons not to take this approach?
@@ -138,6 +142,15 @@ private void OnGUI() | |||
"If not set, auto detects such as 'development', 'production' or 'editor'."), | |||
Options.Environment); | |||
|
|||
GUILayout.Label(new GUIContent(GUIContent.none), EditorStyles.boldLabel); | |||
Options.DisableAutoCompression = EditorGUILayout.BeginToggleGroup( | |||
new GUIContent("Disable Auto Compress Payload", "Disable auto Sentry setup. Rely on SentryOptions config."), |
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 is also a bit confusing IMHO.
Can't we have a "fake" value called Auto
and have that selected? And if a user changes to one of the other values we'll just store that instead?
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.
My idea was to use Sentry CompressionLevel
as is for this window.
I can create another enum with the same structure as CompressionLevel
, call it UnityCompressionLevel
and do the proper mapping to CompressionLevel
.
Do you prefer the second approach (with UnityCompressionLevel
enum)?
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 think it's simpler to have auto
in the UI and not bother creating a new enum
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.
src/test/Sentry.Unity.Tests/UnityApplicationLoggingIntegrationTests.cs
Outdated
Show resolved
Hide resolved
src/test/Sentry.Unity.Tests/UnityApplicationLoggingIntegrationTests.cs
Outdated
Show resolved
Hide resolved
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.
Great improvements. Thanks
src/Sentry.Unity/Integrations/UnityApplicationLoggingIntegration.cs
Outdated
Show resolved
Hide resolved
src/Sentry.Unity/Integrations/UnityApplicationLoggingIntegration.cs
Outdated
Show resolved
Hide resolved
@@ -105,10 +107,16 @@ public void OnLostFocus() | |||
// ReSharper disable once UnusedMember.Local | |||
private void OnGUI() | |||
{ | |||
GUILayout.Label(new GUIContent(GUIContent.none), EditorStyles.boldLabel); | |||
Options.DisableProgrammaticInitialization = EditorGUILayout.BeginToggleGroup( | |||
new GUIContent("Disable Programmatic Initialization", "Disable manual Sentry setup. Rely on SentryOptions config."), |
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.
Another option it to just rely on the Enable flag that' already there. If the user Disables it, it means SentryWindow won't be defining the options to initialize the SDK. The user is always free to call
SentryUnity.Init
.
I think this is the way to go. Any reasons not to take this approach?
src/Sentry.Unity/Integrations/UnityApplicationLoggingIntegration.cs
Outdated
Show resolved
Hide resolved
public UnityBeforeSceneLoadIntegration(IApplication? appDomain = null) | ||
=> _application = appDomain ?? ApplicationAdapter.Instance; | ||
|
||
public void Register(IHub hub, SentryOptions options) |
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 is called by Sentry when the SDK is initialized.
THe integrations are supposed to call into Sentry whenever something happens. Like when the game changes scenes, we could add a new breadcrumb. And even change a tag. That would be an integration
We should discuss this on a call and wrap it up together |
# Conflicts: # src/Sentry.Unity/SentryInitialization.cs
Updated with the latest (+ cc @bruno-garcia let's review it together on a call and close it. |
Initial attempt of programmatic setup, there are a lot to cover.
Current:
SentryUnity
can exist, all subsequent inits will dispose old one and replace with a new one.Example from
SentryInitialization.Init
:All of the above are checked on
il2cpp
builds.SentryUnity
Things to consider:
link.xml
is not implemented for this approach yetSentryUnity
is disposed (removed/destroyed) and a new one is created. My thoughts: retrieve call site (stack? frame? CallMember?) of theInit
methods and store it somewhere, then check and compare when newInit
happens -> notify user.Let's discuss further steps.