mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-18 00:21:33 -07:00
add post exception v2
This commit is contained in:
parent
1f21e8ce0b
commit
1e709f6b35
@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Net.Http.Json;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Windows;
|
||||
using System.Windows.Shell;
|
||||
@ -125,7 +126,7 @@ namespace Bloxstrap
|
||||
|
||||
_showingExceptionDialog = true;
|
||||
|
||||
SendLog();
|
||||
SendLog(ex);
|
||||
|
||||
if (Bootstrapper?.Dialog != null)
|
||||
{
|
||||
@ -198,16 +199,23 @@ namespace Bloxstrap
|
||||
}
|
||||
}
|
||||
|
||||
public static async void SendLog()
|
||||
public static async void SendLog(Exception exception)
|
||||
{
|
||||
if (!Settings.Prop.EnableAnalytics || !CanSendLogs())
|
||||
return;
|
||||
|
||||
var request = new PostExceptionV2Request
|
||||
{
|
||||
Type = exception.GetType().ToString(),
|
||||
Message = exception.Message,
|
||||
Log = Logger.AsDocument
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
await HttpClient.PostAsync(
|
||||
$"https://{WebUrl}/metrics/post-exception",
|
||||
new StringContent(Logger.AsDocument)
|
||||
await HttpClient.PostAsJsonAsync(
|
||||
$"https://{WebUrl}/metrics/post-exception-v2",
|
||||
request
|
||||
);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -27,6 +27,7 @@ global using Bloxstrap.Models.Manifest;
|
||||
global using Bloxstrap.Models.Persistable;
|
||||
global using Bloxstrap.Models.SettingTasks;
|
||||
global using Bloxstrap.Models.SettingTasks.Base;
|
||||
global using Bloxstrap.Models.Web;
|
||||
global using Bloxstrap.Resources;
|
||||
global using Bloxstrap.UI;
|
||||
global using Bloxstrap.Utility;
|
14
Bloxstrap/Models/Web/PostExceptionV2Request.cs
Normal file
14
Bloxstrap/Models/Web/PostExceptionV2Request.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace Bloxstrap.Models.Web
|
||||
{
|
||||
internal class PostExceptionV2Request
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; } = "";
|
||||
|
||||
[JsonPropertyName("message")]
|
||||
public string Message { get; set; } = "";
|
||||
|
||||
[JsonPropertyName("log")]
|
||||
public string Log { get; set; } = "";
|
||||
}
|
||||
}
|
@ -31,13 +31,20 @@
|
||||
|
||||
<!-- This does not need i18n as this is locked behind "Developer Mode" -->
|
||||
<controls:OptionControl
|
||||
Visibility="{Binding Path=WebEnvironmentVisibility, Mode=OneTime}"
|
||||
Visibility="{Binding Path=DeveloperOptionVisibility, Mode=OneTime}"
|
||||
Header="Web environment"
|
||||
Description="Site to use for metrics"
|
||||
HelpLink="https://admin.bloxstraplabs.com/Wiki/Developers/Web-Environments">
|
||||
<ComboBox Width="200" Padding="10,5,10,5" ItemsSource="{Binding WebEnvironments, Mode=OneWay}" SelectedValue="{Binding WebEnvironment, Mode=TwoWay}" />
|
||||
</controls:OptionControl>
|
||||
|
||||
<controls:OptionControl
|
||||
Visibility="{Binding Path=DeveloperOptionVisibility, Mode=OneTime}"
|
||||
Header="Debug crash"
|
||||
Description="All our builds keep blowing up!">
|
||||
<Button Padding="10,5,10,5" Content="Self-destruct" Command="{Binding DebugCrashCommand, Mode=OneTime}" />
|
||||
</controls:OptionControl>
|
||||
|
||||
<ui:CardExpander Margin="0,8,0,0" IsExpanded="True">
|
||||
<ui:CardExpander.Header>
|
||||
<Grid>
|
||||
|
@ -28,14 +28,21 @@ namespace Bloxstrap.UI.ViewModels.Settings
|
||||
set => App.Settings.Prop.WebEnvironment = value;
|
||||
}
|
||||
|
||||
public Visibility WebEnvironmentVisibility => App.Settings.Prop.DeveloperMode ? Visibility.Visible : Visibility.Collapsed;
|
||||
public Visibility DeveloperOptionVisibility => App.Settings.Prop.DeveloperMode ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
public bool ShouldExportConfig { get; set; } = true;
|
||||
|
||||
public bool ShouldExportLogs { get; set; } = true;
|
||||
|
||||
public ICommand DebugCrashCommand => new RelayCommand(DebugCrash);
|
||||
|
||||
public ICommand ExportDataCommand => new RelayCommand(ExportData);
|
||||
|
||||
private void DebugCrash()
|
||||
{
|
||||
throw new ApplicationException("Pretend like something terrible has happened");
|
||||
}
|
||||
|
||||
private void ExportData()
|
||||
{
|
||||
string timestamp = DateTime.UtcNow.ToString("yyyyMMdd'T'HHmmss'Z'");
|
||||
|
Loading…
Reference in New Issue
Block a user