Skip to content

Commit

Permalink
接入 Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
STBBRD committed Oct 19, 2024
1 parent ccf2a76 commit 59d91ec
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
22 changes: 20 additions & 2 deletions ZongziTEK_Blackboard_Sticker/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using AutoUpdaterDotNET;
using System.Globalization;
using ZongziTEK_Blackboard_Sticker.Helpers;
using System.Diagnostics;
using Sentry;

namespace ZongziTEK_Blackboard_Sticker
{
Expand All @@ -19,7 +21,18 @@ public partial class App : Application

public App()
{
this.Startup += new StartupEventHandler(App_Startup);
this.Startup += new StartupEventHandler(App_Startup);

SentrySdk.Init(o =>
{
// Tells which project in Sentry to send events to:
o.Dsn = "https://be9e01f3b4459566b40b8bbc1ce7f8be@o4508149744140288.ingest.de.sentry.io/4508149746040912";
// When configuring for the first time, to see what the SDK is doing:
o.Debug = true;
// Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing.
// We recommend adjusting this value in production.
o.TracesSampleRate = 1.0;
});
}

void App_Startup(object sender, StartupEventArgs e)
Expand All @@ -39,9 +52,14 @@ private void Application_DispatcherUnhandledException(object sender, System.Wind
try
{
e.Handled = true;
SentrySdk.CaptureException(e.Exception);
LogHelper.WriteLogToFile(e.Exception.Message, LogHelper.LogType.Error);
}
catch { }
catch
{
Process.Start(System.Windows.Forms.Application.ExecutablePath, "-m");
Shutdown();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<ikw:SimpleStackPanel Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="32" Spacing="12">
<TextBlock Foreground="{DynamicResource {x:Static ui:ThemeKeys.TextControlForegroundKey}}" Text="嗨!来完成对黑板贴的初始设置吧" FontSize="40" TextWrapping="Wrap"/>
<TextBlock Foreground="{DynamicResource {x:Static ui:ThemeKeys.TextControlForegroundKey}}" Text="点击下方按钮以继续" FontSize="20" TextWrapping="Wrap" Opacity="0.75"/>
<TextBlock Foreground="{DynamicResource {x:Static ui:ThemeKeys.TextControlForegroundKey}}" Text="本程序的错误日志将被上传至 Sentry 以便开发者分析" FontSize="10" TextWrapping="Wrap" Opacity="0.5" VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
</ikw:SimpleStackPanel>
</Grid>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<DependentUpon>TimetableLesson.xaml</DependentUpon>
</Compile>
<Compile Include="Helpers\ControlsHelper.cs" />
<Compile Include="Helpers\LogHelper.cs" />
<Compile Include="Helpers\TTSHelper.cs" />
<Compile Include="Pages\InfoBoardPages\CountdownPage.xaml.cs">
<DependentUpon>CountdownPage.xaml</DependentUpon>
Expand Down Expand Up @@ -400,6 +401,9 @@
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="Sentry">
<Version>4.12.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\ThisPC.ico" />
Expand Down

0 comments on commit 59d91ec

Please sign in to comment.