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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion samples/unity-of-bugs/Assets/Scripts/BugFarmButtons.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Sentry.Unity;
using UnityEngine;
Expand All @@ -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<string, object> { ["telemetry_id"] = telemetryId });
Comment thread
bitsandfoxes marked this conversation as resolved.
}

private void Start()
Expand Down
2 changes: 1 addition & 1 deletion samples/unity-of-bugs/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion samples/unity-of-bugs/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
}
},
"com.unity.ide.rider": {
"version": "3.0.31",
"version": "3.0.40",
"depth": 0,
"source": "registry",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ PlayerSettings:
androidMinimumWindowHeight: 300
androidFullscreenMode: 1
androidAutoRotationBehavior: 1
androidPredictiveBackSupport: 1
defaultIsNativeResolution: 1
macRetinaSupport: 1
runInBackground: 1
Expand Down Expand Up @@ -826,6 +825,7 @@ PlayerSettings:
PS4: 1
PS5: 1
Stadia: 1
Standalone: 3
WebGL: 1
Windows Store Apps: 1
XboxOne: 1
Expand Down
5 changes: 1 addition & 4 deletions scripts/alias-assemblies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)" }
}

Expand Down
11 changes: 11 additions & 0 deletions src/Sentry.Unity/Sentry.Unity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<Target Name="RemoveUnityProvidedBclAssemblies" AfterTargets="Build">
<!-- Unity ships these BCL assemblies as type-forwarding facades in every supported version. -->
<ItemGroup>
<UnityProvidedBcl Include="$(OutDir)/System.Memory.dll" />
<UnityProvidedBcl Include="$(OutDir)/System.Buffers.dll" />
<UnityProvidedBcl Include="$(OutDir)/System.Numerics.Vectors.dll" />
<UnityProvidedBcl Include="$(OutDir)/System.Threading.Tasks.Extensions.dll" />
</ItemGroup>
<Delete Files="@(UnityProvidedBcl)" />
</Target>

<Target Name="CleanDotnetSdkFiles" AfterTargets="Clean">
<!-- CopyLocalLockFileAssemblies brings the .NET SDK assemblies to the output dir.
For that reason they are not clean by the Sentry project clean Target. -->
Expand Down
9 changes: 5 additions & 4 deletions src/Sentry.Unity/SentrySdk.Dotnet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Sentry.Infrastructure;
using Sentry.Protocol.Envelopes;
using Sentry.Unity.Integrations;

namespace Sentry.Unity;

Expand Down Expand Up @@ -334,8 +335,8 @@ public static SentryId CaptureFeedback(SentryFeedback feedback, Action<Scope> co
/// <param name="hint">An optional hint providing high-level context for the source of the event.</param>
/// <returns>The Id of the captured feedback. Returns <see cref="SentryId.Empty"/> when capture failed.</returns>
/// <remarks>
/// 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.
/// </remarks>
[DebuggerStepThrough]
Expand Down Expand Up @@ -367,8 +368,8 @@ public static SentryId CaptureFeedback(SentryFeedback feedback, Scope? scope = n
/// <param name="hint">An optional hint providing high-level context for the source of the event.</param>
/// <returns>The Id of the captured feedback. Returns <see cref="SentryId.Empty"/> when capture failed.</returns>
/// <remarks>
/// 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.
/// </remarks>
[DebuggerStepThrough]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions test/Scripts.Integration.Test/Scripts/IntegrationTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, object> { ["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}");
Expand All @@ -144,6 +170,7 @@ private IEnumerator MessageCapture()
private IEnumerator ExceptionCapture()
{
AddIntegrationTestContext("exception-capture");
EmitLogAndMetric("exception-capture");

try
{
Expand Down
8 changes: 0 additions & 8 deletions test/Scripts.Tests/package-release.zip.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading