-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(mac): add breadcrumbs for Sentry #12939
Changes from 10 commits
8e833c8
76d0d69
162dc40
2b39027
d6ce0af
4a04937
b0776a4
0ec2664
c9c47e8
077229e
e5820f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
#import "KMDownloadKBWindowController.h" | ||
#import "KMDataRepository.h" | ||
#import "KMLogs.h" | ||
#import "KMSentryHelper.h" | ||
|
||
@interface KMConfigurationWindowController () | ||
@property (nonatomic, weak) IBOutlet NSTableView *tableView; | ||
|
@@ -360,21 +361,27 @@ - (BOOL)tableView:(NSTableView *)tableView acceptDrop:(id<NSDraggingInfo>)info r | |
- (void)checkBoxAction:(id)sender { | ||
NSButton *checkBox = (NSButton *)sender; | ||
NSString *kmxFilePath = [self kmxFilePathAtIndex:checkBox.tag]; | ||
NSString * kmxFileName = [kmxFilePath lastPathComponent]; | ||
NSString *partialPath = [KMDataRepository.shared trimToPartialPath:kmxFilePath]; | ||
os_log_debug([KMLogs uiLog], "checkBoxAction, kmxFilePath = %{public}@ for checkBox.tag %li, partialPath = %{public}@", kmxFilePath, checkBox.tag, partialPath); | ||
if (checkBox.state == NSOnState) { | ||
os_log_debug([KMLogs uiLog], "Adding active keyboard: %{public}@", kmxFilePath); | ||
os_log_debug([KMLogs uiLog], "enabling active keyboard: %{public}@", kmxFileName); | ||
NSString *message = [NSString stringWithFormat:@"enabling active keyboard: %@", kmxFileName]; | ||
[KMSentryHelper addUserBreadCrumb:@"config" message:message]; | ||
[self.activeKeyboards addObject:partialPath]; | ||
[self saveActiveKeyboards]; | ||
} | ||
else if (checkBox.state == NSOffState) { | ||
os_log_debug([KMLogs uiLog], "Disabling active keyboard: %{public}@", kmxFilePath); | ||
os_log_debug([KMLogs uiLog], "disabling active keyboard: %{public}@", kmxFileName); | ||
NSString *message = [NSString stringWithFormat:@"disabling active keyboard: %@", kmxFileName]; | ||
[KMSentryHelper addUserBreadCrumb:@"config" message:message]; | ||
[self.activeKeyboards removeObject:partialPath]; | ||
[self saveActiveKeyboards]; | ||
} | ||
} | ||
|
||
- (void)infoAction:(id)sender { | ||
[KMSentryHelper addUserBreadCrumb:@"user" message:@"getting package information"]; | ||
NSButton *infoButton = (NSButton *)sender; | ||
NSString *packagePath = [self packagePathAtIndex:infoButton.tag]; | ||
if (packagePath != nil) { | ||
|
@@ -389,6 +396,7 @@ - (void)infoAction:(id)sender { | |
} | ||
|
||
- (void)helpAction:(id)sender { | ||
[KMSentryHelper addUserBreadCrumb:@"user" message:@"displaying help"]; | ||
NSButton *helpButton = (NSButton *)sender; | ||
NSString *packagePath = [self packagePathAtIndex:helpButton.tag]; | ||
if (packagePath != nil) { | ||
|
@@ -406,22 +414,33 @@ - (void)removeAction:(id)sender { | |
NSButton *deleteButton = (NSButton *)sender; | ||
NSDictionary *info = [self.tableContents objectAtIndex:deleteButton.tag]; | ||
NSString *deleteKeyboardMessage = NSLocalizedString(@"message-confirm-delete-keyboard", nil); | ||
NSString *keyboardName = nil; | ||
|
||
if ([info objectForKey:@"HeaderTitle"] != nil) { | ||
keyboardName = [info objectForKey:@"HeaderTitle"]; | ||
[self.deleteAlertView setMessageText:[NSString localizedStringWithFormat:deleteKeyboardMessage, keyboardName]]; | ||
} else { | ||
keyboardName = [info objectForKey:kKMKeyboardNameKey]; | ||
[self.deleteAlertView setMessageText:[NSString localizedStringWithFormat:deleteKeyboardMessage, keyboardName]]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is identical to l.421, can they be pulled out of the if/else? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, thanks for spotting that! |
||
} | ||
|
||
if ([info objectForKey:@"HeaderTitle"] != nil) | ||
[self.deleteAlertView setMessageText:[NSString localizedStringWithFormat:deleteKeyboardMessage, [info objectForKey:@"HeaderTitle"]]]; | ||
else | ||
[self.deleteAlertView setMessageText:[NSString localizedStringWithFormat:deleteKeyboardMessage, [info objectForKey:kKMKeyboardNameKey]]]; | ||
|
||
os_log_debug([KMLogs configLog], "entered removeAction for keyboardName: %{public}@", keyboardName); | ||
|
||
[self.deleteAlertView beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { | ||
if (returnCode == NSAlertFirstButtonReturn) { | ||
os_log_debug([KMLogs uiLog], "confirm delete keyboard alert dismissed"); | ||
[self deleteFileAtIndex:[NSNumber numberWithInteger:deleteButton.tag]]; | ||
|
||
os_log_debug([KMLogs configLog], "removeAction for keyboardName: %{public}@", keyboardName); | ||
[KMSentryHelper addUserBreadCrumb:@"configure" message:[NSString stringWithFormat:@"remove keyboard: %@", keyboardName]]; | ||
} | ||
self.deleteAlertView = nil; | ||
}]; | ||
} | ||
|
||
- (IBAction)downloadAction:(id)sender { | ||
[KMSentryHelper addUserBreadCrumb:@"user" message:@"download keyboard"]; | ||
|
||
if (self.AppDelegate.infoWindow_.window != nil) | ||
[self.AppDelegate.infoWindow_ close]; | ||
|
||
|
@@ -453,7 +472,8 @@ - (void)handleRequestToInstallPackage:(KMPackage *) package { | |
- (void)installPackageFile:(NSString *)kmpFile { | ||
// kmpFile could be a temp file (in fact, it always is!), so don't display the name. | ||
os_log_debug([KMLogs dataLog], "kmpFile - ready to unzip/install Package File: %{public}@", kmpFile); | ||
|
||
[KMSentryHelper addInfoBreadCrumb:@"configure" message:@"install package file"]; | ||
|
||
BOOL didUnzip = [self.AppDelegate unzipFile:kmpFile]; | ||
|
||
if (!didUnzip) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
#import "KMDownloadKBWindowController.h" | ||
#import "KMInputMethodAppDelegate.h" | ||
#import "KMLogs.h" | ||
#import "KMSentryHelper.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope, I'll remove |
||
|
||
@interface KMDownloadKBWindowController () | ||
@property (nonatomic, weak) IBOutlet WebView *webView; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be easier if
addUserBreadCrumb
happened insideos_log_debug()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os_log_debug is a macOS API, so I can't combine there. I'd like to combine Sentry and macOS logging in a single call, but I am also instructed not to wrap the macOS API call because it tracks the location. So if I leave it in place, I would only be wrapping Sentry (which I am essentially doing to simplify it) and that still leaves two function calls from the location I want to log.