From 4f90ebca9b9a6ffffc08185a2d4e9ddc45f6e190 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 4 Nov 2026 16:46:02 +0100 Subject: [PATCH 1/3] Skip the throw frame source line test on Android 2021.3 --- .github/workflows/test-run-android.yml | 1 + test/IntegrationTest/Integration.Tests.ps1 | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/test-run-android.yml b/.github/workflows/test-run-android.yml index 6400e761d..8d90dc546 100644 --- a/.github/workflows/test-run-android.yml +++ b/.github/workflows/test-run-android.yml @@ -32,6 +32,7 @@ jobs: HOMEBREW_NO_INSTALL_CLEANUP: 1 SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_TEST_UNITY_VERSION: ${{ inputs.unity-version }} steps: - name: Checkout diff --git a/test/IntegrationTest/Integration.Tests.ps1 b/test/IntegrationTest/Integration.Tests.ps1 index 6e9f39c20..9f39a191d 100644 --- a/test/IntegrationTest/Integration.Tests.ps1 +++ b/test/IntegrationTest/Integration.Tests.ps1 @@ -447,6 +447,10 @@ Describe "Unity $($env:SENTRY_TEST_PLATFORM) Integration Tests" { Set-ItResult -Skipped -Because "line numbers come from the IL2CPP mappings, which a Mono player does not produce" return } + if ($script:Platform -eq "Android" -and $script:TestSetup.UnityVersion -like "2021.3*") { + Set-ItResult -Skipped -Because "on the Android 2021.3 x86_64 emulator, IL2CPP intermittently reports no stack frames for the thrown exception, so the event carries only the throwing frame without a native address" + return + } $frame = $runEvent.exception.values[0].stacktrace.frames | Where-Object { $_.module -eq "IntegrationTester" -and $_.function -eq "ThrowException" } | From 1e8f201b9e125d82eee644597013b5503d7c2ad6 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 4 Nov 2026 11:09:14 +0100 Subject: [PATCH 2/3] Limit the window's Event Sample Rate to 0.01 through 1.0 --- CHANGELOG.md | 6 ++++ .../ConfigurationWindow/CoreTab.cs | 11 +++++-- .../Sentry.Unity.Editor.Tests/CoreTabTests.cs | 31 +++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 test/Sentry.Unity.Editor.Tests/CoreTabTests.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 252fc315b..5b182c4e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- The Event Sample Rate in the Sentry window now accepts values from 0.01 to 1.0. A rate of 0 made the SDK fail to initialize and builds fail to load the options. ([#TBD](https://github.com/getsentry/sentry-unity/pull/TBD)) + ## 4.12.0 ### Behavioral Changes diff --git a/src/Sentry.Unity.Editor/ConfigurationWindow/CoreTab.cs b/src/Sentry.Unity.Editor/ConfigurationWindow/CoreTab.cs index bf2709594..f3fa06817 100644 --- a/src/Sentry.Unity.Editor/ConfigurationWindow/CoreTab.cs +++ b/src/Sentry.Unity.Editor/ConfigurationWindow/CoreTab.cs @@ -6,6 +6,11 @@ namespace Sentry.Unity.Editor.ConfigurationWindow; internal static class CoreTab { + // The .NET SDK's SampleRate throws for 0 and documents 0.01 as its minimum. + internal const float MinSampleRate = 0.01f; + + internal static float ClampSampleRate(float sampleRate) => Mathf.Clamp(sampleRate, MinSampleRate, 1.0f); + internal static void Display(ScriptableSentryUnityOptions options) { { @@ -21,12 +26,12 @@ internal static void Display(ScriptableSentryUnityOptions options) var sampleRate = EditorGUILayout.FloatField( new GUIContent("Event Sample Rate", "Indicates the percentage of events that are " + - "captured. Setting this to 0.1 captures 10% of events. " + - "Setting this to 1.0 captures all events." + + "captured, from 0.01 (1%) to 1.0. Setting this to 0.1 " + + "captures 10% of events. Setting this to 1.0 captures all events." + "\nThis affects only errors and logs, not performance " + "(transactions) data. See TraceSampleRate for that."), options.SampleRate); - options.SampleRate = Mathf.Clamp01(sampleRate); + options.SampleRate = ClampSampleRate(sampleRate); options.CaptureInEditor = EditorGUILayout.Toggle( new GUIContent("Capture In Editor", "Capture errors while running in the Editor."), diff --git a/test/Sentry.Unity.Editor.Tests/CoreTabTests.cs b/test/Sentry.Unity.Editor.Tests/CoreTabTests.cs new file mode 100644 index 000000000..1289d6f50 --- /dev/null +++ b/test/Sentry.Unity.Editor.Tests/CoreTabTests.cs @@ -0,0 +1,31 @@ +using NUnit.Framework; +using Sentry.Unity.Editor.ConfigurationWindow; + +namespace Sentry.Unity.Editor.Tests; + +public class CoreTabTests +{ + [Test] + [TestCase(-1f, 0.01f)] + [TestCase(0f, 0.01f)] + [TestCase(0.005f, 0.01f)] + [TestCase(0.01f, 0.01f)] + [TestCase(0.5f, 0.5f)] + [TestCase(1f, 1f)] + [TestCase(2f, 1f)] + public void ClampSampleRate_KeepsValueWithinSupportedRange(float sampleRate, float expected) + { + Assert.AreEqual(expected, CoreTab.ClampSampleRate(sampleRate)); + } + + [Test] + public void ClampSampleRate_Zero_IsAcceptedByToSentryUnityOptions() + { + var scriptableOptions = UnityEngine.ScriptableObject.CreateInstance(); + scriptableOptions.SampleRate = CoreTab.ClampSampleRate(0f); + + var options = scriptableOptions.ToSentryUnityOptions(isBuilding: true); + + Assert.AreEqual(CoreTab.MinSampleRate, options.SampleRate); + } +} From 1f5496dff33fd10ee3667d815e1197db75aa9ca5 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 4 Nov 2026 11:12:24 +0100 Subject: [PATCH 3/3] Add PR link to CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b182c4e9..1a87e905c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Fixes -- The Event Sample Rate in the Sentry window now accepts values from 0.01 to 1.0. A rate of 0 made the SDK fail to initialize and builds fail to load the options. ([#TBD](https://github.com/getsentry/sentry-unity/pull/TBD)) +- The Event Sample Rate in the Sentry window now accepts values from 0.01 to 1.0. A rate of 0 made the SDK fail to initialize and builds fail to load the options. ([#2929](https://github.com/getsentry/sentry-unity/pull/2929)) ## 4.12.0