Skip to content
Draft
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
1 change: 1 addition & 0 deletions .github/workflows/test-run-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Setting `FilterBadGatewayExceptions` to `false` now takes effect when initializing the SDK in code with `SentrySdk.Init`. ([#2930](https://github.com/getsentry/sentry-unity/pull/2930))

## 4.12.0

### Behavioral Changes
Expand Down
5 changes: 0 additions & 5 deletions src/Sentry.Unity/ScriptableSentryUnityOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,6 @@ internal SentryUnityOptions ToSentryUnityOptions(

private void HandleExceptionFilter(SentryUnityOptions options)
{
if (!options.FilterBadGatewayExceptions)
{
options.RemoveExceptionFilter<UnityBadGatewayExceptionFilter>();
}

if (!FilterWebExceptions)
{
options.RemoveExceptionFilter<UnityWebExceptionFilter>();
Expand Down
5 changes: 5 additions & 0 deletions src/Sentry.Unity/SentryUnitySdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ private SentryUnitySdk(SentryUnityOptions options)
// Some integrations are controlled through a flag and opt-in. Adding these integrations late so we have equal
// behaviour whether the options got created through the ScriptableObject or the SDK gets manually initialized
AddIntegrations(options);
if (!options.FilterBadGatewayExceptions)
{
options.RemoveExceptionFilter<UnityBadGatewayExceptionFilter>();
}

SetUpWindowsPlayerCaching(unitySdk, options);

ConfigureUnsupportedPlatformFallbacks(options);
Expand Down
4 changes: 4 additions & 0 deletions test/IntegrationTest/Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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" } |
Expand Down
18 changes: 18 additions & 0 deletions test/Sentry.Unity.Tests/SentryUnityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Debug = UnityEngine.Debug;
using Sentry.Extensibility;
using Sentry.Unity.Integrations;
using Sentry.Unity.Tests.SharedClasses;
using Sentry.Unity.Tests.Stubs;
using UnityEngine;
Expand Down Expand Up @@ -78,6 +80,22 @@ public void SentryUnity_OptionsValid_Initializes()
Assert.IsTrue(SentrySdk.IsEnabled);
}

[Test]
public void SentryUnity_FilterBadGatewayExceptionsDisabled_RemovesBadGatewayFilter()
{
var options = new SentryUnityOptions(application: new TestApplication())
{
Dsn = SentryTests.TestDsn,
FilterBadGatewayExceptions = false
};

SentrySdk.Init(options);

var exceptionFiltersPropertyInfo = typeof(SentryOptions).GetProperty("ExceptionFilters", BindingFlags.NonPublic | BindingFlags.Instance);
var filters = (List<IExceptionFilter>)exceptionFiltersPropertyInfo!.GetValue(options);
Assert.That(filters.OfType<UnityBadGatewayExceptionFilter>(), Is.Empty);
}

[Test]
public void SentryUnity_OptionsInvalid_DoesNotInitialize()
{
Expand Down
Loading