Skip to content

Commit fe29d49

Browse files
committed
Revert "Removed installation"
This reverts commit 3e28372.
1 parent 3e28372 commit fe29d49

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/Elmah.Io.WinUI/ElmahIoWinUI.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Elmah.Io.WinUI
1616
public static class ElmahIoWinUI
1717
{
1818
internal static readonly string _assemblyVersion = typeof(ElmahIoWinUI).Assembly.GetName().Version?.ToString() ?? "Unknown";
19+
internal static readonly string _elmahIoClientAssemblyVersion = typeof(IElmahioAPI).Assembly.GetName().Version?.ToString() ?? "Unknown";
1920
internal static readonly string _winUiAssemblyVersion = typeof(Application).Assembly.GetName().Version?.ToString() ?? "Unknown";
2021

2122
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
@@ -56,6 +57,8 @@ public static void Init(ElmahIoWinUIOptions options)
5657

5758
Application.Current.UnhandledException += (sender, args) =>
5859
Log(args.Exception);
60+
61+
CreateInstallation();
5962
}
6063

6164
/// <summary>
@@ -150,5 +153,37 @@ private static string UserAgent()
150153
.Append(new ProductInfoHeaderValue(new ProductHeaderValue("Microsoft.WinUI", _winUiAssemblyVersion)).ToString())
151154
.ToString();
152155
}
156+
157+
private static void CreateInstallation()
158+
{
159+
try
160+
{
161+
var loggerInfo = new LoggerInfo
162+
{
163+
Type = "Elmah.Io.WinUI",
164+
Properties = [],
165+
ConfigFiles = [],
166+
Assemblies =
167+
[
168+
new AssemblyInfo { Name = "Elmah.Io.WinUI", Version = _assemblyVersion },
169+
new AssemblyInfo { Name = "Elmah.Io.Client", Version = _elmahIoClientAssemblyVersion },
170+
new AssemblyInfo { Name = "Microsoft.WindowsAppSDK", Version = _winUiAssemblyVersion }
171+
],
172+
};
173+
174+
var installation = new CreateInstallation
175+
{
176+
Type = "windowsapp",
177+
Name = _options.Application,
178+
Loggers = [loggerInfo]
179+
};
180+
181+
_logger.Installations.Create(_options.LogId.ToString(), installation);
182+
}
183+
catch
184+
{
185+
// We don't want to crash the entire application if the installation fails. Carry on.
186+
}
187+
}
153188
}
154189
}

0 commit comments

Comments
 (0)