-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from MindscapeHQ/ro/cs-121/fix-send-in-backgro…
…und-ios Fix SendInBackground for iOS
- Loading branch information
Showing
5 changed files
with
58 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
# Full Change Log for Raygun4Maui package | ||
|
||
### v1.4.2 | ||
- Fixed issue with SendInBackground where environment variables are collected on the wrong thread causing it to fail silently | ||
|
||
### v1.4.1 | ||
- Fixed issue with resource locking of device environment information on Android causing app to crash | ||
|
||
### v1.4.0 | ||
- Dependency update to Raygun4Net 8.0.0 | ||
|
||
### v1.3.0 | ||
- Dependency update to Raygun4Net 7.1.0 | ||
- Dependency update to Raygun4Net 7.1.0 |
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
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 |
---|---|---|
@@ -1,53 +1,72 @@ | ||
using System.Globalization; | ||
using Mindscape.Raygun4Net; | ||
|
||
namespace Raygun4Maui; | ||
|
||
internal class RaygunMauiEnvironmentMessageBuilder | ||
{ | ||
private static readonly object EnvironmentLock = new(); | ||
|
||
public string OSVersion { get; init; } = DeviceInfo.Current.VersionString; | ||
public string Architecture { get; init; } = NativeDeviceInfo.Architecture(); | ||
public string OSVersion { get; init; } = DeviceInfo.Current.VersionString; | ||
public string Architecture { get; init; } = NativeDeviceInfo.Architecture(); | ||
|
||
private string DeviceManufacturer = DeviceInfo.Current.Manufacturer; | ||
private string Platform = NativeDeviceInfo.Platform(); | ||
private string Model = DeviceInfo.Current.Model; | ||
|
||
private int ProcessorCount = Environment.ProcessorCount; | ||
|
||
private double UtcOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now).TotalHours; | ||
|
||
|
||
private ulong TotalPhysicalMemory = NativeDeviceInfo.TotalPhysicalMemory(); | ||
|
||
|
||
private string Locale = CultureInfo.CurrentCulture.DisplayName; | ||
|
||
private double? WindowBoundsWidth = null; | ||
|
||
private double? WindowBoundsHeight = null; | ||
|
||
private double? ResolutionScale = null; | ||
|
||
private string CurrentOrientation = null; | ||
|
||
public RaygunMauiEnvironmentMessageBuilder() | ||
{ | ||
DeviceDisplay.MainDisplayInfoChanged += UpdateDisplayInfo; | ||
|
||
// Ensure that we do have assigned values to the display fields by manually sending an update with the current information | ||
MainThread.InvokeOnMainThreadAsync(() => UpdateDisplayInfo(this, new DisplayInfoChangedEventArgs(DeviceDisplay.MainDisplayInfo))); | ||
} | ||
|
||
internal RaygunMauiEnvironmentMessage BuildEnvironmentMessage() | ||
{ | ||
// We create a lock so that during async tasks we do not access device information at the same time | ||
// this has caused issues in Android | ||
lock (EnvironmentLock) | ||
return new RaygunMauiEnvironmentMessage | ||
{ | ||
DateTime now = DateTime.Now; | ||
|
||
return new RaygunMauiEnvironmentMessage | ||
{ | ||
UtcOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now).TotalHours, | ||
Locale = CultureInfo.CurrentCulture.DisplayName, | ||
OSVersion = OSVersion, | ||
Architecture = Architecture, | ||
WindowBoundsWidth = DeviceDisplay.MainDisplayInfo.Width, | ||
WindowBoundsHeight = DeviceDisplay.MainDisplayInfo.Height, | ||
DeviceManufacturer = DeviceInfo.Current.Manufacturer, | ||
Platform = Platform, | ||
Model = Model, | ||
ProcessorCount = ProcessorCount, | ||
ResolutionScale = DeviceDisplay.MainDisplayInfo.Density, | ||
TotalPhysicalMemory = TotalPhysicalMemory, | ||
AvailablePhysicalMemory = NativeDeviceInfo.AvailablePhysicalMemory(), | ||
CurrentOrientation = DeviceDisplay.MainDisplayInfo.Orientation.ToString(), | ||
}; | ||
} | ||
UtcOffset = UtcOffset, | ||
Locale = Locale, | ||
OSVersion = OSVersion, | ||
Architecture = Architecture, | ||
WindowBoundsWidth = WindowBoundsWidth ?? 0, | ||
WindowBoundsHeight = WindowBoundsHeight ?? 0, | ||
DeviceManufacturer = DeviceManufacturer, | ||
Platform = Platform, | ||
Model = Model, | ||
ProcessorCount = ProcessorCount, | ||
ResolutionScale = ResolutionScale ?? 0, | ||
TotalPhysicalMemory = TotalPhysicalMemory, | ||
AvailablePhysicalMemory = | ||
NativeDeviceInfo.AvailablePhysicalMemory(), // Only possible issue for concurrent access | ||
CurrentOrientation = CurrentOrientation, | ||
}; | ||
} | ||
|
||
public static RaygunMauiEnvironmentMessageBuilder Init() | ||
private void UpdateDisplayInfo(object sender, DisplayInfoChangedEventArgs args) | ||
{ | ||
return new RaygunMauiEnvironmentMessageBuilder(); | ||
// We assume the update will come from the UI thread | ||
|
||
WindowBoundsWidth = args.DisplayInfo.Width; | ||
WindowBoundsHeight = args.DisplayInfo.Height; | ||
ResolutionScale = args.DisplayInfo.Density; | ||
CurrentOrientation = args.DisplayInfo.Orientation.ToString(); | ||
} | ||
} |