Skip to content

Commit 7e962ef

Browse files
Merge branch 'version6' into ios-replay
2 parents f93b903 + 6200d99 commit 7e962ef

25 files changed

+439
-126
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44

55
### BREAKING CHANGES
66

7+
- Spans and Transactions now implement `IDisposable` so that they can be used with `using` statements/declarations that will automatically finish the span with a status of OK when it passes out of scope, if it has not already been finished, to be consistent with `Activity` classes when using OpenTelemetry ([#4627](https://github.com/getsentry/sentry-dotnet/pull/4627))
8+
- SpanTracer and TransactionTracer are still public but these are now `sealed` (see also [#4627](https://github.com/getsentry/sentry-dotnet/pull/4627))
9+
- CaptureFeedback now returns a `SentryId` and a `CaptureFeedbackResult` out parameter that indicate whether feedback was captured successfully and what the reason for failure was otherwise ([#4613](https://github.com/getsentry/sentry-dotnet/pull/4613))
10+
11+
### Features
12+
13+
- The SDK now makes use of the new SessionEndStatus `Unhandled` when capturing an unhandled but non-terminal exception, i.e. through the UnobservedTaskExceptionIntegration ([#4633](https://github.com/getsentry/sentry-dotnet/pull/4633), [#4653](https://github.com/getsentry/sentry-dotnet/pull/4653))
14+
- The SDK now provides a `IsSessionActive` to allow checking the session state ([#4662](https://github.com/getsentry/sentry-dotnet/pull/4662))
15+
- The SDK now makes use of the new SessionEndStatus `Unhandled` when capturing an unhandled but non-terminal exception, i.e. through the UnobservedTaskExceptionIntegration ([#4633](https://github.com/getsentry/sentry-dotnet/pull/4633))
16+
17+
## 6.0.0-preview.2
18+
19+
### BREAKING CHANGES
20+
721
- `BreadcrumbLevel.Critical` has been renamed to `BreadcrumbLevel.Fatal` for consistency with the other Sentry SDKs ([#4605](https://github.com/getsentry/sentry-dotnet/pull/4605))
822
- SentryOptions.IsEnvironmentUser now defaults to false on MAUI. The means the User.Name will no longer be set, by default, to the name of the device ([#4606](https://github.com/getsentry/sentry-dotnet/pull/4606))
923
- Remove unnecessary files from SentryCocoaFramework before packing ([#4602](https://github.com/getsentry/sentry-dotnet/pull/4602))

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22

33
<PropertyGroup>
4-
<VersionPrefix>6.0.0-preview.1</VersionPrefix>
4+
<VersionPrefix>6.0.0-preview.2</VersionPrefix>
55
<VersionSuffix>prerelease</VersionSuffix>
66
<LangVersion>13</LangVersion>
77
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>

samples/Sentry.Samples.Console.Basic/Program.cs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
// Always try to finish the transaction successfully.
6565
// Unhandled exceptions will fail the transaction automatically.
66-
// Optionally, you can try/catch the exception, and call transaction.Finish(exception) on failure.
66+
// Optionally, you can try/catch the exception and call transaction.Finish(exception) on failure.
6767
transaction.Finish();
6868

6969
async Task FirstFunction()
@@ -79,7 +79,6 @@ async Task FirstFunction()
7979
async Task SecondFunction()
8080
{
8181
var span = transaction.StartChild("function", nameof(SecondFunction));
82-
8382
try
8483
{
8584
// Simulate doing some work
@@ -97,26 +96,25 @@ async Task SecondFunction()
9796
SentrySdk.Logger.LogError(static log => log.SetAttribute("method", nameof(SecondFunction)),
9897
"Error with message: {0}", exception.Message);
9998
}
100-
101-
span.Finish();
99+
finally
100+
{
101+
span.Finish();
102+
}
102103
}
103104

104105
async Task ThirdFunction()
105106
{
106-
var span = transaction.StartChild("function", nameof(ThirdFunction));
107-
try
108-
{
109-
// Simulate doing some work
110-
await Task.Delay(100);
107+
// The `using` here ensures the span gets finished when we leave this method... This is unnecessary here,
108+
// since the method always throws and the span will be finished automatically when the exception is captured,
109+
// but this gives you another way to ensure spans are finished.
110+
using var span = transaction.StartChild("function", nameof(ThirdFunction));
111111

112-
SentrySdk.Logger.LogFatal(static log => log.SetAttribute("suppress", true),
113-
"Crash imminent!");
112+
// Simulate doing some work
113+
await Task.Delay(100);
114114

115-
// This is an example of an unhandled exception. It will be captured automatically.
116-
throw new InvalidOperationException("Something happened that crashed the app!");
117-
}
118-
finally
119-
{
120-
span.Finish();
121-
}
115+
SentrySdk.Logger.LogFatal(static log => log.SetAttribute("suppress", true),
116+
"Crash imminent!");
117+
118+
// This is an example of an unhandled exception. It will be captured automatically.
119+
throw new InvalidOperationException("Something happened that crashed the app!");
122120
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
namespace Sentry;
2+
3+
/// <summary>
4+
/// Result code for <see cref="ISentryClient.CaptureFeedback"/> requests
5+
/// </summary>
6+
public enum CaptureFeedbackResult
7+
{
8+
/// <summary>
9+
/// Feedback captured successfully.
10+
/// </summary>
11+
Success,
12+
/// <summary>
13+
/// <para>
14+
/// An unknown error occurred (enable debug mode and check the logs for details).
15+
/// </para>
16+
/// <para>
17+
/// Possible causes:
18+
/// <list type="bullet">
19+
/// <item>
20+
/// <description>An exception from the configureScope callback</description>
21+
/// </item>
22+
/// <item>
23+
/// <description>An error when sending the envelope</description>
24+
/// </item>
25+
/// <item>
26+
/// <description>An attempt to send feedback while the application is shutting down</description>
27+
/// </item>
28+
/// <item>
29+
/// <description>Something more mysterious...</description>
30+
/// </item>
31+
/// </list>
32+
/// </para>
33+
/// </summary>
34+
UnknownError,
35+
/// <summary>
36+
/// Capture failed because Sentry is disabled (very likely an empty DSN was provided when initialising the SDK).
37+
/// </summary>
38+
DisabledHub,
39+
/// <summary>
40+
/// Capture failed because the <see cref="SentryFeedback.Message"/> message is empty.
41+
/// </summary>
42+
EmptyMessage,
43+
}

src/Sentry/Extensibility/DisabledHub.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,21 @@ public bool CaptureEnvelope(Envelope envelope)
186186
/// <summary>
187187
/// No-Op.
188188
/// </summary>
189-
public void CaptureFeedback(SentryFeedback feedback, Action<Scope> configureScope, SentryHint? hint = null)
189+
public SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResult result,
190+
Action<Scope> configureScope, SentryHint? hint = null)
190191
{
192+
result = CaptureFeedbackResult.DisabledHub;
193+
return SentryId.Empty;
191194
}
192195

193196
/// <summary>
194197
/// No-Op.
195198
/// </summary>
196-
public void CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null)
199+
public SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResult result,
200+
Scope? scope = null, SentryHint? hint = null)
197201
{
202+
result = CaptureFeedbackResult.DisabledHub;
203+
return SentryId.Empty;
198204
}
199205

200206
/// <summary>

src/Sentry/Extensibility/HubAdapter.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,18 @@ public SentryId CaptureEvent(SentryEvent evt, Scope? scope, SentryHint? hint = n
272272
/// </summary>
273273
[DebuggerStepThrough]
274274
[EditorBrowsable(EditorBrowsableState.Never)]
275-
public void CaptureFeedback(SentryFeedback feedback, Action<Scope> configureScope, SentryHint? hint = null)
276-
=> SentrySdk.CaptureFeedback(feedback, configureScope, hint);
275+
public SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResult result,
276+
Action<Scope> configureScope, SentryHint? hint = null)
277+
=> SentrySdk.CaptureFeedback(feedback, out result, configureScope, hint);
277278

278279
/// <summary>
279280
/// Forwards the call to <see cref="SentrySdk"/>.
280281
/// </summary>
281282
[DebuggerStepThrough]
282283
[EditorBrowsable(EditorBrowsableState.Never)]
283-
public void CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null)
284-
=> SentrySdk.CaptureFeedback(feedback, scope, hint);
284+
public SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResult result, Scope? scope = null,
285+
SentryHint? hint = null)
286+
=> SentrySdk.CaptureFeedback(feedback, out result, scope, hint);
285287

286288
/// <summary>
287289
/// Forwards the call to <see cref="SentrySdk"/>.

src/Sentry/HubExtensions.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,22 @@ internal static SentryId CaptureExceptionInternal(this IHub hub, Exception ex) =
206206
public static SentryId CaptureException(this IHub hub, Exception ex, Action<Scope> configureScope) =>
207207
hub.CaptureEvent(new SentryEvent(ex), configureScope);
208208

209+
/// <summary>
210+
/// Captures feedback from the user.
211+
/// </summary>
212+
/// <param name="hub">The Sentry hub.</param>
213+
/// <param name="feedback">The feedback to send to Sentry.</param>
214+
/// <param name="configureScope">Callback method to configure the scope.</param>
215+
/// <param name="hint">
216+
/// An optional hint providing high-level context for the source of the event, including attachments
217+
/// </param>
218+
/// <returns>
219+
/// A <see cref="SentryId"/> that will contain the Id of the new event (if successful) or
220+
/// <see cref="SentryId.Empty"/> otherwise
221+
/// </returns>
222+
public static SentryId CaptureFeedback(this IHub hub, SentryFeedback feedback, Action<Scope> configureScope, SentryHint? hint = null)
223+
=> hub.CaptureFeedback(feedback, out _, configureScope, hint);
224+
209225
/// <summary>
210226
/// Captures a message with a configurable scope callback.
211227
/// </summary>

src/Sentry/IHub.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,15 @@ public TransactionContext ContinueTrace(
143143
/// Captures feedback from the user.
144144
/// </summary>
145145
/// <param name="feedback">The feedback to send to Sentry.</param>
146+
/// <param name="result">A <see cref="CaptureFeedbackResult"/> indicating either success or a specific error</param>
146147
/// <param name="configureScope">Callback method to configure the scope.</param>
147-
/// <param name="hint">An optional hint providing high level context for the source of the event, including attachments</param>
148-
public void CaptureFeedback(SentryFeedback feedback, Action<Scope> configureScope, SentryHint? hint = null);
148+
/// <param name="hint">
149+
/// An optional hint providing high-level context for the source of the event, including attachments
150+
/// </param>
151+
/// <returns>
152+
/// A <see cref="SentryId"/> that will contain the Id of the new event (if successful) or
153+
/// <see cref="SentryId.Empty"/> otherwise
154+
/// </returns>
155+
public SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResult result, Action<Scope> configureScope,
156+
SentryHint? hint = null);
149157
}

src/Sentry/ISentryClient.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,17 @@ public interface ISentryClient
3232
/// Captures feedback from the user.
3333
/// </summary>
3434
/// <param name="feedback">The feedback to send to Sentry.</param>
35-
/// <param name="scope">An optional scope to be applied to the event.</param>
36-
/// <param name="hint">An optional hint providing high level context for the source of the event</param>
37-
public void CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null);
35+
/// <param name="result">A <see cref="CaptureFeedbackResult"/> indicating either success or a specific error</param>
36+
/// <param name="scope">An optional scope to be applied to the feedback event.</param>
37+
/// <param name="hint">
38+
/// An optional hint providing high-level context for the source of the event, including attachments
39+
/// </param>
40+
/// <returns>
41+
/// A <see cref="SentryId"/> that will contain the Id of the new event (if successful) or
42+
/// <see cref="SentryId.Empty"/> otherwise
43+
/// </returns>
44+
public SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResult result, Scope? scope = null,
45+
SentryHint? hint = null);
3846

3947
/// <summary>
4048
/// Captures a transaction.

src/Sentry/ISpan.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Sentry;
55
/// <summary>
66
/// SpanTracer interface
77
/// </summary>
8-
public interface ISpan : ISpanData
8+
public interface ISpan : ISpanData, IDisposable
99
{
1010
/// <summary>
1111
/// Span description.

0 commit comments

Comments
 (0)