Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### Unreleased

- Fix InApp Exclude for frames without Module by checking against frame's Package ([#4236](https://github.com/getsentry/sentry-dotnet/pull/4236))

## 5.9.0

### Features
Expand Down
88 changes: 46 additions & 42 deletions src/Sentry/SentryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,48 +1292,7 @@ public SentryOptions()
Native = new NativeOptions(this);
#endif

InAppExclude = new() {
"System",
"Mono",
"Sentry",
"Microsoft",
"MS", // MS.Win32, MS.Internal, etc: Desktop apps
"ABI.Microsoft", // MAUI
"WinRT", // WinRT, UWP, WinUI
"UIKit", // iOS / MacCatalyst
"Newtonsoft.Json",
"FSharp",
"Serilog",
"Giraffe",
"NLog",
"Npgsql",
"RabbitMQ",
"Hangfire",
"IdentityServer4",
"AWSSDK",
"Polly",
"Swashbuckle",
"FluentValidation",
"Autofac",
"Stackexchange.Redis",
"Dapper",
"RestSharp",
"SkiaSharp",
"IdentityModel",
"SqlitePclRaw",
"Xamarin",
"Android", // Ex: Android.Runtime.JNINativeWrapper...
"Google",
"MongoDB",
"Remotion.Linq",
"AutoMapper",
"Nest",
"Owin",
"MediatR",
"ICSharpCode",
"Grpc",
"ServiceStack"
};
InAppExclude = GetDefaultInAppExclude();

#if DEBUG
InAppInclude = new()
Expand Down Expand Up @@ -1827,4 +1786,49 @@ internal void SetupLogging()
// In the future, this will most likely contain process ID
return TryGetDsnSpecificCacheDirectoryPath();
}

internal static List<StringOrRegex> GetDefaultInAppExclude() =>
[
"System",
"Mono",
"Sentry",
"Microsoft",
"MS", // MS.Win32, MS.Internal, etc: Desktop apps
"ABI.Microsoft", // MAUI
"WinRT", // WinRT, UWP, WinUI
"UIKit", // iOS / MacCatalyst
"Newtonsoft.Json",
"FSharp",
"Serilog",
"Giraffe",
"NLog",
"Npgsql",
"RabbitMQ",
"Hangfire",
"IdentityServer4",
"AWSSDK",
"Polly",
"Swashbuckle",
"FluentValidation",
"Autofac",
"Stackexchange.Redis",
"Dapper",
"RestSharp",
"SkiaSharp",
"IdentityModel",
"SqlitePclRaw",
"Xamarin",
"Android", // Ex: Android.Runtime.JNINativeWrapper...
"Google",
"MongoDB",
"Remotion.Linq",
"AutoMapper",
"Nest",
"Owin",
"MediatR",
"ICSharpCode",
"Grpc",
"ServiceStack",
"Java.Interop",
];
}
4 changes: 4 additions & 0 deletions src/Sentry/SentryStackFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ public void ConfigureAppFrame(SentryOptions options)
{
ConfigureAppFrame(options, Module, LazyModuleMatcher.Value);
}
else if (!string.IsNullOrEmpty(Package))
{
ConfigureAppFrame(options, Package, LazyModuleMatcher.Value);
}
else if (!string.IsNullOrEmpty(Function))
{
ConfigureAppFrame(options, Function, LazyFunctionMatcher.Value);
Expand Down
52 changes: 52 additions & 0 deletions test/Sentry.Tests/Protocol/Exceptions/SentryStackFrameTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,58 @@ public void ConfigureAppFrame_WithDefaultOptions_RecognizesSentryInternalFrame()
Assert.False(sut.InApp);
}

[Fact]
public void ConfigureAppFrame_WithDefaultOptions_NotBuiltInIgnoredMarkedAsInApp()
{
var options = new SentryOptions();
var sut = new SentryStackFrame
{
Function = "async void MainActivity.OnCreate(Bundle savedInstanceState)+(?) =\\u003E { }",
Package = "SymbolCollector.Android, Version=1.23.0.0, Culture=neutral, PublicKeyToken=null"
};

// Act
sut.ConfigureAppFrame(options);

// Assert
Assert.True(sut.InApp);
}

[Fact]
public void ConfigureAppFrame_WithDefaultOptions_JavaPackageNotInApp()
{
var options = new SentryOptions();
var sut = new SentryStackFrame
{
Function = "void StaticMethods.CallStaticVoidMethod(JniObjectReference, JniMethodInfo, JniArgumentValue*)",
Package = "Java.Interop, Version=9.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"
};

// Act
sut.ConfigureAppFrame(options);

// Assert
Assert.False(sut.InApp);
}

[Fact]
public void ConfigureAppFrame_WithDefaultOptions_SystemPackageNotInApp()
{
var options = new SentryOptions();
var sut = new SentryStackFrame
{
Function = "void Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, string path, bool isDirError)",
Package = "System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e",
FileName = "Interop.IOErrors.cs",
};

// Act
sut.ConfigureAppFrame(options);

// Assert
Assert.False(sut.InApp);
}

[Fact]
public void ConfigureAppFrame_InAppAlreadySet_InAppIgnored()
{
Expand Down
20 changes: 20 additions & 0 deletions test/Sentry.Tests/SentryOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,26 @@ public void AddInAppExclude_StoredInOptions()
Assert.Contains(sut.InAppExclude!, actual => actual.ToString() == expected);
}

[Fact]
public void AddInAppExclude_DoesNotOverrideDefaults()
{
var sut = new SentryOptions();
const string expected = "test";
sut.AddInAppExclude(expected);
Assert.All(SentryOptions.GetDefaultInAppExclude(),
item => Assert.Contains(item, sut.InAppExclude!));
}

[Fact]
public void InAppExcludes_IgnoresJavaFrames()
{
var sut = new SentryOptions();
const string expected = "test";
sut.AddInAppExclude(expected);
Assert.All(SentryOptions.GetDefaultInAppExclude(),
item => Assert.Contains(item, sut.InAppExclude!));
}

[Fact]
public void AddInAppExcludeRegex_StoredInOptions()
{
Expand Down
Loading