diff --git a/CHANGELOG.md b/CHANGELOG.md index 40aebeb17..245833eb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/Sentry.Unity.Android/SentryJava.cs b/src/Sentry.Unity.Android/SentryJava.cs index 918acc746..b2435928b 100644 --- a/src/Sentry.Unity.Android/SentryJava.cs +++ b/src/Sentry.Unity.Android/SentryJava.cs @@ -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("getLogs")) + { + logsOptions.Call("setEnabled", options.EnableLogs); + } + + using (var metricsOptions = androidOptions.Call("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 diff --git a/src/Sentry.Unity.Native/SentryNativeBridge.cs b/src/Sentry.Unity.Native/SentryNativeBridge.cs index 18ea06305..ee79334a3 100644 --- a/src/Sentry.Unity.Native/SentryNativeBridge.cs +++ b/src/Sentry.Unity.Native/SentryNativeBridge.cs @@ -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); + Logger?.LogDebug("Setting EnableMetrics: {0}", options.EnableMetrics); sentry_options_set_enable_metrics(cOptions, options.EnableMetrics ? 1 : 0); @@ -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); diff --git a/src/Sentry.Unity.iOS/SentryCocoaBridgeProxy.cs b/src/Sentry.Unity.iOS/SentryCocoaBridgeProxy.cs index bbb98e40c..9d36d8d6a 100644 --- a/src/Sentry.Unity.iOS/SentryCocoaBridgeProxy.cs +++ b/src/Sentry.Unity.iOS/SentryCocoaBridgeProxy.cs @@ -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);