Skip to content

Commit

Permalink
handle maui mobile apps
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelbeltran committed Oct 11, 2024
1 parent 8398225 commit 8a0561b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/Raygun.Blazor/Models/EnvironmentDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ internal EnvironmentDetails(BrowserSpecs? specs, BrowserStats? stats)
/// Creates a new instance of the <see cref="EnvironmentDetails" /> using runtime information.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
/// <returns>
/// Environment details for the current runtime.
Expand All @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions src/Raygun.Blazor/RaygunBlazorClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8a0561b

Please sign in to comment.