Skip to content

feat: add SetBeforeSendFeedback to process feedback before sending #4092 #4224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
30 changes: 30 additions & 0 deletions src/Sentry/Internal/MemoryMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,37 @@
return;
}


const long maxDumpSizeInBytes = 20 * 1024 * 1024;

var fileInfo = new FileInfo(dumpFile);

Check failure on line 106 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

Route file system access through IFileSystem wrapper

Check failure on line 106 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Build (net8.0)

Route file system access through IFileSystem wrapper

Check failure on line 106 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / .NET (ghcr.io/getsentry/sentry-dotnet-alpine:3.21)

Route file system access through IFileSystem wrapper

Check failure on line 106 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

Route file system access through IFileSystem wrapper

Check failure on line 106 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Trim analysis

Route file system access through IFileSystem wrapper

Check failure on line 106 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

Route file system access through IFileSystem wrapper

Check failure on line 106 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

Route file system access through IFileSystem wrapper
if (fileInfo.Length > maxDumpSizeInBytes)

Check failure on line 107 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

Route file system access through IFileSystem wrapper

Check failure on line 107 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Build (net8.0)

Route file system access through IFileSystem wrapper

Check failure on line 107 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

Route file system access through IFileSystem wrapper

Check failure on line 107 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Trim analysis

Route file system access through IFileSystem wrapper

Check failure on line 107 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

Route file system access through IFileSystem wrapper

Check failure on line 107 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

Route file system access through IFileSystem wrapper
{
_options.LogWarning($"Memory dump file is too large ({fileInfo.Length} bytes). and will not be attached to the Sentry event.");

Check failure on line 109 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

Route file system access through IFileSystem wrapper

Check failure on line 109 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Build (net8.0)

Route file system access through IFileSystem wrapper

Check failure on line 109 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

Route file system access through IFileSystem wrapper

Check failure on line 109 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Trim analysis

Route file system access through IFileSystem wrapper

Check failure on line 109 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

Route file system access through IFileSystem wrapper

Check failure on line 109 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

Route file system access through IFileSystem wrapper

try
{
File.Delete(dumpFile);

Check failure on line 113 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

Route file system access through IFileSystem wrapper

Check failure on line 113 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Build (net8.0)

Route file system access through IFileSystem wrapper

Check failure on line 113 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Trim analysis

Route file system access through IFileSystem wrapper

Check failure on line 113 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

Route file system access through IFileSystem wrapper
}
catch (Exception ex)
{
_options.LogError($"Error deleting memory dump file: {ex.Message}");
}

return;
}


_onDumpCollected(dumpFile);

try
{
File.Delete(dumpFile);

Check failure on line 128 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

Route file system access through IFileSystem wrapper

Check failure on line 128 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Build (net8.0)

Route file system access through IFileSystem wrapper

Check failure on line 128 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / Trim analysis

Route file system access through IFileSystem wrapper

Check failure on line 128 in src/Sentry/Internal/MemoryMonitor.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

Route file system access through IFileSystem wrapper
}
catch (Exception ex)
{
_options.LogError($"Error deleting memory dump file after sending to Sentry: {ex.Message}");
}
}

/// <summary>
Expand Down
11 changes: 11 additions & 0 deletions src/Sentry/SentryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/// <inheritdoc cref="IDisposable" />
public class SentryClient : ISentryClient, IDisposable
{
private readonly ITransport _transport;

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Build (net8.0)

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ghcr.io/getsentry/sentry-dotnet-alpine:3.21)

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ghcr.io/getsentry/sentry-dotnet-alpine:3.21)

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ghcr.io/getsentry/sentry-dotnet-alpine:3.21)

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Analyze

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Analyze

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / ios-tests

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / ios-tests

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Trim analysis

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

Field 'SentryClient._transport' is never assigned to, and will always have its default value null

Check failure on line 18 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

Field 'SentryClient._transport' is never assigned to, and will always have its default value null
private readonly SentryOptions _options;
private readonly ISessionManager _sessionManager;
private readonly RandomValuesFactory _randomValuesFactory;
Expand All @@ -37,7 +38,7 @@
public SentryClient(SentryOptions options)
: this(options, null, null, null) { }

internal SentryClient(

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Build (net8.0)

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ghcr.io/getsentry/sentry-dotnet-alpine:3.21)

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Analyze

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Analyze

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / ios-tests

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / ios-tests

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Trim analysis

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 41 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

Non-nullable field '_transport' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
SentryOptions options,
IBackgroundWorker? worker = null,
RandomValuesFactory? randomValuesFactory = null,
Expand Down Expand Up @@ -84,9 +85,19 @@
/// <inheritdoc />
public void CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null)
{

var processedFeedback = _options?.BeforeSendFeedbackInternal?.Invoke(feedback, hint);
if (processedFeedback is null)
{
_options?.DiagnosticLogger?.LogDebug("BeforeSendFeedback returned null, dropping feedback.");
return;
}

_transport.EnqueueFeedback(processedFeedback, hint);

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Build (net8.0)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ghcr.io/getsentry/sentry-dotnet-alpine:3.21)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ghcr.io/getsentry/sentry-dotnet-alpine:3.21)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ghcr.io/getsentry/sentry-dotnet-alpine:3.21)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Analyze

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Analyze

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / ios-tests

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / ios-tests

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Trim analysis

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

'ITransport' does not contain a definition for 'EnqueueFeedback' and no accessible extension method 'EnqueueFeedback' accepting a first argument of type 'ITransport' could be found (are you missing a using directive or an assembly reference?)

if (string.IsNullOrEmpty(feedback.Message))
{
_options.LogWarning("Feedback dropped due to empty message.");

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Build (net8.0)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ghcr.io/getsentry/sentry-dotnet-alpine:3.21)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Analyze

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Analyze

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / ios-tests

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / ios-tests

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Trim analysis

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.

Check failure on line 100 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogWarning(SentryOptions options, string message)'.
return;
}

Expand All @@ -94,7 +105,7 @@
hint ??= new SentryHint();
hint.AddAttachmentsFromScope(scope);

_options.LogInfo("Capturing feedback: '{0}'.", feedback.Message);

Check failure on line 108 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogInfo<string>(SentryOptions options, string message, string arg)'.

Check failure on line 108 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Build (net8.0)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogInfo<string>(SentryOptions options, string message, string arg)'.

Check failure on line 108 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ghcr.io/getsentry/sentry-dotnet-alpine:3.21)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogInfo<string>(SentryOptions options, string message, string arg)'.

Check failure on line 108 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Analyze

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogInfo<string>(SentryOptions options, string message, string arg)'.

Check failure on line 108 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Analyze

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogInfo<string>(SentryOptions options, string message, string arg)'.

Check failure on line 108 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (ubuntu-22.04)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogInfo<string>(SentryOptions options, string message, string arg)'.

Check failure on line 108 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / ios-tests

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogInfo<string>(SentryOptions options, string message, string arg)'.

Check failure on line 108 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / ios-tests

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogInfo<string>(SentryOptions options, string message, string arg)'.

Check failure on line 108 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / Trim analysis

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogInfo<string>(SentryOptions options, string message, string arg)'.

Check failure on line 108 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (macos-15)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogInfo<string>(SentryOptions options, string message, string arg)'.

Check failure on line 108 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-latest)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogInfo<string>(SentryOptions options, string message, string arg)'.

Check failure on line 108 in src/Sentry/SentryClient.cs

View workflow job for this annotation

GitHub Actions / .NET (windows-11-arm)

Possible null reference argument for parameter 'options' in 'void DiagnosticLoggerExtensions.LogInfo<string>(SentryOptions options, string message, string arg)'.

var evt = new SentryEvent { Level = SentryLevel.Info };
evt.Contexts.Feedback = feedback;
Expand Down
20 changes: 20 additions & 0 deletions src/Sentry/SentryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,26 @@ internal bool IsSentryRequest(Uri? requestUri)

internal Func<SentryEvent, SentryHint, SentryEvent?>? BeforeSendInternal => _beforeSend;

private Func<SentryFeedback, SentryHint?, SentryFeedback?>? _beforeSendFeedback;
internal Func<SentryFeedback, SentryHint?, SentryFeedback?>? BeforeSendFeedbackInternal => _beforeSendFeedback;


/// <summary>
/// Configures a callback to invoke before sending feedback to Sentry.
/// </summary>
public void SetBeforeSendFeedback(Func<SentryFeedback, SentryHint?, SentryFeedback?> beforeSendFeedback)
{
_beforeSendFeedback = beforeSendFeedback;
}

/// <summary>
/// Configures a callback to invoke before sending feedback to Sentry.
/// </summary>
public void SetBeforeSendFeedback(Func<SentryFeedback, SentryFeedback?> beforeSendFeedback)
{
_beforeSendFeedback = (feedback, _) => beforeSendFeedback(feedback);
}

/// <summary>
/// Configures a callback function to be invoked before sending an event to Sentry
/// </summary>
Expand Down
Loading