-
-
Notifications
You must be signed in to change notification settings - Fork 56
Rework Initialization #2227
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
base: main
Are you sure you want to change the base?
Rework Initialization #2227
Changes from all commits
14427b6
bb4dbc0
0f97f0b
a76e957
e494279
df211a3
19c4e78
00e788a
bfcd0f1
4448334
232833c
bcbb551
deb6aa7
a66a5a6
857e492
eefad70
16c9fcf
6542706
b48e60d
76e05b2
3fa372c
1f5e5cc
83deeec
011ba1d
2a46b5f
7ac68be
43f5ae9
ad0ae02
bb6f80a
c53ccb5
d100d4f
7faafb9
490e033
2f42440
d2709d1
326dc32
1183370
f1388b4
594dc4a
3bfc5fa
0843ba5
a4cbc59
32876ac
c6cbb0c
3a2328b
2e4b3db
99bbb4d
d67b2b9
ac366e7
76868b8
1f520ee
a47872d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,7 @@ public void SendFeedback() | |
else | ||
{ | ||
// Since there is no screenshot added we can capture the feedback right away | ||
SentryUnity.CaptureFeedback(_description.text, _email.text, _name.text, addScreenshot: false); | ||
SentrySdk.CaptureFeedback(_description.text, _email.text, _name.text, addScreenshot: false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the desired effect. All things reside within |
||
} | ||
} | ||
|
||
|
@@ -99,7 +99,7 @@ private IEnumerator HideFormAndCaptureFeedback() | |
// We're waiting for the EndOfFrame so the FeedbackForm gets updated before capturing the screenshot | ||
yield return new WaitForEndOfFrame(); | ||
|
||
SentryUnity.CaptureFeedback(_description.text, _email.text, _name.text, addScreenshot: true); | ||
SentrySdk.CaptureFeedback(_description.text, _email.text, _name.text, addScreenshot: true); | ||
|
||
ResetUserFeedback(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,15 @@ public static class SentryNativeCocoa | |
/// Configures the native support. | ||
/// </summary> | ||
/// <param name="options">The Sentry Unity options to use.</param> | ||
/// <param name="sentryUnityInfo">Infos about the current Unity environment</param> | ||
public static void Configure(SentryUnityOptions options, ISentryUnityInfo sentryUnityInfo) => | ||
Configure(options, sentryUnityInfo, ApplicationAdapter.Instance.Platform); | ||
public static void Configure(SentryUnityOptions options) => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a public method, and we only need to pass I think we could validate here (if we expect |
||
Configure(options, ApplicationAdapter.Instance.Platform); | ||
|
||
internal static void Configure(SentryUnityOptions options, ISentryUnityInfo sentryUnityInfo, RuntimePlatform platform) | ||
// For testing | ||
internal static void Configure(SentryUnityOptions options, RuntimePlatform platform) | ||
{ | ||
options.DiagnosticLogger?.LogInfo("Attempting to configure native support via the Cocoa SDK"); | ||
|
||
if (!sentryUnityInfo.IsNativeSupportEnabled(options, platform)) | ||
if (!options.UnityInfo.IsNativeSupportEnabled(options, platform)) | ||
{ | ||
options.DiagnosticLogger?.LogDebug("Native support is disabled for: '{0}'", platform); | ||
return; | ||
|
@@ -66,8 +66,8 @@ internal static void Configure(SentryUnityOptions options, ISentryUnityInfo sent | |
return crashedLastRun; | ||
}; | ||
|
||
options.NativeSupportCloseCallback += () => Close(options, sentryUnityInfo, platform); | ||
if (sentryUnityInfo.IL2CPP) | ||
options.NativeSupportCloseCallback += () => Close(options); | ||
if (options.UnityInfo.IL2CPP) | ||
{ | ||
options.DefaultUserId = SentryCocoaBridgeProxy.GetInstallationId(); | ||
if (string.IsNullOrEmpty(options.DefaultUserId)) | ||
|
@@ -96,14 +96,11 @@ internal static void Configure(SentryUnityOptions options, ISentryUnityInfo sent | |
/// <summary> | ||
/// Closes the native Cocoa support. | ||
/// </summary> | ||
public static void Close(SentryUnityOptions options, ISentryUnityInfo sentryUnityInfo) => | ||
Close(options, sentryUnityInfo, ApplicationAdapter.Instance.Platform); | ||
|
||
internal static void Close(SentryUnityOptions options, ISentryUnityInfo sentryUnityInfo, RuntimePlatform platform) | ||
public static void Close(SentryUnityOptions options) | ||
{ | ||
options.DiagnosticLogger?.LogInfo("Attempting to close the Cocoa SDK"); | ||
|
||
if (!sentryUnityInfo.IsNativeSupportEnabled(options, platform)) | ||
if (!options.UnityInfo.IsNativeSupportEnabled(options, ApplicationAdapter.Instance.Platform)) | ||
{ | ||
options.DiagnosticLogger?.LogDebug("Cocoa Native Support is not enable. Skipping closing the Cocoa SDK"); | ||
return; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
|
||
namespace Sentry.Unity.NativeUtils; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Putting the services into a very distinctive namespace to "discourage" usage. |
||
|
||
/// <summary> | ||
/// These are SDK's services that are only available at runtime and cannot be baked into the SDK. The | ||
/// <c>SentryInitialization.cs</c> is provided as <c>.cs</c> and gets compiled with the game. It sets <c>IUnityInfo</c> | ||
/// and the <c>PlatformConfiguration</c> callback during the game's startup so that they are available during initializtion. | ||
/// </summary> | ||
/// <remarks>Consider this <c>internal</c>.</remarks> | ||
public static class SentryPlatformServices | ||
{ | ||
private static ISentryUnityInfo? _unityInfo; | ||
|
||
/// <summary> | ||
/// The UnityInfo holds methods that rely on conditionally compilation, i.e. IL2CPP backend. | ||
/// </summary> | ||
public static ISentryUnityInfo UnityInfo | ||
{ | ||
get => _unityInfo ?? throw new InvalidOperationException("UnityInfo is null."); | ||
set | ||
{ | ||
if (_unityInfo != null) | ||
{ | ||
throw new InvalidOperationException("Should not set twice. lol."); | ||
} | ||
|
||
_unityInfo = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The PlatformConfiguration callback is responsible for configuring the native SDK and setting up scope sync. | ||
/// </summary> | ||
public static Action<SentryUnityOptions>? PlatformConfiguration { get; set; } | ||
} |
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.
We can safely make this
internal
. The SDK ships with it's own.asmdef
that allows us to hide internal types from the user.