diff --git a/src/Raygun.Blazor/Models/EnvironmentDetails.cs b/src/Raygun.Blazor/Models/EnvironmentDetails.cs index 7c4fb53..60c760a 100644 --- a/src/Raygun.Blazor/Models/EnvironmentDetails.cs +++ b/src/Raygun.Blazor/Models/EnvironmentDetails.cs @@ -212,7 +212,8 @@ internal EnvironmentDetails(BrowserSpecs? specs, BrowserStats? stats) /// Creates a new instance of the using runtime information. /// /// - /// This method should not be called from Browser code (i.e. Blazor WebAssembly). + /// Some of the properties are not available in all environments. + /// e.g. Browsers, Android and iOS cannot access Process information. /// /// /// Environment details for the current runtime. @@ -239,7 +240,7 @@ internal EnvironmentDetails(BrowserSpecs? specs, BrowserStats? stats) ProcessorCount = Environment.ProcessorCount, UtcOffset = (int)DateTimeOffset.Now.Offset.TotalHours, - // Disable warning on platform compatibility: Process not available for "browser" + // Disable warning on platform compatibility: Process not available on all platforms. #pragma warning disable CA1416 // Validate platform compatibility // Memory values obtained in Bytes and must be converted to Megabytes // Working Set: The amount of physical memory, in bytes, allocated for the associated process. diff --git a/src/Raygun.Blazor/RaygunBlazorClient.cs b/src/Raygun.Blazor/RaygunBlazorClient.cs index 748fbca..1605e8a 100644 --- a/src/Raygun.Blazor/RaygunBlazorClient.cs +++ b/src/Raygun.Blazor/RaygunBlazorClient.cs @@ -218,19 +218,19 @@ public async Task RecordExceptionAsync(Exception ex, } EnvironmentDetails? environment; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER"))) + if (OperatingSystem.IsLinux() || OperatingSystem.IsWindows() || OperatingSystem.IsMacOS()) { - // If running on Browser, obtain environment details from the browser - environment = await _browserInterop.GetBrowserEnvironment(); - } - else - { - // If running on Server, obtain environment details from the runtime + // If running on Server or Desktop device (MAUI Hybrid), obtain environment details from the runtime environment = EnvironmentDetails.FromRuntime(); // Add browser details to userCustomData userCustomData ??= []; userCustomData.Add("BrowserEnvironment", await _browserInterop.GetBrowserEnvironment()); } + else + { + // If running Browser or Mobile device (MAUI Hybrid), obtain environment details from the browser + environment = await _browserInterop.GetBrowserEnvironment(); + } var request = new RaygunRequest