Description
Problem Statement
Currently, there is no straight forward way to delay the SDK's initialization. In addition, while manual initialization is possible, it might come with some hurdles.
Context
The Unity SDK relies on configuration provided within the Editor that is saved to /Resources
as a .asset
file.
The SDK compiles SentryInitialization.cs
with your game. This way it has access to preprocessor directives.
sentry-unity/package-dev/Runtime/SentryInitialization.cs
Lines 54 to 56 in ed4cc86
Part of loading the options is invoking the user's configuration callback.
So while you can call SentryUnity.Init
, users are missing out on the native SDK setup (which includes init and scope sync)
So in all practicality, manually calling call SentryUnity.Init
has a very limited usecase.
Proposal
Users should have the option to control automatic initialization. This could be a separate option in addition to Enabled
.
Users should have the option to manually call Init
the same way the SDK does.
Workaround
- Setup programmatic configuration
- Have the
options.Enabled
resolve tofalse
based on your condition for the delay - The SDK will attempt to auto-initialize and because of 2. skip
- When you're ready can call
SentryInitialization.Init
yourself - The SDK will load the options again
- The SDK will invoke the options configuration callback again
- This time, you should have
options.Enabled
resolve totrue
- The SDK will do the rest of the initialization
** Note, that on mobile platforms, for this workaround it is recommended to have the options.InitializationType
set to Runtime
as otherwise, the SDK will close down the native SDK during the first initialization attempt.
I know, this is not a pretty solution but at least you're not blocked.
Metadata
Metadata
Assignees
Type
Projects
Status