Skip to content

Commit

Permalink
docs: #17 document BrowserStats and BrowserSpecs (#54)
Browse files Browse the repository at this point in the history
* docs: #17 document BrowserStats and BrowserSpecs

* Update BrowserSpecs.cs
  • Loading branch information
miquelbeltran authored Oct 9, 2024
1 parent f62cfc7 commit b162a6a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 36 deletions.
54 changes: 31 additions & 23 deletions src/Raygun.Blazor/Models/BrowserSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Raygun.Blazor.Models
/// </summary>
/// <remarks>
/// This exists because we need to parse some stuff from the browser to construct a proper <see cref="EnvironmentDetails" />
/// instance. Also the <see cref="EnvironmentDetails" /> is a hot mess of JavaScript serialization inconsistency.
/// instance. Also, the <see cref="EnvironmentDetails" /> is a hot mess of JavaScript serialization inconsistency.
/// </remarks>
internal record BrowserSpecs
{
Expand All @@ -17,107 +17,115 @@ internal record BrowserSpecs
private string? _calculatedBrowserVersion;
private string? _calculatedBrowserName;
private string? _calculatedOSVersion;
// private string? _browserManufacturer;

#endregion

#region Public Properties

/// <summary>
///
/// True if able to read and write cookies. From `navigator.cookieEnabled`.
/// </summary>
public bool AreCookiesEnabled { get; set; }

/// <summary>
///
/// Browser name as extracted from the User Agent string.
/// </summary>
public string? CalculatedBrowserName => _calculatedBrowserName;

/// <summary>
///
/// Browser version as extracted from the User Agent string.
/// </summary>
public string? CalculatedBrowserVersion => _calculatedBrowserVersion;

/// <summary>
///
/// Color depth of the screen. From `screen.colorDepth`.
/// </summary>
public int ColorDepth { get; set; }

/// <summary>
///
/// The company who manufactured the device.
/// </summary>
/// <remarks>
/// Currently not set by the client.
/// </remarks>
public string? DeviceManufacturer { get; set; }

/// <summary>
///
/// The model of the device.
/// </summary>
/// <remarks>
/// Currently not set by the client.
/// </remarks>
public string? DeviceModel { get; set; }

/// <summary>
///
/// The name of the device.
/// </summary>
/// <remarks>
/// Currently not set by the client.
/// </remarks>
public string? DeviceName { get; set; }

/// <summary>
///
/// Device memory in gigabytes. From `navigator.deviceMemory`.
/// </summary>
public decimal DeviceMemoryInGb { get; set; }

/// <summary>
///
/// If the device has multiple monitors. From `screen.isExtended`.
/// </summary>
/// <remarks>
/// When null, the browser does not support the required API.
/// </remarks>
public bool? HasMultipleMonitors { get; set; }

/// <summary>
///
/// Device locale. From `navigator.language`.
/// </summary>
public string? Locale { get; set; }

/// <summary>
///
/// Operating system version as extracted from the User Agent string.
/// </summary>
public string? CalculatedOSVersion => _calculatedOSVersion;

/// <summary>
///
/// Pixel depth of the screen. From `screen.pixelDepth`.
/// </summary>
public int PixelDepth { get; set; }

/// <summary>
///
/// OS Name. From `navigator.platform`.
/// </summary>
public string? Platform { get; set; }

/// <summary>
///
/// Number of logical processors available to run threads on the user's computer. From `navigator.hardwareConcurrency`.
/// </summary>
public int ProcessorCount { get; set; }

/// <summary>
///
/// Screen height in pixels. From `screen.height`.
/// </summary>
public int ScreenHeight { get; set; }

/// <summary>
///
/// Screen width in pixels. From `screen.width`.
/// </summary>
public int ScreenWidth { get; set; }

/// <summary>
///
/// User Agent Hints.
/// </summary>
public BrowserUserAgentData? UAHints { get; set; }

/// <summary>
///
/// User Agent string. From `navigator.userAgent`.
/// </summary>
public string? UserAgent { get; set; }

/// <summary>
///
/// UTC offset in minutes. From `new Date().getTimezoneOffset() / -60`.
/// </summary>
public int UtcOffset { get; set; }

Expand All @@ -126,7 +134,7 @@ internal record BrowserSpecs
#region Public Methods

/// <summary>
///
/// Calculate values from User Agent.
/// </summary>
internal void ParseUserAgent()
{
Expand All @@ -139,4 +147,4 @@ internal void ParseUserAgent()

#endregion
}
}
}
25 changes: 14 additions & 11 deletions src/Raygun.Blazor/Models/BrowserStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,60 @@ internal record BrowserStats
#region Public Properties

/// <summary>
///
/// Application height. From `screen.availHeight`.
/// </summary>
public int AppHeight { get; set; }

/// <summary>
///
/// Application width. From `screen.availWidth`.
/// </summary>
public int AppWidth { get; set; }

/// <summary>
///
/// Returns the calculated storage remaining in bytes.
/// </summary>
public long CalculatedStorageRemainingInBytes => StorageQuotaInBytes - StorageUsageInBytes;

/// <summary>
///
/// Device pixel ratio. From `window.devicePixelRatio`.
/// </summary>
public decimal DevicePixelRatio { get; set; }

/// <summary>
///
/// JavaScript heap memory size in bytes. From `window.performance.memory.totalJSHeapSize`.
/// </summary>
public long MemoryCurrentSizeInBytes { get; set; }

/// <summary>
///
/// Max JS heap memory size in bytes. From `window.performance.memory.jsHeapSizeLimit`.
/// </summary>
public long MemoryMaxSizeInBytes { get; set; }

/// <summary>
///
/// Used JS heap memory size in bytes. From `window.performance.memory.userJSHeapSize`.
/// </summary>
public long MemoryUsedSizeInBytes { get; set; }

/// <summary>
///
/// Network type.
/// </summary>
/// <remarks>
/// Currently not set.
/// </remarks>
public string? NetworkEffectiveType { get; set; }

/// <summary>
///
/// Orientation type. From `screen.orientation.type`.
/// </summary>
public BrowserOrientationType Orientation { get; set; }

/// <summary>
///
/// Storage quota in bytes. From `navigator.storage.estimate().quota`.
/// </summary>
public long StorageQuotaInBytes { get; set; }

/// <summary>
///
/// Storage usage in bytes. From `navigator.storage.estimate().usage`.
/// </summary>
public long StorageUsageInBytes { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions src/Raygun.Blazor/Models/BrowserUserAgentData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ internal record BrowserUserAgentData
public Dictionary<string, string>? BrandVersions { get; set; }

/// <summary>
///
/// Calculated OS version based on the reported data.
/// </summary>
public string? CalculatedOSVersion => $"{Platform} {(
Platform == "Windows" && Decimal.Parse(PlatformVersion?.Split(".")?[0] ?? "0") >= 13 ? "11" :
Platform == "Windows" && Decimal.Parse(PlatformVersion?.Split(".")?[0] ?? "0") < 13 ? "10" :
PlatformVersion)}";

/// <summary>
///
/// Platform architecture and bits calculated from the reported data.
/// </summary>
public string? CalculatedPlatform
{
Expand Down

0 comments on commit b162a6a

Please sign in to comment.