diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1c929404e..83ce8db38 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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))
diff --git a/src/Sentry.Unity/SentrySdk.Dotnet.cs b/src/Sentry.Unity/SentrySdk.Dotnet.cs
index 33966a487..d4709ff6a 100644
--- a/src/Sentry.Unity/SentrySdk.Dotnet.cs
+++ b/src/Sentry.Unity/SentrySdk.Dotnet.cs
@@ -47,6 +47,11 @@ public static partial class SentrySdk
[DebuggerStepThrough]
public static Task FlushAsync(TimeSpan timeout) => Sentry.SentrySdk.FlushAsync(timeout);
+ ///
+ /// The last event id recorded in the current scope.
+ ///
+ public static SentryId LastEventId { [DebuggerStepThrough] get => Sentry.SentrySdk.LastEventId; }
+
///
/// Whether the SDK is enabled or not.
///
diff --git a/test/Sentry.Unity.Tests/SentryUnityTests.cs b/test/Sentry.Unity.Tests/SentryUnityTests.cs
index d9706593c..4f741a820 100644
--- a/test/Sentry.Unity.Tests/SentryUnityTests.cs
+++ b/test/Sentry.Unity.Tests/SentryUnityTests.cs
@@ -96,6 +96,22 @@ public void SentryUnity_FilterBadGatewayExceptionsDisabled_RemovesBadGatewayFilt
Assert.That(filters.OfType(), 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()
{