Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
- 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))
- On iOS, development builds now respect `UploadDevelopmentSymbols` and no longer upload debug symbols unless it is enabled, matching the other platforms. ([#2928](https://github.com/getsentry/sentry-unity/pull/2928))

### Features

- `SentrySdk.LastEventId` is now available on the Unity `SentrySdk`, returning the ID of the last event captured in the current scope. ([#2945](https://github.com/getsentry/sentry-unity/pull/2945))

### Dependencies

- Bump Java SDK from v8.61.0 to v8.64.0 ([#2897](https://github.com/getsentry/sentry-unity/pull/2897), [#2944](https://github.com/getsentry/sentry-unity/pull/2944))
Expand Down
5 changes: 5 additions & 0 deletions src/Sentry.Unity/SentrySdk.Dotnet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public static partial class SentrySdk
[DebuggerStepThrough]
public static Task FlushAsync(TimeSpan timeout) => Sentry.SentrySdk.FlushAsync(timeout);

/// <summary>
/// The last event id recorded in the current scope.
/// </summary>
public static SentryId LastEventId { [DebuggerStepThrough] get => Sentry.SentrySdk.LastEventId; }

/// <summary>
/// Whether the SDK is enabled or not.
/// </summary>
Expand Down
16 changes: 16 additions & 0 deletions test/Sentry.Unity.Tests/SentryUnityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ public void SentryUnity_FilterBadGatewayExceptionsDisabled_RemovesBadGatewayFilt
Assert.That(filters.OfType<UnityBadGatewayExceptionFilter>(), Is.Empty);
}

[Test]
public void LastEventId_EventCaptured_ReturnsCapturedEventId()
{
var options = new SentryUnityOptions(application: new TestApplication())
{
Dsn = SentryTests.TestDsn,
CreateHttpMessageHandler = () => new TestHttpClientHandler("LastEventIdTest")
};
SentrySdk.Init(options);

var capturedId = SentrySdk.CaptureMessage("test message");

Assert.AreNotEqual(SentryId.Empty, capturedId);
Assert.AreEqual(capturedId, SentrySdk.LastEventId);
}

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