Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/scripts/linux/build-avalonia-packages.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
PROJECT_PATH="$REPO_ROOT/src/GregModmanager.Avalonia/GregModmanager.Avalonia.csproj"
OUTPUT_ROOT="${1:-$REPO_ROOT/artifacts/avalonia-linux}"
VERSION="${2:-1.1.0}"
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "9.0.313",
"version": "10.0.103",
"rollForward": "minor"
}
}
10 changes: 5 additions & 5 deletions src/GregModmanager.Avalonia/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public override void OnFrameworkInitializationCompleted()

var telemetry = Services.GetRequiredService<TelemetryService>();
_ = telemetry.ReportCrashesAsync();
_ = telemetry.TrackEventAsync("startup", new
_ = telemetry.TrackEventAsync("startup", new GregModmanager.Models.AppStartupEvent
{
steamActive = GregModmanager.Steam.SteamApiNativeLoader.IsLoaded,
culture = System.Globalization.CultureInfo.CurrentCulture.Name,
osDescription = System.Runtime.InteropServices.RuntimeInformation.OSDescription,
dotNetVersion = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription
SteamActive = GregModmanager.Steam.SteamApiNativeLoader.IsLoaded,
Culture = System.Globalization.CultureInfo.CurrentCulture.Name,
OsDescription = System.Runtime.InteropServices.RuntimeInformation.OSDescription,
DotNetVersion = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription
});

if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
Expand Down
1 change: 1 addition & 0 deletions src/GregModmanager.Core/Models/AppJsonContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace GregModmanager.Models;
[JsonSerializable(typeof(int))]
[JsonSerializable(typeof(RalphTaskStatus))]
[JsonSerializable(typeof(AssetModMetadata))]
[JsonSerializable(typeof(AppStartupEvent))]
public partial class AppJsonContext : JsonSerializerContext
{
}
9 changes: 9 additions & 0 deletions src/GregModmanager.Core/Models/AppStartupEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace GregModmanager.Models;

public class AppStartupEvent
{
public bool SteamActive { get; set; }
public string Culture { get; set; } = "";
public string OsDescription { get; set; } = "";
public string DotNetVersion { get; set; } = "";
}
7 changes: 4 additions & 3 deletions src/GregModmanager.Core/Services/ModCollectionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ private CollectionCatalog LoadCatalog()
return new CollectionCatalog();
}

var json = File.ReadAllText(_storagePath);
return JsonSerializer.Deserialize(json, AppJsonContext.Default.CollectionCatalog) ?? new CollectionCatalog();
using var stream = File.OpenRead(_storagePath);
return JsonSerializer.Deserialize(stream, AppJsonContext.Default.CollectionCatalog) ?? new CollectionCatalog();
}
catch
{
Expand All @@ -245,6 +245,7 @@ private CollectionCatalog LoadCatalog()

private void SaveCatalog()
{
File.WriteAllText(_storagePath, JsonSerializer.Serialize(_catalog, AppJsonContext.Default.CollectionCatalog));
using var stream = new FileStream(_storagePath, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize: 32768);
JsonSerializer.Serialize(stream, _catalog, AppJsonContext.Default.CollectionCatalog);
}
}
16 changes: 12 additions & 4 deletions src/GregModmanager.Core/Services/TelemetryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,19 @@ public async Task TrackEventAsync(string eventName, object payload, Dictionary<s
foreach (var kvp in extraLabels) labels[kvp.Key] = kvp.Value;
}

var message = payload switch
string message = "";
if (payload is SyncCollectionEvent sync)
{
SyncCollectionEvent sync => JsonSerializer.Serialize(sync, AppJsonContext.Default.SyncCollectionEvent),
_ => JsonSerializer.Serialize(payload, payload.GetType(), AppJsonContext.Default.Options)
};
message = JsonSerializer.Serialize(sync, AppJsonContext.Default.SyncCollectionEvent);
}
else if (payload is AppStartupEvent startup)
{
message = JsonSerializer.Serialize(startup, AppJsonContext.Default.AppStartupEvent);
}
else if (payload != null)
{
message = JsonSerializer.Serialize(payload.ToString(), AppJsonContext.Default.String);
}

await PushToLokiAsync(eventName, message, labels);
}
Expand Down
Loading