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

### Fixes

- The SDK no longer accesses `AnalyticsSessionInfo.userId` when targeting console platforms. This was leading to crashes during launch. ([#2309](https://github.com/getsentry/sentry-unity/pull/2309))
- The SDK now deduplicates trace generation during startup and scene loading ([#2301](https://github.com/getsentry/sentry-unity/pull/2301))
- The SDK no longer appends multiple upload tasks when building for Android ([#2300](https://github.com/getsentry/sentry-unity/pull/2300))
- Fixed false positive ANR events on `WebGL`, i.e. when switching tabs, or unfocusing the player ([#2306](https://github.com/getsentry/sentry-unity/pull/2306))
Expand Down
28 changes: 26 additions & 2 deletions src/Sentry.Unity.Native/SentryNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public static void Configure(SentryUnityOptions options)
options.EnableScopeSync = true;
options.NativeContextWriter = new NativeContextWriter();

// Use AnalyticsSessionInfo.userId as the default UserID in native & dotnet
options.DefaultUserId = AnalyticsSessionInfo.userId;
options.DefaultUserId = GetInstallationId();
if (options.DefaultUserId is not null)
{
options.ScopeObserver.SetUser(new SentryUser { Id = options.DefaultUserId });
Expand Down Expand Up @@ -115,4 +114,29 @@ private static void ReinstallBackend()
Logger?.LogError(e, "Native dependency not found. Did you delete sentry.dll or move files around?");
}
}

private static string? GetInstallationId(IApplication? application = null)
{
application ??= ApplicationAdapter.Instance;
switch (application.Platform)
{
case RuntimePlatform.Switch:
case RuntimePlatform.PS4:
case RuntimePlatform.PS5:
case RuntimePlatform.XboxOne:
case RuntimePlatform.GameCoreXboxSeries:
case RuntimePlatform.GameCoreXboxOne:
// TODO: Fetch the installation ID from sentry-native
// See https://github.com/getsentry/sentry-native/issues/1324
return null;

case RuntimePlatform.WindowsPlayer:
case RuntimePlatform.WindowsEditor:
case RuntimePlatform.LinuxPlayer:
case RuntimePlatform.LinuxEditor:
return AnalyticsSessionInfo.userId;
default:
return null;
}
}
}
2 changes: 1 addition & 1 deletion src/Sentry.Unity/WebGL/SentryWebGL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void Configure(SentryUnityOptions options)
"it currently produces blank screenshots mid-frame.");
}

// Use AnalyticsSessionInfo.userId as the default UserID in native & dotnet
// Use AnalyticsSessionInfo.userId as the default UserID
options.DefaultUserId = AnalyticsSessionInfo.userId;

// Indicate that this platform doesn't support running background threads.
Expand Down
Loading