-
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OS information from MAUI device data (#1717)
- Loading branch information
1 parent
711efd2
commit 54fded1
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Sentry.Extensibility; | ||
using OperatingSystem = Sentry.Protocol.OperatingSystem; | ||
|
||
namespace Sentry.Maui.Internal; | ||
|
||
internal static class MauiOsData | ||
{ | ||
public static void ApplyMauiOsData(this OperatingSystem os, IDiagnosticLogger? logger) | ||
{ | ||
try | ||
{ | ||
// https://docs.microsoft.com/dotnet/maui/platform-integration/device/information | ||
var deviceInfo = DeviceInfo.Current; | ||
if (deviceInfo.Platform == DevicePlatform.Unknown) | ||
{ | ||
// return early so we don't get NotImplementedExceptions (i.e., in unit tests, etc.) | ||
return; | ||
} | ||
|
||
os.Name ??= deviceInfo.Platform.ToString(); | ||
os.Version ??= deviceInfo.VersionString; | ||
|
||
// TODO: fill in these | ||
// os.Build ??= ? | ||
// os.KernelVersion ??= ? | ||
// os.Rooted ??= ? | ||
} | ||
catch (Exception ex) | ||
{ | ||
// Log, but swallow the exception so we can continue sending events | ||
logger?.LogError("Error getting MAUI OS information.", ex); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters