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 @@ -6,6 +6,7 @@

- The SDK now also uses `.sentry-native` as a subdirectory for native support on desktop platforms. It now also falls back to `Application.persistentDataPath` instead of the current working directory. Note: `crashedLastRun` may report `false` for the first time after upgrading. ([#2547](https://github.com/getsentry/sentry-unity/pull/2547))
- The currently experimental Metrics are now opt-in by default ([#2546](https://github.com/getsentry/sentry-unity/pull/2546))
- When targeting Android, the SDK now syncs `AppStartTime` and `AppBuildType` to the native layer ([#2557](https://github.com/getsentry/sentry-unity/pull/2557))
- When targeting Switch, the SDK will no longer cause the build to fail when native libraries are missing but log a warning instead ([#2541](https://github.com/getsentry/sentry-unity/pull/2541))
- The SDK no longer wrongly disables the org slug field based on assumed the auth-tolken type ([#2537](https://github.com/getsentry/sentry-unity/pull/2537))

Expand Down
7 changes: 4 additions & 3 deletions src/Sentry.Unity.Android/NativeContextWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ protected override void WriteScope(
string? UnityRenderingThreadingMode
)
{
// We're only setting the missing contexts, the rest is configured by sentry-java. We could also sync
// the "unity" context, but it doesn't seem so useful and the effort to do is larger because there's no
// class for it in Java - not sure how we could add a generic context object in Java...
_sentryJava.WriteScope(
AppStartTime,
AppBuildType,
GpuId,
GpuName,
GpuVendorName,
Expand All @@ -67,6 +66,8 @@ protected override void WriteScope(
GpuMultiThreadedRendering,
GpuGraphicsShaderLevel);

CWUtil.WriteApp(AppStartTime, AppBuildType);

CWUtil.WriteGpu(
GpuId,
GpuName,
Expand Down
14 changes: 14 additions & 0 deletions src/Sentry.Unity.Android/SentryJava.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ internal interface ISentryJava
public bool? CrashedLastRun();
public void Close();
public void WriteScope(
string? AppStartTime,
string? AppBuildType,
int? GpuId,
string? GpuName,
string? GpuVendorName,
Expand Down Expand Up @@ -212,6 +214,8 @@ public void Init(SentryUnityOptions options)
}

public void WriteScope(
string? AppStartTime,
string? AppBuildType,
int? GpuId,
string? GpuName,
string? GpuVendorName,
Expand All @@ -230,6 +234,15 @@ public void WriteScope(
{
RunJniSafe(() =>
{
using var app = new AndroidJavaObject("io.sentry.protocol.App");
if (AppStartTime is not null)
{
var epochMs = DateTimeOffset.Parse(AppStartTime).ToUnixTimeMilliseconds();
using var date = new AndroidJavaObject("java.util.Date", epochMs);
app.Set("appStartTime", date);
}
app.SetIfNotNull("buildType", AppBuildType);

using var gpu = new AndroidJavaObject("io.sentry.protocol.Gpu");
gpu.SetIfNotNull("name", GpuName);
gpu.SetIfNotNull("id", GpuId);
Expand All @@ -244,6 +257,7 @@ public void WriteScope(
sentry.CallStatic("configureScope", new ScopeCallback(scope =>
{
using var contexts = scope.Call<AndroidJavaObject>("getContexts");
contexts.Call("setApp", app);
contexts.Call("setGpu", gpu);
}));
});
Expand Down
6 changes: 0 additions & 6 deletions test/IntegrationTest/CommonTestCases.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ $CommonTestCases = @(
}
@{ Name = "Contains app context"; TestBlock = {
param($TestSetup, $TestType, $SentryEvent, $RunResult)

if ($TestType -eq "crash-capture") {
Set-ItResult -Skipped -Because "app context is not synced to sentry-native on Android"
return
}

$SentryEvent.contexts.app | Should -Not -BeNullOrEmpty
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/Scripts.Integration.Test/Editor/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void BuildIl2CPPPlayer(BuildTarget target, BuildTargetGroup group,
#endif

Debug.Log("Builder: Configuring code stripping level");
#if UNITY_2022_1_OR_NEWER
#if UNITY_6000_0_OR_NEWER
PlayerSettings.SetManagedStrippingLevel(NamedBuildTarget.FromBuildTargetGroup(group), ManagedStrippingLevel.High);
#else
PlayerSettings.SetManagedStrippingLevel(NamedBuildTarget.FromBuildTargetGroup(group), ManagedStrippingLevel.Low);
Expand Down
2 changes: 2 additions & 0 deletions test/Sentry.Unity.Android.Tests/TestSentryJava.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public void Init(SentryUnityOptions options) { }
public void Close() { }

public void WriteScope(
string? AppStartTime,
string? AppBuildType,
int? GpuId,
string? GpuName,
string? GpuVendorName,
Expand Down