diff --git a/CHANGELOG.md b/CHANGELOG.md index 7823da763..39aa8ac43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixes +- Fixed an issue with the updated dependency resolution introduced in `4.6.0` where usage of the `Metrics` API would cause Unity to error with `The type 'ReadOnlySpan<>' is defined in an assembly that is not referenced`. ([#2754](https://github.com/getsentry/sentry-unity/pull/2754)) - When targeting Nintendo Switch, the SDK will now properly log the state of the native support instead of silently swallowing any configuration issues ([#2753](https://github.com/getsentry/sentry-unity/pull/2753)) ### Dependencies diff --git a/samples/unity-of-bugs/Assets/Scripts/BugFarmButtons.cs b/samples/unity-of-bugs/Assets/Scripts/BugFarmButtons.cs index e0a3d072b..1471b99d1 100644 --- a/samples/unity-of-bugs/Assets/Scripts/BugFarmButtons.cs +++ b/samples/unity-of-bugs/Assets/Scripts/BugFarmButtons.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; using Sentry.Unity; using UnityEngine; @@ -7,7 +8,15 @@ public class BugFarmButtons : MonoBehaviour { private void Awake() { - Debug.Log("The 🐛s awaken!"); + var telemetryId = Guid.NewGuid().ToString(); + SentrySdk.Logger.LogInfo( + log => log.SetAttribute("telemetry_id", telemetryId), + "The 🐛s awaken!"); + + SentrySdk.Metrics.EmitCounter( + "test.integration.counter", + 1, + new Dictionary { ["telemetry_id"] = telemetryId }); } private void Start() diff --git a/samples/unity-of-bugs/Packages/manifest.json b/samples/unity-of-bugs/Packages/manifest.json index 81c1669c4..c8bb9d022 100644 --- a/samples/unity-of-bugs/Packages/manifest.json +++ b/samples/unity-of-bugs/Packages/manifest.json @@ -3,7 +3,7 @@ "com.unity.burst": "1.8.25", "com.unity.collab-proxy": "2.9.3", "com.unity.feature.development": "1.0.1", - "com.unity.ide.rider": "3.0.31", + "com.unity.ide.rider": "3.0.40", "com.unity.ide.visualstudio": "2.0.23", "com.unity.ide.vscode": "1.2.5", "com.unity.mobile.android-logcat": "1.4.6", diff --git a/samples/unity-of-bugs/Packages/packages-lock.json b/samples/unity-of-bugs/Packages/packages-lock.json index c11814176..d0df42ff2 100644 --- a/samples/unity-of-bugs/Packages/packages-lock.json +++ b/samples/unity-of-bugs/Packages/packages-lock.json @@ -46,7 +46,7 @@ } }, "com.unity.ide.rider": { - "version": "3.0.31", + "version": "3.0.40", "depth": 0, "source": "registry", "dependencies": { diff --git a/samples/unity-of-bugs/ProjectSettings/ProjectSettings.asset b/samples/unity-of-bugs/ProjectSettings/ProjectSettings.asset index 5e068d9c7..c4a93faa0 100644 --- a/samples/unity-of-bugs/ProjectSettings/ProjectSettings.asset +++ b/samples/unity-of-bugs/ProjectSettings/ProjectSettings.asset @@ -76,7 +76,6 @@ PlayerSettings: androidMinimumWindowHeight: 300 androidFullscreenMode: 1 androidAutoRotationBehavior: 1 - androidPredictiveBackSupport: 1 defaultIsNativeResolution: 1 macRetinaSupport: 1 runInBackground: 1 @@ -826,6 +825,7 @@ PlayerSettings: PS4: 1 PS5: 1 Stadia: 1 + Standalone: 3 WebGL: 1 Windows Store Apps: 1 XboxOne: 1 diff --git a/scripts/alias-assemblies.ps1 b/scripts/alias-assemblies.ps1 index 8773c91b2..0a729ad02 100644 --- a/scripts/alias-assemblies.ps1 +++ b/scripts/alias-assemblies.ps1 @@ -2,8 +2,6 @@ # release script (repack.ps1) and by CI (build.yml, which runs it inside the Unity # docker container). # -# --assemblies-to-exclude: BCL assemblies Unity's unityaot profile already provides -# For more info see sentry-unity #2717, #1777). param( # Pass an empty string to skip either target. [string]$RuntimeDir = "package-dev/Runtime", @@ -18,8 +16,7 @@ $ErrorActionPreference = "Stop" if ($RuntimeDir) { & $AssemblyAlias --target-directory $RuntimeDir --internalize --prefix "Sentry." ` - --assemblies-to-alias "Microsoft*;System*" ` - --assemblies-to-exclude "System.Buffers;System.Memory;System.Numerics.Vectors;System.Threading.Tasks.Extensions" + --assemblies-to-alias "Microsoft*;System*" if ($LASTEXITCODE -ne 0) { throw "assemblyalias failed for '$RuntimeDir' (exit $LASTEXITCODE)" } } diff --git a/src/Sentry.Unity/Sentry.Unity.csproj b/src/Sentry.Unity/Sentry.Unity.csproj index 69022fda2..23ee56f0a 100644 --- a/src/Sentry.Unity/Sentry.Unity.csproj +++ b/src/Sentry.Unity/Sentry.Unity.csproj @@ -5,6 +5,17 @@ true + + + + + + + + + + + diff --git a/src/Sentry.Unity/SentrySdk.Dotnet.cs b/src/Sentry.Unity/SentrySdk.Dotnet.cs index fb1af3561..5799cce8c 100644 --- a/src/Sentry.Unity/SentrySdk.Dotnet.cs +++ b/src/Sentry.Unity/SentrySdk.Dotnet.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Sentry.Infrastructure; using Sentry.Protocol.Envelopes; +using Sentry.Unity.Integrations; namespace Sentry.Unity; @@ -334,8 +335,8 @@ public static SentryId CaptureFeedback(SentryFeedback feedback, Action co /// An optional hint providing high-level context for the source of the event. /// The Id of the captured feedback. Returns when capture failed. /// - /// Capturing is asynchronous and non-blocking. The envelope is handed to a background worker. Non-success - /// results inform only on whether the capture succeeded or failed on the client, i.e. empty message, + /// Capturing is asynchronous and non-blocking. The envelope is handed to a background worker. Non-success + /// results inform only on whether the capture succeeded or failed on the client, i.e. empty message, /// disabled SDK, dropped by an event processor. /// [DebuggerStepThrough] @@ -367,8 +368,8 @@ public static SentryId CaptureFeedback(SentryFeedback feedback, Scope? scope = n /// An optional hint providing high-level context for the source of the event. /// The Id of the captured feedback. Returns when capture failed. /// - /// Capturing is asynchronous and non-blocking. The envelope is handed to a background worker. Non-success - /// results inform only on whether the capture succeeded or failed on the client, i.e. empty message, + /// Capturing is asynchronous and non-blocking. The envelope is handed to a background worker. Non-success + /// results inform only on whether the capture succeeded or failed on the client, i.e. empty message, /// disabled SDK, dropped by an event processor. /// [DebuggerStepThrough] diff --git a/test/Scripts.Integration.Test/Scripts/IntegrationOptionsConfiguration.cs b/test/Scripts.Integration.Test/Scripts/IntegrationOptionsConfiguration.cs index f52dd4944..9ac81ea2c 100644 --- a/test/Scripts.Integration.Test/Scripts/IntegrationOptionsConfiguration.cs +++ b/test/Scripts.Integration.Test/Scripts/IntegrationOptionsConfiguration.cs @@ -26,6 +26,9 @@ public override void Configure(SentryUnityOptions options) options.DiagnosticLogger = Logger.Instance; options.TracesSampleRate = 1.0d; + options.EnableLogs = true; + options.EnableMetrics = true; + // No custom HTTP handler -- events go to real sentry.io // Filtering test output from breadcrumbs diff --git a/test/Scripts.Integration.Test/Scripts/IntegrationTester.cs b/test/Scripts.Integration.Test/Scripts/IntegrationTester.cs index d86f91af8..fe38471cb 100644 --- a/test/Scripts.Integration.Test/Scripts/IntegrationTester.cs +++ b/test/Scripts.Integration.Test/Scripts/IntegrationTester.cs @@ -131,9 +131,35 @@ private void AddIntegrationTestContext(string testType) SentrySdk.AddBreadcrumb("Context configuration finished"); } + private void EmitLogAndMetric(string testType) + { + Logger.Log($"Emitting structured log."); + + var telemetryId = Guid.NewGuid().ToString(); + + SentrySdk.Logger.LogInfo( + log => log.SetAttribute("test.telemetry_id", telemetryId), + "Integration test log"); + + Logger.Log($"Emitting structured log finished."); + +#if UNITY_2022_1_OR_NEWER + // Unity needs to be newer than 2022 for its AOT to generate the code for the generic implementation + Logger.Log($"Emitting metric."); + + SentrySdk.Metrics.EmitCounter( + "test.integration.counter", + 1, + new Dictionary { ["test.telemetry_id"] = telemetryId }); + + Logger.Log($"Emitting metric finished."); +#endif + } + private IEnumerator MessageCapture() { AddIntegrationTestContext("message-capture"); + EmitLogAndMetric("message-capture"); var eventId = SentrySdk.CaptureMessage("Integration test message"); Logger.Log($"EVENT_CAPTURED: {eventId}"); @@ -144,6 +170,7 @@ private IEnumerator MessageCapture() private IEnumerator ExceptionCapture() { AddIntegrationTestContext("exception-capture"); + EmitLogAndMetric("exception-capture"); try { diff --git a/test/Scripts.Tests/package-release.zip.snapshot b/test/Scripts.Tests/package-release.zip.snapshot index 2d3946f66..baddaa9c1 100644 --- a/test/Scripts.Tests/package-release.zip.snapshot +++ b/test/Scripts.Tests/package-release.zip.snapshot @@ -303,14 +303,6 @@ Runtime/SentryInitialization.cs Runtime/SentryInitialization.cs.meta Runtime/SentryUserFeedback.cs Runtime/SentryUserFeedback.cs.meta -Runtime/System.Buffers.dll -Runtime/System.Buffers.dll.meta -Runtime/System.Memory.dll -Runtime/System.Memory.dll.meta -Runtime/System.Numerics.Vectors.dll -Runtime/System.Numerics.Vectors.dll.meta -Runtime/System.Threading.Tasks.Extensions.dll -Runtime/System.Threading.Tasks.Extensions.dll.meta Samples~/unity-of-bugs/Scenes.meta Samples~/unity-of-bugs/Scripts.meta Samples~/unity-of-bugs/Scenes/1_BugFarm.unity