chore(windows): breadcrumbs

Some of our Sentry reports are difficult to track down. Adding user
interaction breadcrumbs to Keyman Configuration (to start with) may
simplify this. I may add more breadcrumbs to other projects now that
this is available.
This commit is contained in:
Marc Durdin 2021-03-16 06:57:57 +11:00
parent 874c0e251a
commit aebfdecf7a
17 changed files with 61 additions and 192 deletions

View file

@ -97,7 +97,6 @@ uses
MSXMLDomCreate in '..\..\global\delphi\general\MSXMLDomCreate.pas',
utilexecute in '..\..\global\delphi\general\utilexecute.pas',
KeymanVersion in '..\..\global\delphi\general\KeymanVersion.pas',
UfrmScriptError in '..\..\global\delphi\general\UfrmScriptError.pas' {frmScriptError},
BaseKeyboards in '..\..\global\delphi\general\BaseKeyboards.pas',
LoadIndirectStringUnit in '..\..\engine\keyman\langswitch\LoadIndirectStringUnit.pas',
Glossary in '..\..\global\delphi\general\Glossary.pas',

View file

@ -229,9 +229,6 @@
<DCCReference Include="..\..\global\delphi\general\MSXMLDomCreate.pas"/>
<DCCReference Include="..\..\global\delphi\general\utilexecute.pas"/>
<DCCReference Include="..\..\global\delphi\general\KeymanVersion.pas"/>
<DCCReference Include="..\..\global\delphi\general\UfrmScriptError.pas">
<Form>frmScriptError</Form>
</DCCReference>
<DCCReference Include="..\..\global\delphi\general\BaseKeyboards.pas"/>
<DCCReference Include="..\..\engine\keyman\langswitch\LoadIndirectStringUnit.pas"/>
<DCCReference Include="..\..\global\delphi\general\Glossary.pas"/>
@ -432,18 +429,18 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Profiling\AQtimeModule1.aqt" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="kmshell.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>kmshell.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Profiling\AQtimeModule1.aqt" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployClass Name="AdditionalDebugSymbols">
<Platform Name="OSX32">
<Operation>1</Operation>

View file

@ -1,4 +1,4 @@
object frmSettingsAddTSFApp: TfrmSettingsAddTSFApp
inherited frmSettingsAddTSFApp: TfrmSettingsAddTSFApp
Left = 0
Top = 0
ActiveControl = editFilename
@ -7,14 +7,10 @@ object frmSettingsAddTSFApp: TfrmSettingsAddTSFApp
Caption = 'Text Services Framework Application Overrides'
ClientHeight = 139
ClientWidth = 442
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poOwnerFormCenter
ExplicitWidth = 448
ExplicitHeight = 168
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel

View file

@ -13,10 +13,12 @@ uses
Vcl.Grids,
Vcl.StdCtrls,
Winapi.Messages,
Winapi.Windows;
Winapi.Windows,
UfrmKeymanBase;
type
TfrmSettingsAddTSFApp = class(TForm)
TfrmSettingsAddTSFApp = class(TfrmKeymanBase)
cmdOK: TButton;
cmdCancel: TButton;
Label1: TLabel;

View file

@ -1,23 +1,19 @@
object frmSettingsManager: TfrmSettingsManager
inherited frmSettingsManager: TfrmSettingsManager
Left = 0
Top = 0
BorderIcons = [biSystemMenu]
Caption = 'Keyman Settings Manager'
ClientHeight = 447
ClientWidth = 704
Color = clBtnFace
Constraints.MinHeight = 360
Constraints.MinWidth = 720
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poOwnerFormCenter
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
OnResize = FormResize
ExplicitWidth = 720
ExplicitHeight = 486
DesignSize = (
704
447)

View file

@ -15,10 +15,12 @@ uses
Winapi.Messages,
Winapi.Windows,
Keyman.System.Settings, Vcl.Imaging.pngimage, Vcl.ExtCtrls;
Keyman.System.Settings, Vcl.Imaging.pngimage, Vcl.ExtCtrls,
UfrmKeymanBase;
type
TfrmSettingsManager = class(TForm)
TfrmSettingsManager = class(TfrmKeymanBase)
gridDebugOption: TStringGrid;
memoDescription: TMemo;
cmdApply: TButton;
@ -84,6 +86,7 @@ procedure TfrmSettingsManager.FormCreate(Sender: TObject);
var
r: TRegistry;
begin
inherited;
r := TRegistry.Create;
try
r.RootKey := HKEY_LOCAL_MACHINE;
@ -102,12 +105,14 @@ end;
procedure TfrmSettingsManager.FormResize(Sender: TObject);
begin
inherited;
gridDebugOption.ColWidths[1] := gridDebugOption.ClientWidth - gridDebugOption.ColWidths[0] - 1;
end;
procedure TfrmSettingsManager.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
inherited;
CanClose := True;
if settings.Modified then
begin

View file

@ -1,4 +1,4 @@
object frmDiagnosticTests: TfrmDiagnosticTests
inherited frmDiagnosticTests: TfrmDiagnosticTests
Left = 0
Top = 0
BorderIcons = [biSystemMenu]
@ -6,13 +6,9 @@ object frmDiagnosticTests: TfrmDiagnosticTests
Caption = 'Diagnostic Tests'
ClientHeight = 166
ClientWidth = 362
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
ExplicitWidth = 368
ExplicitHeight = 195
PixelsPerInch = 96
TextHeight = 13
object cmdSendTestException: TButton

View file

@ -4,10 +4,11 @@ interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
UfrmKeymanBase;
type
TfrmDiagnosticTests = class(TForm)
TfrmDiagnosticTests = class(TfrmKeymanBase)
cmdSendTestException: TButton;
cmdSendTestCOMAPIException: TButton;
cmdClose: TButton;

View file

@ -70,7 +70,6 @@ uses
UfrmOSKFontHelper in 'viskbd\UfrmOSKFontHelper.pas' {frmOSKFontHelper},
HintConsts in '..\..\global\delphi\hints\HintConsts.pas',
KeymanHints in 'KeymanHints.pas',
UfrmKeymanBase in '..\..\global\delphi\ui\UfrmKeymanBase.pas' {frmKeymanBase: TTntForm},
Hints in '..\..\global\delphi\hints\Hints.pas',
utilcheckfonts in '..\..\global\delphi\general\utilcheckfonts.pas',
findfonts in '..\..\global\delphi\general\findfonts.pas',

View file

@ -171,10 +171,6 @@
</DCCReference>
<DCCReference Include="..\..\global\delphi\hints\HintConsts.pas"/>
<DCCReference Include="KeymanHints.pas"/>
<DCCReference Include="..\..\global\delphi\ui\UfrmKeymanBase.pas">
<Form>frmKeymanBase</Form>
<DesignClass>TTntForm</DesignClass>
</DCCReference>
<DCCReference Include="..\..\global\delphi\hints\Hints.pas"/>
<DCCReference Include="..\..\global\delphi\general\utilcheckfonts.pas"/>
<DCCReference Include="..\..\global\delphi\general\findfonts.pas"/>
@ -297,9 +293,9 @@
<Platform value="Win64">False</Platform>
</Platforms>
<Deployment Version="3">
<DeployFile LocalName="keyman.exe" Configuration="Debug" Class="ProjectOutput">
<DeployFile LocalName="Profiling\AQtimeModule1.aqt" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteName>keyman.exe</RemoteName>
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
@ -309,9 +305,9 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Profiling\AQtimeModule1.aqt" Configuration="Debug" Class="ProjectFile">
<DeployFile LocalName="keyman.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<RemoteName>keyman.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>

View file

@ -54,7 +54,6 @@ uses
ClearTypeDrawCharacter,
keymanapi_TLB,
UfrmKeymanBase,
UfrmOSKPlugInBase,
UserMessages,
utilcheckfonts;

View file

@ -83,6 +83,8 @@ type
function MessageEvent(Level: TSentryLevel; const Message: string; IncludeStack: Boolean = False): string;
function ExceptionEvent(const ExceptionClassName, Message: string; AExceptAddr: Pointer = nil): string;
procedure Breadcrumb(const BreadcrumbType, Message: string; const Category: string = ''; const Level: string = 'info');
property OnBeforeEvent: TSentryClientBeforeEvent read FOnBeforeEvent write FOnBeforeEvent;
property OnAfterEvent: TSentryClientAfterEvent read FOnAfterEvent write FOnAfterEvent;
@ -356,6 +358,18 @@ begin
end;
end;
procedure TSentryClient.Breadcrumb(const BreadcrumbType, Message: string; const Category: string = ''; const Level: string = 'info');
var
crumb: sentry_value_t;
begin
crumb := sentry_value_new_breadcrumb(PAnsiChar(UTF8Encode(BreadcrumbType)), PAnsiChar(UTF8Encode(Message)));
if Category <> '' then
sentry_value_set_by_key(crumb, 'category', sentry_value_new_string(PAnsiChar(UTF8Encode(Category))));
if Level <> '' then
sentry_value_set_by_key(crumb, 'level', sentry_value_new_string(PAnsiChar(UTF8Encode(Level))));
sentry_add_breadcrumb(crumb);
end;
function TSentryClient.ConvertRawStackToSentryStack(wrapWithThread: Boolean): sentry_value_t;
var
frames, s_frame, stacktrace, thread, threads: sentry_value_t;

View file

@ -35,6 +35,8 @@ type
class procedure ReportHandledException(E: Exception; const Message: string = ''; IncludeStack: Boolean = True);
class procedure Breadcrumb(const BreadcrumbType, Message: string; const Category: string = ''; const Level: string = 'info');
class procedure Start(SentryClientClass: TSentryClientClass; AProject: TKeymanSentryClientProject; const ALogger: string; AFlags: TKeymanSentryClientFlags = [kscfCaptureExceptions, kscfShowUI, kscfTerminate]);
class procedure Stop;
class property Client: TSentryClient read FClient;
@ -115,6 +117,13 @@ begin
Result := '';
end;
class procedure TKeymanSentryClient.Breadcrumb(const BreadcrumbType, Message,
Category, Level: string);
begin
if Enabled then
Client.Breadcrumb(BreadcrumbType, Message, Category, Level);
end;
procedure TKeymanSentryClient.ClientAfterEvent(Sender: TObject;
EventType: TSentryClientEventType; const EventID, EventClassName, Message: string;
var EventAction: TSentryClientEventAction);

View file

@ -1,83 +0,0 @@
object frmScriptError: TfrmScriptError
Left = 0
Top = 0
BorderIcons = [biSystemMenu]
BorderStyle = bsDialog
Caption = 'Script Error'
ClientHeight = 201
ClientWidth = 487
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PixelsPerInch = 96
TextHeight = 13
object lblBlurb1: TLabel
Left = 16
Top = 16
Width = 455
Height = 13
Caption =
'We are very sorry but an error has been encountered in this wind' +
'ow. The error received was:'
end
object lblError: TLabel
Left = 36
Top = 44
Width = 397
Height = 45
AutoSize = False
end
object lblBlurb2: TLabel
Left = 16
Top = 108
Width = 321
Height = 13
Caption =
'Do you want to try continuing? In many cases this will be just ' +
'fine.'
end
object cmdContinue: TButton
Left = 16
Top = 161
Width = 95
Height = 25
Caption = '&Try and continue'
Default = True
ModalResult = 6
TabOrder = 0
end
object cmdExit: TButton
Left = 376
Top = 161
Width = 95
Height = 25
Caption = 'E&xit Application'
ModalResult = 3
TabOrder = 1
end
object cmdCancel: TButton
Left = 117
Top = 161
Width = 95
Height = 25
Cancel = True
Caption = '&Cancel'
ModalResult = 2
TabOrder = 2
end
object chkTellKeymanSupport: TCheckBox
Left = 16
Top = 138
Width = 225
Height = 17
Caption = 'Tell Keyman Support about this error'
Checked = True
State = cbChecked
TabOrder = 3
end
end

View file

@ -1,61 +0,0 @@
(*
Name: UfrmScriptError
Copyright: Copyright (C) 2003-2017 SIL International.
Documentation:
Description:
Create Date: 6 Feb 2012
Modified Date: 4 Nov 2012
Authors: mcdurdin
Related Files:
Dependencies:
Bugs:
Todo:
Notes:
History: 06 Feb 2012 - mcdurdin - I2992 - Handle script errors more cleanly
04 Nov 2012 - mcdurdin - I3544 - V9.0 - Merge of I2992 - Handle script errors more cleanly
*)
unit UfrmScriptError; // I3544
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TfrmScriptError = class(TForm)
lblBlurb1: TLabel;
lblError: TLabel;
lblBlurb2: TLabel;
cmdContinue: TButton;
cmdExit: TButton;
cmdCancel: TButton;
chkTellKeymanSupport: TCheckBox;
private
{ Private declarations }
public
{ Public declarations }
end;
/// Return values. mrYes = continue, mrCancel = cancel, mrAbort = exit app
function ShowScriptErrorDialog(Owner: TComponent; Message: WideString; var TellKeymanSupport: Boolean): TModalResult;
implementation
{$R *.dfm}
function ShowScriptErrorDialog(Owner: TComponent; Message: WideString; var TellKeymanSupport: Boolean): TModalResult;
begin
with TfrmScriptError.Create(Owner) do
try
lblError.Caption := Message;
Result := ShowModal;
TellKeymanSupport := chkTellKeymanSupport.Checked;
finally
Free;
end;
end;
end.

View file

@ -64,18 +64,21 @@ uses
System.Win.Registry,
ErrorControlledRegistry,
Keyman.System.KeymanSentryClient,
RegistryKeys;
{$R *.DFM}
procedure TfrmKeymanBase.TntFormCreate(Sender: TObject);
begin
TKeymanSentryClient.Breadcrumb('user', 'Created form '+ClassName, 'form-create');
RegisterWindow; // I2720
end;
procedure TfrmKeymanBase.TntFormDestroy(Sender: TObject);
begin
DeregisterWindow; // I2720
TKeymanSentryClient.Breadcrumb('user', 'Destroyed form '+ClassName, 'form-destroy');
end;
function TfrmKeymanBase.TntFormHelp(Command: Word; Data: NativeInt; var CallHelp: Boolean): Boolean;

View file

@ -110,9 +110,9 @@ uses
custinterfaces,
ErrorControlledRegistry,
Keyman.Configuration.System.UmodWebHttpServer,
Keyman.System.KeymanSentryClient,
kmint,
UILanguages,
UfrmScriptError,
Upload_Settings,
utilexecute,
utilsystem,
@ -220,6 +220,7 @@ end;
procedure TfrmWebContainer.cefCommand(Sender: TObject; const command: string; params: TStringList);
begin
TKeymanSentryClient.Breadcrumb('user', 'Clicked '+command+' in '+ClassName, 'click');
FireCommand(command, params);
end;