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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

### Fixes

- The SDK no longer sends screenshot attachments for events that were dropped during processing (e.g., by `BeforeSend` or sampling) ([#2661](https://github.com/getsentry/sentry-unity/pull/2661))
- The SDK no longer sends screenshot attachments for events that were dropped during processing (e.g., by `BeforeSend` or sampling). ([#2661](https://github.com/getsentry/sentry-unity/pull/2661))
- The SDK now forwards `EnableLogs` and `EnableMetrics` to the native layer. ([#2662](https://github.com/getsentry/sentry-unity/pull/2662))

### Dependencies

Expand Down
10 changes: 10 additions & 0 deletions src/Sentry.Unity.Android/SentryJava.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ public void Init(SentryUnityOptions options)
androidOptions.Call("setEnableScopeSync", options.NdkScopeSyncEnabled);
androidOptions.Call("setNativeSdkName", "sentry.native.android.unity");

using (var logsOptions = androidOptions.Call<AndroidJavaObject>("getLogs"))
{
logsOptions.Call("setEnabled", options.EnableLogs);
}

using (var metricsOptions = androidOptions.Call<AndroidJavaObject>("getMetrics"))
{
metricsOptions.Call("setEnabled", options.EnableMetrics);
}

// Options that are not to be set by the user
// We're disabling some integrations as to not duplicate event or because the SDK relies on the .NET SDK
// implementation of certain feature - i.e. Session Tracking
Expand Down
6 changes: 6 additions & 0 deletions src/Sentry.Unity.Native/SentryNativeBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ is RuntimePlatform.WindowsPlayer or RuntimePlatform.WindowsServer
}
#endif

Logger?.LogDebug("Setting EnableLogs: {0}", options.EnableLogs);
sentry_options_set_enable_logs(cOptions, options.EnableLogs ? 1 : 0);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing native stub for sentry_options_set_enable_logs

High Severity

The new sentry_options_set_enable_logs P/Invoke in SentryNativeBridge.cs is called unconditionally but lacks a corresponding stub in sentry_native_stubs.c. On Switch builds using the stub library, this causes an EntryPointNotFoundException during initialization, which disables all native Sentry features like scope synchronization and crash reporting.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 14683c4. Configure here.


Logger?.LogDebug("Setting EnableMetrics: {0}", options.EnableMetrics);
sentry_options_set_enable_metrics(cOptions, options.EnableMetrics ? 1 : 0);

Expand Down Expand Up @@ -169,6 +172,9 @@ internal static string GetDatabasePath(SentryUnityOptions options, IApplication?
[DllImport(SentryLib)]
private static extern void sentry_options_set_attach_screenshot(IntPtr options, int attachScreenshot);

[DllImport(SentryLib)]
private static extern void sentry_options_set_enable_logs(IntPtr options, int enable_logs);

[DllImport(SentryLib)]
private static extern void sentry_options_set_enable_metrics(IntPtr options, int enable_metrics);

Expand Down
6 changes: 6 additions & 0 deletions src/Sentry.Unity.iOS/SentryCocoaBridgeProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public static bool Init(SentryUnityOptions options)
Logger?.LogDebug("Setting CaptureFailedRequests: {0}", options.CaptureFailedRequests);
OptionsSetInt(cOptions, "enableCaptureFailedRequests", options.CaptureFailedRequests ? 1 : 0);

Logger?.LogDebug("Setting EnableLogs: {0}", options.EnableLogs);
OptionsSetInt(cOptions, "enableLogs", options.EnableLogs ? 1 : 0);

Logger?.LogDebug("Setting EnableMetrics: {0}", options.EnableMetrics);
OptionsSetInt(cOptions, "enableMetrics", options.EnableMetrics ? 1 : 0);

foreach (var range in options.FailedRequestStatusCodes)
{
Logger?.LogDebug("Adding FailedRequestStatusCodeRange: {0}-{1}", range.Start, range.End);
Expand Down
Loading